diff --git a/src/module/config.ts b/src/module/config.ts
index 996ca9f..902b84e 100644
--- a/src/module/config.ts
+++ b/src/module/config.ts
@@ -39,6 +39,12 @@ type ConfigType = {
*/
allowedOrigin: string[];
};
+ stat: {
+ /**
+ * 统计网站ID
+ */
+ websiteId: string;
+ };
};
// export const config = useConfig();
@@ -61,4 +67,7 @@ export const config: ConfigType = {
resources: envConfig.PROXY_RESOURCES,
allowedOrigin: (envConfig.PROXY_ALLOWED_ORIGINS as string)?.split(',') || [],
},
+ stat: {
+ websiteId: envConfig.DATA_WEBSITE_ID,
+ },
};
diff --git a/src/module/html/stat/index.ts b/src/module/html/stat/index.ts
index 4348719..9869cde 100644
--- a/src/module/html/stat/index.ts
+++ b/src/module/html/stat/index.ts
@@ -1,8 +1,17 @@
+import { config } from '../../config.ts';
+
/**
* 添加统计脚本
* @param html
* @returns
*/
-export const addStat = (html: string) => {
- return html.replace('', ``);
+export const addStat = (html: string, addStat = true) => {
+ if (!addStat) {
+ return html;
+ }
+ const { websiteId } = config.stat || {};
+ if (!websiteId) {
+ return html;
+ }
+ return html.replace('', ``);
};
diff --git a/src/module/index.ts b/src/module/index.ts
index c7a6ee3..4ccd450 100644
--- a/src/module/index.ts
+++ b/src/module/index.ts
@@ -296,8 +296,10 @@ export const handleRequest = async (req: http.IncomingMessage, res: http.ServerR
const filePath = path.join(fileStore, indexFilePath);
if (!userApp.fileCheck(filePath)) {
// 动态删除文件
- res.writeHead(500, { 'Content-Type': 'text/html; charset=utf-8' });
- res.write('App Cache expired, Please refresh\n');
+ // res.writeHead(500, { 'Content-Type': 'text/html; charset=utf-8' });
+ // 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();
await userApp.clearCacheData();
return;