fix: 插件API路由统一加面板前缀(/SenSu),解决反代后插件页面空白

This commit is contained in:
qinglong
2026-06-14 20:14:22 +08:00
parent 26d515e080
commit 6c6c88b22a
5 changed files with 26 additions and 14 deletions
+9 -2
View File
@@ -44,7 +44,14 @@ window.toggleTheme = function(){
// ═══ 路由系统 ═══
// Hash format: #/dashboard | #/files | #/plugins/example_plugin
// Built-in pages map to ./static/pages/{name}.html
// Plugin pages load from /plugin/{name}
// Plugin pages load from {base}/plugin/{name}
// 从当前页面路径提取面板前缀 (e.g. /SenSu/home.html → /SenSu)
window.SENSU_BASE = (function(){
var p = window.location.pathname;
// 去掉最后的文件名部分
return p.substring(0, p.lastIndexOf('/')) || '';
})();
var BUILTIN_PAGES = ['dashboard','logs','console','plugins','projects','proxy','files','settings'];
var _pluginPagesCache = null; // {plugin_name: {path, title, icon}}
@@ -167,7 +174,7 @@ async function loadPluginPage(pluginName) {
if(!_pluginPagesCache) await fetchPluginPages();
try {
var resp = await fetch('/plugin/'+pluginName+'?t='+Date.now(), {credentials:'include'});
var resp = await fetch(window.SENSU_BASE+'/plugin/'+pluginName+'?t='+Date.now(), {credentials:'include'});
if(!resp.ok) throw new Error(resp.status);
var html = await resp.text();