Skip to content

Commit c803599

Browse files
committed
更新 前端版本
1 parent c486d66 commit c803599

17 files changed

+1558
-1380
lines changed

frontend/auto-imports.d.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
/* eslint-disable */
22
/* prettier-ignore */
33
// @ts-nocheck
4+
// noinspection JSUnusedGlobalSymbols
45
// Generated by unplugin-auto-import
56
export {}
67
declare global {
7-
8+
const ElLoading: typeof import('element-plus/es')['ElLoading']
9+
const ElMessage: typeof import('element-plus/es')['ElMessage']
810
}

frontend/components.d.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,17 @@
33
// @ts-nocheck
44
// Generated by unplugin-vue-components
55
// Read more: https://github.com/vuejs/core/pull/3399
6-
import '@vue/runtime-core'
7-
86
export {}
97

10-
declare module '@vue/runtime-core' {
8+
declare module 'vue' {
119
export interface GlobalComponents {
1210
ElAside: typeof import('element-plus/es')['ElAside']
1311
ElAutoResizer: typeof import('element-plus/es')['ElAutoResizer']
1412
ElBreadcrumb: typeof import('element-plus/es')['ElBreadcrumb']
1513
ElBreadcrumbItem: typeof import('element-plus/es')['ElBreadcrumbItem']
1614
ElButton: typeof import('element-plus/es')['ElButton']
1715
ElCard: typeof import('element-plus/es')['ElCard']
16+
ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
1817
ElContainer: typeof import('element-plus/es')['ElContainer']
1918
ElCountdown: typeof import('element-plus/es')['ElCountdown']
2019
ElDropdown: typeof import('element-plus/es')['ElDropdown']

frontend/package-lock.json

+1,445-1,300
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,25 @@
1313
"@element-plus/icons-vue": "^2.1.0",
1414
"axios": "^1.4.0",
1515
"echarts": "^5.4.2",
16-
"element-plus": "^2.3.4",
16+
"element-plus": "^2.3.8",
1717
"jsencrypt": "^3.3.2",
18-
"pinia": "^2.0.36",
19-
"vue": "^3.3.2",
18+
"pinia": "^2.1.3",
19+
"vue": "^3.3.4",
2020
"vue-router": "^4.2.0"
2121
},
2222
"devDependencies": {
2323
"@tsconfig/node18": "^2.0.1",
24-
"@types/node": "^18.16.8",
24+
"@types/node": "^18.16.17",
2525
"@vitejs/plugin-vue": "^4.2.3",
2626
"@vitejs/plugin-vue-jsx": "^3.0.1",
2727
"@vue/tsconfig": "^0.4.0",
2828
"less": "^4.1.3",
2929
"less-loader": "^11.1.0",
3030
"npm-run-all": "^4.1.5",
3131
"typescript": "~5.0.4",
32-
"unplugin-auto-import": "^0.15.3",
33-
"unplugin-vue-components": "^0.24.1",
34-
"vite": "^4.3.5",
35-
"vue-tsc": "^1.6.4"
32+
"unplugin-auto-import": "^0.16.6",
33+
"unplugin-vue-components": "^0.25.1",
34+
"vite": "^4.3.9",
35+
"vue-tsc": "^1.6.5"
3636
}
3737
}

frontend/src/App.vue

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
<script setup lang="ts">
22
import { RouterView } from "vue-router";
3+
import zhCn from "element-plus/dist/locale/zh-cn.mjs"; // element-plus 中文语言包
34
</script>
45

56
<template>
6-
<RouterView />
7+
<el-config-provider :locale="zhCn">
8+
<RouterView />
9+
</el-config-provider>
710
</template>
811

912
<style></style>

frontend/src/apis/index.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { get, post } from "@/request";
22
import type { IRequestOption } from "@/request/http";
3+
import axios from "axios";
34
import type { SignUp, Login, List } from "./model";
45

56
/** 注册 */
@@ -26,12 +27,9 @@ export const getLogs = (list: List): Promise<any> => get("/log/list", { ...list
2627
/**
2728
* 仓库获取语言详情(github被封了, 暂时用不了)
2829
*/
29-
// export const getLangList = async (page: number): Promise<any> => {
30-
// return await axios.get(`https://api.github.com/repos/zxiaosi/Vue3-FastAPI/commits?page=${page}`);
31-
// };
32-
33-
/** 仓库获取语言详情 */
34-
export const getLangList = (): Promise<any> => get("/lang/list", {}, { isShowLoading: true });
30+
export const getLangList = async (page: number): Promise<any> => {
31+
return await axios.get(`https://api.github.com/repos/zxiaosi/Vue3-FastAPI/commits?page=${page}`);
32+
};
3533

3634
/** 得到所有角色 */
3735
export const getRoles = (list: List): Promise<any> => get("/role/list", { ...list }, { isShowLoading: true });

frontend/src/assets/js/global.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const IS_DEV: boolean = true;
1313
* 开发、测试、线上环境
1414
*/
1515
export const DEVELOPMENT: string = "http://127.0.0.1:8000"; // 开发环境
16-
export const PRODUCTION: string = "http://114.115.143.81"; // 线上环境
16+
export const PRODUCTION: string = "http://150.158.87.218"; // 线上环境
1717
export const BASE_URL: string = IS_DEV ? DEVELOPMENT : PRODUCTION;
1818

1919
/**

frontend/src/components/MyUpload.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { uploadImg } from "@/apis";
33
import { clearLocal, setLocal } from "@/request/auth";
44
import { useUserStore } from "@/stores";
5-
import { ElMessage, type UploadFile, type UploadFiles, type UploadRequestOptions } from "element-plus";
5+
import type { UploadFile, UploadFiles, UploadRequestOptions } from "element-plus";
66
import { ref } from "vue";
77
88
const userStore = useUserStore();
@@ -86,4 +86,4 @@ const onError = (err: Error, uploadFile: UploadFile, uploadFiles: UploadFiles) =
8686
cursor: pointer;
8787
font-size: 14px;
8888
}
89-
</style>
89+
</style>

frontend/src/main.ts

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
import { createApp } from "vue";
22
import { createPinia } from "pinia";
3-
import ElementPlus from "element-plus"; // ElementPlus
4-
import zhCn from "element-plus/dist/locale/zh-cn.mjs"; // ElementPlus 国际化
5-
import * as ElementPlusIconsVue from "@element-plus/icons-vue"; // ElementPlus 图标
3+
// import * as ElementPlusIconsVue from "@element-plus/icons-vue"; // ElementPlus 图标
64

75
import App from "./App.vue";
86
import router from "./router";
97

108
import "./assets/css/main.css";
11-
import "element-plus/dist/index.css"; // ElementPlus 样式
129

1310
const app = createApp(App);
1411

1512
app.use(createPinia());
1613
app.use(router);
17-
app.use(ElementPlus, { locale: zhCn });
18-
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
19-
app.component(key, component);
20-
}
14+
// for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
15+
// app.component(key, component);
16+
// }
2117

2218
app.mount("#app");

frontend/src/request/http.ts

+27-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import axios, { AxiosError } from "axios";
22
import type { AxiosRequestConfig, AxiosResponse } from "axios";
3-
import { ElLoading, ElMessage } from "element-plus";
43
import { API_URL } from "@/assets/js/global";
54
import { clearLocal } from "./auth";
65

@@ -20,34 +19,42 @@ axios.defaults.baseURL = API_URL;
2019
axios.interceptors.request.use(
2120
(config: any) => {
2221
const { isShowLoading } = config;
23-
const target = ".card, .el-table-v2__body, #line"
22+
const target = ".card, .el-table-v2__body, #line";
2423
isShowLoading && (loading = ElLoading.service({ lock: true, text: "加载中...", target }));
2524
return config;
2625
},
27-
(error: AxiosError) => { // 发送请求时出了点问题,比如网络错误 https://segmentfault.com/q/1010000020659252
26+
(error: AxiosError) => {
27+
// 发送请求时出了点问题,比如网络错误 https://segmentfault.com/q/1010000020659252
2828
ElMessage.error(`请求发起错误 -- ${error.message}`);
2929
return Promise.reject(error);
3030
}
3131
);
3232

3333
// 响应拦截器(全局配置)
3434
axios.interceptors.response.use(
35-
(response: AxiosResponse<IResponseData>) => { // status >= 200 && status < 300 (HTTP 成功)
36-
const { data: { code, msg }, config } = response;
35+
(response: AxiosResponse<IResponseData>) => {
36+
// status >= 200 && status < 300 (HTTP 成功)
37+
const {
38+
data: { code, msg },
39+
config,
40+
} = response;
3741
const { isShowLoading, isShowFailToast, isThrowError } = config as IRequestOption; // 请求配置
3842

3943
isShowLoading && loading?.close(); // 关闭Loading遮罩层
4044

41-
if (code == 0) { // 业务成功 (后端定义的成功)
45+
if (code == 0) {
46+
// 业务成功 (后端定义的成功)
4247
// ElMessage.success("请求成功!");
43-
} else { // 业务失败 (后端定义的失败)
48+
} else {
49+
// 业务失败 (后端定义的失败)
4450
isShowFailToast && ElMessage.error(msg);
4551
if (isThrowError) throw new Error(`后端返回的错误信息-- ${msg}`); // 抛出错误, 阻止程序向下执行 (默认配置)
4652
}
4753

4854
return response;
4955
},
50-
(error: AxiosError) => { // HTTP 失败
56+
(error: AxiosError) => {
57+
// HTTP 失败
5158
const { response, config } = error;
5259
const { url, isShowLoading, isShowFailToast, isThrowError } = config as IRequestOption;
5360

@@ -56,16 +63,21 @@ axios.interceptors.response.use(
5663
let errMsg = ""; // 错误信息
5764
let stateMsg: "error" | "warning" = "error"; // 状态码
5865

59-
if (response) { // 请求成功发出且服务器也响应了状态码,但状态代码超出了 2xx 的范围
66+
if (response) {
67+
// 请求成功发出且服务器也响应了状态码,但状态代码超出了 2xx 的范围
6068
const { status, data } = response as AxiosResponse;
6169
errMsg = data.msg || `url:${(url || "").toString()},statusCode:${status}`;
6270

63-
if (status == 401) {// 跳转登录
71+
if (status == 401) {
72+
// 跳转登录
6473
stateMsg = "warning";
65-
clearLocal()
66-
setTimeout(() => { window.location.href = "/login" }, 2000);
74+
clearLocal();
75+
setTimeout(() => {
76+
window.location.href = "/login";
77+
}, 2000);
6778
}
68-
} else { // 请求已经成功发起,但没有收到响应
79+
} else {
80+
// 请求已经成功发起,但没有收到响应
6981
errMsg = "请求超时或服务器异常,请检查网络或联系管理员!";
7082
}
7183

@@ -111,7 +123,8 @@ export interface IRequestOption extends Partial<AxiosRequestConfig<IRequestData>
111123

112124
// 封装请求类
113125
class Http {
114-
defaultOptions: IRequestOption = { // 自定义配置项默认值
126+
defaultOptions: IRequestOption = {
127+
// 自定义配置项默认值
115128
isShowLoading: false,
116129
isShowFailToast: true,
117130
isThrowError: true,

frontend/src/views/Login.vue

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts">
2-
import { onMounted, reactive, ref } from "vue";
2+
import { reactive, ref } from "vue";
33
import { useRouter } from "vue-router";
4-
import { ElMessage, type FormInstance, type FormRules } from "element-plus";
4+
import type { FormInstance, FormRules } from "element-plus";
55
import { User, Lock } from "@element-plus/icons-vue";
66
import { userLogin, userSignUp } from "@/apis/index";
77
import { encryptContent } from "@/utils/encryption";
@@ -35,8 +35,14 @@ const submitForm = async (formEl: FormInstance | undefined, type: "login" | "sig
3535
let params = { name: userInfo.name, password: encryptContent(userInfo.password) };
3636
3737
let resp: any;
38-
type == "login" && ({ data: { data: resp } } = await userLogin(params));
39-
type == "signup" && ({ data: { data: resp } } = await userSignUp(params));
38+
type == "login" &&
39+
({
40+
data: { data: resp },
41+
} = await userLogin(params));
42+
type == "signup" &&
43+
({
44+
data: { data: resp },
45+
} = await userSignUp(params));
4046
userStore.user = resp;
4147
setLocal("userInfo", resp);
4248

frontend/src/views/pages/Dashboard.vue

+11-15
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,17 @@ const userInfo = computed(() => userStore.user);
1414
let echartDatas = {};
1515
1616
onMounted(async () => {
17-
// let pages = [1, 2, 3]
18-
// const [data1, data2, data3] = await Promise.all(pages.map((item) => {
19-
// return (async () => {
20-
// const { data } = await getLangList(item)
21-
// const obj = processData(data, getCommitDate(data[data.length - 1]), getCommitDate(data[0]));
22-
// return obj
23-
// })()
24-
// }))
25-
// echartDatas = { ...data3, ...data2, ...data1 }
26-
27-
// 模拟数据
28-
const {
29-
data: { data },
30-
} = await getLangList();
31-
echartDatas = data;
17+
let pages = [1, 2, 3];
18+
const [data1, data2, data3] = await Promise.all(
19+
pages.map((item) => {
20+
return (async () => {
21+
const { data } = await getLangList(item);
22+
const obj = processData(data, getCommitDate(data[data.length - 1]), getCommitDate(data[0]));
23+
return obj;
24+
})();
25+
})
26+
);
27+
echartDatas = { ...data3, ...data2, ...data1 };
3228
3329
// @ts-ignore
3430
chart = echarts.init(document.getElementById("line"));

frontend/src/views/pages/Log.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { getLogs } from "@/apis";
33
import { onMounted, ref } from "vue";
44
import MyTableV2 from "@/components/MyTableV2.vue";
5-
import { type Column } from "element-plus";
5+
import type { Column } from "element-plus";
66
77
const tableData = ref({
88
page: 1,

frontend/src/views/pages/system/Resource.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { getResources } from "@/apis";
33
import { computed, onMounted, ref } from "vue";
44
import MyTableV2 from "@/components/MyTableV2.vue";
5-
import { ExpandedRowsChangeHandler, RowExpandHandler, type Column } from "element-plus";
5+
import type { ExpandedRowsChangeHandler, RowExpandHandler, Column } from "element-plus";
66
import { arrayToTree } from "@/utils/handle_data";
77
88
/** 表格数据 */
@@ -26,7 +26,7 @@ const renderLevel = ({ cellData }: any) => {
2626
};
2727
2828
/** 渲染状态 */
29-
const renderSatus = ({ cellData }: any) => {
29+
const renderStatus = ({ cellData }: any) => {
3030
cellData = Boolean(1 - cellData);
3131
return <el-switch v-model={cellData} />;
3232
};
@@ -51,7 +51,7 @@ const columnOptions: Column[] = [
5151
title: "状态",
5252
align: "center",
5353
width: 120,
54-
cellRenderer: (record) => renderSatus(record),
54+
cellRenderer: (record) => renderStatus(record),
5555
},
5656
];
5757

frontend/src/views/pages/system/Role.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { getRoles } from "@/apis";
33
import { onMounted, ref } from "vue";
44
import MyTableV2 from "@/components/MyTableV2.vue";
5-
import { type Column } from "element-plus";
5+
import type { Column } from "element-plus";
66
77
const tableData = ref({
88
page: 1,
@@ -12,7 +12,7 @@ const tableData = ref({
1212
});
1313
1414
/** 渲染状态 */
15-
const renderSatus = ({ cellData }: any) => {
15+
const renderStatus = ({ cellData }: any) => {
1616
cellData = Boolean(1 - cellData);
1717
return <el-switch v-model={cellData} />;
1818
};
@@ -30,7 +30,7 @@ const columnOptions: Column[] = [
3030
title: "状态",
3131
align: "center",
3232
width: 120,
33-
cellRenderer: (record) => renderSatus(record),
33+
cellRenderer: (record) => renderStatus(record),
3434
},
3535
];
3636

0 commit comments

Comments
 (0)