-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
197 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,50 @@ | ||
import { Module } from 'vuex' | ||
import { Module } from 'vuex'; | ||
|
||
const actionTypes = {} | ||
const actionTypes = {}; | ||
|
||
const mutationTypes = { | ||
SET_COLLAPSEMENU: 'SET_COLLAPSEMENU', | ||
SET_SIDEBARMODE: 'SET_SIDEBARMODE', | ||
} | ||
SET_COLLAPSEMENU: 'SET_COLLAPSEMENU', | ||
SET_SIDEBARMODE: 'SET_SIDEBARMODE', | ||
}; | ||
|
||
interface StoreUser { | ||
collapseMenu: boolean | ||
sidebarMode: string | ||
layoute: object | ||
collapseMenu: boolean; | ||
sidebarMode: string; | ||
layoute: object; | ||
} | ||
|
||
const locstorCollapse = localStorage.getItem('appCollapseMenu') || 'false' | ||
const locMenu = JSON.parse(locstorCollapse) | ||
const locstorCollapse = localStorage.getItem('appCollapseMenu') || 'false'; | ||
const locMenu = JSON.parse(locstorCollapse); | ||
|
||
const locstorsSidebarMode = localStorage.getItem('appSidebarMode') || 'vertical' | ||
console.log(locstorsSidebarMode) | ||
const locstorsSidebarMode = localStorage.getItem('appSidebarMode') || 'vertical'; | ||
console.log(locstorsSidebarMode); | ||
|
||
const store: Module<StoreUser, unknown> = { | ||
namespaced: false, // 是否加上所属的模块名 | ||
state() { | ||
return { | ||
collapseMenu: locMenu || false, | ||
sidebarMode: locstorsSidebarMode, | ||
layoute: {}, | ||
} | ||
}, | ||
mutations: { | ||
[mutationTypes.SET_COLLAPSEMENU](state: StoreUser, payload: boolean) { | ||
state.collapseMenu = payload | ||
localStorage.setItem('appCollapseMenu', JSON.stringify(payload)) | ||
}, | ||
[mutationTypes.SET_SIDEBARMODE](state: StoreUser, payload: string) { | ||
state.sidebarMode = payload | ||
localStorage.setItem('appSidebarMode', payload) | ||
}, | ||
}, | ||
actions: {}, | ||
getters: { | ||
collapseMenu: (state) => state.collapseMenu, | ||
sidebarMode: (state) => state.sidebarMode, | ||
}, | ||
} | ||
|
||
export { actionTypes, mutationTypes } | ||
|
||
export default store | ||
namespaced: false, // 是否加上所属的模块名 | ||
state() { | ||
return { | ||
collapseMenu: locMenu || false, | ||
sidebarMode: locstorsSidebarMode, | ||
layoute: {}, | ||
}; | ||
}, | ||
mutations: { | ||
[mutationTypes.SET_COLLAPSEMENU](state: StoreUser, payload: boolean) { | ||
state.collapseMenu = payload; | ||
localStorage.setItem('appCollapseMenu', JSON.stringify(payload)); | ||
}, | ||
[mutationTypes.SET_SIDEBARMODE](state: StoreUser, payload: string) { | ||
state.sidebarMode = payload; | ||
localStorage.setItem('appSidebarMode', payload); | ||
}, | ||
}, | ||
actions: {}, | ||
getters: { | ||
collapseMenu: (state) => state.collapseMenu, | ||
sidebarMode: (state) => state.sidebarMode, | ||
}, | ||
}; | ||
|
||
export { actionTypes, mutationTypes }; | ||
|
||
export default store; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,39 @@ | ||
import { defineStore } from 'pinia'; | ||
import { store } from '@/store'; | ||
import { appConfig } from '#/piniaStore'; | ||
|
||
interface AppState { | ||
collapseMenu: boolean; | ||
sidebarMode: string; | ||
appConfigMode: appConfig; | ||
} | ||
|
||
let localAppConfig: appConfig = { | ||
collapseMenu: false, | ||
sidebarMode: 'vertical', | ||
themeMode: 'day', | ||
}; | ||
|
||
export const useAppStore = defineStore({ | ||
id: 'app', | ||
state: (): AppState => ({ | ||
collapseMenu: false, | ||
sidebarMode: 'vertical', | ||
appConfigMode: localAppConfig, | ||
}), | ||
getters: { | ||
getCollapseMenu(): boolean { | ||
return this.collapseMenu; | ||
}, | ||
getSidebarMode(): string { | ||
return this.sidebarMode; | ||
getAppConfigMode(): appConfig { | ||
return this.appConfigMode; | ||
}, | ||
}, | ||
actions: { | ||
setCollapseMenu(collapseMenu: boolean): void { | ||
this.collapseMenu = collapseMenu; | ||
}, | ||
setSidebarMode(sidebarMode: string): void { | ||
this.sidebarMode = sidebarMode; | ||
setAppConfigMode(appConfigMode: appConfig): void { | ||
localStorage.setItem('appConfigMode', JSON.stringify(appConfigMode)); | ||
this.appConfigMode = appConfigMode; | ||
}, | ||
}, | ||
}); | ||
|
||
export function useAppStoreHook() { | ||
return useAppStore(store); | ||
} | ||
|
||
export const setWindowAppConfig = (appConfig: appConfig) => { | ||
if (appConfig) localAppConfig = appConfig; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.