From f93332d259b96820eb361e7db2cd7a5c17560335 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E4=B8=81?= Date: Fri, 27 Mar 2026 18:30:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=E5=AE=8C=E5=96=84ap?= =?UTF-8?q?i=E7=AE=A1=E7=90=86=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/apiApp.ts | 21 ++- src/api/request.ts | 25 ++++ src/locales/en.json | 16 +- src/locales/ja.json | 16 +- src/locales/ko.json | 16 +- src/locales/zh-CN.json | 16 +- src/locales/zh-TW.json | 16 +- src/views/ApiKey.vue | 333 ++++++++++++++++++++++++++++++++++++++++- 8 files changed, 439 insertions(+), 20 deletions(-) diff --git a/src/api/apiApp.ts b/src/api/apiApp.ts index c06ee69..a30c974 100644 --- a/src/api/apiApp.ts +++ b/src/api/apiApp.ts @@ -3,7 +3,7 @@ * doc.json: /AA/getApiAppList、/AA/createApiApp 等 */ -import { get, post } from './request' +import { get, httpDelete, post } from './request' import { buildQuery } from './request' import type { PageResult } from './types' @@ -37,13 +37,13 @@ export interface ApiAppListResponse { * GET /AA/getApiAppList * 分页获取 API 应用列表,需鉴权(x-token、x-user-id) */ -export async function getApiAppList( +export async function getMyApiAppList( params: GetApiAppListParams = {}, config?: { headers?: Record }, ): Promise { const { page = 1, pageSize = 10, keyword, createdAtRange } = params const query = buildQuery({ page, pageSize, keyword, createdAtRange }) - return get('/AA/getApiAppList', query, config) + return get('/AA/getMyApiAppList', query, config) } /** 创建 API 应用请求体(appKey/appSecret 由后端生成时可传空) */ @@ -65,9 +65,20 @@ export interface CreateApiAppResponse { * POST /AA/createApiApp * 创建 API 应用,需鉴权。成功后返回新创建的 ApiApp(含 appKey、appSecret) */ -export async function createApiApp( +export async function createMyApiApp( body: CreateApiAppBody, config?: { headers?: Record }, ): Promise { - return post('/AA/createApiApp', body, config) + return post('/AA/createMyApiApp', body, config) +} + +/** + * POST /AA/deleteMyApiApp + * 删除 API 应用,需鉴权 + */ +export async function deleteMyApiApp( + ID: number, + config?: { headers?: Record }, +): Promise { + return httpDelete('/AA/deleteMyApiApp?ID='+ ID, null, config) } diff --git a/src/api/request.ts b/src/api/request.ts index 21c9269..1dad2f5 100644 --- a/src/api/request.ts +++ b/src/api/request.ts @@ -159,3 +159,28 @@ export async function put( } return res.json() as Promise } + +/** + * 带 x-token 等自定义头的 POST 请求 + */ +export async function httpDelete( + path: string, + body?: unknown, + config?: RequestConfig, +): Promise { + const url = new URL(path, BASE_URL || window.location.origin) + const headers: Record = { + 'Content-Type': 'application/json', + 'Accept-Language': i18n.global.locale.value as string, + ...config?.headers, + } + const res = await fetch(url.toString(), { + method: 'DELETE', + headers, + body: body !== undefined ? JSON.stringify(body) : undefined, + }) + if (!res.ok) { + throw new Error(`HTTP ${res.status}: ${res.statusText}`) + } + return res.json() as Promise +} diff --git a/src/locales/en.json b/src/locales/en.json index 9ca445d..11817d6 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -18,7 +18,8 @@ "noData": "No data", "more": "More", "user": "User", - "chance": "chance" + "chance": "chance", + "cancel": "Cancel" }, "chart": { "yesnoTimeSeries": "YES/NO Time Series", @@ -148,7 +149,18 @@ "copy": "Copy", "delete": "Delete", "keyDefault": "Key #{n}", - "defaultDesc": "API Key" + "defaultDesc": "API Key", + "newKeyTitle": "Created Successfully", + "newKeyHint": "Save now — App Secret is only shown once", + "appKeyLabel": "App Key", + "appSecretLabel": "App Secret", + "copyAppKey": "Copy App Key", + "copyAppSecret": "Copy App Secret", + "copied": "Copied", + "closeBtn": "I've saved it, Close", + "deleteConfirm": "Are you sure you want to delete this API Key? This action cannot be undone.", + "deleteConfirmTitle": "Confirm Delete", + "deleteSuccess": "Deleted successfully" }, "activity": { "comments": "Comments", diff --git a/src/locales/ja.json b/src/locales/ja.json index 58ebfcf..08edc4a 100644 --- a/src/locales/ja.json +++ b/src/locales/ja.json @@ -18,7 +18,8 @@ "noData": "データがありません", "more": "その他", "user": "ユーザー", - "chance": "確率" + "chance": "確率", + "cancel": "キャンセル" }, "chart": { "yesnoTimeSeries": "YES/NO 時系列", @@ -148,7 +149,18 @@ "copy": "コピー", "delete": "削除", "keyDefault": "Key #{n}", - "defaultDesc": "API Key" + "defaultDesc": "API Key", + "newKeyTitle": "作成完了", + "newKeyHint": "今すぐ保存してください。App Secret はここにのみ表示されます", + "appKeyLabel": "App Key", + "appSecretLabel": "App Secret", + "copyAppKey": "App Key をコピー", + "copyAppSecret": "App Secret をコピー", + "copied": "コピーしました", + "closeBtn": "保存しました、閉じる", + "deleteConfirm": "この API Key を削除してもよろしいですか?この操作は元に戻せません。", + "deleteConfirmTitle": "削除の確認", + "deleteSuccess": "削除しました" }, "activity": { "comments": "コメント", diff --git a/src/locales/ko.json b/src/locales/ko.json index bc4b665..38f5fa7 100644 --- a/src/locales/ko.json +++ b/src/locales/ko.json @@ -18,7 +18,8 @@ "noData": "데이터 없음", "more": "더보기", "user": "사용자", - "chance": "확률" + "chance": "확률", + "cancel": "취소" }, "chart": { "yesnoTimeSeries": "YES/NO 시계열", @@ -148,7 +149,18 @@ "copy": "복사", "delete": "삭제", "keyDefault": "Key #{n}", - "defaultDesc": "API Key" + "defaultDesc": "API Key", + "newKeyTitle": "생성 완료", + "newKeyHint": "지금 저장하세요. App Secret은 여기서만 표시됩니다", + "appKeyLabel": "App Key", + "appSecretLabel": "App Secret", + "copyAppKey": "App Key 복사", + "copyAppSecret": "App Secret 복사", + "copied": "복사됨", + "closeBtn": "저장 완료, 닫기", + "deleteConfirm": "이 API Key를 삭제하시겠습니까? 이 작업은 되돌릴 수 없습니다.", + "deleteConfirmTitle": "삭제 확인", + "deleteSuccess": "삭제되었습니다" }, "activity": { "comments": "댓글", diff --git a/src/locales/zh-CN.json b/src/locales/zh-CN.json index 202b1a4..381244c 100644 --- a/src/locales/zh-CN.json +++ b/src/locales/zh-CN.json @@ -18,7 +18,8 @@ "noData": "暂无数据", "more": "更多操作", "user": "用户", - "chance": "概率" + "chance": "概率", + "cancel": "取消" }, "chart": { "yesnoTimeSeries": "YES/NO 分时", @@ -148,7 +149,18 @@ "copy": "复制", "delete": "删除", "keyDefault": "Key #{n}", - "defaultDesc": "API Key" + "defaultDesc": "API Key", + "newKeyTitle": "创建成功", + "newKeyHint": "请立即保存,AppSecret 仅在此处显示一次", + "appKeyLabel": "App Key", + "appSecretLabel": "App Secret", + "copyAppKey": "复制 App Key", + "copyAppSecret": "复制 App Secret", + "copied": "已复制", + "closeBtn": "我已保存,关闭", + "deleteConfirm": "确定要删除该 API Key 吗?此操作不可撤销。", + "deleteConfirmTitle": "删除确认", + "deleteSuccess": "删除成功" }, "activity": { "comments": "评论", diff --git a/src/locales/zh-TW.json b/src/locales/zh-TW.json index db1a1ff..d1e33d7 100644 --- a/src/locales/zh-TW.json +++ b/src/locales/zh-TW.json @@ -18,7 +18,8 @@ "noData": "暫無數據", "more": "更多操作", "user": "用戶", - "chance": "機率" + "chance": "機率", + "cancel": "取消" }, "chart": { "yesnoTimeSeries": "YES/NO 分時", @@ -148,7 +149,18 @@ "copy": "複製", "delete": "刪除", "keyDefault": "Key #{n}", - "defaultDesc": "API Key" + "defaultDesc": "API Key", + "newKeyTitle": "創建成功", + "newKeyHint": "請立即保存,AppSecret 僅在此處顯示一次", + "appKeyLabel": "App Key", + "appSecretLabel": "App Secret", + "copyAppKey": "複製 App Key", + "copyAppSecret": "複製 App Secret", + "copied": "已複製", + "closeBtn": "我已保存,關閉", + "deleteConfirm": "確定要刪除該 API Key 嗎?此操作不可撤銷。", + "deleteConfirmTitle": "刪除確認", + "deleteSuccess": "刪除成功" }, "activity": { "comments": "評論", diff --git a/src/views/ApiKey.vue b/src/views/ApiKey.vue index 3849177..6f9d1c5 100644 --- a/src/views/ApiKey.vue +++ b/src/views/ApiKey.vue @@ -34,7 +34,14 @@ > {{ t('apiKey.copy') }} - + @@ -46,12 +53,79 @@ + + + + + + + + + +