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