fix(config): 还是加回来了, devMode 还是有必要的

This commit is contained in:
BTMuli
2023-03-28 22:20:47 +08:00
parent c901307ebc
commit 055d3e5d7f
4 changed files with 44 additions and 12 deletions

View File

@@ -15,11 +15,7 @@
</v-list-item>
<v-list-item title="Tauri 版本" @click="toOuter('https://next--tauri.netlify.app/')">
<template v-slot:prepend>
<img
class="config-icon"
src="https://next--tauri.netlify.app/meta/favicon-32x32.png"
alt="Tauri"
/>
<img class="config-icon" src="/tauri.png" alt="Tauri" />
</template>
<template v-slot:append>
<v-list-item-subtitle>{{ versionTauri }}</v-list-item-subtitle>
@@ -68,6 +64,18 @@
/>
</template>
</v-list-item>
<v-list-item>
<v-list-item-title>开发者模式</v-list-item-title>
<v-list-item-subtitle>开启后将显示调试信息</v-list-item-subtitle>
<template v-slot:append>
<v-switch
:label="appStore.devMode ? '开启' : '关闭'"
inset
v-model="appStore.devMode"
color="#0781D8"
/>
</template>
</v-list-item>
</v-list>
</v-card>
<v-card class="common-card">

View File

@@ -31,6 +31,12 @@
查看
</v-btn>
<v-card-subtitle>id:{{ item.post_id }}</v-card-subtitle>
<v-btn @click="toJson(item.post_id)" class="ms-2 card-btn" v-show="appStore.devMode">
<template v-slot:prepend>
<img src="../assets/icons/arrow-right.svg" alt="right" onload="SVGInject(this)" />
</template>
JSON
</v-btn>
</v-card-actions>
</v-card>
</div>
@@ -58,9 +64,17 @@
查看
</v-btn>
<v-card-subtitle>id:{{ item.post_id }}</v-card-subtitle>
<v-btn v-if="item.status === 1" color="ms-2 card-btn-0">进行中</v-btn>
<v-btn v-else-if="item.status === 2" color="ms-2 card-btn-2">已结束</v-btn>
<v-btn v-else color="ms-2 card-btn-1">评选中</v-btn>
<div v-show="!appStore.devMode">
<v-btn v-if="item.status === 1" color="ms-2 card-btn-0">进行中</v-btn>
<v-btn v-else-if="item.status === 2" color="ms-2 card-btn-2">已结束</v-btn>
<v-btn v-else color="ms-2 card-btn-1">评选中</v-btn>
</div>
<v-btn @click="toJson(item.post_id)" class="ms-2 card-btn" v-show="appStore.devMode">
<template v-slot:prepend>
<img src="../assets/icons/arrow-right.svg" alt="right" onload="SVGInject(this)" />
</template>
JSON
</v-btn>
</v-card-actions>
</v-card>
</div>
@@ -87,6 +101,12 @@
查看
</v-btn>
<v-card-subtitle>id:{{ item.post_id }}</v-card-subtitle>
<v-btn @click="toJson(item.post_id)" class="ms-2 card-btn" v-show="appStore.devMode">
<template v-slot:prepend>
<img src="../assets/icons/arrow-right.svg" alt="right" onload="SVGInject(this)" />
</template>
JSON
</v-btn>
</v-card-actions>
</v-card>
</div>
@@ -200,18 +220,18 @@ async function toPost(post_id: string) {
const postUrl = `file:\\\\\\${appStore.dataPath.temp}\\${post.post_id}.html`;
createTGWindow(postUrl, "MysPost", post.subject, 960, 720, false);
}
async function logPost(post_id: string) {
async function toJson(post_id: string) {
const post = await getPost(post_id).then(res => {
return res.data;
});
// 将 json 保存到 文件
await fs.writeTextFile(
`${appStore.dataPath.temp}\\${post_id}_log.json`,
`${appStore.dataPath.temp}\\${post_id}.json`,
JSON.stringify(post, null, 4)
);
const logUrl = `file:\\\\\\${appStore.dataPath.temp}\\${post_id}_log.json`;
const logUrl = `file:\\\\\\${appStore.dataPath.temp}\\${post_id}.json`;
// 打开窗口
createTGWindow(logUrl, "MysPostLog", post_id, 960, 720, false);
createTGWindow(logUrl, "MysPostJson", post_id, 960, 720, false);
}
async function getPost(post_id: string): Promise<ResponsePost> {
return http

View File

@@ -32,6 +32,8 @@ const useAppStore = defineStore({
},
// 咨讯页渲染模式
structureRender: true, // 是否采用结构化渲染,否则采用 raw 渲染
// 开发者模式
devMode: false,
// 数据路径
dataPath: {
app: appDataDir,
@@ -81,6 +83,8 @@ const useAppStore = defineStore({
this.loading = false;
// 初始化咨讯页渲染模式
this.structureRender = true;
// 初始化开发者模式
this.devMode = false;
// 初始化用户数据路径
this.userPath = {
achievements: `${userDataDir}\\achievements.json`,