From 67ba035a95b4a91442f696e12cd6bf50efcfa0ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E5=A4=A7=E6=80=AA?= Date: Fri, 15 Mar 2024 11:50:35 +0800 Subject: [PATCH] fix:init --- mock/auth/user.mock.ts | 23 ++++-- mock/login.mock.ts | 2 + src/components/RoleSelect.vue | 2 +- src/layout/NavMenu.vue | 128 ++++++++++++++++++----------- src/layout/Navigator.vue | 79 +++++++++++------- src/router/index.ts | 53 ++++++------ src/stores/setting.ts | 14 ++++ src/stores/user.ts | 133 ++++++++++++++++--------------- src/views/system/user/Editor.vue | 8 +- src/views/system/user/index.vue | 6 +- 10 files changed, 270 insertions(+), 178 deletions(-) create mode 100644 src/stores/setting.ts diff --git a/mock/auth/user.mock.ts b/mock/auth/user.mock.ts index ca5f9b5..4747744 100644 --- a/mock/auth/user.mock.ts +++ b/mock/auth/user.mock.ts @@ -21,7 +21,8 @@ export default definePostMock([ method: "GET", body(request) { const id = request.params.id as number; - if (id && user.list[id - 1]) return user.list[id - 1]; + const index = user.list.findIndex((item) => item.id == id); + if (index) return user.list[index]; return { error_code: 400, msg: "author not found", @@ -40,7 +41,6 @@ export default definePostMock([ request.body.avatar = "https://picsum.photos/id/1/400/300"; request.body.created_at = Mock.Random.datetime(); request.body.updated_at = Mock.Random.datetime(); - console.log("添加"); user.list.unshift(request.body); return request.body; }, @@ -49,11 +49,10 @@ export default definePostMock([ url: "/system/user/:id", method: "PUT", body(request) { - // user.list[] - console.log("更新"); const id = request.params.id as number; - const result = find(user.list, { id }); - return result; + const index = user.list.findIndex((item) => item.id == id); + Object.assign(user.list[index], request.body); + return user.list[index]; }, }, { @@ -61,8 +60,16 @@ export default definePostMock([ method: "DELETE", body(request) { const id = request.params.id as number; - user.list.splice(id - 1, 1); - return user.list[id - 1]; + const index = user.list.findIndex((item) => item.id == id); + const deleteRueslt = user.list.splice(index, 1); + if (deleteRueslt) { + return { + error_code: 400, + msg: "author not found", + }; + } + const result = user.list[index]; + return result; }, }, ]); diff --git a/mock/login.mock.ts b/mock/login.mock.ts index 627c437..8b27e9f 100644 --- a/mock/login.mock.ts +++ b/mock/login.mock.ts @@ -551,6 +551,7 @@ const menu = [ icon: "mingcute:feeder-fill", }, ]; + export default definePostMock([ { url: "/login/userinfo", @@ -566,6 +567,7 @@ export default definePostMock([ response(req, res) { const { query = {}, body = { account: "", password: "" } } = req; res.setHeader("Content-Type", "application/json"); + console.log(body); if (body.account == "admin" && body.password == "123456") { res.statusCode = 200; res.end( diff --git a/src/components/RoleSelect.vue b/src/components/RoleSelect.vue index fac5543..672a4d8 100644 --- a/src/components/RoleSelect.vue +++ b/src/components/RoleSelect.vue @@ -5,7 +5,7 @@ import { onMounted, reactive } from "vue"; const model = defineModel(); withDefaults( defineProps<{ - multiple: boolean; + multiple?: boolean; }>(), { multiple: false } ); diff --git a/src/layout/NavMenu.vue b/src/layout/NavMenu.vue index 74d68f1..333c21e 100644 --- a/src/layout/NavMenu.vue +++ b/src/layout/NavMenu.vue @@ -1,64 +1,102 @@ \ No newline at end of file + diff --git a/src/layout/Navigator.vue b/src/layout/Navigator.vue index 59cf224..af2e4ba 100644 --- a/src/layout/Navigator.vue +++ b/src/layout/Navigator.vue @@ -3,31 +3,38 @@ import { Search, Fold } from "@element-plus/icons-vue"; import { Icon } from "@iconify/vue"; import { ref } from "vue"; import { useUserStore } from "@/stores/user"; +import { useSettingStore } from "@/stores/setting"; import { storeToRefs } from "pinia"; +const settingStore = useSettingStore(); const userStore = useUserStore(); const { userinfo } = storeToRefs(userStore); const keyword = ref(); -const TabsRef = ref(null) +const TabsRef = ref(null); const scrollLeft = () => { if (TabsRef.value != null) { - TabsRef.value.scrollLeft -= 80 + TabsRef.value.scrollLeft -= 80; } -} +}; const scrollRight = () => { if (TabsRef.value != null) { - TabsRef.value.scrollLeft += 80 + TabsRef.value.scrollLeft += 80; } -} +}; const handlerClick = (item) => { - item.badge = Math.random().toFixed(1) -} + item.badge = Math.random().toFixed(1); +};