From 09ad843f959d55560f942a6320f641ef9b02df99 Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Wed, 27 Nov 2024 15:46:58 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E9=80=9A=E7=9F=A5=E9=A1=BE?= =?UTF-8?q?=E9=97=AE=E5=B7=B2=E4=B8=8A=E4=BC=A0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/AuthStore.js | 25 ++++++++++++++++++++++--- src/utils/pagespy.js | 2 +- src/views/AuthApp.jsx | 3 ++- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/stores/AuthStore.js b/src/stores/AuthStore.js index 66cca5d..fce5851 100644 --- a/src/stores/AuthStore.js +++ b/src/stores/AuthStore.js @@ -1,9 +1,8 @@ import { create } from 'zustand' import { devtools } from 'zustand/middleware' -import { fetchJSON, postForm } from '@/utils/request' +import { fetchJSON } from '@/utils/request' import { isEmpty, isNotEmpty } from '@/utils/commons' -import { API_HOST } from '@/config' - +import { API_HOST, BUILD_VERSION } from '@/config' export const PERM_MERGE_CONVERSATION = 'merge-conversation' export const PERM_ASSIGN_NEW_CONVERSATION = 'assign-new-conversation' @@ -194,6 +193,26 @@ const useAuthStore = create(devtools((set, get) => ({ } }) }, + + sendNotify: async () => { + const { loginUser } = get() + const notifyUrl = 'https://p9axztuwd7x8a7.mycht.cn/dingtalk/dingtalkwork/SendMDMsgByDingRobotToGroup' + + const params = { + groupid: 'cidFtzcIzNwNoiaGU9Q795CIg==', + msgTitle: '有人求助', + msgText: loginUser.username + '上传了销售平台' + BUILD_VERSION + '的日志' + }; + + return fetchJSON(notifyUrl, params) + .then(json => { + if (json.errcode === 0) { + console.info('发送通知成功') + } else { + throw new Error(json?.errmsg + ': ' + json.errcode) + } + }) + }, }), { name: 'authStore' })) export default useAuthStore diff --git a/src/utils/pagespy.js b/src/utils/pagespy.js index 3f5267d..2d953df 100644 --- a/src/utils/pagespy.js +++ b/src/utils/pagespy.js @@ -1,5 +1,5 @@ import { loadScript } from '@/utils/commons'; -import { BUILD_VERSION, BUILD_DATE } from '@/config' +import { BUILD_VERSION } from '@/config' export const loadPageSpy = (title) => { diff --git a/src/views/AuthApp.jsx b/src/views/AuthApp.jsx index 2ab35e2..d1e6ed2 100644 --- a/src/views/AuthApp.jsx +++ b/src/views/AuthApp.jsx @@ -31,7 +31,7 @@ function AuthApp() { const [messageApi, contextHolder] = message.useMessage() const { colorPrimary, borderRadius } = useThemeContext() - const loginUser = useAuthStore((state) => state.loginUser) + const [loginUser, sendNotify] = useAuthStore((state) => [state.loginUser, state.sendNotify]) const href = useHref() @@ -67,6 +67,7 @@ function AuthApp() { } const uploadLog = () => { + sendNotify() if (window.$pageSpy) { window.$pageSpy.triggerPlugins('onOfflineLog', 'upload') messageApi.info('Success') From a9f2db4591bcf15276276422d4f9409d3a7677ad Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Wed, 27 Nov 2024 16:49:03 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9pagespy=E6=A0=87?= =?UTF-8?q?=E9=A2=98=EF=BC=8C=E6=96=B9=E4=BE=BF=E6=9F=A5=E7=9C=8B=E7=89=88?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/pagespy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/pagespy.js b/src/utils/pagespy.js index 2d953df..0a0ed1c 100644 --- a/src/utils/pagespy.js +++ b/src/utils/pagespy.js @@ -14,6 +14,6 @@ export const loadPageSpy = (title) => { // 注册插件 PageSpy.registerPlugin(new DataHarborPlugin({ maximum: 2 * 1024 * 1024 })); // 实例化 PageSpy - window.$pageSpy = new PageSpy({ api: 'page-spy.mycht.cn', project: 'Sales CRM v' + BUILD_VERSION, title: title, autoRender: false }); + window.$pageSpy = new PageSpy({ api: 'page-spy.mycht.cn', project: 'Sales CRM' + BUILD_VERSION, title: title + '(v' + BUILD_VERSION + ')', autoRender: false }); }); };