mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-15 09:48:14 +08:00
fix(config): 替换非必要 dialog
This commit is contained in:
@@ -57,6 +57,7 @@
|
|||||||
inset
|
inset
|
||||||
v-model="appStore.devMode"
|
v-model="appStore.devMode"
|
||||||
color="#FAC51E"
|
color="#FAC51E"
|
||||||
|
@click="submitDevMode"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
@@ -91,9 +92,11 @@
|
|||||||
</v-list-item>
|
</v-list-item>
|
||||||
</v-list>
|
</v-list>
|
||||||
<!-- 弹窗提示条 -->
|
<!-- 弹窗提示条 -->
|
||||||
<v-snackbar v-model="snackbar" timeout="1500" color="success">
|
<v-snackbar v-model="snackbar" timeout="1500" :color="snackbarColor">
|
||||||
{{ snackbarText }}
|
{{ snackbarText }}
|
||||||
</v-snackbar>
|
</v-snackbar>
|
||||||
|
<!-- 确认弹窗 -->
|
||||||
|
<t-confirm :title="confirmText" v-model:show="confirmShow" v-model:value="confirmValue" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -101,6 +104,7 @@
|
|||||||
// vue
|
// vue
|
||||||
import { onMounted, ref } from "vue";
|
import { onMounted, ref } from "vue";
|
||||||
import TLoading from "../components/t-loading.vue";
|
import TLoading from "../components/t-loading.vue";
|
||||||
|
import TConfirm from "../components/t-confirm.vue";
|
||||||
// tauri
|
// tauri
|
||||||
import { dialog, fs, app } from "@tauri-apps/api";
|
import { dialog, fs, app } from "@tauri-apps/api";
|
||||||
// store
|
// store
|
||||||
@@ -128,6 +132,12 @@ const showHome = ref(homeStore.getShowValue());
|
|||||||
// snackbar
|
// snackbar
|
||||||
const snackbar = ref(false);
|
const snackbar = ref(false);
|
||||||
const snackbarText = ref("");
|
const snackbarText = ref("");
|
||||||
|
const snackbarColor = ref("success");
|
||||||
|
|
||||||
|
// confirm
|
||||||
|
const confirmShow = ref(false);
|
||||||
|
const confirmText = ref("");
|
||||||
|
const confirmValue = ref(false);
|
||||||
|
|
||||||
// load version
|
// load version
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
@@ -152,7 +162,10 @@ async function openMergeData() {
|
|||||||
}
|
}
|
||||||
// 删除本地数据
|
// 删除本地数据
|
||||||
async function deleteData() {
|
async function deleteData() {
|
||||||
const res = await dialog.confirm("确定要删除用户数据吗?");
|
confirmShow.value = true;
|
||||||
|
confirmText.value = "确定要删除用户数据吗?";
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 1500));
|
||||||
|
const res = confirmValue.value;
|
||||||
if (res) {
|
if (res) {
|
||||||
await fs.removeDir("userData", {
|
await fs.removeDir("userData", {
|
||||||
dir: fs.BaseDirectory.AppLocalData,
|
dir: fs.BaseDirectory.AppLocalData,
|
||||||
@@ -174,7 +187,10 @@ async function deleteData() {
|
|||||||
}
|
}
|
||||||
// 删除临时数据
|
// 删除临时数据
|
||||||
async function deleteTemp() {
|
async function deleteTemp() {
|
||||||
const res = await dialog.confirm("确定要删除临时数据吗?");
|
confirmText.value = "确定要删除临时数据吗?";
|
||||||
|
confirmShow.value = true;
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 1500));
|
||||||
|
const res = confirmValue.value;
|
||||||
if (res) {
|
if (res) {
|
||||||
await fs.removeDir("tempData", {
|
await fs.removeDir("tempData", {
|
||||||
dir: fs.BaseDirectory.AppLocalData,
|
dir: fs.BaseDirectory.AppLocalData,
|
||||||
@@ -186,23 +202,39 @@ async function deleteTemp() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 开启 dev 模式
|
||||||
|
async function submitDevMode() {
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 200));
|
||||||
|
appStore.devMode
|
||||||
|
? (snackbarText.value = "已开启 dev 模式!")
|
||||||
|
: (snackbarText.value = "已关闭 dev 模式!");
|
||||||
|
snackbarColor.value = "success";
|
||||||
|
snackbar.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
// 修改首页显示
|
// 修改首页显示
|
||||||
async function submitHome() {
|
async function submitHome() {
|
||||||
// 获取已选
|
// 获取已选
|
||||||
const show = showHome.value;
|
const show = showHome.value;
|
||||||
if (show.length < 1) {
|
if (show.length < 1) {
|
||||||
await dialog.message("请至少选择一个!");
|
snackbarText.value = "请至少选择一个!";
|
||||||
|
snackbarColor.value = "error";
|
||||||
|
snackbar.value = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 设置
|
// 设置
|
||||||
await homeStore.setShowValue(show);
|
await homeStore.setShowValue(show);
|
||||||
snackbarText.value = "已修改!";
|
snackbarText.value = "已修改!";
|
||||||
|
snackbarColor.value = "success";
|
||||||
snackbar.value = true;
|
snackbar.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 恢复默认配置
|
// 恢复默认配置
|
||||||
async function setDefaultConfig() {
|
async function setDefaultConfig() {
|
||||||
const res = await dialog.confirm("确定要初始化数据吗?");
|
confirmText.value = "确定要恢复默认配置吗?";
|
||||||
|
confirmShow.value = true;
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 1500));
|
||||||
|
const res = confirmValue.value;
|
||||||
if (res) {
|
if (res) {
|
||||||
await appStore.init();
|
await appStore.init();
|
||||||
await homeStore.init();
|
await homeStore.init();
|
||||||
|
|||||||
Reference in New Issue
Block a user