Files
Frpilot/src/components/CloseConfirmModal.vue
T
Yuhang Wu 5c1ce2fa5c feat: 新增常规设置页面,支持关闭行为与语言切换
新增常规设置路由和页面,实现关闭行为(每次询问/保持选择)与应用语言的持久化配置;封装卡片式单选组组件复用在关闭弹窗和设置页;修改关闭逻辑,根据关闭行为决定是否显示确认弹窗,同步更新多语言文案和类型定义。
2026-10-16 11:38:00 +08:00

71 lines
2.2 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<a-modal
:open="store.closeConfirmOpen"
:title="t('closeDialog.title')"
:width="400"
centered
:mask-closable="false"
:closable="!store.quitting"
:keyboard="!store.quitting"
@cancel="store.cancelClose()"
>
<!-- 关闭方式:最小化到系统托盘 / 直接退出 -->
<CardRadioGroup v-model="draftChoice" :options="choiceOptions" :disabled="store.quitting" />
<a-divider class="!my-3" />
<!-- 关闭行为:每次询问 / 保持以上选择 -->
<div class="mb-2 text-xs opacity-60">{{ t("closeDialog.behavior") }}</div>
<CardRadioGroup v-model="draftBehavior" :options="behaviorOptions" :disabled="store.quitting" />
<template #footer>
<a-button :disabled="store.quitting" @click="store.cancelClose()">
{{ t("common.cancel") }}
</a-button>
<a-button type="primary" :loading="store.quitting" @click="onConfirm">
{{ t("common.confirm") }}
</a-button>
</template>
</a-modal>
</template>
<script setup lang="ts">
import { useI18n } from "vue-i18n"
import { useWindowStore, type CloseBehavior, type CloseChoice } from "@/stores/window"
const { t } = useI18n()
const store = useWindowStore()
/** 弹窗内的临时选择,点击「确定」后才写回设置(避免误触单选框又取消时被改掉) */
const draftChoice = ref<CloseChoice>("tray")
const draftBehavior = ref<CloseBehavior>("ask")
const choiceOptions = computed(() => [
{ value: "tray" as const, label: t("closeDialog.tray"), description: t("closeDialog.trayDesc") },
{ value: "exit" as const, label: t("closeDialog.exit"), description: t("closeDialog.exitDesc") },
])
const behaviorOptions = computed(() => [
{ value: "ask" as const, label: t("closeDialog.ask"), description: t("closeDialog.askDesc") },
{
value: "remember" as const,
label: t("closeDialog.remember"),
description: t("closeDialog.rememberDesc"),
},
])
// 每次打开弹窗时,用当前设置初始化临时选择
watch(
() => store.closeConfirmOpen,
(open) => {
if (!open) return
draftChoice.value = store.closeChoice
draftBehavior.value = store.closeBehavior
},
)
function onConfirm() {
void store.confirmClose(draftChoice.value, draftBehavior.value)
}
</script>