temp
This commit is contained in:
		@@ -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,
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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>`);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user