fix some bugs
This commit is contained in:
+18
-25
@@ -1,39 +1,32 @@
|
||||
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 { ref } from 'vue'
|
||||
import { defineStore } from 'pinia'
|
||||
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)
|
||||
const myPiggyFunds = ref<TableOutput<Fund> | undefined>(undefined)
|
||||
|
||||
async function getMyFund() {
|
||||
try {
|
||||
// console.log('fff')
|
||||
myFunds.value = await getFundTable()
|
||||
// داراییها — inventory؛ سازگار با صفحهٔ /fund
|
||||
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)
|
||||
async function getMyPiggyFunds() {
|
||||
try {
|
||||
myPiggyFunds.value = await getFundTable()
|
||||
return myPiggyFunds.value
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
*/
|
||||
/*
|
||||
const isAdmin = computed(() => {
|
||||
return userInfo.value?.is_admin
|
||||
})*/
|
||||
|
||||
return { getMyFund, myFunds/* permissions, canAccess, isAdmin*/ }
|
||||
return { getMyFund, getMyPiggyFunds, myFunds, myPiggyFunds }
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user