设置i18n刷新定时器
This commit is contained in:
parent
09fe290ad2
commit
9fd8253007
|
|
@ -98,6 +98,11 @@
|
|||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "启用Checker检查(极其消耗性能)"
|
||||
},
|
||||
"oak-assistant.localesRefreshInterval": {
|
||||
"type": "number",
|
||||
"default": 300000,
|
||||
"description": "组件的国际化文件主动刷新间隔(小于1000表示不主动刷新)"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -466,10 +466,44 @@ export const addKeyToLocale = (
|
|||
error: '暂不支持entity的locales编辑',
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
assert(false, '不应该走到这里');
|
||||
};
|
||||
|
||||
// 主动定时刷新缓存
|
||||
const setRefreshInterval = () => {
|
||||
|
||||
let timer: NodeJS.Timeout | null = null;
|
||||
|
||||
if (timer) {
|
||||
clearInterval(timer);
|
||||
}
|
||||
|
||||
const refresh = () => {
|
||||
const componentsPath = componentConfig.getAllComponents().map((c) => {
|
||||
return c.path;
|
||||
});
|
||||
componentsPath.forEach((path) => {
|
||||
updatePathCached(path);
|
||||
});
|
||||
};
|
||||
|
||||
// 获取配置项
|
||||
const config = vscode.workspace.getConfiguration('oak-assistant').get('localesRefreshInterval');
|
||||
|
||||
assert(typeof config === 'number', '配置项必须是数字');
|
||||
|
||||
// 如果配置项小于1000,则不刷新
|
||||
if (config < 1000) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('设置i18n刷新定时器', config);
|
||||
|
||||
// 设置定时器
|
||||
timer = setInterval(refresh, config);
|
||||
};
|
||||
|
||||
subscribeEntity('#all', (name) => {
|
||||
setEntityLocales(name);
|
||||
});
|
||||
|
|
@ -478,3 +512,5 @@ subscribeEntity('#all', (name) => {
|
|||
subsPath(() => {
|
||||
setNameSpaceLocales();
|
||||
});
|
||||
|
||||
setRefreshInterval();
|
||||
Loading…
Reference in New Issue