fix(config): 采用 snackbar 替换部分dialog

This commit is contained in:
BTMuli
2023-04-03 18:50:57 +08:00
parent 790b4dad2b
commit 1fff6dd0d6

View File

@@ -90,6 +90,18 @@
<v-list-item-subtitle>{{ appStore.dataPath.user }}</v-list-item-subtitle> <v-list-item-subtitle>{{ appStore.dataPath.user }}</v-list-item-subtitle>
</v-list-item> </v-list-item>
</v-list> </v-list>
<!-- 弹窗提示条 -->
<v-snackbar
v-model="snackbar"
timeout="1500"
color="#50596B"
rounded="pill"
width="50px"
class="snack-div"
>
<img src="../assets/icons/circle-check.svg" alt="check" />
<span>{{ snackbarText }}</span>
</v-snackbar>
</div> </div>
</template> </template>
@@ -121,6 +133,10 @@ const versionTauri = ref("");
// data // data
const showHome = ref(homeStore.getShowValue()); const showHome = ref(homeStore.getShowValue());
// snackbar
const snackbar = ref(false);
const snackbarText = ref("");
// load version // load version
onMounted(async () => { onMounted(async () => {
versionApp.value = await app.getVersion(); versionApp.value = await app.getVersion();
@@ -157,7 +173,8 @@ async function deleteData() {
getDataList.map(async item => { getDataList.map(async item => {
await WriteTGData(item.name, item.data); await WriteTGData(item.name, item.data);
}); });
await dialog.message("用户数据已删除!"); snackbarText.value = "用户数据已删除!";
snackbar.value = true;
await achievementsStore.init(); await achievementsStore.init();
await fs.createDir("userData", { dir: fs.BaseDirectory.AppLocalData }); await fs.createDir("userData", { dir: fs.BaseDirectory.AppLocalData });
await fs.createDir("tempData", { dir: fs.BaseDirectory.AppLocalData }); await fs.createDir("tempData", { dir: fs.BaseDirectory.AppLocalData });
@@ -172,7 +189,8 @@ async function deleteTemp() {
recursive: true, recursive: true,
}); });
await fs.createDir("tempData", { dir: fs.BaseDirectory.AppLocalData }); await fs.createDir("tempData", { dir: fs.BaseDirectory.AppLocalData });
await dialog.message("临时数据已删除!"); snackbarText.value = "临时数据已删除!";
snackbar.value = true;
} }
} }
@@ -186,7 +204,8 @@ async function submitHome() {
} }
// 设置 // 设置
await homeStore.setShowValue(show); await homeStore.setShowValue(show);
await dialog.message("已修改!"); snackbarText.value = "已修改!";
snackbar.value = true;
} }
// 恢复默认配置 // 恢复默认配置
@@ -196,9 +215,11 @@ async function setDefaultConfig() {
await appStore.init(); await appStore.init();
await homeStore.init(); await homeStore.init();
await achievementsStore.init(); await achievementsStore.init();
dialog.message("已恢复默认配置!").then(() => { snackbarText.value = "已恢复默认配置!";
snackbar.value = true;
setTimeout(() => {
window.location.reload(); window.location.reload();
}); }, 1500);
} }
} }
</script> </script>
@@ -228,4 +249,16 @@ async function setDefaultConfig() {
background: #5b738f; background: #5b738f;
border-radius: 10px; border-radius: 10px;
} }
.snack-div img {
position: absolute;
width: 20px;
height: 20px;
}
.snack-div span {
margin-left: 30px;
font-family: Genshin-Light, serif;
color: #faf7e8;
}
</style> </style>