feat: update API response structure to nest payloads under a single "data" key

This commit is contained in:
2026-09-09 16:15:33 +08:00
parent b88e86f386
commit bc7eb9dfdd
8 changed files with 36 additions and 29 deletions
+2 -1
View File
@@ -5,13 +5,14 @@ export const authApi = {
register: (username, password) => http.post('/user/register', { username, password })
};
// /api/server/getStatus?uuid=all → { success, "<uuid>": { uuid, name, online, report } }
// /api/server/getStatus?uuid=all → { success, message, data: { "<uuid>": { uuid, name, online, report } } }
export const serverApi = {
statusAll: () => http.get('/server/getStatus?uuid=all'),
infoAll: () => http.get('/server/getInfo?uuid=all')
};
// /api/settings/get?type=… / /api/settings/set?type=…
// get → { success, message, data: { config } }.
// `type` is one of global | bot_user_config | bot_node_config.
// For set, pass a partial object; a JSON null value removes that key.
export const settingsApi = {
+11 -9
View File
@@ -34,18 +34,20 @@ async function submit() {
try {
if (mode.value === 'login') {
const res = await authApi.login(form.username.trim(), form.password);
afterLogin(res.token, {
userID: res.userID,
username: res.username,
level: res.level,
registerDate: res.registerDate
const d = res.data;
afterLogin(d.token, {
userID: d.userID,
username: d.username,
level: d.level,
registerDate: d.registerDate
});
} else {
const res = await authApi.register(form.username.trim(), form.password);
afterLogin(res.token, {
userID: res.userID,
username: res.username,
level: res.level
const d = res.data;
afterLogin(d.token, {
userID: d.userID,
username: d.username,
level: d.level
});
toast.success('Admin created — welcome to Nukumizu');
}
+6 -5
View File
@@ -43,12 +43,13 @@ async function load() {
serverApi.infoAll(),
settingsApi.get('bot_node_config')
]);
const nodeConf = (nodes && nodes.config) || {};
const statusData = (status && status.data) || {};
const infoData = (info && info.data) || {};
const nodeConf = (nodes && nodes.data && nodes.data.config) || {};
const list = [];
for (const key of Object.keys(status)) {
if (key === 'success') continue;
const s = status[key] || {};
const infoEntry = info[key] || {};
for (const key of Object.keys(statusData)) {
const s = statusData[key] || {};
const infoEntry = infoData[key] || {};
const conf = nodeConf[key] || {};
list.push({
uuid: s.uuid || key,
+1 -1
View File
@@ -168,7 +168,7 @@ function defaults(f) {
async function load() {
try {
const res = await settingsApi.get('global');
const cfg = (res && res.config) || {};
const cfg = (res && res.data && res.data.config) || {};
for (const s of sections) {
const obj = {};
for (const f of s.fields) {
+1 -1
View File
@@ -50,7 +50,7 @@ const defaultOpts = () => ({
async function load() {
try {
const res = await settingsApi.get('bot_user_config');
const cfg = (res && res.config) || {};
const cfg = (res && res.data && res.data.config) || {};
const flat = [];
for (const c of CHANNELS) {
const chData = cfg[c.key] || {};