新增一个 devEnv 用于判断生产环境|开发环境

fix #26
This commit is contained in:
BTMuli
2023-05-24 15:45:03 +08:00
parent d1e39ed8cd
commit f55a688aae
4 changed files with 23 additions and 12 deletions

View File

@@ -40,12 +40,12 @@
</template>
</v-list-item>
<v-divider />
<v-list-item title="测试" value="test" link href="/user/test">
<v-list-item v-show="appStore.devEnv" title="测试" value="test" link href="/user/test">
<template #prepend>
<v-icon>mdi-test-tube</v-icon>
</template>
</v-list-item>
<v-divider />
<v-divider v-show="appStore.devEnv" />
<v-list-group value="wiki" fluid>
<template #activator="{ props }">
<v-list-item title="图鉴" v-bind="props">

View File

@@ -119,7 +119,7 @@
调试
</v-list-subheader>
<v-divider inset class="border-opacity-75" />
<v-list-item title="开发者模式" subtitle="开启后将显示调试信息">
<v-list-item v-if="appStore.devEnv" title="调试模式" subtitle="开启后将显示调试信息">
<template #prepend>
<v-icon>mdi-bug</v-icon>
</template>
@@ -138,12 +138,9 @@
<span style="cursor: pointer" @click="tryConfirm('inputCookie')">手动输入 Cookie</span>
</template>
<template #append>
<div style="cursor: pointer" @click="toOuter('https://github.com/BTMuli/Tauri.Genshin/issues/18')">
<span>如何获取 Cookie</span>
<v-icon @click="">
<v-icon style="cursor: pointer" @click="toOuter('https://github.com/BTMuli/Tauri.Genshin/issues/18')">
mdi-help-circle-outline
</v-icon>
</div>
</template>
</v-list-item>
<v-list-item title="删除 IndexedDB" prepend-icon="mdi-delete" @click="tryConfirm('delDB')" />
@@ -178,7 +175,6 @@
<script lang="ts" setup>
// vue
import { computed, onMounted, ref } from "vue";
import { getBuildTime } from "../utils/TGBuild";
import TLoading from "../components/t-loading.vue";
import TConfirm from "../components/t-confirm.vue";
// tauri
@@ -204,7 +200,7 @@ const achievementsStore = useAchievementsStore();
// About App
const versionApp = ref("" as string);
const versionTauri = ref("" as string);
const buildTime = ref(getBuildTime());
const buildTime = computed(() => appStore.buildTime);
// About OS
const osPlatform = ref("" as string);

View File

@@ -12,8 +12,12 @@ import TPosition from "../components/t-position.vue";
import TCalendar from "../components/t-calendar.vue";
// store
import { useHomeStore } from "../store/modules/home";
import { useAppStore } from "../store/modules/app";
// utils
import { getBuildTime } from "../utils/TGBuild";
// store
const appStore = useAppStore();
const homeStore = useHomeStore();
// loading
@@ -57,6 +61,13 @@ onMounted(async () => {
}),
);
timer.value = setInterval(readLoading, 100);
// 获取当前环境
const timeGet = getBuildTime();
appStore.devEnv = timeGet.startsWith("dev");
if (!appStore.devEnv && appStore.devMode) {
appStore.devMode = false;
}
appStore.buildTime = getBuildTime();
});
function setItemRef (item: any) {

View File

@@ -38,6 +38,8 @@ export const useAppStore = defineStore(
});
// 开发者模式
const devMode = ref(false);
// 环境检测
const devEnv = ref(false);
// 应用主题
const theme = ref("default");
// 是否登录
@@ -57,6 +59,7 @@ export const useAppStore = defineStore(
function init (): void {
loading.value = false;
devMode.value = false;
devEnv.value = false;
sidebar.submenu = {
wiki: false,
};
@@ -81,6 +84,7 @@ export const useAppStore = defineStore(
buildTime,
sidebar,
devMode,
devEnv,
dataPath,
userPath,
init,
@@ -98,7 +102,7 @@ export const useAppStore = defineStore(
{
key: "app",
storage: window.localStorage,
paths: ["devMode", "loading", "buildTime", "isLogin"],
paths: ["devMode", "loading", "buildTime", "isLogin", "devEnv"],
},
{
key: "sidebar",