|
|
@@ -78,11 +78,11 @@ export class OperationsVocabularyComponent implements OnInit {
|
|
|
this.preview.set({batchId:result.batchId,status:result.status,summary:result.previewSummary||{total:result.summary.total,create:0,update:0,unchanged:0,duplicate:0,error:0,missingMedia:0},items:result.items,createdAt:''});
|
|
|
}catch{this.error.set('上次导入进度暂时无法读取,请稍后重新打开词库页面核对');}
|
|
|
}
|
|
|
- async initialLoad(): Promise<void> {
|
|
|
+ async initialLoad(refresh = false): Promise<boolean> {
|
|
|
this.loading.set(true); this.error.set('');
|
|
|
this.selectedNodeId.set(0);
|
|
|
const [tree, words] = await Promise.allSettled([
|
|
|
- this.operations.vocabularyTree(),
|
|
|
+ this.operations.vocabularyTree(refresh),
|
|
|
this.operations.vocabulary(1, this.pageSize(), this.query(), { nodeId: 0, status: this.status(), missingAudio: this.missingAudio() }),
|
|
|
]);
|
|
|
if (tree.status === 'fulfilled') {
|
|
|
@@ -92,13 +92,17 @@ export class OperationsVocabularyComponent implements OnInit {
|
|
|
}
|
|
|
if (words.status === 'fulfilled') this.page.set(words.value);
|
|
|
const failures = [
|
|
|
- tree.status === 'rejected' ? this.errorText(tree.reason, '词库目录加载失败') : '',
|
|
|
- words.status === 'rejected' ? this.errorText(words.reason, '词条加载失败') : '',
|
|
|
+ tree.status === 'rejected' ? '词库目录:' + this.errorText(tree.reason, '加载失败') : '',
|
|
|
+ words.status === 'rejected' ? '词条列表:' + this.errorText(words.reason, '加载失败') : '',
|
|
|
].filter(Boolean);
|
|
|
if (failures.length) this.error.set(failures.join(';'));
|
|
|
this.loading.set(false);
|
|
|
+ return failures.length === 0;
|
|
|
+ }
|
|
|
+ async refresh(): Promise<void> {
|
|
|
+ this.message.set('');
|
|
|
+ if (await this.initialLoad(true)) this.message.set(`已从服务端刷新 · ${new Date().toLocaleTimeString('zh-CN')}`);
|
|
|
}
|
|
|
- async refresh(): Promise<void> { await this.initialLoad(); this.message.set(`已从服务端刷新 · ${new Date().toLocaleTimeString('zh-CN')}`); }
|
|
|
async loadWords(page = 1, setLoading = true): Promise<void> {
|
|
|
if (setLoading) this.loading.set(true); this.error.set('');
|
|
|
try { this.page.set(await this.operations.vocabulary(page, this.pageSize(), this.query(), { nodeId:this.selectedNodeId(), status:this.status(), missingAudio:this.missingAudio() })); }
|