diff --git a/.forgejo/workflows/depoly.yml b/.forgejo/workflows/depoly.yml index 385fbb2..b541fa0 100644 --- a/.forgejo/workflows/depoly.yml +++ b/.forgejo/workflows/depoly.yml @@ -33,10 +33,14 @@ jobs: - name: Build Dist (Staging) run: bun dist -m staging if: env.GITHUB_REF_NAME == 'master' + env: + VITE_CODE_VERSION: ${{ env.GITHUB_SHA }} - name: Build Dist run: bun dist if: env.GITHUB_REF_NAME != 'master' + env: + VITE_CODE_VERSION: ${{ env.GITHUB_SHA }} - name: Depoly to Preview uses: https://github.com/cloudflare/wrangler-action@v3 diff --git a/src/overrides.d.ts b/src/overrides.d.ts index fc32e50..4e0ce4d 100644 --- a/src/overrides.d.ts +++ b/src/overrides.d.ts @@ -3,6 +3,10 @@ interface ImportMetaEnv { readonly BUILT_AT: string; readonly PACKAGE_VERSION: string; + /** + * The code reversion. It's recommended to be the git commit sha. + */ + readonly VITE_CODE_VERSION?: string; } interface ImportMeta { diff --git a/src/settings/Settings.tsx b/src/settings/Settings.tsx index 50ec67d..34bb4cc 100644 --- a/src/settings/Settings.tsx +++ b/src/settings/Settings.tsx @@ -346,6 +346,18 @@ const Settings: ParentComponent = (props) => { + {import.meta.env.VITE_CODE_VERSION ? ( + <> + + + {t("version.code")} + + + + + ) : ( + <> + )} {import.meta.env.DEV ? (
  • diff --git a/src/settings/i18n/en.json b/src/settings/i18n/en.json index 98424be..24ce5e5 100644 --- a/src/settings/i18n/en.json +++ b/src/settings/i18n/en.json @@ -12,6 +12,7 @@ "updates.ready": "An update is ready, restart the Tutu to apply", "updates.no": "No updates", "version": "Using v{{packageVersion}} (built on {{builtAt}}, {{buildMode}})", + "version.code": "Code Version", "Language": "Language", "Region": "Region", "lang.auto": "(Auto) {{detected}}", diff --git a/src/settings/i18n/zh-Hans.json b/src/settings/i18n/zh-Hans.json index 481d57c..d898801 100644 --- a/src/settings/i18n/zh-Hans.json +++ b/src/settings/i18n/zh-Hans.json @@ -12,6 +12,7 @@ "updates.ready": "更新已准备好,下次开启会启动新版本", "updates.no": "已是最新版本", "version": "正在使用 v{{packageVersion}} ({{builtAt}}构建, {{buildMode}})", + "version.code": "代码版本", "Language": "语言", "Region": "区域", "lang.auto": "(自动){{detected}}",