Skip to content

Commit 25c3195

Browse files
author
sunshine824
committed
修复打包报错bug
1 parent 32afa24 commit 25c3195

File tree

10 files changed

+115
-145
lines changed

10 files changed

+115
-145
lines changed

src/components/ABreadCrumb/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import styles from './index.module.less'
66

77
const ABreadCrumb = defineComponent({
88
name: 'ABreadCrumb',
9-
setup({ props }) {
9+
setup(props) {
1010
const route = useRoute()
1111
const router = useRouter()
1212

src/components/GlobalHeader/Menus.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,13 @@ const Menus = defineComponent({
8686
class={`${styles['menu-class']} ${styles[props.mode + '-menu-class']}`}
8787
>
8888
<Menu
89-
selectedKeys={[activeRoute.value]}
90-
openKeys={openKeys.value}
91-
mode={props.mode}
89+
{...({
90+
selectedKeys: [activeRoute.value],
91+
openKeys: openKeys.value,
92+
mode: props.mode,
93+
onClick: handleMenuClick,
94+
} as any)}
9295
style={{ lineHeight: '54px' }}
93-
onClick={handleMenuClick}
9496
>
9597
{(props.menuLists as RouteRecordRaw[]).map((menu) => {
9698
if (!menu.children || !menu.children.length) {

src/router/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ router.beforeEach(
6969
if (!isAddDynamicMenuRoutes) {
7070
try {
7171
//获取动态路由表
72-
const res = await getPermissionsList({})
72+
const res: any = await getPermissionsList({})
7373
if (res.code == 200) {
7474
isAddDynamicMenuRoutes = true
7575
const menu = res.data

src/router/router.config.ts

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,7 @@ import { RouteRecordRaw } from 'vue-router'
22
import { LevelBasicLayout, RouteLayout } from '@/layouts'
33

44
// 导航路由
5-
const Routes: Array<RouteRecordRaw> = [
6-
{
7-
path: '/home',
8-
name: 'home',
9-
component: () => import(/* webpackChunkName: "home" */ '@/views/home'),
10-
meta: { title: '首页', hidden: true },
11-
},
12-
{
13-
path: '/database',
14-
name: 'database',
15-
component: () =>
16-
import(/* webpackChunkName: "database" */ '@/views/database'),
17-
meta: { title: '数据库配置', hidden: false, icon: 'icon-zichan' },
18-
},
19-
{
20-
path: '/smart',
21-
name: 'smart',
22-
component: () => import(/* webpackChunkName: "smart" */ '@/views/smart'),
23-
meta: { title: '物联管理', hidden: false, icon: 'icon-wulianwang' },
24-
},
25-
{
26-
path: '/eoms',
27-
name: 'eoms',
28-
component: RouteLayout,
29-
meta: { title: '运维配置', hidden: false, icon: 'icon-yunwei1' },
30-
children: [
31-
{
32-
path: '/eoms/fault',
33-
name: 'fault',
34-
component: () =>
35-
import(/* webpackChunkName: "fault" */ '@/views/eoms/fault'),
36-
meta: { title: '故障处理方案', hidden: false },
37-
},
38-
{
39-
path: '/eoms/alarm',
40-
name: 'alarm',
41-
component: () =>
42-
import(/* webpackChunkName: "alarm" */ '@/views/eoms/alarm'),
43-
meta: { title: '告警模板管理', hidden: false },
44-
},
45-
],
46-
},
47-
]
5+
const Routes: Array<RouteRecordRaw> = []
486

497
// 主路由
508
const mainRoutes: RouteRecordRaw = {

src/utils/fetch.ts

Lines changed: 58 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import axios, { AxiosRequestConfig, AxiosResponse, AxiosInstance } from 'axios';
2-
import { getToken, removeToken } from './token';
3-
import { Modal } from 'ant-design-vue';
4-
import { Message, Notification } from './resetMessage';
1+
import axios, { AxiosRequestConfig, AxiosResponse, AxiosInstance } from 'axios'
2+
import { getToken, removeToken } from './token'
3+
import { Modal } from 'ant-design-vue'
4+
import { Message, Notification } from '@/utils/resetMessage'
55

66
// .env环境变量
77
const BaseUrl = import.meta.env.VITE_API_BASE_URL as string
@@ -10,86 +10,90 @@ const BaseUrl = import.meta.env.VITE_API_BASE_URL as string
1010
const service: AxiosInstance = axios.create({
1111
baseURL: BaseUrl, // 正式环境
1212
timeout: 60 * 1000,
13-
headers: {}
14-
});
13+
headers: {},
14+
})
1515

1616
/**
1717
* 请求拦截
1818
*/
19-
service.interceptors.request.use((config: AxiosRequestConfig) => {
20-
config.headers.common.Authorization = getToken(); // 请求头带上token
21-
config.headers.common.token = getToken();
22-
return config;
23-
},
24-
(error) => Promise.reject(error));
19+
service.interceptors.request.use(
20+
(config: AxiosRequestConfig) => {
21+
config.headers.common.Authorization = getToken() // 请求头带上token
22+
config.headers.common.token = getToken()
23+
return config
24+
},
25+
(error) => Promise.reject(error),
26+
)
2527

2628
/**
2729
* 响应拦截
2830
*/
29-
service.interceptors.response.use((response: AxiosResponse) => {
30-
if (response.status == 201 || response.status == 200) {
31-
const { code, status, msg } = response.data;
32-
if (code == 401) {
33-
Modal.warning({
34-
title: 'token出错',
35-
content: 'token失效,请重新登录!',
36-
onOk: () => {
37-
removeToken();
31+
service.interceptors.response.use(
32+
(response: AxiosResponse) => {
33+
if (response.status == 201 || response.status == 200) {
34+
const { code, status, msg } = response.data
35+
if (code == 401) {
36+
Modal.warning({
37+
title: 'token出错',
38+
content: 'token失效,请重新登录!',
39+
onOk: () => {
40+
removeToken()
41+
},
42+
})
43+
} else if (code == 200) {
44+
if (status) {
45+
// 接口请求成功
46+
msg && Message.success(msg) // 后台如果返回了msg,则将msg提示出来
47+
return Promise.resolve(response.data) // 返回成功数据
3848
}
39-
});
40-
} else if (code == 200) {
41-
if (status) {
42-
// 接口请求成功
43-
msg && Message.success(msg); // 后台如果返回了msg,则将msg提示出来
44-
return Promise.resolve(response.data); // 返回成功数据
49+
// 接口异常
50+
msg && Message.warning(msg) // 后台如果返回了msg,则将msg提示出来
51+
return Promise.reject(response.data) // 返回异常数据
52+
} else {
53+
// 接口异常
54+
msg && Message.error(msg)
55+
return Promise.reject(response.data)
4556
}
46-
// 接口异常
47-
msg && Message.warning(msg); // 后台如果返回了msg,则将msg提示出来
48-
return Promise.reject(response.data); // 返回异常数据
49-
} else {
50-
// 接口异常
51-
msg && Message.error(msg);
52-
return Promise.reject(response.data);
5357
}
54-
}
55-
return response;
56-
},
58+
return response
59+
},
5760
(error) => {
5861
if (error.response.status) {
5962
switch (error.response.status) {
6063
case 500:
6164
Notification.error({
6265
message: '温馨提示',
63-
description: '服务异常,请重启服务器!'
64-
});
65-
break;
66+
description: '服务异常,请重启服务器!',
67+
})
68+
break
6669
case 401:
6770
Notification.error({
6871
message: '温馨提示',
69-
description: '服务异常,请重启服务器!'
70-
});
71-
break;
72+
description: '服务异常,请重启服务器!',
73+
})
74+
break
7275
case 403:
7376
Notification.error({
7477
message: '温馨提示',
75-
description: '服务异常,请重启服务器!'
76-
});
77-
break;
78+
description: '服务异常,请重启服务器!',
79+
})
80+
break
7881
// 404请求不存在
7982
case 404:
8083
Notification.error({
8184
message: '温馨提示',
82-
description: '服务异常,请重启服务器!'
83-
});
84-
break;
85+
description: '服务异常,请重启服务器!',
86+
})
87+
break
8588
default:
8689
Notification.error({
8790
message: '温馨提示',
88-
description: '服务异常,请重启服务器!'
89-
});
91+
description: '服务异常,请重启服务器!',
92+
})
9093
}
9194
}
92-
return Promise.reject(error.response);
93-
});
95+
return Promise.reject(error.response)
96+
},
97+
)
9498

95-
export default service;
99+
export default service

src/utils/resetMessage.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
import { message } from 'ant-design-vue';
2-
import notification from 'ant-design-vue/es/notification';
1+
import { message } from 'ant-design-vue'
2+
import notification from 'ant-design-vue/es/notification'
33

44
const Message = (options) => {
5-
message.destroy();
6-
message[options.type](options);
7-
};
5+
message.destroy()
6+
message[options.type](options)
7+
}
88

99
const Notification = (options) => {
10-
notification.destroy();
11-
notification[options.type](options);
10+
notification.destroy()
11+
notification[options.type](options)
1212
};
1313

1414
['success', 'info', 'warning', 'error', 'loading'].forEach((type) => {
1515
Message[type] = (options) => {
1616
if (typeof options === 'string') {
1717
options = {
18-
content: options
19-
};
18+
content: options,
19+
}
2020
}
21-
options.type = type;
22-
return Message(options);
23-
};
21+
options.type = type
22+
return Message(options)
23+
}
2424
});
2525

2626
['success', 'info', 'warning', 'error', 'loading', 'warn', 'open'].forEach(
@@ -29,13 +29,13 @@ const Notification = (options) => {
2929
if (typeof options === 'string') {
3030
options = {
3131
message: '温馨提示',
32-
description: options
33-
};
32+
description: options,
33+
}
3434
}
35-
options.type = type;
36-
return Notification(options);
37-
};
38-
}
39-
);
35+
options.type = type
36+
return Notification(options)
37+
}
38+
},
39+
)
4040

41-
export { Message, Notification };
41+
export { Message, Notification }

src/views/dataManage/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { RouteLayout } from '@/layouts'
44
import styles from './index.module.less'
55

66
const DataManage = defineComponent({
7-
name: 'Database',
7+
name: 'DataManage',
88
setup() {
99
const slots = {
1010
default: () => <div>数据管理</div>,

src/views/user/login/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const Login = defineComponent({
4949
const { data } = await login(formData)
5050
sessionStorage.setItem('token', data.token)
5151
sessionStorage.setItem('userInfo', JSON.stringify(data.userInfo))
52-
router.push('/database')
52+
router.push('/dataProtal')
5353
loading.value = false
5454
} catch (error) {
5555
loading.value = false

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
"resolveJsonModule": true,
1010
"esModuleInterop": true,
1111
"lib": ["esnext", "dom"],
12+
"baseUrl": "./",
1213
"paths": {
1314
"@/*": ["*","src/*"]
1415
}
1516
},
16-
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue", "src/App.vue"]
17+
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue", "src/App.vue", "src/utils/resetMessage.js"]
1718
}

0 commit comments

Comments
 (0)