From 7f92a9b773ad0eba85f99f11acfaafc0d00d2bc3 Mon Sep 17 00:00:00 2001 From: "fengchuanhn@gmail.com" Date: Thu, 21 May 2026 16:00:02 +0800 Subject: [PATCH] 11 --- src-tauri/capabilities/default.json | 1 + src/api/oemCardKeys.js | 72 +++ src/api/oemUsers.js | 2 +- src/components/AppTitlebar.vue | 18 + src/components/agent/AgentImageUpload.vue | 101 +++++ src/components/agent/AgentSubNav.vue | 31 ++ src/router/index.js | 31 ++ src/styles/main.css | 10 + src/views/agent/AgentCardKeysView.vue | 517 ++++++++++++++++++++++ src/views/agent/AgentUsersView.vue | 455 +++++++++++++++++++ src/views/oem/OemCardKeysView.vue | 14 +- src/views/oem/OemUsersView.vue | 48 +- 12 files changed, 1267 insertions(+), 33 deletions(-) create mode 100644 src/api/oemCardKeys.js create mode 100644 src/components/agent/AgentImageUpload.vue create mode 100644 src/components/agent/AgentSubNav.vue create mode 100644 src/views/agent/AgentCardKeysView.vue create mode 100644 src/views/agent/AgentUsersView.vue diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index ed3e2cd..3c563a0 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -7,6 +7,7 @@ "core:default", "core:window:default", "core:window:allow-start-dragging", + "core:window:allow-close", "core:window:allow-minimize", "core:window:allow-maximize", "core:window:allow-unmaximize", diff --git a/src/api/oemCardKeys.js b/src/api/oemCardKeys.js new file mode 100644 index 0000000..9a4a930 --- /dev/null +++ b/src/api/oemCardKeys.js @@ -0,0 +1,72 @@ +import { apiRequest } from "./client.js"; + +/** + * @param {string} token + * @param {RequestInit} [options] + */ +function oemRequest(token, path, options = {}) { + return apiRequest(path, { + ...options, + headers: { + Authorization: `Bearer ${token}`, + ...options.headers, + }, + }); +} + +/** + * @param {string} token + * @param {{ + * page?: number, + * pageSize?: number, + * status?: string, + * username?: string, + * oemId?: number | null, + * agentId?: number | null, + * }} [params] + */ +export function listAdminCardKeysApi( + token, + { page = 1, pageSize = 20, status = "all", username, oemId, agentId } = {}, +) { + const query = new URLSearchParams({ + page: String(page), + page_size: String(pageSize), + status, + }); + const trimmed = username?.trim(); + if (trimmed) query.set("username", trimmed); + if (oemId != null) query.set("oem_id", String(oemId)); + if (agentId != null) query.set("agent_id", String(agentId)); + return oemRequest(token, `/oem/card-keys?${query}`); +} + +/** + * @param {string} token + * @param {object} payload + */ +export function createAdminCardKeysApi(token, payload) { + return oemRequest(token, "/oem/card-keys", { + method: "POST", + body: JSON.stringify(payload), + }); +} + +/** + * @param {string} token + * @param {number} cardId + * @param {object} payload + */ +export function updateAdminCardKeyApi(token, cardId, payload) { + return oemRequest(token, `/oem/card-keys/${cardId}`, { + method: "PATCH", + body: JSON.stringify(payload), + }); +} + +/** @param {string} token @param {number} cardId */ +export function deleteAdminCardKeyApi(token, cardId) { + return oemRequest(token, `/oem/card-keys/${cardId}`, { + method: "DELETE", + }); +} diff --git a/src/api/oemUsers.js b/src/api/oemUsers.js index 4b48330..0be1dc3 100644 --- a/src/api/oemUsers.js +++ b/src/api/oemUsers.js @@ -25,7 +25,7 @@ function oemRequest(token, path, options = {}) { * roleId?: number | null, * }} [params] */ -export function listOemUsersApi( +export function listAgentUsersApi( token, { page = 1, pageSize = 20, username, oemId, agentId, roleId } = {}, ) { diff --git a/src/components/AppTitlebar.vue b/src/components/AppTitlebar.vue index d068373..fdb71d7 100644 --- a/src/components/AppTitlebar.vue +++ b/src/components/AppTitlebar.vue @@ -79,6 +79,15 @@ async function onToggleMaximize() { } } +async function onClose() { + if (!isTauri()) return; + try { + await getCurrentWindow().close(); + } catch { + /* ignore */ + } +} + async function onLogout() { if (loggingOut.value) return; loggingOut.value = true; @@ -213,6 +222,15 @@ onUnmounted(() => { :class="isMaximized ? 'pi-window-minimize' : 'pi-window-maximize'" /> + diff --git a/src/components/agent/AgentImageUpload.vue b/src/components/agent/AgentImageUpload.vue new file mode 100644 index 0000000..7339f74 --- /dev/null +++ b/src/components/agent/AgentImageUpload.vue @@ -0,0 +1,101 @@ + + + diff --git a/src/components/agent/AgentSubNav.vue b/src/components/agent/AgentSubNav.vue new file mode 100644 index 0000000..75f91ee --- /dev/null +++ b/src/components/agent/AgentSubNav.vue @@ -0,0 +1,31 @@ + + + diff --git a/src/router/index.js b/src/router/index.js index 71aa5fa..626ffb5 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -264,8 +264,39 @@ const mainChildren = [ meta: { title: "代理", requiresRole: ROLE_AGENT }, + children: [ + + + + { + + path: "users", + + name: "agent-users", + + component: () => import("../views/agent/AgentUsersView.vue"), + + meta: { title: "用户管理" }, + + }, + + { + + path: "card-keys", + + name: "agent-card-keys", + + component: () => import("../views/agent/AgentCardKeysView.vue"), + + meta: { title: "卡密管理" }, + + }, + + ], + }, + ]; diff --git a/src/styles/main.css b/src/styles/main.css index 9c505a2..dcd3a14 100644 --- a/src/styles/main.css +++ b/src/styles/main.css @@ -420,6 +420,16 @@ body { background: rgba(255, 255, 255, 0.12); } +.app-titlebar__btn--close:hover { + background: rgba(239, 68, 68, 0.85); + color: #fff; +} + +.app-titlebar__btn--close:active { + background: rgba(220, 38, 38, 0.9); + color: #fff; +} + .admin-image-upload { display: flex; flex-direction: column; diff --git a/src/views/agent/AgentCardKeysView.vue b/src/views/agent/AgentCardKeysView.vue new file mode 100644 index 0000000..c577eab --- /dev/null +++ b/src/views/agent/AgentCardKeysView.vue @@ -0,0 +1,517 @@ + + +