feat:first commit

This commit is contained in:
2024-08-16 14:04:26 +08:00
commit f276677d09
72 changed files with 33361 additions and 0 deletions

34
src/store/index.ts Normal file
View File

@@ -0,0 +1,34 @@
import Vuex from 'vuex'
import Vue from 'vue'
Vue.use(Vuex)
import UserStore from './modules/user'
const store = new Vuex.Store({
state: {
// 在此定义状态
navHeight: 0
},
getters: {
// 在此定义 getter 函数
getNavHeight(state: any) {
return state.navHeight
}
},
mutations: {
// 在此定义 mutation 函数
setNavHeight(state: any, height: number) {
state.navHeight = height
}
},
actions: {
// 在此定义 action 函数
SetNavHeight({ commit }: any, height: number) {
commit('setNavHeight', height)
}
},
modules: {
UserStore,
}
})
export default store

29
src/store/modules/user.js Normal file
View File

@@ -0,0 +1,29 @@
import { getUserInfo, setUserInfo } from '@/utils/util'
const prevUserInfo = getUserInfo()
export default {
namespaced: true,
state: {
userInfo: prevUserInfo || {},
registerInfo: {},
isLogin: !!prevUserInfo
},
getters: {
// 在此定义 getter 函数
getUserInfo(state) {
return state.userInfo
}
},
mutations: {
changeUserInfo(state, data) {
state.userInfo = data
state.isLogin = !!data
setUserInfo(state.userInfo)
}
},
actions: {
setUserInfo({ commit }, data) {
commit('changeUserInfo', data)
}
}
}