This commit is contained in:
fengchuanhn@gmail.com
2026-05-21 16:38:10 +08:00
parent 2aff213edd
commit 5e17e68329
2 changed files with 71 additions and 9 deletions

View File

@@ -0,0 +1,62 @@
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, keyword?: string }} [params]
*/
export function listOemDesktopConfigsApi(
token,
{ page = 1, pageSize = 20, keyword = "" } = {},
) {
const query = new URLSearchParams({
page: String(page),
page_size: String(pageSize),
});
const kw = keyword?.trim();
if (kw) query.set("keyword", kw);
return oemRequest(token, `/oem/desktop-configs?${query}`);
}
/**
* @param {string} token
* @param {object} payload
*/
export function createOemDesktopConfigApi(token, payload) {
return oemRequest(token, "/oem/desktop-configs", {
method: "POST",
body: JSON.stringify(payload),
});
}
/**
* @param {string} token
* @param {number} configId
* @param {object} payload
*/
export function updateOemDesktopConfigApi(token, configId, payload) {
return oemRequest(token, `/oem/desktop-configs/${configId}`, {
method: "PATCH",
body: JSON.stringify(payload),
});
}
/** @param {string} token @param {number} configId */
export function deleteOemDesktopConfigApi(token, configId) {
return oemRequest(token, `/oem/desktop-configs/${configId}`, {
method: "DELETE",
});
}

View File

@@ -2,11 +2,11 @@
import { computed, onMounted, ref } from "vue"; import { computed, onMounted, ref } from "vue";
import { useAuthStore } from "../../stores/auth.js"; import { useAuthStore } from "../../stores/auth.js";
import { import {
listAdminDesktopConfigsApi, listOemDesktopConfigsApi,
createAdminDesktopConfigApi, createOemDesktopConfigApi,
updateAdminDesktopConfigApi, updateOemDesktopConfigApi,
deleteAdminDesktopConfigApi, deleteOemDesktopConfigApi,
} from "../../api/adminDesktopConfigs.js"; } from "../../api/oemDesktopConfigs.js";
const auth = useAuthStore(); const auth = useAuthStore();
@@ -61,7 +61,7 @@ function truncateValue(value, max = 48) {
async function loadConfigs() { async function loadConfigs() {
loading.value = true; loading.value = true;
feedback.value = { severity: "", message: "" }; feedback.value = { severity: "", message: "" };
const res = await listAdminDesktopConfigsApi(auth.token, { const res = await listOemDesktopConfigsApi(auth.token, {
page: page.value, page: page.value,
pageSize: pageSize.value, pageSize: pageSize.value,
keyword: keyword.value, keyword: keyword.value,
@@ -136,9 +136,9 @@ async function saveConfig() {
let res; let res;
if (dialogMode.value === "create") { if (dialogMode.value === "create") {
res = await createAdminDesktopConfigApi(auth.token, payload); res = await createOemDesktopConfigApi(auth.token, payload);
} else { } else {
res = await updateAdminDesktopConfigApi(auth.token, editingId.value, { res = await updateOemDesktopConfigApi(auth.token, editingId.value, {
value: payload.value, value: payload.value,
mark: payload.mark, mark: payload.mark,
}); });
@@ -160,7 +160,7 @@ async function removeConfig(row) {
const ok = window.confirm(`确定删除配置「${row.name}」?桌面端需重新登录后生效。`); const ok = window.confirm(`确定删除配置「${row.name}」?桌面端需重新登录后生效。`);
if (!ok) return; if (!ok) return;
const res = await deleteAdminDesktopConfigApi(auth.token, row.id); const res = await deleteOemDesktopConfigApi(auth.token, row.id);
if (!res.ok) { if (!res.ok) {
showMessage("error", res.message || "删除失败"); showMessage("error", res.message || "删除失败");
return; return;