feat: 更新助手配置,添加应用ID和URL,优化身份验证和代理逻辑
This commit is contained in:
@@ -44,7 +44,7 @@ export class LocalProxy {
|
||||
initFromAssistantConfig(assistantConfig?: AssistantConfig) {
|
||||
if (!assistantConfig) return;
|
||||
this.pagesDir = assistantConfig.configPath?.pagesDir || '';
|
||||
this.watch = !!assistantConfig.getCacheAssistantConfig()?.watch.enabled;
|
||||
this.watch = assistantConfig.getCacheAssistantConfig?.()?.watch?.enabled ?? true;
|
||||
this.init();
|
||||
if (this.watch) {
|
||||
this.onWatch();
|
||||
@@ -112,14 +112,26 @@ export class LocalProxy {
|
||||
};
|
||||
fs.watch(frontAppDir, { recursive: true }, (eventType, filename) => {
|
||||
if (eventType === 'rename' || eventType === 'change') {
|
||||
// 过滤 node_modules 目录
|
||||
if (filename && filename.includes('node_modules')) {
|
||||
return;
|
||||
}
|
||||
// 只监听 js、html、css 文件
|
||||
const validExtensions = ['.js', '.html', '.css', '.json', '.png'];
|
||||
const hasValidExtension = validExtensions.some(ext => filename && filename.endsWith(ext));
|
||||
|
||||
if (!hasValidExtension) {
|
||||
return;
|
||||
}
|
||||
|
||||
const filePath = path.join(frontAppDir, filename);
|
||||
try {
|
||||
const stat = fs.statSync(filePath);
|
||||
if (stat.isDirectory() || filename.endsWith('.html')) {
|
||||
if (stat.isFile() || stat.isDirectory()) {
|
||||
// 重新加载
|
||||
debounce(that.init.bind(that), 5 * 1000);
|
||||
}
|
||||
} catch (error) {}
|
||||
} catch (error) { }
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user