ui-next: remove _ui_next search param

This commit is contained in:
Baoshuo committed 2026-05-10 01:12:47 +08:00
1 parent b66bdfac77
commit 8bb08926f8
2 files changed
+18 -16

No files matched your search

+10 -13
View File
@@ -77,22 +77,19 @@ export default (logger, xff, xhost) => async (ctx: KoaContext, next: Next) => {
} else if (
request.json || response.redirect
|| request.query.noTemplate || !response.template // no template, send raw data
|| request.query._ui_next) { // for ui-next, we always send json
) {
// Send raw data
try {
if (typeof response.body === 'object' && request.headers['x-hydro-inject']) {
if (request.headers['x-hydro-inject']) {
const inject = request.headers['x-hydro-inject'].toString().toLowerCase().split(',').map((i) => i.trim());
if (inject.includes('uicontext')) response.body.UiContext = UiContext;
if (inject.includes('usercontext')) response.body.UserContext = user;
}
if (request.query._ui_next) {
response.body = {
// `_matchedRouteName` is koa-router's internal property, but it works,
// maybe we should migrate to a more official solution in the future.
name: ctx._matchedRouteName,
args: response.body || {},
url: ctx.req.url,
};
if (inject.includes('pagename')) {
ctx.set('x-hydro-page', ctx._matchedRouteName || '');
}
if (response.body !== null && typeof response.body === 'object') {
if (inject.includes('uicontext')) response.body.UiContext = UiContext;
if (inject.includes('usercontext')) response.body.UserContext = user;
if (inject.includes('routemap')) response.body.routeMap = handler.ctx.server.routeMap;
}
}
response.body = JSON.stringify(response.body, serializer(false, handler));
} catch (e) {