Settings: add code version
All checks were successful
/ depoly (push) Successful in 1m21s

This commit is contained in:
thislight 2024-11-10 23:08:54 +08:00
parent 814ac07581
commit b2b84a9e5b
No known key found for this signature in database
GPG key ID: FCFE5192241CCD4E
5 changed files with 22 additions and 0 deletions

View file

@ -33,10 +33,14 @@ jobs:
- name: Build Dist (Staging) - name: Build Dist (Staging)
run: bun dist -m staging run: bun dist -m staging
if: env.GITHUB_REF_NAME == 'master' if: env.GITHUB_REF_NAME == 'master'
env:
VITE_CODE_VERSION: ${{ env.GITHUB_SHA }}
- name: Build Dist - name: Build Dist
run: bun dist run: bun dist
if: env.GITHUB_REF_NAME != 'master' if: env.GITHUB_REF_NAME != 'master'
env:
VITE_CODE_VERSION: ${{ env.GITHUB_SHA }}
- name: Depoly to Preview - name: Depoly to Preview
uses: https://github.com/cloudflare/wrangler-action@v3 uses: https://github.com/cloudflare/wrangler-action@v3

4
src/overrides.d.ts vendored
View file

@ -3,6 +3,10 @@
interface ImportMetaEnv { interface ImportMetaEnv {
readonly BUILT_AT: string; readonly BUILT_AT: string;
readonly PACKAGE_VERSION: string; readonly PACKAGE_VERSION: string;
/**
* The code reversion. It's recommended to be the git commit sha.
*/
readonly VITE_CODE_VERSION?: string;
} }
interface ImportMeta { interface ImportMeta {

View file

@ -346,6 +346,18 @@ const Settings: ParentComponent = (props) => {
</Show> </Show>
</ListItem> </ListItem>
<Divider /> <Divider />
{import.meta.env.VITE_CODE_VERSION ? (
<>
<ListItem>
<ListItemText secondary={import.meta.env.VITE_CODE_VERSION}>
{t("version.code")}
</ListItemText>
</ListItem>
<Divider />
</>
) : (
<></>
)}
</li> </li>
{import.meta.env.DEV ? ( {import.meta.env.DEV ? (
<li> <li>

View file

@ -12,6 +12,7 @@
"updates.ready": "An update is ready, restart the Tutu to apply", "updates.ready": "An update is ready, restart the Tutu to apply",
"updates.no": "No updates", "updates.no": "No updates",
"version": "Using v{{packageVersion}} (built on {{builtAt}}, {{buildMode}})", "version": "Using v{{packageVersion}} (built on {{builtAt}}, {{buildMode}})",
"version.code": "Code Version",
"Language": "Language", "Language": "Language",
"Region": "Region", "Region": "Region",
"lang.auto": "(Auto) {{detected}}", "lang.auto": "(Auto) {{detected}}",

View file

@ -12,6 +12,7 @@
"updates.ready": "更新已准备好,下次开启会启动新版本", "updates.ready": "更新已准备好,下次开启会启动新版本",
"updates.no": "已是最新版本", "updates.no": "已是最新版本",
"version": "正在使用 v{{packageVersion}} ({{builtAt}}构建, {{buildMode}})", "version": "正在使用 v{{packageVersion}} ({{builtAt}}构建, {{buildMode}})",
"version.code": "代码版本",
"Language": "语言", "Language": "语言",
"Region": "区域", "Region": "区域",
"lang.auto": "(自动){{detected}}", "lang.auto": "(自动){{detected}}",