From 03136c4864cd1afc8873c58d68c857e58fe7b6d9 Mon Sep 17 00:00:00 2001 From: BTMuli Date: Thu, 1 Jan 2026 23:15:51 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E6=AD=A3isDevEnv?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- eslint/vueEslint.js | 4 ++-- src/components/app/t-sidebar.vue | 4 ++-- src/vite-env.d.ts | 5 +++++ vite.config.ts | 1 + 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/eslint/vueEslint.js b/eslint/vueEslint.js index 557bd28c..875fd9fe 100644 --- a/eslint/vueEslint.js +++ b/eslint/vueEslint.js @@ -1,5 +1,5 @@ /** - * Vue&Typescirpt 文件的 Eslint 配置 + * Vue & Typescript 文件的 Eslint 配置 * @since Beta v0.9.1 */ import pluginImport from "eslint-plugin-import"; @@ -47,7 +47,7 @@ const vueConfig = { files: ["src/**/*.vue", "src/App.vue"], plugins: { vue: pluginVue, import: pluginImport, prettier: pluginPrettier }, languageOptions: { - globals: { ...globals.browser, ...globals.es2021, TGApp: "readonly", window: "readonly" }, + globals: { ...globals.browser, ...globals.es2021, TGApp: "readonly", window: "readonly", proEnv: "readonly" }, ecmaVersion: "latest", sourceType: "module", parser: parserVue, diff --git a/src/components/app/t-sidebar.vue b/src/components/app/t-sidebar.vue index c0760ea8..13f25e33 100644 --- a/src/components/app/t-sidebar.vue +++ b/src/components/app/t-sidebar.vue @@ -330,8 +330,8 @@ const userStore = useUserStore(); const { sidebar, theme, isLogin, recentNewsType, gameDir } = storeToRefs(useAppStore()); const { uid, briefInfo, cookie, account } = storeToRefs(userStore); let themeListener: UnlistenFn | null = null; -// @ts-expect-error The import.meta meta-property is not allowed in files which will build into CommonJS output. -const isDevEnv = import.meta.env.MODE === "development"; + +const isDevEnv = proEnv.TAURI_ENV_DEBUG; const showFollow = ref(); const showLoginQr = ref(false); const isTryLogin = ref(false); diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts index 6e7ced70..02ed7ea1 100644 --- a/src/vite-env.d.ts +++ b/src/vite-env.d.ts @@ -51,3 +51,8 @@ declare type TauriProcessEnv = NodeJS.ProcessEnv & { /** 平台类型,例如 `"desktop"`。 */ TAURI_PLATFORM_TYPE?: string; }; + +/** + * ProcessEnv的转换 + */ +declare const proEnv: TauriProcessEnv; diff --git a/vite.config.ts b/vite.config.ts index 74a8c285..7a2a072b 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -14,6 +14,7 @@ const host = process.env.TAURI_DEV_HOST; // https://vitejs.dev/config/ export default defineConfig({ + define: { proEnv: process.env }, plugins: [ vue(), vuetify(),