40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import { type ComputedRef, ref } from 'vue'
|
|||
|
|
// import { get } from 'lodash'
|
||
|
|
import {defineStore} from "pinia";
|
||
|
|
import {getMe} from "@/api/me";
|
||
|
|
import {getFundTable} from "@/api/fund";
|
||
|
|
import type {Fund} from "@/models/fund";
|
||
|
|
import type {TableOutput} from "@/models/table";
|
||
|
|
import { getProductInventory } from '@/api/products'
|
||
|
|
export const useFundUserStore = defineStore('fund', () => {
|
||
|
|
const myFunds = ref<TableOutput<Fund> | undefined>(undefined)
|
||
|
|
async function getMyFund() {
|
||
|
|
try {
|
||
|
|
console.log('fff')
|
||
|
|
myFunds.value = await getProductInventory()
|
||
|
|
return myFunds.value
|
||
|
|
} catch (e) {
|
||
|
|
console.log(e)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/* const permissions: ComputedRef<string[]> = computed(() => {
|
||
|
|
const permissions: string[] = get(userInfo.value, 'permission', [])
|
||
|
|
const excludes: string[] = get(userInfo.value, 'exclude', [])
|
||
|
|
return permissions.filter((item) => !excludes.includes(item))
|
||
|
|
})*/
|
||
|
|
|
||
|
|
/*
|
||
|
|
function canAccess(permissionKey: string) {
|
||
|
|
if (isAdmin.value) return true
|
||
|
|
return permissions.value.includes(permissionKey)
|
||
|
|
}
|
||
|
|
*/
|
||
|
|
/*
|
||
|
|
const isAdmin = computed(() => {
|
||
|
|
return userInfo.value?.is_admin
|
||
|
|
})*/
|
||
|
|
|
||
|
|
return { getMyFund, myFunds/* permissions, canAccess, isAdmin*/ }
|
||
|
|
})
|