From 9ad82d53696221c6a1c1557ec1d93e4c144e90c8 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Tue, 9 Jul 2024 14:48:08 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E7=B3=BB=E7=BB=9FAPI?= =?UTF-8?q?=5FKeys?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --story=1015434 --user=王孝刚 【X-pack】系统API Key管理及接口文档 https://www.tapd.cn/57709429/s/1545690 --- ui/src/api/system-api-key.ts | 58 ++++++ .../top-bar/avatar/APIKeyDialog.vue | 185 ++++++++++++++++++ .../top-bar/avatar/SettingAPIKeyDialog.vue | 98 ++++++++++ .../components/top-bar/avatar/index.vue | 9 + ui/src/locales/lang/en_US/layout.ts | 30 ++- ui/src/locales/lang/zh_CN/layout.ts | 2 + 6 files changed, 366 insertions(+), 16 deletions(-) create mode 100644 ui/src/api/system-api-key.ts create mode 100644 ui/src/layout/components/top-bar/avatar/APIKeyDialog.vue create mode 100644 ui/src/layout/components/top-bar/avatar/SettingAPIKeyDialog.vue diff --git a/ui/src/api/system-api-key.ts b/ui/src/api/system-api-key.ts new file mode 100644 index 000000000..9d66bc7cb --- /dev/null +++ b/ui/src/api/system-api-key.ts @@ -0,0 +1,58 @@ +import {Result} from '@/request/Result' +import {get, post, del, put} from '@/request/index' + +import {type Ref} from 'vue' + +const prefix = '/system/api_key' + +/** + * API_KEY列表 + */ +const getAPIKey: (loading?: Ref) => Promise> = () => { + return get(`${prefix}/`) +} + +/** + * 新增API_KEY + */ +const postAPIKey: (loading?: Ref) => Promise> = ( + loading +) => { + return post(`${prefix}/`, {}, undefined, loading) +} + +/** + * 删除API_KEY + * @param 参数 application_id api_key_id + */ +const delAPIKey: ( + api_key_id: String, + loading?: Ref +) => Promise> = (api_key_id, loading) => { + return del(`${prefix}/${api_key_id}/`, undefined, undefined, loading) +} + +/** + * 修改API_KEY + * data { + * is_active: boolean + * } + * @param api_key_id + * @param data + * @param loading + */ +const putAPIKey: ( + api_key_id: String, + data: any, + loading?: Ref +) => Promise> = (api_key_id, data, loading) => { + return put(`${prefix}/${api_key_id}/`, data, undefined, loading) +} + + +export default { + getAPIKey, + postAPIKey, + delAPIKey, + putAPIKey +} diff --git a/ui/src/layout/components/top-bar/avatar/APIKeyDialog.vue b/ui/src/layout/components/top-bar/avatar/APIKeyDialog.vue new file mode 100644 index 000000000..6451eed4b --- /dev/null +++ b/ui/src/layout/components/top-bar/avatar/APIKeyDialog.vue @@ -0,0 +1,185 @@ + + + diff --git a/ui/src/layout/components/top-bar/avatar/SettingAPIKeyDialog.vue b/ui/src/layout/components/top-bar/avatar/SettingAPIKeyDialog.vue new file mode 100644 index 000000000..2a48a95ee --- /dev/null +++ b/ui/src/layout/components/top-bar/avatar/SettingAPIKeyDialog.vue @@ -0,0 +1,98 @@ + + + diff --git a/ui/src/layout/components/top-bar/avatar/index.vue b/ui/src/layout/components/top-bar/avatar/index.vue index 8042bd2a7..a225ca9b8 100644 --- a/ui/src/layout/components/top-bar/avatar/index.vue +++ b/ui/src/layout/components/top-bar/avatar/index.vue @@ -22,6 +22,9 @@ {{ $t("layout.topbar.avatar.resetPassword") }} + + + {{ $t("layout.topbar.avatar.apiKey") }} {{ $t("layout.topbar.avatar.about") }} {{ $t("layout.topbar.avatar.logout") }} @@ -30,6 +33,7 @@ +