From 24faed14286c66436ae64e1cb68042e5c2c6e6f5 Mon Sep 17 00:00:00 2001 From: codex Date: Sat, 24 Oct 2026 19:46:41 +0800 Subject: [PATCH] feat(web): localize public entry pages --- web/app/Controllers/AuthController.php | 111 ++++++++++---- web/app/Controllers/BaseController.php | 37 +++++ web/app/Controllers/HomeController.php | 5 +- web/app/Controllers/LegalController.php | 10 +- web/app/Controllers/PasswordController.php | 42 ++++-- web/app/Services/PublicLocale.php | 132 +++++++++++++++++ web/public/cloud/account.css | 135 ++---------------- web/public/theme/venix/css/home.css | 40 +++++- web/resources/views/venix/auth/copyright.tpl | 1 - .../views/venix/auth/layout_footer.tpl | 2 + .../views/venix/auth/layout_header.tpl | 19 +-- web/resources/views/venix/auth/login.tpl | 3 +- web/resources/views/venix/auth/register.tpl | 11 +- .../views/venix/home/language_switch.tpl | 4 + .../views/venix/home/nav_actions.tpl | 8 ++ .../views/venix/home/site_footer.tpl | 4 +- .../views/venix/home/site_header.tpl | 15 +- web/resources/views/venix/index.tpl | 6 +- web/resources/views/venix/layout_assets.tpl | 2 +- web/resources/views/venix/legal.tpl | 2 +- web/resources/views/venix/password/reset.tpl | 6 +- web/resources/views/venix/password/token.tpl | 6 +- web/tests/AuthVisualContractTest.php | 20 ++- web/tests/LegalPagesContractTest.php | 4 +- web/tests/PublicLocaleTest.php | 71 +++++++++ web/tests/PublicPageLocaleContractTest.php | 86 +++++++++++ web/tests/PublicPageLocaleRenderTest.php | 108 ++++++++++++++ web/tests/SiteBrandContractTest.php | 5 +- 28 files changed, 667 insertions(+), 228 deletions(-) create mode 100644 web/app/Services/PublicLocale.php delete mode 100644 web/resources/views/venix/auth/copyright.tpl create mode 100644 web/resources/views/venix/auth/layout_footer.tpl create mode 100644 web/resources/views/venix/home/language_switch.tpl create mode 100644 web/resources/views/venix/home/nav_actions.tpl create mode 100644 web/tests/PublicLocaleTest.php create mode 100644 web/tests/PublicPageLocaleContractTest.php create mode 100644 web/tests/PublicPageLocaleRenderTest.php diff --git a/web/app/Controllers/AuthController.php b/web/app/Controllers/AuthController.php index 8302150f..318dcefb 100644 --- a/web/app/Controllers/AuthController.php +++ b/web/app/Controllers/AuthController.php @@ -30,7 +30,6 @@ use App\Models\EmailVerify; class AuthController extends BaseController { - private $language = 'false'; private $login_forbidden_ips = ''; private $enable_login_email_verify = 'false'; private $login_session_ttl = 2592000; @@ -97,16 +96,17 @@ class AuthController extends BaseController }); $this->trusted_login_device_ttl = TrustedLoginDeviceService::ttlSeconds($trustedLoginDeviceDays); $this->appName = Config::get('appName'); + $this->initializePublicLocale(); } public function login() { $this->getLoginDeviceId(); - return $this->view()->assign('captch_login', CaptchaConfig::get('captch_login')) + return $this->publicView()->assign('captch_login', CaptchaConfig::get('captch_login')) ->assign('cdn', $this->cdn)->assign('backup_cdn', $this->backup_cdn) ->assign('appName', $this->appName)->assign('seo', $this->seo) - ->assign('language', $this->language)->display('auth/login.tpl'); + ->display('auth/login.tpl'); } private function getLoginClientIp() @@ -374,7 +374,10 @@ class AuthController extends BaseController $email = $request->getParam('email'); $passwd = $request->getParam('passwd'); if (!is_string($email) || !is_string($passwd) || strlen($email) > 254 || strlen($passwd) > 72) { - return $response->withJson(['ret' => 0, 'msg' => '邮箱或密码格式无效'], 400); + return $response->withJson([ + 'ret' => 0, + 'msg' => $this->publicText('邮箱或密码格式无效', 'The email or password format is invalid.'), + ], 400); } $email = strtolower(trim($email)); $code = $request->getParam('code'); @@ -404,7 +407,10 @@ class AuthController extends BaseController unset($_SESSION['captch']); } if ($this->isLoginVerifyPasswordLimited($redis, $email, $clientIp)) { - return $response->withJson(['ret' => 0, 'msg' => '尝试次数过多,请稍后再试'], 429); + return $response->withJson([ + 'ret' => 0, + 'msg' => $this->publicText('尝试次数过多,请稍后再试', 'Too many attempts. Please try again later.'), + ], 429); } // Handle Login $user = User::where('email', '=', $email)->first(); @@ -445,7 +451,10 @@ class AuthController extends BaseController } if ((int) $user->enable !== 1) { - return $this->echoJson($response, ['ret' => 0, 'msg' => '账户已停用']); + return $this->echoJson($response, [ + 'ret' => 0, + 'msg' => $this->publicText('账户已停用', 'This account has been disabled.'), + ]); } $this->clearLoginVerifyPasswordFail($redis, $email, $clientIp); @@ -699,14 +708,14 @@ class AuthController extends BaseController Cookie::set(['affid' => (string) $legacyAffid], time() + 86400 * 30); } - return $this->view()->assign('enable_invite_code', $this->enable_invite_code) + return $this->publicView()->assign('enable_invite_code', $this->enable_invite_code) ->assign('enable_email_verify', CaptchaConfig::get('enable_email_verify')) ->assign('code', $code)->assign('aff_code', $code)->assign('aff', max(0, $legacyAffid))->assign('aff_method', $this->aff_method) ->assign('invite_required', $this->aff_method === 'code')->assign('tos_reg', Config::get('tos_reg')) ->assign('captch_reg', CaptchaConfig::get('captch_reg')) ->assign('cdn', $this->cdn)->assign('backup_cdn', $this->backup_cdn) ->assign('appName', $this->appName)->assign('seo', $this->seo) - ->assign('language', $this->language)->display('auth/register.tpl'); + ->display('auth/register.tpl'); } public function sendVerify($request, $response, $next) @@ -848,35 +857,59 @@ class AuthController extends BaseController { Cookie::startSession(); if (Config::get('enable_register', 'true') === 'false') { - return $this->echoJson($response, ['ret' => 0, 'msg' => '目前关闭注册']); + return $this->echoJson($response, [ + 'ret' => 0, + 'msg' => $this->publicText('目前关闭注册', 'Registration is currently unavailable.'), + ]); } $read = static function ($name) use ($request) { $value = $request->getParam($name, ''); return is_string($value) ? $value : ''; }; if (Config::get('tos_reg') === 'true' && $read('accept_legal') !== 'true') { - return $this->echoJson($response, ['ret' => 0, 'msg' => '请先阅读并同意服务条款和隐私政策']); + return $this->echoJson($response, [ + 'ret' => 0, + 'msg' => $this->publicText( + '请先阅读并同意服务条款和隐私政策', + 'Please read and accept the Terms of Service and Privacy Policy.' + ), + ]); } $email = strtolower(trim($read('email'))); $name = trim($read('name')); $password = $read('passwd'); $code = trim($read('code')); if (!Check::isEmailLegal($email) || strlen($email) > 254 || $name === '' || mb_strlen($name) > 128) { - return $this->echoJson($response, ['ret' => 0, 'msg' => '请填写有效的用户名和邮箱']); + return $this->echoJson($response, [ + 'ret' => 0, + 'msg' => $this->publicText('请填写有效的用户名和邮箱', 'Please enter a valid username and email address.'), + ]); } $whitelist = RegistrationEmailWhitelist::configuredRules(); if ($whitelist['enabled'] && !RegistrationEmailWhitelist::allows($email, $whitelist['domains'])) { - return $this->echoJson($response, ['ret' => 0, 'msg' => '此邮箱暂不允许注册']); + return $this->echoJson($response, [ + 'ret' => 0, + 'msg' => $this->publicText('此邮箱暂不允许注册', 'This email address is not currently allowed to register.'), + ]); } $error = Hash::newPasswordError($password); if ($error !== null || $password !== $read('repasswd')) { - return $this->echoJson($response, ['ret' => 0, 'msg' => $error ?? '两次密码不一致']); + $message = $error !== null + ? $this->publicText( + $error, + 'The password must be 12–72 bytes and include uppercase and lowercase letters, a number, and a symbol.' + ) + : $this->publicText('两次密码不一致', 'The passwords do not match.'); + return $this->echoJson($response, ['ret' => 0, 'msg' => $message]); } if (CaptchaConfig::get('captch_reg') === 'true') { $expected = isset($_SESSION['captch']) && is_string($_SESSION['captch']) ? strtolower($_SESSION['captch']) : ''; $provided = strtolower(trim($read('captch'))); if ($expected === '' || !hash_equals($expected, $provided)) { - return $this->echoJson($response, ['ret' => 0, 'msg' => '验证码错误']); + return $this->echoJson($response, [ + 'ret' => 0, + 'msg' => $this->publicText('验证码错误', 'The verification code is incorrect.'), + ]); } unset($_SESSION['captch']); } @@ -885,13 +918,19 @@ class AuthController extends BaseController try { $connection->transaction(function () use ($read, $email, $name, $password, $code) { if (User::where('email', $email)->exists()) { - throw new \InvalidArgumentException('该邮箱已被注册'); + throw new \InvalidArgumentException($this->publicText( + '该邮箱已被注册', + 'This email address is already registered.' + )); } if (CaptchaConfig::get('enable_email_verify') === 'true') { $verification = EmailVerify::where('email', $email)->where('code', $read('emailcode')) ->where('expire_in', '>', time())->lockForUpdate()->first(); if ($verification === null) { - throw new \InvalidArgumentException('邮箱验证码错误或已过期'); + throw new \InvalidArgumentException($this->publicText( + '邮箱验证码错误或已过期', + 'The email verification code is incorrect or expired.' + )); } EmailVerify::where('email', $email)->delete(); } @@ -905,7 +944,10 @@ class AuthController extends BaseController if ($affCode !== '') { $invitation = ReferralService::findInvitation($affCode, true); if ($invitation === null) { - throw new \InvalidArgumentException('推广链接无效'); + throw new \InvalidArgumentException($this->publicText( + '推广链接无效', + 'The referral link is invalid.' + )); } $refBy = (int) $invitation->user_id; } elseif ($code !== '' && $this->aff_method === 'code') { @@ -913,28 +955,43 @@ class AuthController extends BaseController // older installations while new links stay eight chars. $invitation = InviteCode::where('code', $code)->lockForUpdate()->first(); if ($invitation === null) { - throw new \InvalidArgumentException('邀请码无效'); + throw new \InvalidArgumentException($this->publicText( + '邀请码无效', + 'The invitation code is invalid.' + )); } $refBy = (int) $invitation->user_id; } elseif ($this->aff_method === 'code') { - throw new \InvalidArgumentException('推广链接或邀请码无效'); + throw new \InvalidArgumentException($this->publicText( + '推广链接或邀请码无效', + 'A valid referral link or invitation code is required.' + )); } else { if ($aff !== '' && (!ctype_digit($aff) || (int) $aff < 0)) { - throw new \InvalidArgumentException('邀请链接无效'); + throw new \InvalidArgumentException($this->publicText( + '邀请链接无效', + 'The invitation link is invalid.' + )); } $refBy = (int) $aff; } if ($refBy > 0) { $referrer = User::where('id', $refBy)->lockForUpdate()->first(); if ($referrer === null || !$referrer->canInvite()) { - throw new \InvalidArgumentException('邀请服务暂不可用'); + throw new \InvalidArgumentException($this->publicText( + '邀请服务暂不可用', + 'The invitation service is currently unavailable.' + )); } // New eight-character promotion links are reusable and do // not consume the legacy invite quota. Older, longer // `code` invitations retain their one-time quota rules. if ($invitation !== null && $affCode === '') { if ((int) $referrer->invite_num < 1) { - throw new \InvalidArgumentException('邀请次数不足'); + throw new \InvalidArgumentException($this->publicText( + '邀请次数不足', + 'The inviter has no invitation quota remaining.' + )); } $referrer->invite_num = (int) $referrer->invite_num - 1; $referrer->save(); @@ -963,10 +1020,16 @@ class AuthController extends BaseController return $this->echoJson($response, ['ret' => 0, 'msg' => $exception->getMessage()]); } catch (\Throwable $exception) { error_log('Account registration failed: ' . get_class($exception)); - return $this->echoJson($response, ['ret' => 0, 'msg' => '注册失败,请稍后重试']); + return $this->echoJson($response, [ + 'ret' => 0, + 'msg' => $this->publicText('注册失败,请稍后重试', 'Registration failed. Please try again later.'), + ]); } - return $this->echoJson($response, ['ret' => 1, 'msg' => '注册成功']); + return $this->echoJson($response, [ + 'ret' => 1, + 'msg' => $this->publicText('注册成功', 'Registration completed successfully.'), + ]); } public function logout($request, $response, $next) diff --git a/web/app/Controllers/BaseController.php b/web/app/Controllers/BaseController.php index 82ae4a3c..b821f341 100644 --- a/web/app/Controllers/BaseController.php +++ b/web/app/Controllers/BaseController.php @@ -5,8 +5,10 @@ namespace App\Controllers; use App\Models\Configurations; use App\Services\Auth; use App\Services\Config; +use App\Services\PublicLocale; use App\Services\RedisClient; use App\Services\View; +use App\Utils\Cookie; /** * BaseController @@ -20,6 +22,10 @@ class BaseController public $smarty; protected $viewTheme = null; + + protected $language = 'false'; + + protected $publicLocale = PublicLocale::CHINESE; public function construct__() { @@ -36,6 +42,37 @@ class BaseController return $this->smarty(); } + protected function initializePublicLocale() + { + $query = is_array($_GET) ? $_GET : []; + $cookies = is_array($_COOKIE) ? $_COOKIE : []; + $requestedLocale = PublicLocale::requestedLocale($query); + if ($requestedLocale !== null) { + Cookie::set([ + PublicLocale::COOKIE_NAME => $requestedLocale, + ], time() + PublicLocale::COOKIE_TTL); + $cookies[PublicLocale::COOKIE_NAME] = $requestedLocale; + } + + $this->publicLocale = PublicLocale::resolve( + $query, + $cookies, + isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? (string) $_SERVER['HTTP_ACCEPT_LANGUAGE'] : '' + ); + $this->language = PublicLocale::templateLanguage($this->publicLocale); + } + + protected function publicView() + { + $requestUri = isset($_SERVER['REQUEST_URI']) ? (string) $_SERVER['REQUEST_URI'] : '/'; + return $this->view()->assign(PublicLocale::viewData($this->publicLocale, $requestUri)); + } + + protected function publicText(string $chinese, string $english): string + { + return $this->language === 'true' ? $english : $chinese; + } + /** * @param $response * @param $res diff --git a/web/app/Controllers/HomeController.php b/web/app/Controllers/HomeController.php index 2c3e80ce..1b953662 100644 --- a/web/app/Controllers/HomeController.php +++ b/web/app/Controllers/HomeController.php @@ -18,8 +18,6 @@ use App\Utils\Tools; */ class HomeController extends BaseController { - protected $language = 'false'; - public function __construct() { $configurations = $this->getDomainConfigurations(); @@ -49,11 +47,12 @@ class HomeController extends BaseController return Configurations::where('name', 'seo')->value('value'); }); $this->appName = Config::get('appName'); + $this->initializePublicLocale(); } public function index() { - return $this->view()->assign('cdn', $this->cdn)->assign('backup_cdn', $this->backup_cdn)->assign('appName', $this->appName)->assign('seo', $this->seo)->assign('language', $this->language)->display('index.tpl'); + return $this->publicView()->assign('cdn', $this->cdn)->assign('backup_cdn', $this->backup_cdn)->assign('appName', $this->appName)->assign('seo', $this->seo)->display('index.tpl'); } public function page404($request, $response, $args) diff --git a/web/app/Controllers/LegalController.php b/web/app/Controllers/LegalController.php index 4366e241..14a09443 100644 --- a/web/app/Controllers/LegalController.php +++ b/web/app/Controllers/LegalController.php @@ -18,24 +18,20 @@ final class LegalController extends HomeController private function renderDocument($request, $response, string $slug) { - $query = $request->getQueryParams(); - $requestedLocale = $query['lang'] ?? ''; - $locale = is_string($requestedLocale) && in_array($requestedLocale, ['zh-CN', 'en'], true) - ? $requestedLocale - : ($this->language === 'true' ? 'en' : 'zh-CN'); + $locale = $this->publicLocale; $document = LegalDocumentService::published($slug, $locale, (string) $this->appName); - $smarty = $this->view()->assign([ + $smarty = $this->publicView()->assign([ 'cdn' => $this->cdn, 'backup_cdn' => $this->backup_cdn, 'appName' => $this->appName, 'seo' => $this->seo, - 'language' => $locale === 'en' ? 'true' : 'false', 'legal_document' => $document, 'legal_slug' => $slug, ]); $response->getBody()->write($smarty->fetch('legal.tpl')); return $response ->withHeader('Cache-Control', 'public, max-age=60') + ->withHeader('Vary', 'Accept-Language, Cookie') ->withHeader('X-Content-Type-Options', 'nosniff'); } } diff --git a/web/app/Controllers/PasswordController.php b/web/app/Controllers/PasswordController.php index f97fdd51..37013ab7 100644 --- a/web/app/Controllers/PasswordController.php +++ b/web/app/Controllers/PasswordController.php @@ -17,18 +17,16 @@ use App\Utils\Cookie; class PasswordController extends BaseController { - private $language = 'false'; - public function __construct() { $this->applyDomainTheme($this->getDomainConfigurations()); + $this->initializePublicLocale(); } public function reset() { - return $this->view() + return $this->publicView() ->assign('captch_respass', CaptchaConfig::get('captch_respass')) - ->assign('language', $this->language) ->display('password/reset.tpl'); } @@ -69,9 +67,8 @@ class PasswordController extends BaseController public function token($request, $response, $args) { $token = $args['token']; - return $this->view() + return $this->publicView() ->assign('token', $token) - ->assign('language', $this->language) ->display('password/token.tpl'); } @@ -80,22 +77,37 @@ class PasswordController extends BaseController $password = $request->getParam('password'); $error = Hash::newPasswordError($password); if ($error !== null || $password !== $request->getParam('repasswd')) { - return $this->echoJson($response, ['ret' => 0, 'msg' => $error ?? '两次密码不一致']); + $message = $error !== null + ? $this->publicText( + $error, + 'The password must be 12–72 bytes and include uppercase and lowercase letters, a number, and a symbol.' + ) + : $this->publicText('两次密码不一致', 'The passwords do not match.'); + return $this->echoJson($response, ['ret' => 0, 'msg' => $message]); } $tokenStr = isset($args['token']) && is_string($args['token']) ? $args['token'] : ''; if (preg_match('/^[a-f0-9]{64}$/', $tokenStr) !== 1) { - return $this->echoJson($response, ['ret' => 0, 'msg' => '链接无效或已过期']); + return $this->echoJson($response, [ + 'ret' => 0, + 'msg' => $this->publicText('链接无效或已过期', 'This link is invalid or has expired.'), + ]); } $connection = (new User())->getConnection(); try { $connection->transaction(function () use ($tokenStr, $password) { $token = PasswordReset::where('token', $tokenStr)->lockForUpdate()->first(); if ($token === null || (int) $token->expire_time < time()) { - throw new \InvalidArgumentException('链接无效或已过期'); + throw new \InvalidArgumentException($this->publicText( + '链接无效或已过期', + 'This link is invalid or has expired.' + )); } $user = User::where('email', $token->email)->lockForUpdate()->first(); if ($user === null) { - throw new \InvalidArgumentException('链接无效或已过期'); + throw new \InvalidArgumentException($this->publicText( + '链接无效或已过期', + 'This link is invalid or has expired.' + )); } $user->updatePassword($password); PasswordReset::where('email', $token->email)->delete(); @@ -104,9 +116,15 @@ class PasswordController extends BaseController return $this->echoJson($response, ['ret' => 0, 'msg' => $exception->getMessage()]); } catch (\Throwable $exception) { error_log('Password recovery failed: ' . get_class($exception)); - return $this->echoJson($response, ['ret' => 0, 'msg' => '重置失败,请稍后重试']); + return $this->echoJson($response, [ + 'ret' => 0, + 'msg' => $this->publicText('重置失败,请稍后重试', 'Password reset failed. Please try again later.'), + ]); } - return $this->echoJson($response, ['ret' => 1, 'msg' => '密码已重置,请重新登录']); + return $this->echoJson($response, [ + 'ret' => 1, + 'msg' => $this->publicText('密码已重置,请重新登录', 'Your password has been reset. Please log in again.'), + ]); } } diff --git a/web/app/Services/PublicLocale.php b/web/app/Services/PublicLocale.php new file mode 100644 index 00000000..e47c0873 --- /dev/null +++ b/web/app/Services/PublicLocale.php @@ -0,0 +1,132 @@ + $entry) { + $parts = array_map('trim', explode(';', $entry)); + $locale = self::normalizeLocale(array_shift($parts)); + if ($locale === null) { + continue; + } + + $quality = 1.0; + foreach ($parts as $parameter) { + if (stripos($parameter, 'q=') !== 0) { + continue; + } + $qualityValue = substr($parameter, 2); + $quality = is_numeric($qualityValue) ? (float) $qualityValue : 0.0; + break; + } + if ($quality <= 0.0 || $quality > 1.0) { + continue; + } + + $supported[] = [ + 'locale' => $locale, + 'quality' => $quality, + 'position' => $position, + ]; + } + + usort($supported, static function (array $left, array $right): int { + if ($left['quality'] === $right['quality']) { + return $left['position'] <=> $right['position']; + } + return $left['quality'] < $right['quality'] ? 1 : -1; + }); + + return $supported[0]['locale'] ?? self::ENGLISH; + } + + public static function templateLanguage(string $locale): string + { + return self::normalizeLocale($locale) === self::ENGLISH ? 'true' : 'false'; + } + + public static function switchUrl(string $locale, string $requestUri): string + { + $locale = self::normalizeLocale($locale) ?? self::CHINESE; + $parts = parse_url($requestUri); + if (!is_array($parts) || isset($parts['scheme']) || isset($parts['host'])) { + $parts = ['path' => '/']; + } + $path = is_array($parts) && isset($parts['path']) ? (string) $parts['path'] : '/'; + if ($path === '' || $path[0] !== '/' || str_starts_with($path, '//') + || preg_match('/[\x00-\x1F\x7F]/', $path)) { + $path = '/'; + } + + $query = []; + if (is_array($parts) && isset($parts['query'])) { + parse_str((string) $parts['query'], $query); + } + $query['lang'] = $locale; + + return $path . '?' . http_build_query($query, '', '&', PHP_QUERY_RFC3986); + } + + public static function viewData(string $locale, string $requestUri): array + { + $locale = self::normalizeLocale($locale) ?? self::CHINESE; + + return [ + 'public_locale' => $locale, + 'language' => self::templateLanguage($locale), + 'language_zh_url' => self::switchUrl(self::CHINESE, $requestUri), + 'language_en_url' => self::switchUrl(self::ENGLISH, $requestUri), + ]; + } +} diff --git a/web/public/cloud/account.css b/web/public/cloud/account.css index 87bb65c1..f741c506 100644 --- a/web/public/cloud/account.css +++ b/web/public/cloud/account.css @@ -1059,41 +1059,6 @@ body.venix-auth { background: radial-gradient(circle at 12% 8%, rgba(41, 194, 197, .12), transparent 26%), radial-gradient(circle at 88% 92%, rgba(42, 102, 150, .09), transparent 30%), var(--vu-bg); } -body.venix-auth .auth-site-nav { - min-height: 78px; - display: flex; - align-items: center; - justify-content: space-between; - gap: 20px; - padding: 16px clamp(22px, 5vw, 76px); - background: rgba(255, 255, 255, .86); - border-bottom: 1px solid rgba(223, 231, 238, .85); - backdrop-filter: blur(16px); -} -body.venix-auth .auth-site-nav .home-brand { - min-width: 0; - display: flex; - align-items: center; - gap: 12px; - color: var(--vu-text); - font-size: 20px; - font-weight: 800; - letter-spacing: -.3px; - text-decoration: none; -} -body.venix-auth .auth-site-nav .home-brand > span:last-child { - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} -body.venix-auth .auth-site-nav nav { - display: flex; - flex-wrap: wrap; - align-items: center; - justify-content: flex-end; - gap: 8px; -} -body.venix-auth .auth-site-nav nav a, body.venix-auth .auth-link { padding: 9px 11px; color: var(--vu-brand-strong); @@ -1102,15 +1067,7 @@ body.venix-auth .auth-link { font-weight: 750; text-decoration: none; } -body.venix-auth .auth-site-nav nav a:hover, -body.venix-auth .auth-site-nav nav a[aria-current="page"], body.venix-auth .auth-link:hover { background: var(--vu-brand-soft); } -body.venix-auth .auth-site-nav .home-nav-button { color: #fff; background: var(--vu-brand); } -body.venix-auth .auth-site-nav .home-nav-button:hover, -body.venix-auth .auth-site-nav .home-nav-button[aria-current="page"] { - color: #fff; - background: var(--vu-brand-strong); -} body.venix-auth .auth-shell { width: 100%; @@ -1258,10 +1215,6 @@ body.venix-auth .auth-legal-consent a:hover { text-decoration: underline; } background: radial-gradient(circle at 12% 8%, rgba(41, 194, 197, .1), transparent 26%), radial-gradient(circle at 88% 92%, rgba(42, 102, 150, .11), transparent 30%), var(--vu-bg); } -:root[data-bs-theme="dark"] body.venix-auth .auth-site-nav { - background: rgba(16, 32, 52, .86); - border-color: var(--vu-border); -} :root[data-bs-theme="dark"] body.venix-auth .auth-panel { background: rgba(20, 36, 56, .96); } @media (max-width: 1150px) { @@ -1353,9 +1306,6 @@ body.venix-auth .auth-legal-consent a:hover { text-decoration: underline; } padding: 25px 20px; border-radius: 16px; } - body.venix-auth .auth-site-nav { min-height: 68px; padding: 13px 16px; } - body.venix-auth .auth-site-nav .home-brand { font-size: 17px; } - body.venix-auth .auth-site-nav nav a { padding: 7px 8px; font-size: 12px; } body.venix-auth .auth-shell { align-items: start; padding: 28px 14px; } body.venix-auth .auth-panel { padding: 26px 20px; border-radius: 15px; } body.venix-auth .auth-panel-wide { @@ -1374,7 +1324,6 @@ body.venix-auth .auth-legal-consent a:hover { text-decoration: underline; } } @media (max-width: 390px) { - body.venix-auth .auth-site-nav .home-brand > span:last-child { max-width: 138px; } body.vu-body .vu-top-actions > :where(.vu-btn, .vu-theme-toggle) { width: 100%; flex-basis: 100%; @@ -1389,8 +1338,6 @@ body.venix-auth .auth-legal-consent a:hover { text-decoration: underline; } body.vu-body .vu-invoice-head, body.vu-body .vu-invoice-parties, body.vu-body .vu-invoice-bottom { flex-direction: column; } - body.venix-auth .auth-site-nav nav { gap: 2px; } - body.venix-auth .auth-site-nav nav a:not(.home-nav-button) { display: none; } body.venix-auth .auth-row-inline { flex-wrap: wrap; } body.venix-auth .auth-row-inline .auth-field { flex-basis: 100%; } } @@ -1955,48 +1902,6 @@ body.venix-auth.virsh-auth { background: #fff; } -body.venix-auth.virsh-auth .auth-site-nav { - position: absolute; - top: 0; - right: 0; - left: 0; - z-index: 20; - width: 100%; - min-height: 86px; - padding: 24px clamp(32px, 5vw, 88px); - background: transparent; - border: 0; - backdrop-filter: none; -} - -body.venix-auth.virsh-auth .auth-site-nav .home-brand { - max-width: min(40vw, 520px); - color: #fff; - font-size: 23px; - letter-spacing: -.6px; -} - -body.venix-auth.virsh-auth .auth-site-nav nav { - margin-left: auto; -} - -body.venix-auth.virsh-auth .auth-site-nav nav a { - color: #526276; -} - -body.venix-auth.virsh-auth .auth-site-nav nav a:hover, -body.venix-auth.virsh-auth .auth-site-nav nav a[aria-current="page"] { - color: #0f8f9a; - background: #e7f7f8; -} - -body.venix-auth.virsh-auth .auth-site-nav .home-nav-button, -body.venix-auth.virsh-auth .auth-site-nav .home-nav-button:hover, -body.venix-auth.virsh-auth .auth-site-nav .home-nav-button[aria-current="page"] { - color: #fff; - background: #0f9eaa; -} - body.venix-auth.virsh-auth .auth-shell-virsh { width: 100%; min-height: 100vh; @@ -2283,39 +2188,19 @@ body.venix-auth.virsh-auth .auth-switch a { body.venix-auth.virsh-auth .auth-switch a:hover { text-decoration: underline; } -body.venix-auth.virsh-auth .auth-copyright { - margin: 25px 0 0; - color: #9aa5b2; - font-size: 12px; - line-height: 1.7; -} - @media (max-width: 740px) { - body.venix-auth.virsh-auth .auth-site-nav { - position: relative; - min-height: 68px; - padding: 13px 18px; - background: #fff; - border-bottom: 1px solid #e7edf2; - } - - body.venix-auth.virsh-auth .auth-site-nav .home-brand { - max-width: 52vw; - color: #15243a; - font-size: 18px; - } - body.venix-auth.virsh-auth .auth-shell-virsh { - min-height: calc(100vh - 68px); - min-height: calc(100svh - 68px); + min-height: 100vh; + min-height: 100svh; display: block; + padding-top: 88px; } body.venix-auth.virsh-auth .auth-story-virsh { display: none; } body.venix-auth.virsh-auth .auth-panel-wrap { - min-height: calc(100vh - 68px); - min-height: calc(100svh - 68px); + min-height: calc(100vh - 88px); + min-height: calc(100svh - 88px); align-items: flex-start; padding: 46px 25px 64px; } @@ -2323,10 +2208,16 @@ body.venix-auth.virsh-auth .auth-copyright { body.venix-auth.virsh-auth .auth-title { font-size: 29px; } } +@media (max-width: 560px) { + body.venix-auth.virsh-auth .auth-shell-virsh { padding-top: 76px; } + body.venix-auth.virsh-auth .auth-panel-wrap { + min-height: calc(100vh - 76px); + min-height: calc(100svh - 76px); + } +} + @media (max-width: 420px) { body.venix-auth.virsh-auth .auth-panel-wrap { padding: 38px 20px 54px; } - body.venix-auth.virsh-auth .auth-site-nav nav { gap: 2px; } - body.venix-auth.virsh-auth .auth-site-nav nav a { padding: 7px 8px; font-size: 12px; } body.venix-auth.virsh-auth .auth-row-inline { flex-wrap: wrap; } body.venix-auth.virsh-auth .auth-row-inline > input { flex-basis: 100%; } body.venix-auth.virsh-auth .auth-row-inline .auth-button, diff --git a/web/public/theme/venix/css/home.css b/web/public/theme/venix/css/home.css index 056a76ce..d8408615 100644 --- a/web/public/theme/venix/css/home.css +++ b/web/public/theme/venix/css/home.css @@ -82,7 +82,31 @@ body.venix-home ::selection { color: #04191b; background: var(--landing-teal-bri } .landing-nav-actions { display: flex; align-items: center; gap: 16px; } .landing-nav-login { color: rgba(255, 255, 255, .8); font-size: 13px; font-weight: 750; text-decoration: none; } -.landing-nav-login:hover { color: #fff; } +.landing-nav-login:hover, +.landing-nav-login.is-active { color: #fff; } +.landing-language-switch { + padding: 3px; + border: 1px solid rgba(255,255,255,.14); + border-radius: 9px; + display: inline-flex; + align-items: center; + gap: 2px; + background: rgba(255,255,255,.05); +} +.landing-language-switch a { + min-width: 35px; + padding: 6px 8px; + border-radius: 6px; + color: rgba(255,255,255,.58); + font-size: 10px; + font-weight: 850; + line-height: 1; + text-align: center; + text-decoration: none; +} +.landing-language-switch a:hover { color: #fff; } +.landing-language-switch a.is-active { color: #04191b; background: var(--landing-teal-bright); } +.landing-mobile-nav-actions { display: none; } .landing-button { min-height: 48px; padding: 0 21px; @@ -361,6 +385,20 @@ body.venix-home > main.home-error { width: 100%; min-height: 100vh; min-height: .landing-site-header.is-menu-open .landing-main-nav a { padding: 12px; border-radius: 8px; } .landing-site-header.is-menu-open .landing-main-nav a:hover { background: rgba(255,255,255,.06); } .landing-site-header.is-menu-open .landing-main-nav a.is-active::after { display: none; } + .landing-site-header.is-menu-open .landing-mobile-nav-actions { + grid-column: 1 / -1; + margin-top: 8px; + padding-top: 14px; + border-top: 1px solid rgba(255,255,255,.1); + display: flex; + align-items: center; + flex-wrap: wrap; + gap: 10px; + } + .landing-site-header.is-menu-open .landing-mobile-nav-actions .landing-language-switch { margin-right: auto; } + .landing-site-header.is-menu-open .landing-mobile-nav-actions .landing-language-switch a { min-width: 34px; padding: 6px 8px; } + .landing-site-header.is-menu-open .landing-mobile-nav-actions .landing-nav-login { padding: 9px 11px; } + .landing-site-header.is-menu-open .landing-mobile-nav-actions .landing-button { min-height: 38px; padding: 0 13px; } .landing-hero { gap: 40px; } .landing-feature-grid { grid-template-columns: 1fr; } .landing-feature-grid article { min-height: 300px; border-right: 0; border-bottom: 1px solid #cfdbdd; } diff --git a/web/resources/views/venix/auth/copyright.tpl b/web/resources/views/venix/auth/copyright.tpl deleted file mode 100644 index e14d9826..00000000 --- a/web/resources/views/venix/auth/copyright.tpl +++ /dev/null @@ -1 +0,0 @@ - diff --git a/web/resources/views/venix/auth/layout_footer.tpl b/web/resources/views/venix/auth/layout_footer.tpl new file mode 100644 index 00000000..f6a76ad6 --- /dev/null +++ b/web/resources/views/venix/auth/layout_footer.tpl @@ -0,0 +1,2 @@ +{include file='home/site_footer.tpl'} +{include file='auth/layout_scripts.tpl'} diff --git a/web/resources/views/venix/auth/layout_header.tpl b/web/resources/views/venix/auth/layout_header.tpl index 2c47fe4b..b6708280 100644 --- a/web/resources/views/venix/auth/layout_header.tpl +++ b/web/resources/views/venix/auth/layout_header.tpl @@ -1,4 +1,5 @@ {include file='layout_assets.tpl'} +{assign var=home_active value=$auth_page|default:''} @@ -12,22 +13,8 @@ + -
- - {include file='components/site_brand_mark.tpl'} - {$auth_app_name|escape:"html"} - - -
+{include file='home/site_header.tpl'} diff --git a/web/resources/views/venix/auth/login.tpl b/web/resources/views/venix/auth/login.tpl index 47313210..21c03255 100644 --- a/web/resources/views/venix/auth/login.tpl +++ b/web/resources/views/venix/auth/login.tpl @@ -54,12 +54,11 @@

{if $language == 'true'}No account yet?{else}还没有账户?{/if} {if $language == 'true'}Create one{else}立即注册{/if}

- {include file='auth/copyright.tpl' auth_app_name=$appName} -{include file='auth/layout_scripts.tpl'} +{include file='auth/layout_footer.tpl'}