apply license

This commit is contained in:
2025-11-03 13:52:55 +08:00
parent 9e57d52769
commit d411c24df6
23 changed files with 1116 additions and 59 deletions

51
src/utils/permissions.ts Normal file
View File

@@ -0,0 +1,51 @@
// 权限检查工具类
import type { PermissionConfig } from '@/types/license';
import client from '@/plugins/kintoneClient.ts'
export class PermissionService {
/**
* 检查用户是否有管理插件的权限
* 基于kintone的权限系统判断用户是否可以管理应用插件
*/
static async checkPermissions(): Promise<PermissionConfig> {
try {
// 获取应用信息
const appId = kintone.app.getId() || kintone.mobile.app.getId();
if (!appId) {
return this.getDefaultPermissions();
}
// 检查应用的管理权限
const hasAdminRights = await this.checkAppAdminRights(appId);
return {
canManagePlugins: hasAdminRights,
};
} catch (error) {
console.error('Failed to check permissions:', error);
return this.getDefaultPermissions();
}
}
/**
* 检查应用管理员权限
*/
private static async checkAppAdminRights(appId: number): Promise<boolean> {
try {
await client.app.getAppAcl({ app: appId });
return true;
} catch (error) {
// 如果API调用失败默认认为没有权限
return false;
}
}
/**
* 获取默认权限配置(无权限)
*/
private static getDefaultPermissions(): PermissionConfig {
return {
canManagePlugins: false,
};
}
}