chore: Merge user data into payload in SUI libsui index.ts

This commit is contained in:
Max 2024-09-03 18:15:12 +08:00
parent 07353d0084
commit 72542dab79
2 changed files with 68 additions and 63 deletions

File diff suppressed because one or more lines are too long

View file

@ -354,10 +354,15 @@ async function __sui_render(
const root = document.body.getAttribute("s:public") || ""; const root = document.body.getAttribute("s:public") || "";
const route = routeAttr ? `${root}${routeAttr}` : window.location.pathname; const route = routeAttr ? `${root}${routeAttr}` : window.location.pathname;
console.log("Route", route, elm, root);
const url = `/api/__yao/sui/v1/render${route}`; const url = `/api/__yao/sui/v1/render${route}`;
const payload = { name, data: { ..._data, ...data }, option }; const payload = { name, data: _data, option };
// merge the user data
if (data) {
for (const key in data) {
payload.data[key] = data[key];
}
}
const headers = { const headers = {
"Content-Type": "application/json", "Content-Type": "application/json",
Cookie: document.cookie, Cookie: document.cookie,