fix: 优化错误提示
This commit is contained in:
1 parent
d4f629106f
commit
3f61e92549
9 files changed
+122
-23
No files matched your search
@@ -2,9 +2,12 @@
|
||||
/**
|
||||
* shared/components/LevelMessageDialog.vue
|
||||
* 全局分级消息弹窗(info/success/warning/error)。
|
||||
* 依赖:vue-i18n、lucide-vue-next。
|
||||
* 逻辑:App.vue 挂载本组件;useGlobalMessageDialog 驱动 title(顶部摘要)与 message(正文)展示。
|
||||
*/
|
||||
|
||||
import { computed, onBeforeUnmount, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Check, Info, AlertTriangle, XCircle, X } from 'lucide-vue-next';
|
||||
|
||||
type MessageLevel = 'success' | 'info' | 'warning' | 'error';
|
||||
@@ -47,16 +50,18 @@ const ICON_MAP: Record<MessageLevel, typeof Check> = {
|
||||
error: XCircle,
|
||||
};
|
||||
|
||||
const DEFAULT_TITLE_MAP: Record<MessageLevel, string> = {
|
||||
success: 'Success',
|
||||
info: 'Info',
|
||||
warning: 'Warning',
|
||||
error: 'Error',
|
||||
const { t } = useI18n();
|
||||
|
||||
const DEFAULT_TITLE_KEY_MAP: Record<MessageLevel, string> = {
|
||||
success: 'common.messageDialog.success',
|
||||
info: 'common.messageDialog.info',
|
||||
warning: 'common.messageDialog.warning',
|
||||
error: 'common.messageDialog.error',
|
||||
};
|
||||
|
||||
const panelClass = computed(() => ALERT_CLASS[props.level]);
|
||||
const resolvedIcon = computed(() => ICON_MAP[props.level]);
|
||||
const resolvedTitle = computed(() => props.title || DEFAULT_TITLE_MAP[props.level]);
|
||||
const resolvedTitle = computed(() => props.title || t(DEFAULT_TITLE_KEY_MAP[props.level]));
|
||||
const resolvedMessage = computed(() => props.message || '');
|
||||
let autoCloseTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
@@ -139,7 +144,10 @@ onBeforeUnmount(() => {
|
||||
<h3 class="text-base font-semibold leading-6">
|
||||
{{ resolvedTitle }}
|
||||
</h3>
|
||||
<p class="level-dialog-message mt-3 text-sm leading-7 whitespace-pre-line break-words opacity-90">
|
||||
<p
|
||||
v-if="resolvedMessage"
|
||||
class="level-dialog-message mt-3 text-sm leading-7 whitespace-pre-line break-words opacity-90"
|
||||
>
|
||||
{{ resolvedMessage }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user