enhance(frontend): 非同期的なコンポーネントの読み込み時のハンドリングを強化
This commit is contained in:
parent
8f025c447b
commit
d40c083233
|
@ -211,13 +211,17 @@ export async function popupAsyncWithDialog<T extends Component>(
|
||||||
props: ComponentProps<T>,
|
props: ComponentProps<T>,
|
||||||
events: Partial<ComponentEmit<T>> = {},
|
events: Partial<ComponentEmit<T>> = {},
|
||||||
): Promise<{ dispose: () => void }> {
|
): Promise<{ dispose: () => void }> {
|
||||||
const closeWaiting = waiting();
|
|
||||||
|
|
||||||
let component: T;
|
let component: T;
|
||||||
|
let closeWaiting = () => {};
|
||||||
|
|
||||||
|
const timer = window.setTimeout(() => {
|
||||||
|
closeWaiting = waiting();
|
||||||
|
}, 100); // コンポーネントがキャッシュされている場合にもwaitingが表示されて画面がちらつくのを防止するためにラグを追加
|
||||||
|
|
||||||
try {
|
try {
|
||||||
component = await componentFetching;
|
component = await componentFetching;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
window.clearTimeout(timer);
|
||||||
closeWaiting();
|
closeWaiting();
|
||||||
alert({
|
alert({
|
||||||
type: 'error',
|
type: 'error',
|
||||||
|
@ -227,6 +231,7 @@ export async function popupAsyncWithDialog<T extends Component>(
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.clearTimeout(timer);
|
||||||
closeWaiting();
|
closeWaiting();
|
||||||
|
|
||||||
markRaw(component);
|
markRaw(component);
|
||||||
|
|
Loading…
Reference in New Issue