diff --git a/package.json b/package.json index d519e1a..bc958bb 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,6 @@ }, "dependencies": { "@riophae/vue-treeselect": "^0.0.38", - "D": "^1.0.0", "animate.css": "^3.7.2", "axios": "^0.19.0", "core-js": "^2.6.5", diff --git a/src/myview/index.js b/src/myview/index.js index 23ba20c..6dc3164 100644 --- a/src/myview/index.js +++ b/src/myview/index.js @@ -2,7 +2,7 @@ import CopyRight from './components/CopyRight' import WhiteSpace from './components/WhiteSpace' import Label from './components/Label' import LabelGroup from './components/LabelGroup' -import Card from '..component/Card' +import Card from './components/Card' const components = { CopyRight, diff --git a/src/router/route.js b/src/router/route.js deleted file mode 100644 index e69de29..0000000 diff --git a/src/store/app.js b/src/store/app.js deleted file mode 100644 index 642e211..0000000 --- a/src/store/app.js +++ /dev/null @@ -1,67 +0,0 @@ -import Vue from 'vue' -import Vuex from 'vuex' - -Vue.use(Vuex) - -const state = { - currentPage: {}, - cachePages: [], - expandMisMenu: false, - loading: false -} - -const getters = { - getCurrentPage (state) { - return state.currentPage - }, - getCachePages (state) { - return state.cachePages - }, - getCachePagesKeys (state) { - // TODO 用于页面缓存 - }, - getExpandMisMenu (state) { - return state.expandMisMenu - }, - getLoading (state) { - return state.loading - } -} - -const mutations = { - changeExpandMisMenu (state) { - let { expandMisMenu } = { ...state } - state.expandMisMenu = !expandMisMenu - }, - loadingStart (state) { - state.loading = true - }, - loadingFinish (state) { - state.loading = false - } -} - -/** - * @description actions 当中包含异步操作 - * @type {{UPDATECACHEPAGES(*, *=): void}} - */ -const actions = { - CHANGEEXPANDMISMENU (context) { - context.commit('changeExpandMisMenu') - }, - LOADINGSTART (context) { - context.commit('loadingStart') - }, - LOADINGFINISHED (context) { - context.commit('loadingFinish') - } -} - -const appnew = { - state, - getters, - mutations, - actions -} - -export default appnew diff --git a/src/store/index.d.ts b/src/store/index.d.ts deleted file mode 100644 index 5d18f42..0000000 --- a/src/store/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import Vuex from 'vuex-class' -// FIXME 稍后使用typescript进行重构 -declare var store: any diff --git a/src/store/index.js b/src/store/index.ts similarity index 79% rename from src/store/index.js rename to src/store/index.ts index 54c3a02..db26676 100644 --- a/src/store/index.js +++ b/src/store/index.ts @@ -1,8 +1,8 @@ import Vue from 'vue' import Vuex from 'vuex' -import app from './app' -import user from './user' +import app from './newapp' +import user from './newuser' Vue.use(Vuex) diff --git a/src/store/newapp/index.ts b/src/store/newapp/index.ts new file mode 100644 index 0000000..d83411f --- /dev/null +++ b/src/store/newapp/index.ts @@ -0,0 +1,71 @@ +import { State } from './interface' +import { Menu } from '../newuser/interface' +import { Commit } from 'vuex' + +const state: State = { + currentPage: null, + cachePages: [], + expandMisMenu: false, + loading: false +} + +const getters = { + getCurrentPage: (state: State) => state.currentPage, + getCachePages: (state: State) => state.cachePages, + getCachePagesKeys: (state: State) => state.cachePages, + getExpandMisMenu: (state: State) => state.expandMisMenu, + getLoading: (state: State) => state.loading +} + +const mutations = { + updateCurrentPage: (state: State, menu: Menu) => { + state.currentPage = menu + }, + updateCachePages: (state: State, menu: Menu) => { + let isHave: Boolean = false + let { cachePages } = { ...state } + cachePages.forEach((item: Menu) => { + if (item.mid === menu.mid) { + isHave = true + } + }) + if (!isHave) { + state.cachePages.push(menu) + } + }, + changeExpandMisMenu: (state: State) => { + let { expandMisMenu } = { ...state } + state.expandMisMenu = !expandMisMenu + }, + loadingStart: (state: State) => { + state.loading = true + }, + loadingFinish: (state: State) => { + state.loading = false + } +} + +const actions = { + UPDATECURRENTPAGE: (context: { commit: Commit }, menu: Menu) => { + context.commit('updateCurrentPage', menu) + context.commit('updateCachePages', menu) + }, + CHANGEEXPANDMISMENU: (context: { commit: Commit }) => { + context.commit('changeExpandMisMenu') + }, + LOADINGSTART: (context: { commit: Commit }) => { + context.commit('loadingStart') + }, + LOADINGFINISHED: (context: { commit: Commit }) => { + context.commit('loadingFinish') + } +} + +const newapp = { + state, + getters, + mutations, + actions +} + +export default newapp diff --git a/src/store/newapp/interface.ts b/src/store/newapp/interface.ts new file mode 100644 index 0000000..f69c3bf --- /dev/null +++ b/src/store/newapp/interface.ts @@ -0,0 +1,8 @@ +import { Menu } from '../newuser/interface' + +export interface State { + currentPage: Menu | null, + cachePages: Array