iot-gateway_fontend/src/store/modules/auth/index.ts
2024-11-12 15:44:05 +08:00

55 lines
1.1 KiB
TypeScript

import { defineStore } from 'pinia';
import {
AuthCreateRecord,
AuthRecord,
create,
queryAuthList,
enabled,
remove,
update,
getDetail
} from '@/api/authority';
import { authStore } from './type';
const useAuthStore = defineStore('auth', {
state: (): authStore => ({
id: undefined,
remark: undefined,
// createTime: undefined,
name: undefined,
enabled: undefined,
}),
getters: {
AuthInfo(state: authStore): authStore {
return { ...state };
},
},
actions: {
// 获取所有的角色列表
async getAuthList(data: AuthRecord) {
return queryAuthList(data);
},
async enabledAuth(id: string) {
return enabled(id);
},
async removeAuth(id: string) {
return remove(id);
},
async createAuth(params: AuthCreateRecord) {
return create(params);
},
async updateAuth(params: AuthRecord) {
return update(params);
},
async getAuthDetail(id: string) {
return getDetail(id);
},
},
});
export default useAuthStore;