解决报错
This commit is contained in:
parent
44274cff5c
commit
248958fba8
|
@ -12,7 +12,7 @@ const app = createApp(App)
|
||||||
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
||||||
app.component(key, component)
|
app.component(key, component)
|
||||||
}
|
}
|
||||||
//
|
|
||||||
app.use(ElementPlus, {size: 'small'})
|
app.use(ElementPlus, {size: 'small'})
|
||||||
//配置路由
|
//配置路由
|
||||||
app.use(router)
|
app.use(router)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import { myAxios } from '../api/myAxios'
|
import myAxios from '../api/myAxios'
|
||||||
|
|
||||||
export const userStore = defineStore( 'user' , {
|
export const userStore = defineStore( 'user' , {
|
||||||
//state是应用的核心数据,通常用于管理用户信息、应用设置、数据列表等。
|
//state是应用的核心数据,通常用于管理用户信息、应用设置、数据列表等。
|
||||||
|
@ -17,14 +17,15 @@ export const userStore = defineStore( 'user' , {
|
||||||
//获取登录用户信息
|
//获取登录用户信息
|
||||||
async getLoginUser() {
|
async getLoginUser() {
|
||||||
//请求登录信息
|
//请求登录信息
|
||||||
const res = await myAxios.get('接口接口接口')
|
const res = await myAxios.get('/user/get')
|
||||||
|
// console.log(res.data)
|
||||||
if( res.data.code === 1 && res ?.data ) {
|
if( res.data.code === 1 && res ?.data ) {
|
||||||
this.updateUser( res.data )
|
this.updateUser( res.data )
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
//更新用户信息
|
//更新用户信息
|
||||||
//更新state
|
//更新state
|
||||||
updateUser(payLoad) {
|
updateUser(payLoad : any) {
|
||||||
this.loginUser = payLoad
|
this.loginUser = payLoad
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -41,7 +41,7 @@
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import {useRouter} from 'vue-router'
|
import {useRouter} from 'vue-router'
|
||||||
import myAxios from '@/api/myAxios';
|
import myAxios from '@/api/myAxios';
|
||||||
import { userStore } from '@/store/userStore';
|
import { userStore } from '../store/userStore';
|
||||||
|
|
||||||
const user = ref({})
|
const user = ref({})
|
||||||
const username = ref('')
|
const username = ref('')
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
userAccount: username.value,
|
userAccount: username.value,
|
||||||
userPassword: password.value
|
userPassword: password.value
|
||||||
})
|
})
|
||||||
console.log(res.data.code)
|
// console.log(res.data.code)
|
||||||
if(res.data.code === 1 && res ?.data) {
|
if(res.data.code === 1 && res ?.data) {
|
||||||
//将用户信息放入pinia
|
//将用户信息放入pinia
|
||||||
await store.getLoginUser()
|
await store.getLoginUser()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user