mirror of
https://github.com/cool-team-official/cool-admin-vue.git
synced 2025-12-16 16:42:50 +00:00
42 lines
969 B
TypeScript
42 lines
969 B
TypeScript
import BaseService from "./service/base";
|
|
import { Service, Permission, useService } from "./service";
|
|
import { useRouter } from "./router";
|
|
import { useModule } from "./module";
|
|
import router from "/@/router";
|
|
import store from "/@/store";
|
|
|
|
const services = useService();
|
|
|
|
async function bootstrap(app: any) {
|
|
app.config.globalProperties.service = store.service = services;
|
|
app.provide("service", services);
|
|
|
|
useRouter();
|
|
useModule(app);
|
|
|
|
router.$plugin?.addViews(store.getters.routes || []);
|
|
}
|
|
|
|
function usePermission(list: any[]) {
|
|
function deep(d: any) {
|
|
if (d.permission) {
|
|
d._permission = {};
|
|
for (const i in d.permission) {
|
|
d._permission[i] =
|
|
list.findIndex((e: string) =>
|
|
e.replace(/:/g, "/").includes(`${d.namespace}/${i}`)
|
|
) >= 0;
|
|
}
|
|
} else {
|
|
for (const i in d) {
|
|
deep(d[i]);
|
|
}
|
|
}
|
|
}
|
|
|
|
deep(services);
|
|
}
|
|
|
|
export { Service, Permission, BaseService, services, bootstrap, usePermission };
|
|
export * from "./hook";
|