55 lines
1.3 KiB
Vue
55 lines
1.3 KiB
Vue
<script>
|
|
/** 将父级 message/severity/details 转交给 operations 通知组;默认插槽仍正常渲染。 */
|
|
import { onMounted } from "vue";
|
|
import { renderSlot } from "vue";
|
|
import { watch } from "vue";
|
|
import { defineComponent } from "vue";
|
|
import { useToast } from "primevue/usetoast";
|
|
var a = Object.assign(
|
|
defineComponent({
|
|
__name: `OperationNotice`,
|
|
props: {
|
|
message: {},
|
|
severity: {
|
|
default: `success`,
|
|
},
|
|
details: {
|
|
default: () => [],
|
|
},
|
|
},
|
|
setup(r) {
|
|
let a = r,
|
|
o = useToast();
|
|
function s() {
|
|
// 有逐项结果时不自动消失,便于用户检查;普通成功/失败通知按不同寿命自动关闭。
|
|
a.message.trim() &&
|
|
o.add({
|
|
group: `operations`,
|
|
severity: a.severity,
|
|
summary: a.message,
|
|
detail: [...a.details],
|
|
life: a.details.length
|
|
? void 0
|
|
: a.severity === `success`
|
|
? 4e3
|
|
: 8e3,
|
|
closable: !0,
|
|
});
|
|
}
|
|
return (
|
|
onMounted(s),
|
|
watch(() => [a.message, a.severity], s, {
|
|
flush: `post`,
|
|
}),
|
|
(e, n) => renderSlot(e.$slots, `default`)
|
|
);
|
|
},
|
|
}),
|
|
{
|
|
__name: `OperationNotice`,
|
|
},
|
|
);
|
|
export {};
|
|
export default a;
|
|
</script>
|