perf: 支持授权给管理员查看和下载用户证书

This commit is contained in:
xiaojunnuo
2025-12-28 23:36:53 +08:00
parent f847c4a414
commit 1347355cb1
12 changed files with 213 additions and 13 deletions
+2 -2
View File
@@ -71,7 +71,7 @@ function createService() {
// @ts-ignore
response.config.onError(err);
}
errorCreate(`${errorMessage}: ${response.config.url}`, showErrorNotify, dataAxios);
errorCreate(`${errorMessage} (请求接口: ${response.config.url}`, showErrorNotify, dataAxios);
}
},
error => {
@@ -113,7 +113,7 @@ function createService() {
default:
break;
}
error.message += `: ${error.response?.config?.url}`;
error.message += ` 请求接口:${error.response?.config?.url}`;
errorLog(error, error?.response?.config?.showErrorNotify);
if (status === 401) {
const userStore = useUserStore();
@@ -52,6 +52,7 @@ export default {
siteMonitorSetting: "Site Monitor Settings",
userSecurity: "Security Settings",
userProfile: "Account Info",
userGrant: "Grant Delegation",
suite: "Suite",
mySuite: "My Suite",
suiteBuy: "Suite Purchase",
@@ -62,6 +63,12 @@ export default {
greeting: "Hello",
profile: "Account Info",
logout: "Logout",
setting: {
grantSetting: "Grant Settings",
saveSuccess: "Save Success",
allowAdminViewCerts: "Allow Admin view and download Certs",
allowAdminViewCertsHelper: "Allow admin view and download all certificates",
},
},
dashboard: {
greeting: "Hello, {name}, welcome to 【{site}】",
@@ -57,6 +57,7 @@ export default {
siteMonitorSetting: "站点监控设置",
userSecurity: "认证安全设置",
userProfile: "账号信息",
userGrant: "授权委托",
suite: "套餐",
mySuite: "我的套餐",
suiteBuy: "套餐购买",
@@ -68,6 +69,13 @@ export default {
greeting: "您好",
profile: "账号信息",
logout: "注销登录",
setting: {
grantSetting: "授权委托设置",
saveSuccess: "保存成功",
allowAdminViewCerts: "授权管理员查看和下载证书",
allowAdminViewCertsHelper: "允许管理员查看和下载我的所有证书",
},
},
dashboard: {
greeting: "您好,{name},欢迎使用 【{site}】",
@@ -204,6 +204,17 @@ export const certdResources = [
isMenu: true,
},
},
{
title: "certd.userGrant",
name: "UserGrantSetting",
path: "/certd/mine/grant",
component: "/certd/mine/grant/index.vue",
meta: {
icon: "mi:user-check",
auth: true,
isMenu: true,
},
},
{
title: "certd.userProfile",
name: "UserProfile",
@@ -1,6 +1,6 @@
<template>
<a-button v-if="showButton" type="primary" @click="open">
{{ $t("authentication.changePasswordButton") }}
{{ t("authentication.changePasswordButton") }}
</a-button>
</template>
@@ -0,0 +1,25 @@
// @ts-ignore
import { request } from "/@/api/service";
const apiPrefix = "/user/settings";
export type UserGrantSetting = {
allowAdminViewCerts: boolean;
};
export async function GrantSettingsGet() {
const res = await request({
url: apiPrefix + "/grant/get",
method: "post",
});
if (!res) {
return {};
}
return res as UserGrantSetting;
}
export async function UserSettingSave(req: any) {
return await request({
url: apiPrefix + "/grant/save",
method: "post",
data: req,
});
}
@@ -0,0 +1,67 @@
<template>
<fs-page class="page-user-settings page-grant">
<template #header>
<div class="title">{{ t("certd.user.setting.grantSetting") }}</div>
</template>
<div class="user-settings-form settings-form">
<a-form :model="formState" name="basic" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off">
<a-form-item :label="t('certd.user.setting.allowAdminViewCerts')" :name="['allowAdminViewCerts']">
<div class="flex mt-5">
<a-switch v-model:checked="formState.allowAdminViewCerts" :disabled="!settingsStore.isPlus" />
<vip-button class="ml-5" mode="button"></vip-button>
</div>
<div class="helper">{{ t("certd.user.setting.allowAdminViewCertsHelper") }}</div>
</a-form-item>
<a-form-item label=" " :colon="false" :wrapper-col="{ span: 16 }">
<loading-button type="primary" html-type="button" :click="doSave">{{ t("certd.confirm") }}</loading-button>
</a-form-item>
</a-form>
</div>
</fs-page>
</template>
<script setup lang="tsx">
import { computed, reactive, watch } from "vue";
import * as api from "./api";
import { UserGrantSetting } from "./api";
import { Modal, notification } from "ant-design-vue";
import { merge } from "lodash-es";
import { useSettingStore } from "/@/store/settings";
import { useI18n } from "/src/locales";
const { t } = useI18n();
const settingsStore = useSettingStore();
defineOptions({
name: "UserSecurity",
});
const formState = reactive<Partial<UserGrantSetting>>({
allowAdminViewCerts: false,
});
async function loadUserSettings() {
const data: any = await api.GrantSettingsGet();
merge(formState, data);
}
loadUserSettings();
const doSave = async () => {
await api.UserSettingSave({
...formState,
});
notification.success({
message: t("certd.user.setting.saveSuccess"),
});
};
</script>
<style lang="less">
.page-user-settings {
.user-settings-form {
width: 600px;
margin: 20px;
}
}
</style>