From 554bb14c36a19d6a891446d28c28f96e33e03dcc Mon Sep 17 00:00:00 2001 From: Kane Date: Thu, 2 Mar 2023 00:35:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5vuex=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/web/task_schedule/src/main.js | 4 +- code/web/task_schedule/src/store/index.js | 9 - code/web/task_schedule/src/store/index.ts | 19 + .../task_schedule/src/store/modules/app.ts | 24 + code/web/task_schedule/src/utils/api/url.ts | 11 +- code/web/task_schedule/src/views/Login.vue | 13 +- code/web/task_schedule/tsconfig.json | 41 + code/web/task_schedule/yarn.lock | 9318 ++++++++--------- 8 files changed, 4759 insertions(+), 4680 deletions(-) delete mode 100644 code/web/task_schedule/src/store/index.js create mode 100644 code/web/task_schedule/src/store/index.ts create mode 100644 code/web/task_schedule/src/store/modules/app.ts create mode 100644 code/web/task_schedule/tsconfig.json diff --git a/code/web/task_schedule/src/main.js b/code/web/task_schedule/src/main.js index 58646f2..ed2ef5a 100644 --- a/code/web/task_schedule/src/main.js +++ b/code/web/task_schedule/src/main.js @@ -2,7 +2,7 @@ * @Author: Kane * @Date: 2023-02-15 09:25:52 * @LastEditors: Kane - * @LastEditTime: 2023-02-28 19:14:16 + * @LastEditTime: 2023-03-01 23:17:06 * @FilePath: /task_schedule/src/main.js * @Description: * @@ -10,6 +10,7 @@ */ import { createApp } from 'vue'; import { router } from "./router/index.js"; +import store from "@/store/index"; import App from './App.vue'; @@ -32,4 +33,5 @@ for (const [key, component,] of Object.entries(ElementPlusIconsVue)) app.use(ElementPlus); app.use(router); +app.use(store); app.mount('#app'); diff --git a/code/web/task_schedule/src/store/index.js b/code/web/task_schedule/src/store/index.js deleted file mode 100644 index aaa94be..0000000 --- a/code/web/task_schedule/src/store/index.js +++ /dev/null @@ -1,9 +0,0 @@ -/* - * @Author: Kane - * @Date: 2023-03-01 18:23:32 - * @LastEditors: Kane - * @FilePath: /deskop_task_schedule/code/web/task_schedule/src/store/index.js - * @Description: vuex配置文件 - * - * Copyright (c) ${2022} by Kane, All Rights Reserved. - */ diff --git a/code/web/task_schedule/src/store/index.ts b/code/web/task_schedule/src/store/index.ts new file mode 100644 index 0000000..928a89d --- /dev/null +++ b/code/web/task_schedule/src/store/index.ts @@ -0,0 +1,19 @@ +/* + * @Author: Kane + * @Date: 2023-03-01 18:23:32 + * @LastEditors: Kane + * @FilePath: /task_schedule/src/store/index.ts + * @Description: vuex配置文件 + * + * Copyright (c) ${2022} by Kane, All Rights Reserved. + */ +import { createStore } from "vuex"; +import app from "./modules/app"; + +const store = createStore({ + modules: { + app, + }, +}); + +export default store; \ No newline at end of file diff --git a/code/web/task_schedule/src/store/modules/app.ts b/code/web/task_schedule/src/store/modules/app.ts new file mode 100644 index 0000000..46fd730 --- /dev/null +++ b/code/web/task_schedule/src/store/modules/app.ts @@ -0,0 +1,24 @@ +/* + * @Author: Kane + * @Date: 2023-03-01 23:03:02 + * @LastEditors: Kane + * @FilePath: /task_schedule/src/store/modules/app.ts + * @Description: + * + * Copyright (c) ${2022} by Kane, All Rights Reserved. + */ +const state = { + staffInfo: null, +}; + +const getters = {}; +const mutations = {}; +const actions = {}; + +export default { + namespaced: true, + state, + getters, + mutations, + actions, +}; \ No newline at end of file diff --git a/code/web/task_schedule/src/utils/api/url.ts b/code/web/task_schedule/src/utils/api/url.ts index 88b2d89..2e8be7e 100644 --- a/code/web/task_schedule/src/utils/api/url.ts +++ b/code/web/task_schedule/src/utils/api/url.ts @@ -2,12 +2,14 @@ * @Author: Kane * @Date: 2023-02-28 19:30:40 * @LastEditors: Kane - * @FilePath: /deskop_task_schedule/code/web/task_schedule/src/utils/api/url.ts + * @FilePath: /task_schedule/src/utils/api/url.ts * @Description: 对URL的操作 * * Copyright (c) ${2022} by Kane, All Rights Reserved. */ +type stringkey = Record; + /** * 将url的参数拆分成对象 * @param url 访问的url @@ -17,7 +19,7 @@ function getURLParams(url: string) { const arr = url.split("?"); const params = arr[1].split("&"); - const obj = {}; + const obj: stringkey = {}; for (let i = 0; i < params.length; i++) { @@ -34,11 +36,12 @@ function getURLParams(url: string) * @param url url字符串 * @returns 返回包含url中参数作为key,值作为value的对象。 */ -function getParamsFromURL(url: string): any +function getParamsFromURL(url: string): stringkey { + const indexOfQuestionMark: number = url.indexOf("?"); const indexOfSharp: number = url.indexOf("#"); - const paramObj = {}; + const paramObj: stringkey = {}; let paramString; //url中没有问号,说明没有参数 diff --git a/code/web/task_schedule/src/views/Login.vue b/code/web/task_schedule/src/views/Login.vue index 7b67127..a2c61cb 100644 --- a/code/web/task_schedule/src/views/Login.vue +++ b/code/web/task_schedule/src/views/Login.vue @@ -2,7 +2,7 @@ * @Author: Kane * @Date: 2023-02-28 00:57:21 * @LastEditors: Kane - * @FilePath: /deskop_task_schedule/code/web/task_schedule/src/views/Login.vue + * @FilePath: /task_schedule/src/views/Login.vue * @Description: * 登录页面,路由默认指向这个页面 * 1、判断url中的参数,取得用户信息,根据用户的部门改变路由 @@ -12,6 +12,7 @@ @@ -31,14 +32,12 @@ export default { p13uid: "", savedP13uid: "", showNeedAccountTip: false, + showAccountErrorTip: false, }); //根据url获取用户账号 const urlParams = getParamsFromURL(window.location.href); - console.log(window.location.href); - console.log(urlParams); - if (urlParams.account != undefined) { //根据账号查询员工信息 @@ -56,9 +55,9 @@ export default {