mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-16 09:58:13 +08:00
♻️ showSnackbar重构
This commit is contained in:
@@ -100,7 +100,7 @@ async function loadAchi(): Promise<void> {
|
||||
if (ncFind) ncData.value = ncFind;
|
||||
else ncData.value = undefined;
|
||||
}
|
||||
showSnackbar({ text: `已获取 ${renderAchi.value.length} 条成就数据`, color: "success" });
|
||||
showSnackbar.success(`已获取 ${achievements.value.length} 条成就数据`);
|
||||
}
|
||||
|
||||
function selectAchi(data: TGApp.Sqlite.Achievement.RenderAchi): void {
|
||||
@@ -114,27 +114,26 @@ function selectSeries(data: number): void {
|
||||
|
||||
function switchAchiInfo(next: boolean): void {
|
||||
if (selectedAchi.value === undefined) {
|
||||
showSnackbar({ text: "当前未选中成就!", color: "warn" });
|
||||
showSnackbar.warn("当前未选中成就!");
|
||||
return;
|
||||
}
|
||||
const index = renderAchi.value.findIndex((i) => i === selectedAchi.value);
|
||||
if (index === -1) {
|
||||
showSnackbar({
|
||||
text: `未找到选中成就 ${selectedAchi.value.name}(${selectedAchi.value.id}) 的索引!`,
|
||||
color: "error",
|
||||
});
|
||||
showSnackbar.warn(
|
||||
`未找到选中成就 ${selectedAchi.value.name}(${selectedAchi.value.id}) 的索引!`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (next) {
|
||||
if (index === renderAchi.value.length - 1) {
|
||||
showSnackbar({ text: "已经是最后一个了", color: "warn" });
|
||||
showSnackbar.warn("已经是最后一个了");
|
||||
return;
|
||||
}
|
||||
selectedAchi.value = renderAchi.value[index + 1];
|
||||
return;
|
||||
}
|
||||
if (index === 0) {
|
||||
showSnackbar({ text: "已经是第一个了", color: "warn" });
|
||||
showSnackbar.warn("已经是第一个了");
|
||||
return;
|
||||
}
|
||||
selectedAchi.value = renderAchi.value[index - 1];
|
||||
|
||||
@@ -78,25 +78,22 @@ async function setAchiStat(stat: boolean): Promise<void> {
|
||||
await TSUserAchi.updateAchi(data.value);
|
||||
emits("update:modelValue", data.value);
|
||||
await event.emit("updateAchi", data.value.series);
|
||||
showSnackbar({
|
||||
text: `已将成就 ${data.value.name}(${data.value.id}) 状态设为未完成`,
|
||||
color: "success",
|
||||
});
|
||||
showSnackbar.success(`已将成就 ${data.value.name}(${data.value.id}) 状态设为未完成`);
|
||||
return;
|
||||
}
|
||||
let progress: false | undefined | string = await showConfirm({
|
||||
let progress: boolean | undefined | string = await showConfirm({
|
||||
mode: "input",
|
||||
title: "请输入成就进度",
|
||||
text: "进度",
|
||||
input: data.value.progress,
|
||||
});
|
||||
if (progress === false) {
|
||||
showSnackbar({ text: "已取消成就编辑", color: "cancel" });
|
||||
showSnackbar.cancel("已取消成就编辑");
|
||||
return;
|
||||
}
|
||||
if (progress === undefined) progress = data.value.progress.toString();
|
||||
if (isNaN(Number(progress)) || progress === "0") {
|
||||
showSnackbar({ text: "请输入有效数字!", color: "warn" });
|
||||
showSnackbar.warn("请输入有效数字!");
|
||||
return;
|
||||
}
|
||||
data.value.progress = Number(progress);
|
||||
@@ -104,10 +101,7 @@ async function setAchiStat(stat: boolean): Promise<void> {
|
||||
data.value.isCompleted = true;
|
||||
await TSUserAchi.updateAchi(data.value);
|
||||
await event.emit("updateAchi", data.value.series);
|
||||
showSnackbar({
|
||||
text: `已将成就 ${data.value.name}(${data.value.id}) 状态设为已完成`,
|
||||
color: "success",
|
||||
});
|
||||
showSnackbar.success(`已将成就 ${data.value.name}(${data.value.id}) 状态设为已完成`);
|
||||
emits("update:modelValue", data.value);
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -64,10 +64,7 @@ onUnmounted(async () => {
|
||||
|
||||
async function selectSeries(): Promise<void> {
|
||||
if (props.cur === props.series) {
|
||||
showSnackbar({
|
||||
text: "已选中当前系列!",
|
||||
color: "warn",
|
||||
});
|
||||
showSnackbar.warn("已选中当前系列!");
|
||||
return;
|
||||
}
|
||||
emits("selectSeries", props.series);
|
||||
|
||||
Reference in New Issue
Block a user