优化编译配置
This commit is contained in:
parent
488001574a
commit
0d80435461
34
README.md
Normal file
34
README.md
Normal file
@ -0,0 +1,34 @@
|
||||
## 注意事项:
|
||||
|
||||
项目编译时需要修改tsconfig.json中的如下配置
|
||||
```json
|
||||
{
|
||||
"compilerOptions": {
|
||||
// 将如下commonjs改为esnext
|
||||
// "module": "commonjs",
|
||||
"module": "esnext"
|
||||
// 省略其他配置...
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
```
|
||||
|
||||
## 相关命令
|
||||
1. 请使用 `npm install` 安装依赖
|
||||
2. 请使用 `npm run build` 打包
|
||||
3. 请使用 `npm run dev` 启动
|
||||
4. 请使用 `npm run test` 测试
|
||||
5. 请使用 `npm run lint` 检查代码
|
||||
6. 请使用 `npm run doc` 生成文档
|
||||
7. 请使用 `npm run deploy` 部署
|
||||
8. 请使用 `npm run deploy:dev` 部署开发环境
|
||||
9. 请使用 `npm run deploy:test` 部署测试环境
|
||||
10. 请使用 `npm run deploy:prod` 部署生产环境
|
||||
11. 请使用 `npm run deploy:pre` 部署预发布环境
|
||||
12. 请使用 `npm run deploy:sit` 部署体验环境
|
||||
13. 请使用 `npm run deploy:uat` 部署UAT环境
|
||||
14. 请使用 `npm run deploy:pro` 部署生产环境
|
||||
15. 请使用 `npm run deploy:pre` 部署预发布环境
|
||||
16. 请使用 `npm run deploy:sit` 部署体验环境
|
||||
17. 请使用 `npm run deploy:uat` 部署UAT环境
|
@ -2,6 +2,7 @@ import React, {useEffect} from 'react'
|
||||
import './assets/global.scss'
|
||||
import {AppRouter} from "./pages/Router.tsx";
|
||||
import {useUserinfoStore} from "./store/userinfoStore.ts";
|
||||
import {useLocation, useNavigation} from "react-router-dom";
|
||||
|
||||
|
||||
export function App() {
|
||||
|
@ -27,7 +27,7 @@ export const IconMap: {
|
||||
// '500': serverError,
|
||||
// '403': unauthorized,
|
||||
};
|
||||
export const Index: React.FC<ResultProps> = (props) => {
|
||||
export const Result: React.FC<ResultProps> = (props) => {
|
||||
const icon = props.icon || (props.status ? IconMap[props.status] : <></>)
|
||||
return <div className="result-wrapper">
|
||||
<div className="icon">{icon}</div>
|
||||
|
@ -5,7 +5,7 @@ export const NotFound: React.FC = () => {
|
||||
<defs>
|
||||
<path d="M0 .387h251.772v251.772H0z"></path>
|
||||
</defs>
|
||||
<g fill="none" fill-rule="evenodd">
|
||||
<g fill="none" fillRule="evenodd">
|
||||
<g transform="translate(0 .012)">
|
||||
<mask fill="#fff"></mask>
|
||||
<path
|
||||
@ -13,21 +13,21 @@ export const NotFound: React.FC = () => {
|
||||
fill="#E4EBF7" mask="url(#b)"></path>
|
||||
</g>
|
||||
<path d="M39.755 130.84a8.276 8.276 0 1 1-16.468-1.66 8.276 8.276 0 0 1 16.468 1.66" fill="#FFF"></path>
|
||||
<path d="M36.975 134.297l10.482 5.943M48.373 146.508l-12.648 10.788" stroke="#FFF" stroke-width="2"></path>
|
||||
<path d="M36.975 134.297l10.482 5.943M48.373 146.508l-12.648 10.788" stroke="#FFF" strokeWidth="2"></path>
|
||||
<path
|
||||
d="M39.875 159.352a5.667 5.667 0 1 1-11.277-1.136 5.667 5.667 0 0 1 11.277 1.136M57.588 143.247a5.708 5.708 0 1 1-11.358-1.145 5.708 5.708 0 0 1 11.358 1.145M99.018 26.875l29.82-.014a4.587 4.587 0 1 0-.003-9.175l-29.82.013a4.587 4.587 0 1 0 .003 9.176M110.424 45.211l29.82-.013a4.588 4.588 0 0 0-.004-9.175l-29.82.013a4.587 4.587 0 1 0 .004 9.175"
|
||||
fill="#FFF"></path>
|
||||
<path
|
||||
d="M112.798 26.861v-.002l15.784-.006a4.588 4.588 0 1 0 .003 9.175l-15.783.007v-.002a4.586 4.586 0 0 0-.004-9.172M184.523 135.668c-.553 5.485-5.447 9.483-10.931 8.93-5.485-.553-9.483-5.448-8.93-10.932.552-5.485 5.447-9.483 10.932-8.93 5.485.553 9.483 5.447 8.93 10.932"
|
||||
fill="#FFF"></path>
|
||||
<path d="M179.26 141.75l12.64 7.167M193.006 156.477l-15.255 13.011" stroke="#FFF" stroke-width="2"></path>
|
||||
<path d="M179.26 141.75l12.64 7.167M193.006 156.477l-15.255 13.011" stroke="#FFF" strokeWidth="2"></path>
|
||||
<path
|
||||
d="M184.668 170.057a6.835 6.835 0 1 1-13.6-1.372 6.835 6.835 0 0 1 13.6 1.372M203.34 153.325a6.885 6.885 0 1 1-13.7-1.382 6.885 6.885 0 0 1 13.7 1.382"
|
||||
fill="#FFF"></path>
|
||||
<path
|
||||
d="M151.931 192.324a2.222 2.222 0 1 1-4.444 0 2.222 2.222 0 0 1 4.444 0zM225.27 116.056a2.222 2.222 0 1 1-4.445 0 2.222 2.222 0 0 1 4.444 0zM216.38 151.08a2.223 2.223 0 1 1-4.446-.001 2.223 2.223 0 0 1 4.446 0zM176.917 107.636a2.223 2.223 0 1 1-4.445 0 2.223 2.223 0 0 1 4.445 0zM195.291 92.165a2.223 2.223 0 1 1-4.445 0 2.223 2.223 0 0 1 4.445 0zM202.058 180.711a2.223 2.223 0 1 1-4.446 0 2.223 2.223 0 0 1 4.446 0z"
|
||||
stroke="#FFF" stroke-width="2"></path>
|
||||
<path stroke="#FFF" stroke-width="2"
|
||||
stroke="#FFF" strokeWidth="2"></path>
|
||||
<path stroke="#FFF" strokeWidth="2"
|
||||
d="M214.404 153.302l-1.912 20.184-10.928 5.99M173.661 174.792l-6.356 9.814h-11.36l-4.508 6.484M174.941 125.168v-15.804M220.824 117.25l-12.84 7.901-15.31-7.902V94.39"></path>
|
||||
<path
|
||||
d="M166.588 65.936h-3.951a4.756 4.756 0 0 1-4.743-4.742 4.756 4.756 0 0 1 4.743-4.743h3.951a4.756 4.756 0 0 1 4.743 4.743 4.756 4.756 0 0 1-4.743 4.742"
|
||||
@ -68,12 +68,12 @@ export const NotFound: React.FC = () => {
|
||||
d="M99.66 278.514l13.378.092s1.298-54.52 1.853-64.403c.554-9.882 3.776-43.364 1.002-63.128l-12.547-.644-22.849.78s-.434 3.966-1.195 9.976c-.063.496-.682.843-.749 1.365-.075.585.423 1.354.32 1.966-2.364 14.08-6.377 33.104-8.744 46.677-.116.666-1.234 1.009-1.458 2.691-.04.302.211 1.525.112 1.795-6.873 18.744-10.949 47.842-14.277 61.885l14.607-.014s2.197-8.57 4.03-16.97c2.811-12.886 23.111-85.01 23.111-85.01l3.016-.521 1.043 46.35s-.224 1.234.337 2.02c.56.785-.56 1.123-.392 2.244l.392 1.794s-.449 7.178-.898 11.89c-.448 4.71-.092 39.165-.092 39.165"
|
||||
fill="#7BB2F9"></path>
|
||||
<path d="M76.085 221.626c1.153.094 4.038-2.019 6.955-4.935M106.36 225.142s2.774-1.11 6.103-3.883"
|
||||
stroke="#648BD8" stroke-width="1.051" stroke-linecap="round" stroke-linejoin="round"></path>
|
||||
<path d="M107.275 222.1s2.773-1.11 6.102-3.884" stroke="#648BD8" stroke-linecap="round"
|
||||
stroke-linejoin="round"></path>
|
||||
stroke="#648BD8" strokeWidth="1.051" strokeLinecap="round" strokeLinejoin="round"></path>
|
||||
<path d="M107.275 222.1s2.773-1.11 6.102-3.884" stroke="#648BD8" strokeLinecap="round"
|
||||
strokeLinejoin="round"></path>
|
||||
<path
|
||||
d="M74.74 224.767s2.622-.591 6.505-3.365M86.03 151.634c-.27 3.106.3 8.525-4.336 9.123M103.625 149.88s.11 14.012-1.293 15.065c-2.219 1.664-2.99 1.944-2.99 1.944M99.79 150.438s.035 12.88-1.196 24.377M93.673 175.911s7.212-1.664 9.431-1.664M74.31 205.861a212.013 212.013 0 0 1-.979 4.56s-1.458 1.832-1.009 3.776c.449 1.944-.947 2.045-4.985 15.355-1.696 5.59-4.49 18.591-6.348 27.597l-.231 1.12M75.689 197.807a320.934 320.934 0 0 1-.882 4.754M82.591 152.233L81.395 162.7s-1.097.15-.5 2.244c.113 1.346-2.674 15.775-5.18 30.43M56.12 274.418h13.31"
|
||||
stroke="#648BD8" stroke-width="1.051" stroke-linecap="round" stroke-linejoin="round"></path>
|
||||
stroke="#648BD8" strokeWidth="1.051" strokeLinecap="round" strokeLinejoin="round"></path>
|
||||
<path
|
||||
d="M116.241 148.22s-17.047-3.104-35.893.2c.158 2.514-.003 4.15-.003 4.15s14.687-2.818 35.67-.312c.252-2.355.226-4.038.226-4.038"
|
||||
fill="#192064"></path>
|
||||
@ -85,7 +85,7 @@ export const NotFound: React.FC = () => {
|
||||
fill="#192064"></path>
|
||||
<path
|
||||
d="M100.263 275.415h12.338M101.436 270.53c.006 3.387.042 5.79.111 6.506M101.451 264.548a915.75 915.75 0 0 0-.015 4.337M100.986 174.965l.898 44.642s.673 1.57-.225 2.692c-.897 1.122 2.468.673.898 2.243-1.57 1.57.897 1.122 0 3.365-.596 1.489-.994 21.1-1.096 35.146"
|
||||
stroke="#648BD8" stroke-width="1.051" stroke-linecap="round" stroke-linejoin="round"></path>
|
||||
stroke="#648BD8" strokeWidth="1.051" strokeLinecap="round" strokeLinejoin="round"></path>
|
||||
<path
|
||||
d="M46.876 83.427s-.516 6.045 7.223 5.552c11.2-.712 9.218-9.345 31.54-21.655-.786-2.708-2.447-4.744-2.447-4.744s-11.068 3.11-22.584 8.046c-6.766 2.9-13.395 6.352-13.732 12.801M104.46 91.057l.941-5.372-8.884-11.43-5.037 5.372-1.74 7.834a.321.321 0 0 0 .108.32c.965.8 6.5 5.013 14.347 3.544a.332.332 0 0 0 .264-.268"
|
||||
fill="#FFC6A0"></path>
|
||||
@ -98,23 +98,23 @@ export const NotFound: React.FC = () => {
|
||||
<path
|
||||
d="M104.977 76.064c-.103.61-.582 1.038-1.07.956-.489-.083-.801-.644-.698-1.254.103-.61.582-1.038 1.07-.956.488.082.8.644.698 1.254M112.132 77.694c-.103.61-.582 1.038-1.07.956-.488-.083-.8-.644-.698-1.254.103-.61.582-1.038 1.07-.956.488.082.8.643.698 1.254"
|
||||
fill="#552950"></path>
|
||||
<path stroke="#DB836E" stroke-width="1.118" stroke-linecap="round" stroke-linejoin="round"
|
||||
<path stroke="#DB836E" strokeWidth="1.118" strokeLinecap="round" strokeLinejoin="round"
|
||||
d="M110.13 74.84l-.896 1.61-.298 4.357h-2.228"></path>
|
||||
<path d="M110.846 74.481s1.79-.716 2.506.537" stroke="#5C2552" stroke-width="1.118" stroke-linecap="round"
|
||||
stroke-linejoin="round"></path>
|
||||
<path d="M110.846 74.481s1.79-.716 2.506.537" stroke="#5C2552" strokeWidth="1.118" strokeLinecap="round"
|
||||
strokeLinejoin="round"></path>
|
||||
<path d="M92.386 74.282s.477-1.114 1.113-.716c.637.398 1.274 1.433.558 1.99-.717.556.159 1.67.159 1.67"
|
||||
stroke="#DB836E" stroke-width="1.118" stroke-linecap="round" stroke-linejoin="round"></path>
|
||||
<path d="M103.287 72.93s1.83 1.113 4.137.954" stroke="#5C2552" stroke-width="1.118" stroke-linecap="round"
|
||||
stroke-linejoin="round"></path>
|
||||
stroke="#DB836E" strokeWidth="1.118" strokeLinecap="round" strokeLinejoin="round"></path>
|
||||
<path d="M103.287 72.93s1.83 1.113 4.137.954" stroke="#5C2552" strokeWidth="1.118" strokeLinecap="round"
|
||||
strokeLinejoin="round"></path>
|
||||
<path
|
||||
d="M103.685 81.762s2.227 1.193 4.376 1.193M104.64 84.308s.954.398 1.511.318M94.693 81.205s2.308 7.4 10.424 7.639"
|
||||
stroke="#DB836E" stroke-width="1.118" stroke-linecap="round" stroke-linejoin="round"></path>
|
||||
stroke="#DB836E" strokeWidth="1.118" strokeLinecap="round" strokeLinejoin="round"></path>
|
||||
<path d="M81.45 89.384s.45 5.647-4.935 12.787M69 82.654s-.726 9.282-8.204 14.206" stroke="#E4EBF7"
|
||||
stroke-width="1.101" stroke-linecap="round" stroke-linejoin="round"></path>
|
||||
<path d="M129.405 122.865s-5.272 7.403-9.422 10.768" stroke="#E4EBF7" stroke-width="1.051"
|
||||
stroke-linecap="round" stroke-linejoin="round"></path>
|
||||
<path d="M119.306 107.329s.452 4.366-2.127 32.062" stroke="#E4EBF7" stroke-width="1.101"
|
||||
stroke-linecap="round" stroke-linejoin="round"></path>
|
||||
strokeWidth="1.101" strokeLinecap="round" strokeLinejoin="round"></path>
|
||||
<path d="M129.405 122.865s-5.272 7.403-9.422 10.768" stroke="#E4EBF7" strokeWidth="1.051"
|
||||
strokeLinecap="round" strokeLinejoin="round"></path>
|
||||
<path d="M119.306 107.329s.452 4.366-2.127 32.062" stroke="#E4EBF7" strokeWidth="1.101"
|
||||
strokeLinecap="round" strokeLinejoin="round"></path>
|
||||
<path
|
||||
d="M150.028 151.232h-49.837a1.01 1.01 0 0 1-1.01-1.01v-31.688c0-.557.452-1.01 1.01-1.01h49.837c.558 0 1.01.453 1.01 1.01v31.688a1.01 1.01 0 0 1-1.01 1.01"
|
||||
fill="#F2D7AD"></path>
|
||||
@ -135,12 +135,12 @@ export const NotFound: React.FC = () => {
|
||||
fill="#FFC6A0"></path>
|
||||
<path
|
||||
d="M153.686 133.577s-6.522.47-8.36.372c-1.836-.098-1.904 2.19 2.359 2.264 3.739.15 5.451-.044 5.451-.044"
|
||||
stroke="#DB836E" stroke-width="1.051" stroke-linecap="round" stroke-linejoin="round"></path>
|
||||
stroke="#DB836E" strokeWidth="1.051" strokeLinecap="round" strokeLinejoin="round"></path>
|
||||
<path d="M145.16 135.877c-1.85 1.346.561 2.355.561 2.355s3.478.898 6.73.617" stroke="#DB836E"
|
||||
stroke-width="1.051" stroke-linecap="round" stroke-linejoin="round"></path>
|
||||
strokeWidth="1.051" strokeLinecap="round" strokeLinejoin="round"></path>
|
||||
<path
|
||||
d="M151.89 141.71s-6.28.111-6.73-2.132c-.223-1.346.45-1.402.45-1.402M146.114 140.868s-1.103 3.16 5.44 3.533M151.202 129.932v3.477M52.838 89.286c3.533-.337 8.423-1.248 13.582-7.754"
|
||||
stroke="#DB836E" stroke-width="1.051" stroke-linecap="round" stroke-linejoin="round"></path>
|
||||
stroke="#DB836E" strokeWidth="1.051" strokeLinecap="round" strokeLinejoin="round"></path>
|
||||
<path
|
||||
d="M168.567 248.318a6.647 6.647 0 0 1-6.647-6.647v-66.466a6.647 6.647 0 1 1 13.294 0v66.466a6.647 6.647 0 0 1-6.647 6.647"
|
||||
fill="#5BA02E"></path>
|
||||
@ -150,8 +150,8 @@ export const NotFound: React.FC = () => {
|
||||
<path
|
||||
d="M186.443 293.613H158.92a3.187 3.187 0 0 1-3.187-3.187v-46.134a3.187 3.187 0 0 1 3.187-3.187h27.524a3.187 3.187 0 0 1 3.187 3.187v46.134a3.187 3.187 0 0 1-3.187 3.187"
|
||||
fill="#F2D7AD"></path>
|
||||
<path d="M88.979 89.48s7.776 5.384 16.6 2.842" stroke="#E4EBF7" stroke-width="1.101" stroke-linecap="round"
|
||||
stroke-linejoin="round"></path>
|
||||
<path d="M88.979 89.48s7.776 5.384 16.6 2.842" stroke="#E4EBF7" strokeWidth="1.101" strokeLinecap="round"
|
||||
strokeLinejoin="round"></path>
|
||||
</g>
|
||||
</svg>)
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
import React from "react";
|
||||
import {BrowserRouter, HashRouter, Navigate, Route, Routes, useNavigate} from "react-router-dom";
|
||||
import {APP_CONFIG} from "../config.ts";
|
||||
import React, {useEffect} from "react";
|
||||
import {BrowserRouter, HashRouter, Route, Routes, useLocation, useNavigate} from "react-router-dom";
|
||||
import {APP_CONFIG} from "../config";
|
||||
import {Button} from "@douyinfe/semi-ui";
|
||||
import DefaultPage from "./index";
|
||||
import {Index} from "../components/Result";
|
||||
import {Result} from "../components/Result";
|
||||
import {DashboardIndex} from "./dashboard";
|
||||
import {useUserinfoStore} from "../store/userinfoStore.ts";
|
||||
|
||||
const routerMode: 'browser' | 'hash' | string = APP_CONFIG.ROUTER_MODE;
|
||||
|
||||
@ -16,18 +17,36 @@ const WebRouter: React.FC<{
|
||||
|
||||
const NotFound: React.FC = () => {
|
||||
const navigate = useNavigate();
|
||||
return <Index
|
||||
return <Result
|
||||
status="404"
|
||||
title="页面不存在或无法找到所请求的资源"
|
||||
// subTitle="Sorry, the page you visited does not exist."
|
||||
extra={<Button onClick={() => navigate('/')} type="primary">返回首页</Button>}/>
|
||||
}
|
||||
export const AppRouter = () => (<WebRouter>
|
||||
<div className="page-body-content">
|
||||
<Routes>
|
||||
<Route path="/" element={<DefaultPage/>}/>
|
||||
<Route path="/dashboard" element={<DashboardIndex/>}/>
|
||||
<Route path="*" element={<NotFound/>}/>
|
||||
</Routes>
|
||||
</div>
|
||||
</WebRouter>)
|
||||
const AppRoutes = () => (<Routes>
|
||||
<Route path="/" element={<DefaultPage/>}/>
|
||||
<Route path="/dashboard" element={<DashboardIndex/>}/>
|
||||
<Route path="*" element={<NotFound/>}/>
|
||||
</Routes>)
|
||||
const RouteView = () => {
|
||||
const navigate = useNavigate();
|
||||
const loc = useLocation();
|
||||
const {userinfo, setUid} = useUserinfoStore();
|
||||
|
||||
useEffect(() => {
|
||||
if (userinfo.id == -1 && loc.pathname !== '/') {
|
||||
setUid(0)
|
||||
navigate('/')
|
||||
}
|
||||
}, [userinfo])
|
||||
return (
|
||||
<div className="page-body-content">
|
||||
<h1>{loc.pathname}</h1>
|
||||
<AppRoutes></AppRoutes>
|
||||
</div>)
|
||||
}
|
||||
export const AppRouter = () => {
|
||||
return (<WebRouter>
|
||||
<RouteView/>
|
||||
</WebRouter>)
|
||||
}
|
||||
|
@ -2,10 +2,10 @@ import React from "react";
|
||||
import {Panel} from "../../components/panel";
|
||||
import {AppList} from "../../components/AppList";
|
||||
import {AppModel, EventDataModel, EventModel} from "../../../model";
|
||||
import {appList, appEventList, appEventDataList} from "../../service/api.app.ts";
|
||||
import {appList, appEventList, appEventDataList} from "../../service/api.app";
|
||||
import './style.scss'
|
||||
import {Space, Table} from "@douyinfe/semi-ui";
|
||||
import {formatDate} from "../../../utils/date.ts";
|
||||
import {formatDate} from "../../../utils/date";
|
||||
import {useInterval} from "ahooks";
|
||||
|
||||
export const DashboardIndex: React.FC = () => {
|
||||
@ -62,6 +62,7 @@ export const DashboardIndex: React.FC = () => {
|
||||
|
||||
// 加载引用所有事件上报的数据
|
||||
const loadAppEventsAndDataList = (page = 1) => {
|
||||
if (currentAppID < 1) return;
|
||||
appEventDataList({
|
||||
appId: currentAppID,
|
||||
pageSize: 10,
|
||||
@ -72,7 +73,7 @@ export const DashboardIndex: React.FC = () => {
|
||||
})
|
||||
}
|
||||
|
||||
const getAppEventAndData = ()=>{
|
||||
const getAppEventAndData = () => {
|
||||
if (currentAppID > 0) {
|
||||
getAppEvents()
|
||||
loadAppEventsAndDataList()
|
||||
|
@ -23,7 +23,9 @@ const DefaultPage: React.FC = () => {
|
||||
console.log(err)
|
||||
// 登录失败
|
||||
Notification.error({
|
||||
content: '登录失败,请检查用户名和密码'
|
||||
content: '登录失败,请检查用户名和密码',
|
||||
position: 'top',
|
||||
// duration: 2,
|
||||
})
|
||||
}
|
||||
setLoading(false);
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {get, post} from "./request.ts";
|
||||
import {get, post} from "./request";
|
||||
import {AppModel, EventDataModel, EventModel, UserModel} from "../../model";
|
||||
|
||||
// 获取用户归属应用列表
|
||||
|
@ -1,8 +1,9 @@
|
||||
import axios from 'axios';
|
||||
import {BizError} from "./types.ts";
|
||||
import Storage from "./storage.ts";
|
||||
import {useUserinfoStore} from "../store/userinfoStore.ts";
|
||||
import {APP_CONFIG} from "../config.ts";
|
||||
import {BizError} from "./types";
|
||||
import Storage from "./storage";
|
||||
import {useUserinfoStore} from "../store/userinfoStore";
|
||||
import {APP_CONFIG} from "../config";
|
||||
import {stat} from "fs";
|
||||
|
||||
export interface APIResponse<T> {
|
||||
/**
|
||||
@ -95,7 +96,7 @@ export function request<T>(url: string, method: RequestMethod, data: any = null,
|
||||
if (code == 403) {
|
||||
const state = useUserinfoStore.getState()
|
||||
// 未登录 显示登录modal
|
||||
// state.showLogin(true);
|
||||
state.showLogin();
|
||||
}
|
||||
reject(new BizError(msg, code))
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {get, post} from "./request.ts";
|
||||
import {get, post} from "./request";
|
||||
import {UserModel} from "../../model";
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import {create} from "zustand";
|
||||
import Storage from "../service/storage.ts";
|
||||
import {getInfo, login} from './../service/user.ts'
|
||||
import {APP_CONFIG} from "../config.ts";
|
||||
import Storage from "../service/storage";
|
||||
import {getInfo, login} from './../service/user'
|
||||
import {APP_CONFIG} from "../config";
|
||||
import {UserModel} from "../../model";
|
||||
|
||||
type LoginDataType = { account: string; code?: string; password: string }
|
||||
@ -34,8 +34,27 @@ export const useUserinfoStore = create<{
|
||||
* 初始化用户数据
|
||||
*/
|
||||
init: () => void;
|
||||
showLogin: () => void;
|
||||
setUid: (id: number) => void;
|
||||
}>((set, _, _state) => {
|
||||
return {
|
||||
showLogin() {
|
||||
// const navigate = useNavigate()
|
||||
// navigate('/')
|
||||
|
||||
set({
|
||||
userinfo: {
|
||||
id: -1
|
||||
},
|
||||
token: undefined
|
||||
})
|
||||
Storage.remove(LOGIN_TOKEN_KEY)
|
||||
},
|
||||
setUid(id) {
|
||||
set({
|
||||
userinfo: {id}
|
||||
})
|
||||
},
|
||||
userinfo: {
|
||||
id: 0
|
||||
},
|
||||
|
@ -1,15 +1,15 @@
|
||||
{
|
||||
"name": "app-report-all",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"main": "service/index.ts",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"dev": "nodemon service/index.ts",
|
||||
"start": "ts-node service/index.ts",
|
||||
"build": "tsc -p service.tsconfig.json",
|
||||
"preview": "vite preview",
|
||||
"dev-front": "vite --mode development --host 0.0.0.0",
|
||||
"build-front": "tsc && vite build --mode production",
|
||||
"build": "tsc",
|
||||
"test": "mocha -r ts-node/register test/**/**.test.ts",
|
||||
"test-db": "mocha -r ts-node/register test/db.test.ts"
|
||||
},
|
||||
|
19
service.tsconfig.json
Normal file
19
service.tsconfig.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2020",
|
||||
"lib": ["DOM", "DOM.Iterable", "ES2020"],
|
||||
"module": "commonjs",
|
||||
"skipLibCheck": true,
|
||||
"moduleResolution": "node",
|
||||
"outDir": "dist"
|
||||
},
|
||||
"include": [
|
||||
"service/**/*",
|
||||
"utils/**/*",
|
||||
"model/**/*"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||
|
@ -1,14 +1,16 @@
|
||||
import {InitServerOption} from "./types";
|
||||
// import { createServer as createServerOrigin } from "http";
|
||||
// import express = require("express");
|
||||
import * as express from "express";
|
||||
import {dirname,resolve} from "path";
|
||||
|
||||
const WEB_ROOT = dirname(dirname(__dirname))
|
||||
export function createServer(options: Partial<InitServerOption>, callback?: () => void) {
|
||||
// 创建express服务器
|
||||
const app = express();
|
||||
// 将请求体转换为JSON格式
|
||||
app.use(express.json())
|
||||
app.use(express.urlencoded({extended: true}))
|
||||
// 指定静态资源目录
|
||||
app.use('/',express.static(resolve(WEB_ROOT, "static")));
|
||||
// 监听端口
|
||||
app.listen(options.port, callback);
|
||||
// 添加允许跨域中间件
|
||||
|
@ -2,11 +2,12 @@ import {Application, Request, Response} from "express";
|
||||
import {RouteHandleFunction, RouteHandleFunctionParam} from "../core/types";
|
||||
import {home} from "./home";
|
||||
import {appList, reportToServer, appEvent, eventData} from "./reportor";
|
||||
import {decodeUserToken, getUserInfo, loginHandler} from "./user.ts";
|
||||
import {decodeUserToken, getUserInfo, loginHandler} from "./user";
|
||||
|
||||
const excludes = [
|
||||
'/home',
|
||||
'/api/report',
|
||||
'/api/user/login',
|
||||
]
|
||||
|
||||
//
|
||||
|
@ -1,7 +1,7 @@
|
||||
import {RouteHandleFunction} from "../core/types.ts";
|
||||
import {login} from "../service/app.ts";
|
||||
import {RouteHandleFunction} from "../core/types";
|
||||
import {login} from "../service/app";
|
||||
import {UserModel} from "../../model";
|
||||
import {getFromRedis, setToRedis} from "../service/redis.ts";
|
||||
import {getFromRedis, setToRedis} from "../service/redis";
|
||||
|
||||
export function encodeUserToken(user: UserModel) {
|
||||
if (user == null) throw new Error('user is null')
|
||||
|
@ -3,7 +3,7 @@
|
||||
/* ESNext */
|
||||
"target": "ESNext",
|
||||
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
||||
"module": "commonjs",
|
||||
"module": "ESNext",
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
|
@ -17,7 +17,7 @@ export default defineConfig(({mode}) => {
|
||||
// mode:JSON.stringify(mode),
|
||||
// },
|
||||
build: {
|
||||
outDir:'static',
|
||||
outDir:'./dist/static',
|
||||
// 小于10kb直接base64
|
||||
assetsInlineLimit: 10240,
|
||||
rollupOptions: {
|
||||
@ -33,7 +33,7 @@ export default defineConfig(({mode}) => {
|
||||
}
|
||||
}
|
||||
},
|
||||
base: "/",
|
||||
base: "./",
|
||||
server: {
|
||||
proxy: {
|
||||
'/api': {
|
||||
|
Loading…
x
Reference in New Issue
Block a user