diff --git a/doc/RBAC 权限.sql b/doc/RBAC 权限.sql index 00a6bff..489d8f4 100644 --- a/doc/RBAC 权限.sql +++ b/doc/RBAC 权限.sql @@ -1,3 +1,5 @@ +use Tourmanager + CREATE TABLE auth_role ( [role_id] [int] IDENTITY(1,1) NOT NULL, diff --git a/src/components/LogUploader.jsx b/src/components/LogUploader.jsx new file mode 100644 index 0000000..b32ad4f --- /dev/null +++ b/src/components/LogUploader.jsx @@ -0,0 +1,77 @@ +import { useState } from "react"; +import { Popover, message, FloatButton, Button, Form, Input } from "antd"; +import "antd/dist/reset.css"; +import "dayjs/locale/zh-cn"; +import { BugOutlined } from "@ant-design/icons"; +import useAuthStore from "@/stores/Auth"; +import { uploadPageSpyLog, sendNotify } from "@/pageSpy"; + +function LogUploader() { + const [open, setOpen] = useState(false); + const hide = () => { + setOpen(false); + }; + const handleOpenChange = (newOpen) => { + setOpen(newOpen); + }; + + const [currentUser] = useAuthStore((s) => [s.currentUser]); + + const [messageApi, contextHolder] = message.useMessage(); + const [formBug] = Form.useForm(); + + const popoverContent = ( +
{ + const success = await uploadPageSpyLog(); + messageApi.success("Thanks for the feedback😊"); + if (success) { + sendNotify(currentUser?.realname + "说:" + values.problem); + } else { + sendNotify(currentUser?.realname + "上传日志失败"); + } + hide(); + formBug.setFieldsValue({problem: ''}); + }} + > + + + + +
+ ); + + return ( + <>{contextHolder} + + } /> + + + ); +} + +export default LogUploader; diff --git a/src/pageSpy/index.jsx b/src/pageSpy/index.jsx index 66925fd..a31a301 100644 --- a/src/pageSpy/index.jsx +++ b/src/pageSpy/index.jsx @@ -1,16 +1,17 @@ import { loadScript } from '@/utils/commons'; import { PROJECT_NAME, BUILD_VERSION } from '@/config'; import { fetchJSON } from '@/utils/request' +import { usingStorage } from "@/hooks/usingStorage"; -let spyTitle = ''; +export const sendNotify = async (message) => { -const sendNotify = async () => { + const { userId, travelAgencyId } = usingStorage(); const notifyUrl = 'https://p9axztuwd7x8a7.mycht.cn/dingtalk/dingtalkwork/SendMDMsgByDingRobotToGroup'; const params = { groupid: 'cidFtzcIzNwNoiaGU9Q795CIg==', msgTitle: '有人求助', - msgText: `${spyTitle}上传了${PROJECT_NAME} (${BUILD_VERSION})的日志`, + msgText: `${message}\\n\\nID: ${userId}, ${travelAgencyId} | ${PROJECT_NAME} (${BUILD_VERSION})`, }; return fetchJSON(notifyUrl, params).then((json) => { @@ -23,7 +24,6 @@ const sendNotify = async () => { }; export const loadPageSpy = (title) => { - spyTitle = title; if (import.meta.env.DEV || window.$pageSpy) return @@ -56,7 +56,9 @@ export const loadPageSpy = (title) => { }; export const uploadPageSpyLog = async () => { - // window.$pageSpy.triggerPlugins('onOfflineLog', 'upload'); + + if (import.meta.env.DEV || window.$pageSpy) return true; + if (window.$pageSpy) { try { // await window.$harbor.upload() // 上传日志 { clearCache: true, remark: '' } @@ -66,13 +68,12 @@ export const uploadPageSpyLog = async () => { startTime: now - 60 * 60000, endTime: now, }); - alert('Success'); - sendNotify() + return true; } catch (error) { - alert('Failure'); + return false; } } else { - alert('Failure') + return false; } } diff --git a/src/views/App.jsx b/src/views/App.jsx index 63d27fb..94a4eb6 100644 --- a/src/views/App.jsx +++ b/src/views/App.jsx @@ -1,6 +1,9 @@ import { Outlet, Link, useHref, useNavigate, NavLink } from 'react-router-dom' import { useEffect, useState } from 'react' -import { Layout, Menu, ConfigProvider, theme, Dropdown, message, FloatButton, Space, Row, Col, Badge, App as AntApp } from 'antd' +import { + Popover, Layout, Menu, ConfigProvider, theme, Dropdown, message, FloatButton, Space, Row, Col, Badge, App as AntApp, + Button, Form, Input +} from 'antd' import { DownOutlined } from '@ant-design/icons' import 'antd/dist/reset.css' import AppLogo from '@/assets/highlights_travel_600_550.png' @@ -9,7 +12,6 @@ import { useTranslation } from 'react-i18next' import zhLocale from 'antd/locale/zh_CN' import enLocale from 'antd/locale/en_US' import 'dayjs/locale/zh-cn' -import { BugOutlined } from "@ant-design/icons" import ErrorBoundary from '@/components/ErrorBoundary' import { BUILD_VERSION, PERM_PRODUCTS_OFFER_PUT, PERM_PRODUCTS_INFO_PUT } from '@/config' import useNoticeStore from '@/stores/Notice' @@ -18,7 +20,7 @@ import { useThemeContext } from '@/stores/ThemeContext' import { usingStorage } from '@/hooks/usingStorage' import { useDefaultLgc } from '@/i18n/LanguageSwitcher' import { appendRequestParams } from '@/utils/request' -import { uploadPageSpyLog } from '@/pageSpy'; +import LogUploader from '@/components/LogUploader' import { PERM_ACCOUNT_MANAGEMENT, PERM_ROLE_NEW, PERM_OVERSEA, PERM_AIR_TICKET, PERM_PRODUCTS_MANAGEMENT,PERM_TRAIN_TICKET } from '@/config' @@ -63,26 +65,15 @@ function App() { appendRequestParams('lgc', language) }, [i18n.language]) - const uploadLog = () => { - if (window.$pageSpy) { - window.$pageSpy.triggerPlugins('onOfflineLog', 'upload') - messageApi.info('Success') - } else { - messageApi.error('Failure') - } - } - // 地接和客服权限不同,产品管理页面也不同 const isProductPermitted = isPermitted(PERM_PRODUCTS_MANAGEMENT) || isPermitted(PERM_PRODUCTS_INFO_PUT) - const productLink = isPermitted(PERM_PRODUCTS_MANAGEMENT) ? '/products' : '/products/edit' + const productLink = isPermitted(PERM_PRODUCTS_MANAGEMENT) ? '/products' : '/products/pick-year' return ( @@ -93,7 +84,7 @@ function App() { insetInlineEnd: 94, }} > - } onClick={() => uploadPageSpyLog()} /> + {contextHolder}