Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix: fix resource unload (#6000)
wpxp1234563608424e82b0
diff --git a/packages/core/src/services/resource-loader/resource-loader.service.ts b/packages/core/src/services/resource-loader/resource-loader.service.tsindex 2b41f1ad69..46705f31c1 100644--- a/packages/core/src/services/resource-loader/resource-loader.service.ts+++ b/packages/core/src/services/resource-loader/resource-loader.service.ts@@ -98,13 +98,13 @@ export class ResourceLoaderService extends Disposable implements IResourceLoaderthis.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$<Workbook>(UniverInstanceType.UNIVER_SHEET).subscribe((workbook) => {- this._resourceManagerService.unloadResources(workbook.getUnitId());+ this._resourceManagerService.unloadResources(workbook.getUnitId(), UniverInstanceType.UNIVER_SHEET);}));this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$<DocumentDataModel>(UniverInstanceType.UNIVER_DOC).subscribe((doc) => {- this._resourceManagerService.unloadResources(doc.getUnitId());+ this._resourceManagerService.unloadResources(doc.getUnitId(), UniverInstanceType.UNIVER_DOC);}));}diff --git a/packages/core/src/services/resource-manager/resource-manager.service.ts b/packages/core/src/services/resource-manager/resource-manager.service.tsindex 4298235637..1c09f110c9 100644--- a/packages/core/src/services/resource-manager/resource-manager.service.ts+++ b/packages/core/src/services/resource-manager/resource-manager.service.ts@@ -94,8 +94,8 @@ export class ResourceManagerService extends Disposable implements IResourceManag});}- public unloadResources(unitId: string) {- this.getAllResourceHooks().forEach((hook) => {+ public unloadResources(unitId: string, type: UniverInstanceType) {+ this.getAllResourceHooks().filter((hook) => hook.businesses.includes(type)).forEach((hook) => {hook.onUnLoad(unitId);});}diff --git a/packages/core/src/services/resource-manager/type.ts b/packages/core/src/services/resource-manager/type.tsindex d1e9c338a9..882a45d868 100644--- a/packages/core/src/services/resource-manager/type.ts+++ b/packages/core/src/services/resource-manager/type.ts@@ -46,7 +46,7 @@ export interface IResourceManagerService {getResources(unitId: string, type: UniverInstanceType): IResources;getResourcesByType: (unitId: string, type: UniverInstanceType) => IResources;loadResources: (unitId: string, resources?: IResources) => void;- unloadResources(unitId: string): void;+ unloadResources(unitId: string, type: UniverInstanceType): void;}export const IResourceManagerService = createIdentifier<IResourceManagerService>('core.resource-manager.service');diff --git a/packages/sheets-conditional-formatting/src/services/conditional-formatting.service.ts b/packages/sheets-conditional-formatting/src/services/conditional-formatting.service.tsindex 6cc3192748..93fa0f7646 100644--- a/packages/sheets-conditional-formatting/src/services/conditional-formatting.service.ts+++ b/packages/sheets-conditional-formatting/src/services/conditional-formatting.service.ts@@ -28,7 +28,7 @@ import type {import type { IDeleteConditionalRuleMutationParams } from '../commands/mutations/delete-conditional-rule.mutation';import type { IConditionFormattingRule, IHighlightCell, IRuleModelJson } from '../models/type';import type { IDataBarCellData, IDataBarRenderParams, IIconSetCellData, IIconSetRenderParams } from '../render/type';-import { Disposable, ICommandService, Inject, Injector, IResourceManagerService, IUniverInstanceService, merge, ObjectMatrix, Rectangle, UniverInstanceType } from '@univerjs/core';+import { Disposable, ICommandService, Inject, Injector, IResourceManagerService, isInternalEditorID, IUniverInstanceService, merge, ObjectMatrix, Rectangle, UniverInstanceType } from '@univerjs/core';import {InsertColMutation,InsertRowMutation,@@ -138,6 +138,7 @@ export class ConditionalFormattingService extends Disposable {parseJson: (json) => parseJson(json),onUnLoad: (unitID) => {this._conditionalFormattingRuleModel.deleteUnitId(unitID);+ if (isInternalEditorID(unitID)) return;this._conditionalFormattingViewModelV2.dispose();},onLoad: (unitID, value) => {