diff --git a/.github/workflows/frontend_deploy.yaml b/.github/workflows/frontend_deploy.yaml index b0336865..8394cfc4 100644 --- a/.github/workflows/frontend_deploy.yaml +++ b/.github/workflows/frontend_deploy.yaml @@ -34,7 +34,6 @@ jobs: cd frontend/ echo "${{ secrets.FRONTEND_ENV }}" > .env.prod export project_name=${{ secrets.FRONTEND_NAME }} - export VITE_VERSION=${{ github.ref_name }} pnpm install --no-frozen-lockfile pnpm run deploy --project-name=$project_name echo "Deploying prodcution for ${{ github.ref_name }}" diff --git a/frontend/package.json b/frontend/package.json index bdfe4a2d..f64d15cb 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "cloudflare_temp_email", - "version": "0.0.0", + "version": "0.4.2", "private": true, "type": "module", "scripts": { diff --git a/frontend/src/views/Header.vue b/frontend/src/views/Header.vue index 6764af48..adedfa1f 100644 --- a/frontend/src/views/Header.vue +++ b/frontend/src/views/Header.vue @@ -69,6 +69,8 @@ const { t } = useI18n({ } }); +const version = import.meta.env.PACKAGE_VERSION ? `v${import.meta.env.PACKAGE_VERSION}` : ""; + const menuOptions = computed(() => [ { label: () => h(NButton, @@ -171,7 +173,7 @@ const menuOptions = computed(() => [ href: "https://github.com/dreamhunter2333/cloudflare_temp_email", }, { - default: () => import.meta.env.VITE_VERSION || "Github", + default: () => version || "Github", icon: () => h(NIcon, { component: GithubAlt }) } ), diff --git a/frontend/vite.config.js b/frontend/vite.config.js index 70f00f25..442a6561 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -71,5 +71,8 @@ export default defineConfig({ alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) } + }, + define: { + 'import.meta.env.PACKAGE_VERSION': JSON.stringify(process.env.npm_package_version), } }) diff --git a/vitepress-docs/docs/zh/guide/cli/pages.md b/vitepress-docs/docs/zh/guide/cli/pages.md index 78dc82af..b3d23c01 100644 --- a/vitepress-docs/docs/zh/guide/cli/pages.md +++ b/vitepress-docs/docs/zh/guide/cli/pages.md @@ -15,8 +15,6 @@ cp .env.example .env.prod 例如: `VITE_API_BASE=https://xxx.xxx.workers.dev` ```bash -# 请修改为你的版本号, 可以不填 -# export VITE_VERSION=0.0.0 pnpm build --emptyOutDir # 根据提示创建 pages pnpm run deploy diff --git a/worker/src/commom_api.js b/worker/src/commom_api.js index 99472b8d..a394750a 100644 --- a/worker/src/commom_api.js +++ b/worker/src/commom_api.js @@ -1,6 +1,7 @@ import { Hono } from 'hono' import { getDomains, getPasswords, getBooleanValue } from './utils'; +import { CONSTANTS } from './constants'; const api = new Hono() @@ -22,6 +23,7 @@ api.get('/open_api/settings', async (c) => { "enableAutoReply": getBooleanValue(c.env.ENABLE_AUTO_REPLY), "copyright": c.env.COPYRIGHT, "cfTurnstileSiteKey": c.env.CF_TURNSTILE_SITE_KEY, + "version": CONSTANTS.VERSION, }); }) diff --git a/worker/src/constants.js b/worker/src/constants.js index 45a8fc58..7f942c0e 100644 --- a/worker/src/constants.js +++ b/worker/src/constants.js @@ -1,4 +1,5 @@ export const CONSTANTS = { + VERSION: 'v0.4.2', ADDRESS_BLOCK_LIST_KEY: 'address_block_list', SEND_BLOCK_LIST_KEY: 'send_block_list', AUTO_CLEANUP_KEY: 'auto_cleanup',