feat: PageSpy ; +日志上传

dev/timezone
Lei OT 1 year ago
parent 422c6f651e
commit 3b80855c75

@ -7,10 +7,20 @@
<title>销售平台</title> <title>销售平台</title>
<link rel="preconnect" crossorigin="anonymous" href="https://haina-sale-system.oss-cn-shenzhen.aliyuncs.com"> <link rel="preconnect" crossorigin="anonymous" href="https://haina-sale-system.oss-cn-shenzhen.aliyuncs.com">
<link rel="preconnect" crossorigin="anonymous" href="https://hiana-crm.oss-ap-southeast-1.aliyuncs.com"> <link rel="preconnect" crossorigin="anonymous" href="https://hiana-crm.oss-ap-southeast-1.aliyuncs.com">
<script crossorigin="anonymous" src="https://page-spy.mycht.cn/page-spy/index.min.js"></script>
<script crossorigin="anonymous" src="https://page-spy.mycht.cn/plugin/data-harbor/index.min.js"></script>
<script crossorigin="anonymous" src="https://page-spy.mycht.cn/plugin/rrweb/index.min.js"></script>
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
<script type="module" src="/src/main.jsx"></script> <script type="module" src="/src/main.jsx"></script>
<p style="display: none;">VERSION: %BUILD_VERSION%</p> <p style="display: none;">VERSION: %BUILD_VERSION%</p>
<script defer>
window.initPageSpy = function () {
PageSpy.registerPlugin(new DataHarborPlugin());
window.$pageSpy = new PageSpy({ api: 'page-spy.mycht.cn', project: 'Sales CRM', title: window.__spytitle, autoRender: false, });
// console.log(window.$pageSpy.address.substring(0, 4)); // device ID
}
</script>
</body> </body>
</html> </html>

@ -90,3 +90,5 @@ ReactDOM.createRoot(document.getElementById('root')).render(
</ThemeContext.Provider> </ThemeContext.Provider>
// </React.StrictMode> // </React.StrictMode>
); );
window.initPageSpy();

@ -76,7 +76,7 @@ const useAuthStore = create((set, get) => ({
loadUserSession: () => { loadUserSession: () => {
let sessionData = window.sessionStorage.getItem('GLOBAL_SALES_LOGIN_USER') let sessionData = window.sessionStorage.getItem('GLOBAL_SALES_LOGIN_USER')
if (import.meta.env.DEV && isEmpty(sessionData)) { if (import.meta.env.DEV && isEmpty(sessionData)) {
sessionData = window.localStorage.getItem('GLOBAL_SALES_LOGIN_USER') sessionData = window.localStorage.getItem('GLOBAL_SALES_LOGIN_USER')
} }
@ -86,8 +86,10 @@ const useAuthStore = create((set, get) => ({
set(() => ({ set(() => ({
loginUser: sesstionObj loginUser: sesstionObj
})) }))
appendRequestHeader('X-User-Id', sesstionObj.userId) appendRequestHeader('X-User-Id', sesstionObj.userId)
window.__spytitle = sesstionObj.username;
} }
}, },

@ -2,7 +2,7 @@ import useAuthStore from '@/stores/AuthStore'
import useConversationStore from '@/stores/ConversationStore' import useConversationStore from '@/stores/ConversationStore'
import { useThemeContext } from '@/stores/ThemeContext' import { useThemeContext } from '@/stores/ThemeContext'
import { DownOutlined } from '@ant-design/icons' import { DownOutlined } from '@ant-design/icons'
import { Avatar, Col, Dropdown, Layout, Menu, Row, Space, Typography, theme, Badge } from 'antd' import { Avatar, Col, Dropdown, Layout, Menu, Row, Space, Typography, theme, Badge, Button } from 'antd'
import 'dayjs/locale/zh-cn' import 'dayjs/locale/zh-cn'
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { Link, NavLink, Outlet, useHref } from 'react-router-dom' import { Link, NavLink, Outlet, useHref } from 'react-router-dom'
@ -140,7 +140,10 @@ function DesktopApp() {
<Outlet /> <Outlet />
</Content> </Content>
</Layout> </Layout>
<Footer>桂林海纳国际旅行社有限公司 Version: {BUILD_VERSION}({BUILD_DATE})</Footer> <Footer>桂林海纳国际旅行社有限公司 Version: {BUILD_VERSION}({BUILD_DATE}) <Button type='link' onClick={() => {
window.$pageSpy.triggerPlugins('onOfflineLog', 'download');
window.$pageSpy.triggerPlugins('onOfflineLog', 'upload');
}}>下载/上传Debug日志</Button></Footer>
</Layout> </Layout>
); );
} }

Loading…
Cancel
Save