新增管理员权限检查和模型选择逻辑优化

- 在用户 API 中新增 `checkIsSuperAdmin` 函数,用于检查用户是否为超级管理员。
- 更新模型选择器,非管理员用户只能选择内置模型并需配置 API Key,提升安全性和用户体验。
- 优化模型配置页面,动态显示操作按钮,确保管理员与普通用户的操作权限区分明确。
This commit is contained in:
2026-05-12 13:52:24 +08:00
parent 87b25dee42
commit 72af38ea00
5 changed files with 103 additions and 40 deletions

View File

@@ -41,12 +41,12 @@
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
<el-form-item label="访问类型" prop="isPrivate">
<el-radio-group v-model="state.ruleForm.isPrivate" @change="onIsPrivateChange">
<el-radio :label="0">私有</el-radio>
<el-radio :label="1">公共</el-radio>
<el-radio :label="0">本地模型</el-radio>
<el-radio :label="1">服务商模型</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col v-if="state.ruleForm.isPrivate === 1" :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
<el-col v-if="!props.isSuperAdmin && state.ruleForm.isPrivate === 1" :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
<el-form-item label="API 密钥" prop="apiKey">
<el-input v-model="state.ruleForm.apiKey" type="password" show-password placeholder="请输入 API 密钥字符串" clearable></el-input>
</el-form-item>
@@ -254,8 +254,12 @@ export type ModelTypeOption = { id: number | string; label: string };
const props = withDefaults(
defineProps<{
modelTypes?: ModelTypeOption[];
isSuperAdmin?: boolean;
}>(),
{ modelTypes: () => [] as ModelTypeOption[] }
{
modelTypes: () => [] as ModelTypeOption[],
isSuperAdmin: false,
}
);
const modelTypeOptions = computed(() => props.modelTypes);