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

chore: update

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