mirror of
https://github.com/dream-num/univer.git
synced 2026-09-24 15:32:18 +08:00
fix: fix univer plugin not started
This commit is contained in:
@@ -37,7 +37,7 @@ export class PluginService implements IDisposable {
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this._clearFlushLazyPluginsTimer();
|
||||
this._clearFlushTimer();
|
||||
|
||||
for (const holder of this._pluginHoldersForTypes.values()) {
|
||||
holder.dispose();
|
||||
@@ -93,27 +93,31 @@ export class PluginService implements IDisposable {
|
||||
}
|
||||
}
|
||||
|
||||
private _initLazyPluginsTimer?: number;
|
||||
private _flushTimer?: number;
|
||||
private _scheduleInitPlugin() {
|
||||
if (this._initLazyPluginsTimer === undefined) {
|
||||
this._initLazyPluginsTimer = setTimeout(
|
||||
if (this._flushTimer === undefined) {
|
||||
this._flushTimer = setTimeout(
|
||||
() => {
|
||||
this._flushLazyPlugins();
|
||||
this._clearFlushLazyPluginsTimer();
|
||||
if (!this._pluginHolderForUniver.started) {
|
||||
this._pluginHolderForUniver.start();
|
||||
}
|
||||
|
||||
this._flushPlugins();
|
||||
this._clearFlushTimer();
|
||||
},
|
||||
INIT_LAZY_PLUGINS_TIMEOUT
|
||||
) as unknown as number;
|
||||
}
|
||||
}
|
||||
|
||||
private _clearFlushLazyPluginsTimer() {
|
||||
if (this._initLazyPluginsTimer) {
|
||||
clearTimeout(this._initLazyPluginsTimer);
|
||||
this._initLazyPluginsTimer = undefined;
|
||||
private _clearFlushTimer() {
|
||||
if (this._flushTimer) {
|
||||
clearTimeout(this._flushTimer);
|
||||
this._flushTimer = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
private _flushLazyPlugins() {
|
||||
private _flushPlugins() {
|
||||
this._pluginHolderForUniver.flush();
|
||||
for (const [_, holder] of this._pluginHoldersForTypes) {
|
||||
if (holder.started) {
|
||||
|
||||
@@ -119,7 +119,7 @@ export class Univer {
|
||||
const univerInstanceService = injector.get(IUniverInstanceService) as UniverInstanceService;
|
||||
univerInstanceService.__setCreateHandler(
|
||||
(type: UnitType, data, ctor) => {
|
||||
this._tryProgressToStart();
|
||||
this._pluginService.start();
|
||||
|
||||
if (!this._startedTypes.has(type)) {
|
||||
this._pluginService.startPluginForType(type);
|
||||
@@ -140,10 +140,6 @@ export class Univer {
|
||||
);
|
||||
}
|
||||
|
||||
private _tryProgressToStart(): void {
|
||||
this._pluginService.start();
|
||||
}
|
||||
|
||||
private _tryProgressToReady(): void {
|
||||
const lifecycleService = this._injector.get(LifecycleService);
|
||||
if (lifecycleService.stage < LifecycleStages.Ready) {
|
||||
|
||||
Reference in New Issue
Block a user