From 5b9c14184e42d6f0a1c1b1e0a2b3a8a40b1a95c3 Mon Sep 17 00:00:00 2001 From: luoer Date: Thu, 26 Oct 2023 17:48:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 2 +- src/api/service/Api.ts | 116 ++++++++------- src/components/table/colume.tsx | 4 +- src/components/table/table.tsx | 3 + src/components/table/use-table.tsx | 21 +-- src/pages/_login/index.vue | 4 +- src/pages/post/media/components/group.vue | 2 +- src/pages/post/media/components/upload.vue | 5 +- src/pages/post/media/index.vue | 11 +- src/pages/system/dict/components/group.vue | 135 ++++++++++++++++++ src/pages/system/dict/index.vue | 70 +++++++++ src/pages/system/login-log/index.vue | 39 ++++- src/pages/system/menu/index.vue | 132 ++++++++++------- src/pages/system/role/index.vue | 4 +- .../system/user/{ => components}/avatar.vue | 6 +- .../system/user/{ => components}/password.tsx | 3 +- src/pages/system/user/index.vue | 7 +- src/store/user/index.ts | 13 +- src/styles/css-unocss.less | 2 +- 19 files changed, 435 insertions(+), 144 deletions(-) create mode 100644 src/pages/system/dict/components/group.vue create mode 100644 src/pages/system/dict/index.vue rename src/pages/system/user/{ => components}/avatar.vue (88%) rename src/pages/system/user/{ => components}/password.tsx (83%) diff --git a/.env b/.env index f84a78f..8de803f 100644 --- a/.env +++ b/.env @@ -2,7 +2,7 @@ # 应用配置 # ===================================================================================== # 网站标题 -VITE_TITLE = 绝弹管理后台 +VITE_TITLE = 绝弹项目管理 # 网站副标题 VITE_SUBTITLE = 快速开发web应用的模板工具 # 接口前缀 说明:参见 axios 的 baseURL diff --git a/src/api/service/Api.ts b/src/api/service/Api.ts index adf7b64..9a4ef07 100644 --- a/src/api/service/Api.ts +++ b/src/api/service/Api.ts @@ -166,43 +166,6 @@ export interface AuthUserDto { password: string; } -export interface LoginedUserVo { - /** 用户ID */ - id: number; - /** - * 访问令牌 - * @example "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MjIsInVzZXJuYW1lIjoianVldGFuIiwiaWF0IjoxNjkxMTM5MjI3LCJleHAiOjE2OTExOTkyMjd9.6z7f-xfsHABbsyg401o2boKeqNQ1epPDYfEdavIcfYc" - */ - token: string; - /** - * 登录账号 - * @example "juetan" - */ - username: string; - /** - * 用户昵称 - * @example "绝弹" - */ - nickname: string; - /** - * 用户介绍 - * @example "这个人很懒, 什么也没有留下!" - */ - description: string; - /** - * 用户头像 - * @example "/upload/assets/222421415123.png " - */ - avatar: string; - /** - * 用户邮箱 - * @example "example@mail.com" - */ - email: string; - /** 用户角色ID */ - roleIds: number[]; -} - export interface CreateLogDto { /** * 字段描述(Swagger用途) @@ -545,7 +508,6 @@ export interface Menu { } export interface UpdateMenuDto { - id: number; /** * 父级ID * @example 0 @@ -950,7 +912,7 @@ export namespace Role { }; } /** - * @description 批量查询角色 + * @description 分页查询角色 * @tags role * @name GetRoles * @request GET:/api/v1/roles @@ -1037,7 +999,7 @@ export namespace Role { export namespace Auth { /** - * @description 账号登陆 + * @description 登陆 * @tags auth * @name Login * @request POST:/api/v1/auth/login @@ -1059,7 +1021,33 @@ export namespace Auth { * @example "请求成功" */ message: string; - data?: LoginedUserVo; + data?: string; + }; + } + /** + * @description 获取登陆用户信息 + * @tags auth + * @name GetUserInfo + * @request POST:/api/v1/auth/info + */ + export namespace GetUserInfo { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = { + /** + * 状态码 + * @format int32 + * @example 2000 + */ + code: number; + /** + * 提示信息 + * @example "请求成功" + */ + message: string; + data?: User; }; } } @@ -1889,7 +1877,7 @@ export namespace Menu { */ export namespace GetMenu { export type RequestParams = { - id: string; + id: number; }; export type RequestQuery = {}; export type RequestBody = never; @@ -1917,7 +1905,7 @@ export namespace Menu { */ export namespace SetMenu { export type RequestParams = { - id: string; + id: number; }; export type RequestQuery = {}; export type RequestBody = UpdateMenuDto; @@ -2250,7 +2238,7 @@ export class Api extends HttpClient extends HttpClient extends HttpClient({ @@ -2381,6 +2369,38 @@ export class Api extends HttpClient { + return this.request< + { + /** + * 状态码 + * @format int32 + * @example 2000 + */ + code: number; + /** + * 提示信息 + * @example "请求成功" + */ + message: string; + data?: User; + }, + any + >({ + path: `/api/v1/auth/info`, + method: "POST", + format: "json", + ...params, + }); + }, }; log = { /** @@ -3188,7 +3208,7 @@ export class Api extends HttpClient { + getMenu: (id: number, params: RequestParams = {}) => { return this.request< { /** @@ -3220,7 +3240,7 @@ export class Api extends HttpClient { + setMenu: (id: number, data: UpdateMenuDto, params: RequestParams = {}) => { return this.request({ path: `/api/v1/menus/${id}`, method: "PATCH", diff --git a/src/components/table/colume.tsx b/src/components/table/colume.tsx index c9acda4..535009e 100644 --- a/src/components/table/colume.tsx +++ b/src/components/table/colume.tsx @@ -8,7 +8,7 @@ const defineColumn = (column: T) => { export const updateColumn = defineColumn({ title: "更新者", dataIndex: "createdAt", - width: 200, + width: 190, render({ record }) { return (
@@ -24,7 +24,7 @@ export const updateColumn = defineColumn({ export const createColumn = defineColumn({ title: "创建者", dataIndex: "createdAt", - width: 200, + width: 190, render({ record }) { return (
diff --git a/src/components/table/table.tsx b/src/components/table/table.tsx index 91b85e2..357e03c 100644 --- a/src/components/table/table.tsx +++ b/src/components/table/table.tsx @@ -72,6 +72,7 @@ export const Table = defineComponent({ }, setup(props) { const loading = ref(false); + const tableRef = ref>() const searchRef = ref(); const createRef = ref(); const modifyRef = ref(); @@ -142,6 +143,7 @@ export const Table = defineComponent({ const state = { loading, inlined, + tableRef, searchRef, createRef, modifyRef, @@ -184,6 +186,7 @@ export const Table = defineComponent({
UseTableOptions)) buttons.push(merge({}, config.columnButtonBase)); } column.render = (columnData) => { - return column.buttons?.map((btn) => { + return column.buttons?.map((btn, index) => { if (btn.visible?.(columnData) === false) { return null; } return ( - onClick(btn, columnData, getTable)} - disabled={btn.disabled?.(columnData)} - > - {btn.text} - + <> + {index !== 0 ? : null} + onClick(btn, columnData, getTable)} + disabled={btn.disabled?.(columnData)} + > + {btn.text} + + ); }); }; diff --git a/src/pages/_login/index.vue b/src/pages/_login/index.vue index d97c3d7..1e2cf38 100644 --- a/src/pages/_login/index.vue +++ b/src/pages/_login/index.vue @@ -101,10 +101,10 @@ const onSubmitForm = async () => { try { loading.value = true; const res = await api.auth.login(model); - userStore.setUser(res.data.data); + userStore.setAccessToken(res.data.data as unknown as string); Notification.success({ title: "提示", - content: `欢迎回来,${res.data.data.nickname}!`, + content: `登陆成功!`, }); router.push({ path: (route.query.redirect as string) || "/" }); } catch (error: any) { diff --git a/src/pages/post/media/components/group.vue b/src/pages/post/media/components/group.vue index e735523..4c258b9 100644 --- a/src/pages/post/media/components/group.vue +++ b/src/pages/post/media/components/group.vue @@ -17,7 +17,7 @@ class="group flex items-center justify-between gap-1 h-8 rounded mb-2 pl-3 hover:bg-gray-100 cursor-pointer" >
- + {{ item.title }} ({{ item.count }})
diff --git a/src/pages/post/media/components/upload.vue b/src/pages/post/media/components/upload.vue index 27fb7a1..a872528 100644 --- a/src/pages/post/media/components/upload.vue +++ b/src/pages/post/media/components/upload.vue @@ -1,5 +1,8 @@ diff --git a/src/pages/post/media/index.vue b/src/pages/post/media/index.vue index de95416..9b21899 100644 --- a/src/pages/post/media/index.vue +++ b/src/pages/post/media/index.vue @@ -22,7 +22,7 @@ + + diff --git a/src/pages/system/dict/index.vue b/src/pages/system/dict/index.vue new file mode 100644 index 0000000..daecd76 --- /dev/null +++ b/src/pages/system/dict/index.vue @@ -0,0 +1,70 @@ + + + + + + + +{ + "meta": { + "sort": 20010, + "title": "字典管理", + "icon": "icon-park-outline-spanner" + } +} + diff --git a/src/pages/system/login-log/index.vue b/src/pages/system/login-log/index.vue index b9fd0df..6ec22b7 100644 --- a/src/pages/system/login-log/index.vue +++ b/src/pages/system/login-log/index.vue @@ -57,21 +57,46 @@ const table = useTable({ ); }, }, + { + title: "登陆地址", + dataIndex: "ip", + width: 200, + render({ record }) { + return ( +
+ {record.addr || "未知"} + {record.ip} +
+ ); + }, + }, { title: "操作系统", dataIndex: "os", - width: 160, + width: 200, + render({ record }) { + const [os, version] = record.os.split(" "); + return ( +
+ {os || "未知"} + {version} +
+ ); + }, }, { title: "浏览器", dataIndex: "browser", - width: 160, - }, - { - title: "登陆地址", - dataIndex: "ip", width: 200, - render: ({ record }) => `${record.addr || "未知"}(${record.ip})`, + render({ record }) { + const [browser, version] = record.browser.split(" "); + return ( +
+ {browser || "未知"} + v{version} +
+ ); + }, }, ], search: { diff --git a/src/pages/system/menu/index.vue b/src/pages/system/menu/index.vue index db6bffb..faf615c 100644 --- a/src/pages/system/menu/index.vue +++ b/src/pages/system/menu/index.vue @@ -1,69 +1,93 @@ - + { "meta": { - "sort": 10201, + "sort": 10302, "title": "菜单管理", "icon": "icon-park-outline-add-subtract" } diff --git a/src/pages/system/role/index.vue b/src/pages/system/role/index.vue index 43a639d..848ec93 100644 --- a/src/pages/system/role/index.vue +++ b/src/pages/system/role/index.vue @@ -35,7 +35,7 @@ const [roleTable, roleCtx] = useAniTable({ { title: "操作", type: "button", - width: 184, + width: 200, buttons: [ { type: "modify", @@ -74,7 +74,7 @@ const [roleTable, roleCtx] = useAniTable({ create: { title: "新建角色", modalProps: { - width: 580, + width: 1080, maskClosable: false, }, formProps: { diff --git a/src/pages/system/user/avatar.vue b/src/pages/system/user/components/avatar.vue similarity index 88% rename from src/pages/system/user/avatar.vue rename to src/pages/system/user/components/avatar.vue index 8fd6247..d5d436e 100644 --- a/src/pages/system/user/avatar.vue +++ b/src/pages/system/user/components/avatar.vue @@ -14,10 +14,12 @@ @progress="onProgress" > -
请选择不超过5MB,.png, .jpg, .webp格式的图片
+
请选择大小不超过5MB,.png, .jpg, .webp格式的图片
diff --git a/src/pages/system/user/password.tsx b/src/pages/system/user/components/password.tsx similarity index 83% rename from src/pages/system/user/password.tsx rename to src/pages/system/user/components/password.tsx index df72177..e54c677 100644 --- a/src/pages/system/user/password.tsx +++ b/src/pages/system/user/components/password.tsx @@ -17,8 +17,7 @@ export const usePassworModal = () => { field: "password", label: ({ model }) => ( - 设置 {model.nickname} - 的新密码 + {model.nickname} 的新密码: ), type: "input", diff --git a/src/pages/system/user/index.vue b/src/pages/system/user/index.vue index 7a52b59..9317aa1 100644 --- a/src/pages/system/user/index.vue +++ b/src/pages/system/user/index.vue @@ -8,9 +8,8 @@