♻️ 通过 import.meta 获取当前环境

This commit is contained in:
BTMuli
2023-10-08 23:51:34 +08:00
parent 6e79c0a7e0
commit 66ecd9a91e
5 changed files with 13 additions and 14 deletions

View File

@@ -107,7 +107,7 @@
<v-list-subheader :inset="true" class="config-header" title="调试" />
<v-divider :inset="true" class="border-opacity-75" />
<v-list-item
v-if="appStore.devEnv"
v-if="isDevEnv"
title="调试模式"
subtitle="开启后将显示调试信息"
prepend-icon="mdi-bug-play"
@@ -176,6 +176,8 @@ const userStore = useUserStore();
const homeStore = useHomeStore();
const achievementsStore = useAchievementsStore();
const isDevEnv = ref<boolean>(!import.meta?.env?.PROD);
// About App
const versionApp = ref<string>("");
const versionTauri = ref<string>("");

View File

@@ -49,10 +49,9 @@ function readLoading(): void {
onMounted(async () => {
loadingTitle.value = "正在加载首页";
loading.value = true;
const isProdEnv = import.meta?.env?.PROD;
// 获取当前环境
const timeGet = getBuildTime();
appStore.devEnv = timeGet.startsWith("dev");
if (!appStore.devEnv && appStore.devMode) {
if (isProdEnv && appStore.devMode) {
appStore.devMode = false;
}
const showItems = homeStore.getShowValue();
@@ -71,7 +70,7 @@ onMounted(async () => {
}),
);
timer.value = setInterval(readLoading, 100);
if (appStore.buildTime !== getBuildTime() && !appStore.devEnv) {
if (appStore.buildTime !== getBuildTime() && isProdEnv) {
const confirm = await showConfirm({
title: "检测到版本更新",
text: "请到设置页手动更新版本,即将弹出更新说明子页面",