From 78e372fa21a7ac843b41eb382e8427597f2a09f1 Mon Sep 17 00:00:00 2001 From: wangdan-fit2cloud Date: Fri, 8 Dec 2023 16:55:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BA=94=E7=94=A8=E6=A6=82=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/api/application-overview.ts | 63 +++++++++ ui/src/api/application.ts | 28 ++-- ui/src/request/index.ts | 2 +- ui/src/router/modules/application.ts | 2 +- .../component/APIKeyDialog.vue | 124 ++++++++++++++++++ .../component}/EmbedDialog.vue | 0 .../index.vue} | 68 ++++++---- ui/src/views/document/index.vue | 4 +- 8 files changed, 251 insertions(+), 40 deletions(-) create mode 100644 ui/src/api/application-overview.ts create mode 100644 ui/src/views/applicaiton-overview/component/APIKeyDialog.vue rename ui/src/views/{application/components => applicaiton-overview/component}/EmbedDialog.vue (100%) rename ui/src/views/{application/AppOverview.vue => applicaiton-overview/index.vue} (63%) diff --git a/ui/src/api/application-overview.ts b/ui/src/api/application-overview.ts new file mode 100644 index 000000000..361990193 --- /dev/null +++ b/ui/src/api/application-overview.ts @@ -0,0 +1,63 @@ +import { Result } from '@/request/Result' +import { get, post, postStream, del, put } from '@/request/index' + +import { type Ref } from 'vue' + +const prefix = '/application' + +/** + * API_KEY列表 + * @param 参数 applicaiton_id + */ +const getAPIKey: (applicaiton_id: string, loading?: Ref) => Promise> = ( + applicaiton_id, + loading +) => { + return get(`${prefix}/${applicaiton_id}/api_key`, undefined, loading) +} + +/** + * 新增API_KEY + * @param 参数 applicaiton_id + */ +const postAPIKey: (applicaiton_id: string, loading?: Ref) => Promise> = ( + applicaiton_id, + loading +) => { + return post(`${prefix}/${applicaiton_id}/api_key`, {}, undefined, loading) +} + +/** + * 删除API_KEY + * @param 参数 applicaiton_id api_key_id + */ +const delAPIKey: ( + applicaiton_id: String, + api_key_id: String, + loading?: Ref +) => Promise> = (applicaiton_id, api_key_id, loading) => { + return del(`${prefix}/${applicaiton_id}/api_key/${api_key_id}`, undefined, undefined, loading) +} + +/** + * 修改API_KEY + * @param 参数 applicaiton_id,api_key_id + * data { + * is_active: boolean + * } + */ +const putAPIKey: ( + applicaiton_id: string, + api_key_id: String, + data: any, + loading?: Ref +) => Promise> = (applicaiton_id, api_key_id, data, loading) => { + return put(`${prefix}/${applicaiton_id}/api_key/${api_key_id}`, data, undefined, loading) +} + +export default { + getAPIKey, + postAPIKey, + delAPIKey, + putAPIKey +} diff --git a/ui/src/api/application.ts b/ui/src/api/application.ts index 9569cd119..0b1b60c5a 100644 --- a/ui/src/api/application.ts +++ b/ui/src/api/application.ts @@ -111,17 +111,6 @@ const getApplicationDataset: ( return get(`${prefix}/${applicaiton_id}/list_dataset`, undefined, loading) } -/** - * API_KEY列表 - * @param 参数 applicaiton_id - */ -const getAPIKey: (applicaiton_id: string, loading?: Ref) => Promise> = ( - applicaiton_id, - loading -) => { - return get(`${prefix}/${applicaiton_id}/api_key`, undefined, loading) -} - /** * 获取AccessToken * @param 参数 applicaiton_id @@ -133,6 +122,21 @@ const getAccessToken: (applicaiton_id: string, loading?: Ref) => Promis return get(`${prefix}/${applicaiton_id}/access_token`, undefined, loading) } +/** + * 修改AccessToken + * @param 参数 applicaiton_id + * data { + * "is_active": true + * } + */ +const putAccessToken: ( + applicaiton_id: string, + data: any, + loading?: Ref +) => Promise> = (applicaiton_id, data, loading) => { + return put(`${prefix}/${applicaiton_id}/access_token`, data, undefined, loading) +} + /** * 应用认证 * @param 参数 @@ -235,8 +239,8 @@ export default { delApplication, getApplicationDetail, getApplicationDataset, - getAPIKey, getAccessToken, + putAccessToken, postAppAuthentication, getProfile, putChatVote diff --git a/ui/src/request/index.ts b/ui/src/request/index.ts index cb586b305..e016c62d3 100644 --- a/ui/src/request/index.ts +++ b/ui/src/request/index.ts @@ -141,8 +141,8 @@ export const post: ( */ export const put: ( url: string, - params?: unknown, data?: unknown, + params?: unknown, loading?: NProgress | Ref ) => Promise> = (url, data, params, loading) => { return promise(request({ url: url, method: 'put', data, params }), loading) diff --git a/ui/src/router/modules/application.ts b/ui/src/router/modules/application.ts index f3a89140e..20afe834f 100644 --- a/ui/src/router/modules/application.ts +++ b/ui/src/router/modules/application.ts @@ -35,7 +35,7 @@ const applicationRouter = { parentPath: '/application/:id', parentName: 'ApplicationDetail' }, - component: () => import('@/views/application/AppOverview.vue') + component: () => import('@/views/applicaiton-overview/index.vue') }, { path: 'setting', diff --git a/ui/src/views/applicaiton-overview/component/APIKeyDialog.vue b/ui/src/views/applicaiton-overview/component/APIKeyDialog.vue new file mode 100644 index 000000000..0057c6b0a --- /dev/null +++ b/ui/src/views/applicaiton-overview/component/APIKeyDialog.vue @@ -0,0 +1,124 @@ + + + diff --git a/ui/src/views/application/components/EmbedDialog.vue b/ui/src/views/applicaiton-overview/component/EmbedDialog.vue similarity index 100% rename from ui/src/views/application/components/EmbedDialog.vue rename to ui/src/views/applicaiton-overview/component/EmbedDialog.vue diff --git a/ui/src/views/application/AppOverview.vue b/ui/src/views/applicaiton-overview/index.vue similarity index 63% rename from ui/src/views/application/AppOverview.vue rename to ui/src/views/applicaiton-overview/index.vue index 55886b277..df0bb1b23 100644 --- a/ui/src/views/application/AppOverview.vue +++ b/ui/src/views/applicaiton-overview/index.vue @@ -2,7 +2,7 @@

应用信息

- +
公开访问链接
-
+
{{ shareUrl }} @@ -36,40 +38,46 @@ + + +
-
- 演示 - 嵌入第三方 +
+ 演示 + 嵌入第三方
API访问凭据
-
+
- API Key: OGZmZThlZjYyYzU2MWE1OTlkYTVjZTBi + {{ apiUrl }} - +
-
- 获取密钥 +
+ API Key
+ @@ -122,5 +139,8 @@ onMounted(() => { right: 16px; top: 21px; } + .url-height { + min-height: 50px; + } } diff --git a/ui/src/views/document/index.vue b/ui/src/views/document/index.vue index 882ea3bd5..27c58794d 100644 --- a/ui/src/views/document/index.vue +++ b/ui/src/views/document/index.vue @@ -57,7 +57,7 @@ - +