Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 35 additions & 14 deletions packages/docs/src/pages/components/notification/demo/close-tag.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,77 @@
import { Notification as notification } from "@antdv-next/x";

const describeInfo: Record<NotificationPermission, string> = {
denied: "้€š็Ÿฅๆƒ้™ๅทฒ่ขซๆ‹’็ป๏ผŒไฝ ้œ€่ฆๅœจๆต่งˆๅ™จ็ฝ‘็ซ™่ฎพ็ฝฎไธญๆ‰‹ๅŠจ้‡็ฝฎ้€š็Ÿฅๆƒ้™ใ€‚",
granted: "้€š็Ÿฅๆƒ้™ๅทฒๆŽˆไบˆ๏ผŒไฝ ๅฏไปฅ็‚นๅ‡ปใ€Œๅ‘้€้€š็Ÿฅใ€ๆŒ‰้’ฎๆฅๆŽจ้€ไธ€ๆก้€š็Ÿฅใ€‚",
default: "่ฏทๅ…ˆ่ฏทๆฑ‚ๆƒ้™๏ผŒๆŽˆๆƒๅŽๅณๅฏๆŽจ้€้€š็Ÿฅใ€‚",
denied:
"Notification permission has been denied, You need to manually reset the notification permissions in the website settings to trigger the permission request pop-up.",
granted:
'Notification permission has been granted, you can click the "Open a notification" button to push a notification.',
default:
"Please Request Permission,After the request is approved, you can push notifications.",
};

const [{ permission }, { open, close, requestPermission }] =
notification.useNotification();

const openClick = () => {
open({
title: "ไปปๅŠกๅฎŒๆˆ",
body: "ไปปๅŠกไบŽ 13:12 ๅฎŒๆˆ",
title: "Task completed",
body: "The task was completed at 13:12",
tag: "tag_task_completed",
icon: "https://mdn.alipayobjects.com/huamei_iwk9zp/afts/img/A*eco6RrQhxbMAAAAAAAAAAAAADgCCAQ/original",
onClick: (event, closeFn) => {
console.log("onClick", event, closeFn);
closeFn?.();
icon: "https://x.antdv-next.com/x.svg",
onClick: (event, close) => {
console.log("onClick", event, close);
close?.();
},
onClose: event => {
console.log("onClose", event);
},
onError: event => {
console.log("onError", event);
},
onShow: event => {
console.log("onShow", event);
},
});
};
</script>

<template>
<a-flex vertical gap="middle">
<span>{{ describeInfo[permission] }}</span>
{{ describeInfo[permission] }}
<a-flex gap="middle">
<a-button
type="primary"
:disabled="permission !== 'default'"
@click="requestPermission()"
@click="requestPermission"
>
{{ permission === "default" ? "่ฏทๆฑ‚ๆƒ้™" : `้€š็Ÿฅๆƒ้™๏ผš${permission}` }}
{{
permission === "default"
? "Please Request Permission"
: `Notification permission has been ${permission}`
}}
</a-button>
<a-button
type="primary"
:disabled="permission !== 'granted'"
@click="openClick"
>
ๅ‘้€้€š็Ÿฅ
Open a notification
</a-button>
<a-button
danger
:disabled="permission !== 'granted'"
@click="close(['tag_task_completed'])"
>
ๆŒ‰ Tag ๅ…ณ้—ญ
Destroy tag
</a-button>
</a-flex>
</a-flex>
</template>

<docs lang="zh-CN">
ๅ…ณ้—ญๆŒ‡ๅฎš`tag`้€š็Ÿฅๆก†ใ€‚
</docs>

<docs lang="en-US">
Close the specified `tag` notification box.
</docs>
41 changes: 31 additions & 10 deletions packages/docs/src/pages/components/notification/demo/duration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,70 @@
import { Notification as notification } from "@antdv-next/x";

const describeInfo: Record<NotificationPermission, string> = {
denied: "้€š็Ÿฅๆƒ้™ๅทฒ่ขซๆ‹’็ป๏ผŒไฝ ้œ€่ฆๅœจๆต่งˆๅ™จ็ฝ‘็ซ™่ฎพ็ฝฎไธญๆ‰‹ๅŠจ้‡็ฝฎ้€š็Ÿฅๆƒ้™ใ€‚",
granted: "้€š็Ÿฅๆƒ้™ๅทฒๆŽˆไบˆ๏ผŒไฝ ๅฏไปฅ็‚นๅ‡ปใ€Œๅ‘้€้€š็Ÿฅใ€ๆŒ‰้’ฎๆฅๆŽจ้€ไธ€ๆก้€š็Ÿฅใ€‚",
default: "่ฏทๅ…ˆ่ฏทๆฑ‚ๆƒ้™๏ผŒๆŽˆๆƒๅŽๅณๅฏๆŽจ้€้€š็Ÿฅใ€‚",
denied:
"Notification permission has been denied, You need to manually reset the notification permissions in the website settings to trigger the permission request pop-up.",
granted:
'Notification permission has been granted, you can click the "Open a notification" button to push a notification.',
default:
"Please Request Permission,After the request is approved, you can push notifications.",
};

const [{ permission }, { open, requestPermission }] =
notification.useNotification();

const openClick = () => {
open({
title: "ไปปๅŠกๅฎŒๆˆ",
body: "ไปปๅŠกไบŽ 13:12 ๅฎŒๆˆ๏ผˆ4.5 ็ง’ๅŽ่‡ชๅŠจๅ…ณ้—ญ๏ผ‰",
title: "Task completed",
body: "The task was completed at 13:12",
duration: 4.5,
icon: "https://mdn.alipayobjects.com/huamei_iwk9zp/afts/img/A*eco6RrQhxbMAAAAAAAAAAAAADgCCAQ/original",
icon: "https://x.antdv-next.com/x.svg",
onClick: (event, close) => {
console.log("onClick", event, close);
close?.();
},
onClose: event => {
console.log("onClose", event);
},
onError: event => {
console.log("onError", event);
},
onShow: event => {
console.log("onShow", event);
},
});
};
</script>

<template>
<a-flex vertical gap="middle">
<span>{{ describeInfo[permission] }}</span>
{{ describeInfo[permission] }}
<a-flex gap="middle">
<a-button
type="primary"
:disabled="permission !== 'default'"
@click="requestPermission()"
@click="requestPermission"
>
{{ permission === "default" ? "่ฏทๆฑ‚ๆƒ้™" : `้€š็Ÿฅๆƒ้™๏ผš${permission}` }}
{{
permission === "default"
? "Please Request Permission"
: `Notification permission has been ${permission}`
}}
</a-button>
<a-button
type="primary"
:disabled="permission !== 'granted'"
@click="openClick"
>
ๅ‘้€้€š็Ÿฅ๏ผˆ่‡ชๅŠจๅ…ณ้—ญ๏ผ‰
Open a notification
</a-button>
</a-flex>
</a-flex>
</template>

<docs lang="zh-CN">
ไฝฟ็”จ`duration`่ฎพ็ฝฎ้€š็Ÿฅๆก†่‡ชๅŠจๅ…ณ้—ญ็š„ๅปถๆ—ถใ€‚
</docs>

<docs lang="en-US">
Use 'duration' to set the delay for the notification box to automatically close.
</docs>
92 changes: 61 additions & 31 deletions packages/docs/src/pages/components/notification/demo/hooks.vue
Original file line number Diff line number Diff line change
@@ -1,58 +1,88 @@
<script setup lang="ts">
import type { XNotificationOpenArgs } from "@antdv-next/x";

import { Notification as notification } from "@antdv-next/x";
import { onMounted, ref } from "vue";

const describeInfo: Record<NotificationPermission, string> = {
denied: "้€š็Ÿฅๆƒ้™ๅทฒ่ขซๆ‹’็ป๏ผŒไฝ ้œ€่ฆๅœจๆต่งˆๅ™จ็ฝ‘็ซ™่ฎพ็ฝฎไธญๆ‰‹ๅŠจ้‡็ฝฎ้€š็Ÿฅๆƒ้™ใ€‚",
granted: "้€š็Ÿฅๆƒ้™ๅทฒๆŽˆไบˆ๏ผŒไฝ ๅฏไปฅ็‚นๅ‡ปใ€Œๅ‘้€้€š็Ÿฅใ€ๆŒ‰้’ฎๆฅๆŽจ้€ไธ€ๆก้€š็Ÿฅใ€‚",
default: "่ฏทๅ…ˆ่ฏทๆฑ‚ๆƒ้™๏ผŒๆŽˆๆƒๅŽๅณๅฏๆŽจ้€้€š็Ÿฅใ€‚",
denied:
"Notification permission has been denied, You need to manually reset the notification permissions in the website settings to trigger the permission request pop-up.",
granted:
'Notification permission has been granted, you can click the "Open a notification" button to push a notification.',
default:
"Please Request Permission,After the request is approved, you can push notifications.",
};

const permission = ref<NotificationPermission>();

const open = () => {
notification.open({
title: "Task completed",
body: "The task was completed at 13:12",
badge: "https://x.antdv-next.com/x.svg",
icon: "https://x.antdv-next.com/x.svg",
onClick: (event, close) => {
console.log("onClick", event, close);
close?.();
},
onClose: event => {
console.log("onClose", event);
},
onError: event => {
console.log("onError", event);
},
onShow: event => {
console.log("onShow", event);
},
});
};

const openData: XNotificationOpenArgs = {
title: "ไปปๅŠกๅฎŒๆˆ",
body: "ไปปๅŠกไบŽ 13:12 ๅฎŒๆˆ",
icon: "https://mdn.alipayobjects.com/huamei_iwk9zp/afts/img/A*eco6RrQhxbMAAAAAAAAAAAAADgCCAQ/original",
onClick: (event, close) => {
console.log("onClick", event, close);
close?.();
},
onClose: event => {
console.log("onClose", event);
},
onError: event => {
console.log("onError", event);
},
onShow: event => {
console.log("onShow", event);
},
const close = () => {
notification.close();
};

const [{ permission }, { open, requestPermission, close }] =
notification.useNotification();
const request = async () => {
permission.value = await notification.requestPermission();
};

onMounted(() => {
permission.value = notification.permission;
});
</script>

<template>
<a-flex vertical gap="middle">
<span>{{ describeInfo[permission] }}</span>
<template v-if="permission">
{{ describeInfo[permission] }}
</template>
<a-flex gap="middle">
<a-button
type="primary"
:disabled="permission !== 'default'"
@click="requestPermission()"
@click="request"
>
{{ permission === "default" ? "่ฏทๆฑ‚ๆƒ้™" : `้€š็Ÿฅๆƒ้™๏ผš${permission}` }}
{{
permission === "default"
? "Please Request Permission"
: `Notification permission has been ${permission}`
}}
</a-button>
<a-button
type="primary"
:disabled="permission !== 'granted'"
@click="open(openData)"
@click="open"
>
ๅ‘้€้€š็Ÿฅ
Open a notification
</a-button>
<a-button danger :disabled="permission !== 'granted'" @click="close()">
ๅ…ณ้—ญๆ‰€ๆœ‰
<a-button danger :disabled="permission !== 'granted'" @click="close">
Destroy All
</a-button>
</a-flex>
</a-flex>
</template>

<docs lang="zh-CN">
hooks่ฐƒ็”จใ€‚ๅ‘้€้€š็Ÿฅๅ‰้œ€่ฆๅ‘็”จๆˆท่ฏทๆฑ‚้€š็Ÿฅๆƒ้™๏ผŒๆŽˆๆƒๅฏ้€š็ŸฅๅŽๅฏๅ‘้€้€š็Ÿฅ๏ผŒ ่‹ฅๆŽˆๆƒ็ฆๆญข้€š็Ÿฅๅˆ™ไธๅฏไปฅๅ‘้€้€š็Ÿฅใ€‚
</docs>

<docs lang="en-US">
hooks call.Before sending notifications, it is necessary to request notification permission from the user. Once authorized, notifications can be sent. If authorization prohibits notifications, notifications cannot be sent.
</docs>
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
<script setup lang="ts">
import { Notification as notification } from "@antdv-next/x";
import { onMounted, ref } from "vue";

const describeInfo: Record<NotificationPermission, string> = {
denied: "้€š็Ÿฅๆƒ้™ๅทฒ่ขซๆ‹’็ป๏ผŒไฝ ้œ€่ฆๅœจๆต่งˆๅ™จ็ฝ‘็ซ™่ฎพ็ฝฎไธญๆ‰‹ๅŠจ้‡็ฝฎ้€š็Ÿฅๆƒ้™ใ€‚",
granted: "้€š็Ÿฅๆƒ้™ๅทฒๆŽˆไบˆ๏ผŒไฝ ๅฏไปฅ็‚นๅ‡ปใ€Œๅ‘้€้€š็Ÿฅใ€ๆŒ‰้’ฎๆฅๆŽจ้€ไธ€ๆก้€š็Ÿฅใ€‚",
default: "่ฏทๅ…ˆ่ฏทๆฑ‚ๆƒ้™๏ผŒๆŽˆๆƒๅŽๅณๅฏๆŽจ้€้€š็Ÿฅใ€‚",
denied:
"Notification permission has been denied, You need to manually reset the notification permissions in the website settings to trigger the permission request pop-up.",
granted:
'Notification permission has been granted, you can click the "Open a notification" button to push a notification.',
default:
"Please Request Permission,After the request is approved, you can push notifications.",
};

// ้™ๆ€ๆ–นๆณ•๏ผšไธไฝฟ็”จ useNotification()๏ผŒ็›ดๆŽฅ่ฐƒ็”จๅฎžไพ‹ๆ–นๆณ•
// permission ไป้€š่ฟ‡ useNotification ่Žทๅ–ๅ“ๅบ”ๅผ็Šถๆ€
const [{ permission }] = notification.useNotification();

const request = async () => {
await notification.requestPermission();
};
const permission = ref<NotificationPermission>();

const open = () => {
notification.open({
title: "ไปปๅŠกๅฎŒๆˆ",
body: "ไปปๅŠกไบŽ 13:12 ๅฎŒๆˆ",
icon: "https://mdn.alipayobjects.com/huamei_iwk9zp/afts/img/A*eco6RrQhxbMAAAAAAAAAAAAADgCCAQ/original",
title: "Task completed",
body: "The task was completed at 13:12",
badge: "https://x.antdv-next.com/x.svg",
icon: "https://x.antdv-next.com/x.svg",
onClick: (event, close) => {
console.log("onClick", event, close);
close?.();
Expand All @@ -36,32 +35,54 @@ const open = () => {
});
};

const closeAll = () => {
const close = () => {
notification.close();
};

const request = async () => {
permission.value = await notification.requestPermission();
};

onMounted(() => {
permission.value = notification.permission;
});
</script>

<template>
<a-flex vertical gap="middle">
<span>{{ describeInfo[permission] }}</span>
<template v-if="permission">
{{ describeInfo[permission] }}
</template>
<a-flex gap="middle">
<a-button
type="primary"
:disabled="permission !== 'default'"
@click="request"
>
{{ permission === "default" ? "่ฏทๆฑ‚ๆƒ้™" : `้€š็Ÿฅๆƒ้™๏ผš${permission}` }}
{{
permission === "default"
? "Please Request Permission"
: `Notification permission has been ${permission}`
}}
</a-button>
<a-button
type="primary"
:disabled="permission !== 'granted'"
@click="open"
>
ๅ‘้€้€š็Ÿฅ
Open a notification
</a-button>
<a-button danger :disabled="permission !== 'granted'" @click="closeAll">
ๅ…ณ้—ญๆ‰€ๆœ‰
<a-button danger :disabled="permission !== 'granted'" @click="close">
Destroy All
</a-button>
</a-flex>
</a-flex>
</template>

<docs lang="zh-CN">
้™ๆ€ๆ–นๆณ•่ฐƒ็”จใ€‚ๅ‘้€้€š็Ÿฅๅ‰้œ€่ฆๅ‘็”จๆˆท่ฏทๆฑ‚้€š็Ÿฅๆƒ้™๏ผŒๆŽˆๆƒๅฏ้€š็ŸฅๅŽๅฏๅ‘้€้€š็Ÿฅ๏ผŒ ่‹ฅๆŽˆๆƒ็ฆๆญข้€š็Ÿฅๅˆ™ไธๅฏไปฅๅ‘้€้€š็Ÿฅใ€‚
</docs>

<docs lang="en-US">
Static method invocation.Before sending notifications, it is necessary to request notification permission from the user. Once authorized, notifications can be sent. If authorization prohibits notifications, notifications cannot be sent.
</docs>
Loading
Loading