mirror of
https://github.com/cnlimiter/codex-register.git
synced 2026-08-21 16:24:29 +08:00
增加前端资源版本号
This commit is contained in:
@@ -36,6 +36,16 @@ STATIC_DIR = _RESOURCE_ROOT / "static"
|
|||||||
TEMPLATES_DIR = _RESOURCE_ROOT / "templates"
|
TEMPLATES_DIR = _RESOURCE_ROOT / "templates"
|
||||||
|
|
||||||
|
|
||||||
|
def _build_static_asset_version(static_dir: Path) -> str:
|
||||||
|
"""基于静态文件最后修改时间生成版本号,避免部署后浏览器继续使用旧缓存。"""
|
||||||
|
latest_mtime = 0
|
||||||
|
if static_dir.exists():
|
||||||
|
for path in static_dir.rglob("*"):
|
||||||
|
if path.is_file():
|
||||||
|
latest_mtime = max(latest_mtime, int(path.stat().st_mtime))
|
||||||
|
return str(latest_mtime or 1)
|
||||||
|
|
||||||
|
|
||||||
def create_app() -> FastAPI:
|
def create_app() -> FastAPI:
|
||||||
"""创建 FastAPI 应用实例"""
|
"""创建 FastAPI 应用实例"""
|
||||||
settings = get_settings()
|
settings = get_settings()
|
||||||
@@ -80,6 +90,7 @@ def create_app() -> FastAPI:
|
|||||||
|
|
||||||
# 模板引擎
|
# 模板引擎
|
||||||
templates = Jinja2Templates(directory=str(TEMPLATES_DIR))
|
templates = Jinja2Templates(directory=str(TEMPLATES_DIR))
|
||||||
|
templates.env.globals["static_version"] = _build_static_asset_version(STATIC_DIR)
|
||||||
|
|
||||||
def _auth_token(password: str) -> str:
|
def _auth_token(password: str) -> str:
|
||||||
secret = get_settings().webui_secret_key.get_secret_value().encode("utf-8")
|
secret = get_settings().webui_secret_key.get_secret_value().encode("utf-8")
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>账号管理 - OpenAI 注册系统</title>
|
<title>账号管理 - OpenAI 注册系统</title>
|
||||||
<link rel="stylesheet" href="/static/css/style.css">
|
<link rel="stylesheet" href="/static/css/style.css?v={{ static_version }}">
|
||||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>📋</text></svg>">
|
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>📋</text></svg>">
|
||||||
<style>
|
<style>
|
||||||
.password-cell {
|
.password-cell {
|
||||||
@@ -257,7 +257,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/static/js/utils.js"></script>
|
<script src="/static/js/utils.js?v={{ static_version }}"></script>
|
||||||
<script src="/static/js/accounts.js"></script>
|
<script src="/static/js/accounts.js?v={{ static_version }}"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>邮箱服务 - OpenAI 注册系统</title>
|
<title>邮箱服务 - OpenAI 注册系统</title>
|
||||||
<link rel="stylesheet" href="/static/css/style.css">
|
<link rel="stylesheet" href="/static/css/style.css?v={{ static_version }}">
|
||||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>📧</text></svg>">
|
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>📧</text></svg>">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -425,7 +425,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<script src="/static/js/utils.js"></script>
|
<script src="/static/js/utils.js?v={{ static_version }}"></script>
|
||||||
<script src="/static/js/email_services.js"></script>
|
<script src="/static/js/email_services.js?v={{ static_version }}"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>注册控制台 - OpenAI 注册系统</title>
|
<title>注册控制台 - OpenAI 注册系统</title>
|
||||||
<link rel="stylesheet" href="/static/css/style.css">
|
<link rel="stylesheet" href="/static/css/style.css?v={{ static_version }}">
|
||||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🚀</text></svg>">
|
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🚀</text></svg>">
|
||||||
<style>
|
<style>
|
||||||
/* 两栏布局 */
|
/* 两栏布局 */
|
||||||
@@ -409,7 +409,7 @@
|
|||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/static/js/utils.js"></script>
|
<script src="/static/js/utils.js?v={{ static_version }}"></script>
|
||||||
<script src="/static/js/app.js"></script>
|
<script src="/static/js/app.js?v={{ static_version }}"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>访问验证 - OpenAI 注册系统</title>
|
<title>访问验证 - OpenAI 注册系统</title>
|
||||||
<link rel="stylesheet" href="/static/css/style.css">
|
<link rel="stylesheet" href="/static/css/style.css?v={{ static_version }}">
|
||||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🔒</text></svg>">
|
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🔒</text></svg>">
|
||||||
<style>
|
<style>
|
||||||
.login-wrap {
|
.login-wrap {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>支付升级 - OpenAI 注册系统</title>
|
<title>支付升级 - OpenAI 注册系统</title>
|
||||||
<link rel="stylesheet" href="/static/css/style.css">
|
<link rel="stylesheet" href="/static/css/style.css?v={{ static_version }}">
|
||||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>💳</text></svg>">
|
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>💳</text></svg>">
|
||||||
<style>
|
<style>
|
||||||
.plan-cards {
|
.plan-cards {
|
||||||
@@ -166,7 +166,7 @@
|
|||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/static/js/utils.js"></script>
|
<script src="/static/js/utils.js?v={{ static_version }}"></script>
|
||||||
<script src="/static/js/payment.js"></script>
|
<script src="/static/js/payment.js?v={{ static_version }}"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>系统设置 - OpenAI 注册系统</title>
|
<title>系统设置 - OpenAI 注册系统</title>
|
||||||
<link rel="stylesheet" href="/static/css/style.css">
|
<link rel="stylesheet" href="/static/css/style.css?v={{ static_version }}">
|
||||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>⚙️</text></svg>">
|
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>⚙️</text></svg>">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -568,7 +568,7 @@
|
|||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/static/js/utils.js"></script>
|
<script src="/static/js/utils.js?v={{ static_version }}"></script>
|
||||||
<script src="/static/js/settings.js"></script>
|
<script src="/static/js/settings.js?v={{ static_version }}"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user