This commit is contained in:
xion 2025-04-10 01:00:37 +08:00
parent c9a3f7fda9
commit e15d0be1e1
3 changed files with 24 additions and 4 deletions

View File

@ -39,6 +39,12 @@ type ConfigType = {
*/ */
allowedOrigin: string[]; allowedOrigin: string[];
}; };
stat: {
/**
* ID
*/
websiteId: string;
};
}; };
// export const config = useConfig(); // export const config = useConfig();
@ -61,4 +67,7 @@ export const config: ConfigType = {
resources: envConfig.PROXY_RESOURCES, resources: envConfig.PROXY_RESOURCES,
allowedOrigin: (envConfig.PROXY_ALLOWED_ORIGINS as string)?.split(',') || [], allowedOrigin: (envConfig.PROXY_ALLOWED_ORIGINS as string)?.split(',') || [],
}, },
stat: {
websiteId: envConfig.DATA_WEBSITE_ID,
},
}; };

View File

@ -1,8 +1,17 @@
import { config } from '../../config.ts';
/** /**
* *
* @param html * @param html
* @returns * @returns
*/ */
export const addStat = (html: string) => { export const addStat = (html: string, addStat = true) => {
return html.replace('</head>', `<script defer src="https://umami.xiongxiao.me/script.js" data-website-id="c21bf841-e707-4d37-bd0f-2685fe7826a7"></script></head>`); if (!addStat) {
return html;
}
const { websiteId } = config.stat || {};
if (!websiteId) {
return html;
}
return html.replace('</head>', `<script defer src="https://umami.xiongxiao.me/script.js" data-website-id="${websiteId}"></script></head>`);
}; };

View File

@ -296,8 +296,10 @@ export const handleRequest = async (req: http.IncomingMessage, res: http.ServerR
const filePath = path.join(fileStore, indexFilePath); const filePath = path.join(fileStore, indexFilePath);
if (!userApp.fileCheck(filePath)) { if (!userApp.fileCheck(filePath)) {
// 动态删除文件 // 动态删除文件
res.writeHead(500, { 'Content-Type': 'text/html; charset=utf-8' }); // res.writeHead(500, { 'Content-Type': 'text/html; charset=utf-8' });
res.write('App Cache expired, Please refresh\n'); // res.write('App Cache expired, Please refresh\n');
res.writeHead(500, { 'Content-Type': 'text/html; charset=utf-8', tips: 'App Cache expired, Please refresh' });
res.write(createRefreshHtml(user, app));
res.end(); res.end();
await userApp.clearCacheData(); await userApp.clearCacheData();
return; return;