From 69fbbbb51a49aa5f73aa2ef58cfc5ef88bdc12fa Mon Sep 17 00:00:00 2001 From: Hide_D Date: Sun, 19 Mar 2023 12:54:53 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EA=B0=9C=EC=9D=B8/=EC=99=B8=EA=B5=90?= =?UTF-8?q?=20=EB=A9=94=EC=8B=9C=EC=A7=80=20=EC=88=98=EC=8B=A0=EC=8B=9C=20?= =?UTF-8?q?=EB=B2=84=ED=8A=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/ts/components/MessagePanel.vue | 38 +++++++++++++++++++++++------- hwe/ts/utilGame/getNewMsgToast.ts | 21 +++++++++++++++++ 2 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 hwe/ts/utilGame/getNewMsgToast.ts diff --git a/hwe/ts/components/MessagePanel.vue b/hwe/ts/components/MessagePanel.vue index 3e05b278..b66aaa9b 100644 --- a/hwe/ts/components/MessagePanel.vue +++ b/hwe/ts/components/MessagePanel.vue @@ -173,6 +173,8 @@ import MessagePlate from "@/components/MessagePlate.vue"; import { useToast, BFormSelect } from "bootstrap-vue-3"; import { unwrap } from "@/util/unwrap"; import { isBrightColor } from "@/util/isBrightColor"; +import { getNewMsgToast } from "@/utilGame/getNewMsgToast"; +import { scrollToSelector } from "@/util/scrollToSelector"; const serverID = staticValues.serverID; const toasts = unwrap(useToast()); @@ -269,10 +271,20 @@ function _updateLatestMsg(msg: MsgItem) { toasts.remove(toastID); } const newToastID = toasts.show( - { - title: "새로운 개인 메시지", - body: "새로운 개인 메시지가 도착했습니다.", - }, + getNewMsgToast( + "새로운 개인 메시지", + "새로운 개인 메시지가 도착했습니다.", + (type, e)=>{ + if(type === 'goto'){ + scrollToSelector('.PrivateTalk > .stickyAnchor') + return; + } + if(type === 'ignore'){ + readLatestMsg('private'); + return; + } + } + ), { delay: 1000 * 60 * 10, variant: 'warning' @@ -292,10 +304,20 @@ function _updateLatestMsg(msg: MsgItem) { toasts.remove(toastID); } const newToastID = toasts.show( - { - title: "새로운 외교 메시지", - body: "새로운 외교 메시지가 도착했습니다.", - }, + getNewMsgToast( + "새로운 외교 메시지", + "새로운 외교 메시지가 도착했습니다.", + (type, e)=>{ + if(type === 'goto'){ + scrollToSelector('.DiplomacyTalk > .stickyAnchor') + return; + } + if(type === 'ignore'){ + readLatestMsg('diplomacy'); + return; + } + } + ), { delay: 1000 * 60 * 10, variant: 'warning' diff --git a/hwe/ts/utilGame/getNewMsgToast.ts b/hwe/ts/utilGame/getNewMsgToast.ts new file mode 100644 index 00000000..8cb099f1 --- /dev/null +++ b/hwe/ts/utilGame/getNewMsgToast.ts @@ -0,0 +1,21 @@ +import { BButton } from "bootstrap-vue-3"; +import type { ToastContent } from "bootstrap-vue-3/dist/components/BToast/plugin"; +import { h } from "vue"; + +type CallbackType = (type: "goto" | "ignore", e: MouseEvent) => void; + +export function getNewMsgToast(title: string, body: string, callback: CallbackType): ToastContent{ + const bodyNode = h( + "span", + null, + [ + body, + h(BButton, { variant: "primary", size: "sm", onClick: (e)=>{ callback('goto', e) } }, "보러가기"), + h(BButton, { variant: "secondary", size: "sm", onClick: (e)=>{ callback('ignore', e)} }, "이미읽음"), + ] + ); + return { + title, + body: bodyNode, + } +} \ No newline at end of file