提交 ac3e8616 authored 作者: 王鹏飞's avatar 王鹏飞

chore: update

上级 94320ddb
...@@ -2,7 +2,7 @@ import type { Router } from 'vue-router' ...@@ -2,7 +2,7 @@ import type { Router } from 'vue-router'
import type { AppModule } from '@/types' import type { AppModule } from '@/types'
export default function ({ router }: { router: Router }) { export default function ({ router }: { router: Router }) {
const modules: Array<AppModule> = Object.values(import.meta.globEager('./**/index.ts')) const modules: Array<AppModule> = Object.values(import.meta.glob('./**/index.ts', { eager: true }))
modules.forEach(({ routes = [] }) => { modules.forEach(({ routes = [] }) => {
// 注册路由 // 注册路由
routes.forEach(route => { routes.forEach(route => {
......
...@@ -20,13 +20,13 @@ export const useShopStore = defineStore({ ...@@ -20,13 +20,13 @@ export const useShopStore = defineStore({
list: (window as any).SHOP.SHOP_LIST // 商品列表 list: (window as any).SHOP.SHOP_LIST // 商品列表
}), }),
getters: { getters: {
shopList({ list }): ShopListItem[] { shopList({ list }) {
return list.map(item => { return list.map(item => {
item.isBuy = !!courses.find((course: any) => course.course_id === item.course_id) item.isBuy = !!courses.find((course: any) => course.course_id === item.course_id)
return item return item
}) })
}, },
shopItem() { shopItem(): ShopListItem | undefined {
const route = useRoute() const route = useRoute()
const found = this.shopList.find(item => item.id === route.params.id) const found = this.shopList.find(item => item.id === route.params.id)
if (found) { if (found) {
......
...@@ -2,7 +2,6 @@ import { defineStore } from 'pinia' ...@@ -2,7 +2,6 @@ import { defineStore } from 'pinia'
import { getUser, logout, getBuyShop } from '@/api/base' import { getUser, logout, getBuyShop } from '@/api/base'
import type { UserState } from '@/types' import type { UserState } from '@/types'
interface State { interface State {
user: UserState | null user: UserState | null
courses: any courses: any
...@@ -27,8 +26,10 @@ export const useUserStore = defineStore({ ...@@ -27,8 +26,10 @@ export const useUserStore = defineStore({
actions: { actions: {
async getUser() { async getUser() {
const res = await getUser() const res = await getUser()
if (res.code === 0) { try {
this.courses = await getBuyShop() this.courses = await getBuyShop()
} catch (error) {
console.log(error)
} }
this.user = res.data this.user = res.data
}, },
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论