fix: complete Douyin release remediation
This commit is contained in:
+16
-12
@@ -57,6 +57,7 @@ const resourcePaths = {
|
||||
"network-exits": "/network-exits",
|
||||
"creator-accounts": "/creator/accounts",
|
||||
"creator-competitors": "/creator/competitors",
|
||||
"creator-competitor-preview": "/creator/competitors/preview",
|
||||
"creator-works": "/creator/works",
|
||||
"creator-comments": "/creator/comments",
|
||||
"creator-leads": "/creator/leads",
|
||||
@@ -107,10 +108,7 @@ export const dataProvider = {
|
||||
data: data.map((record, index) => withID(record, index)),
|
||||
total: records.total ?? data.length,
|
||||
};
|
||||
if (
|
||||
!Array.isArray(records) &&
|
||||
Object.prototype.hasOwnProperty.call(records, "has_next")
|
||||
) {
|
||||
if (!Array.isArray(records) && Object.hasOwn(records, "has_next")) {
|
||||
result.hasNext = Boolean(records.has_next);
|
||||
}
|
||||
return result;
|
||||
@@ -230,7 +228,7 @@ export const dataProvider = {
|
||||
);
|
||||
},
|
||||
async networkExitAction(id, action) {
|
||||
if (action !== "check" && action !== "disable")
|
||||
if (!["check", "disable", "enable"].includes(action))
|
||||
throw new Error(`未知网络出口操作: ${action}`);
|
||||
return request(`/network-exits/${encodeURIComponent(id)}/${action}`, {
|
||||
method: "POST",
|
||||
@@ -275,17 +273,23 @@ export const dataProvider = {
|
||||
onStatus?.("connected");
|
||||
const decoder = new TextDecoder();
|
||||
let buffer = "";
|
||||
const dispatch = (frame) => {
|
||||
if (frame.split(/\r\n|\n|\r/).some((line) => line.startsWith("data:")))
|
||||
onMessage(frame);
|
||||
};
|
||||
while (true) {
|
||||
const { value, done } = await reader.read();
|
||||
buffer += decoder.decode(value || new Uint8Array(), { stream: !done });
|
||||
let boundary;
|
||||
while ((boundary = buffer.indexOf("\\n\\n")) >= 0) {
|
||||
const frame = buffer.slice(0, boundary);
|
||||
buffer = buffer.slice(boundary + 2);
|
||||
if (frame.split(/\\r?\\n/).some((line) => line.startsWith("data:")))
|
||||
onMessage(frame);
|
||||
let match;
|
||||
while ((match = buffer.match(/\r\n\r\n|\n\n|\r\r/))) {
|
||||
dispatch(buffer.slice(0, match.index));
|
||||
buffer = buffer.slice(match.index + match[0].length);
|
||||
}
|
||||
if (done) {
|
||||
if (buffer.trim()) dispatch(buffer);
|
||||
onStatus?.("disconnected");
|
||||
return;
|
||||
}
|
||||
if (done) return;
|
||||
}
|
||||
},
|
||||
creatorUpdate(path, data) {
|
||||
|
||||
Reference in New Issue
Block a user