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_DEMOS=true
|
||||||
VITE_APP_MENU_SHOW_ORDER=true
|
VITE_APP_MENU_SHOW_ORDER=true
|
||||||
VITE_APP_ENABLE_ROUTER_LOG_GUARD=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({
|
definePage({
|
||||||
meta: {},
|
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>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -16,27 +39,20 @@ definePage({
|
|||||||
<Panel header="Toast 消息" class="mt-1.5">
|
<Panel header="Toast 消息" class="mt-1.5">
|
||||||
<div flex="~ wrap" gap="4">
|
<div flex="~ wrap" gap="4">
|
||||||
<Button
|
<Button
|
||||||
v-for="severity in [
|
v-for="(severity, index) in tostSeverities"
|
||||||
'secondary',
|
|
||||||
'success',
|
|
||||||
'info',
|
|
||||||
'warn',
|
|
||||||
'error',
|
|
||||||
'contrast',
|
|
||||||
undefined,
|
|
||||||
] satisfies ToastMessageOptions['severity'][]"
|
|
||||||
:key="severity ?? 'default'"
|
:key="severity ?? 'default'"
|
||||||
@click="
|
@click="
|
||||||
ToastService.add({
|
ToastService.add({
|
||||||
severity: severity,
|
severity: severity,
|
||||||
summary: `severity: ${severity ?? 'default'}`,
|
summary: `severity: ${severity ?? 'default'}`,
|
||||||
life: 5000,
|
life: 3000,
|
||||||
detail: '消息内容',
|
detail: '消息内容',
|
||||||
})
|
})
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
{{ `${severity ?? 'default'}` }}
|
{{ `${index + 1}. ${severity ?? 'default'}` }}
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button @click="openAllToasts"> 一键打开所有 </Button>
|
||||||
</div>
|
</div>
|
||||||
</Panel>
|
</Panel>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ export const viteConfigRollupOptions: RollupOptions = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
['primelocale', 'primevue', '@primeuix', 'primeicons'].some((name) =>
|
['primelocale', 'primevue', 'primeuix', 'primeicons'].some((name) =>
|
||||||
packageName!.includes(name),
|
packageName!.includes(name),
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
|
|||||||
Reference in New Issue
Block a user