feat(toast): 添加一键打开所有 Toast 消息功能并优化显示时间
This commit is contained in:
2
.env
2
.env
@@ -10,3 +10,5 @@ VITE_APP_ENABLE_VUE_DEVTOOLS=true
|
||||
VITE_APP_MENU_SHOW_DEMOS=true
|
||||
VITE_APP_MENU_SHOW_ORDER=true
|
||||
VITE_APP_ENABLE_ROUTER_LOG_GUARD=true
|
||||
VITE_APP_API_URL=/API
|
||||
VITE_APP_PROXY=[["/API","https://jsonplaceholder.typicode.com"]]
|
||||
|
||||
@@ -4,6 +4,29 @@ import type { ToastMessageOptions } from 'primevue/toast';
|
||||
definePage({
|
||||
meta: {},
|
||||
});
|
||||
|
||||
const tostSeverities = [
|
||||
'secondary',
|
||||
'success',
|
||||
'info' /* 默认 */,
|
||||
'warn',
|
||||
'error',
|
||||
'contrast',
|
||||
undefined,
|
||||
] satisfies ToastMessageOptions['severity'][];
|
||||
|
||||
const openAllToasts = () => {
|
||||
tostSeverities.forEach((severity, index) => {
|
||||
setTimeout(() => {
|
||||
ToastService.add({
|
||||
severity,
|
||||
summary: `severity: ${severity ?? 'default'}`,
|
||||
life: 3000,
|
||||
detail: `${index + 1}. 消息内容`,
|
||||
});
|
||||
}, index * 500);
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -16,27 +39,20 @@ definePage({
|
||||
<Panel header="Toast 消息" class="mt-1.5">
|
||||
<div flex="~ wrap" gap="4">
|
||||
<Button
|
||||
v-for="severity in [
|
||||
'secondary',
|
||||
'success',
|
||||
'info',
|
||||
'warn',
|
||||
'error',
|
||||
'contrast',
|
||||
undefined,
|
||||
] satisfies ToastMessageOptions['severity'][]"
|
||||
v-for="(severity, index) in tostSeverities"
|
||||
:key="severity ?? 'default'"
|
||||
@click="
|
||||
ToastService.add({
|
||||
severity: severity,
|
||||
summary: `severity: ${severity ?? 'default'}`,
|
||||
life: 5000,
|
||||
life: 3000,
|
||||
detail: '消息内容',
|
||||
})
|
||||
"
|
||||
>
|
||||
{{ `${severity ?? 'default'}` }}
|
||||
{{ `${index + 1}. ${severity ?? 'default'}` }}
|
||||
</Button>
|
||||
<Button @click="openAllToasts"> 一键打开所有 </Button>
|
||||
</div>
|
||||
</Panel>
|
||||
</template>
|
||||
|
||||
@@ -101,7 +101,7 @@ export const viteConfigRollupOptions: RollupOptions = {
|
||||
}
|
||||
|
||||
if (
|
||||
['primelocale', 'primevue', '@primeuix', 'primeicons'].some((name) =>
|
||||
['primelocale', 'primevue', 'primeuix', 'primeicons'].some((name) =>
|
||||
packageName!.includes(name),
|
||||
)
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user