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(slide): fix slide resource red err (#7008)
VicKuncc421d116314
diff --git a/packages/core/src/services/resource-loader/resource-loader.service.ts b/packages/core/src/services/resource-loader/resource-loader.service.tsindex f701844eff..e71859be9e 100644--- a/packages/core/src/services/resource-loader/resource-loader.service.ts+++ b/packages/core/src/services/resource-loader/resource-loader.service.ts@@ -17,7 +17,7 @@import type { UnitModel } from '../../common/unit';import type { DocumentDataModel } from '../../docs';import type { Workbook } from '../../sheets/workbook';-import type { IResourceHook, IResourceName, IResources } from '../resource-manager/type';+import type { IResourceHook, IResourceName, IResourceSnapshot } from '../resource-manager/type';import type { IResourceLoaderService } from './type';import { isInternalEditorID } from '../../common/const';import { Inject } from '../../common/di';@@ -92,7 +92,7 @@ export class ResourceLoaderService extends Disposable implements IResourceLoaderbreak;}case UniverInstanceType.UNIVER_SLIDE: {- this._univerInstanceService.getAllUnitsForType<UnitModel<{ resources?: IResources }>>(UniverInstanceType.UNIVER_SLIDE).forEach((slide) => {+ this._univerInstanceService.getAllUnitsForType<UnitModel<{ resources?: IResourceSnapshot }>>(UniverInstanceType.UNIVER_SLIDE).forEach((slide) => {loadHookResource(hook, slide.getUnitId(), slide.getSnapshot().resources, 'Slide');});break;@@ -101,6 +101,7 @@ export class ResourceLoaderService extends Disposable implements IResourceLoaderthis._univerInstanceService.getAllUnitsForType<Workbook>(UniverInstanceType.UNIVER_SHEET).forEach((workbook) => {loadHookResource(hook, workbook.getUnitId(), workbook.getSnapshot().resources, 'Workbook');});+ break;}}});@@ -127,7 +128,7 @@ export class ResourceLoaderService extends Disposable implements IResourceLoader}));this.disposeWithMe(- this._univerInstanceService.getTypeOfUnitAdded$<UnitModel<{ resources?: IResources }>>(UniverInstanceType.UNIVER_SLIDE).subscribe((event) => {+ this._univerInstanceService.getTypeOfUnitAdded$<UnitModel<{ resources?: IResourceSnapshot }>>(UniverInstanceType.UNIVER_SLIDE).subscribe((event) => {const { unit: slide } = event;this._resourceManagerService.loadResources(slide.getUnitId(), slide.getSnapshot().resources);})diff --git a/packages/core/src/services/resource-manager/resource-manager.service.ts b/packages/core/src/services/resource-manager/resource-manager.service.tsindex f50f690f2d..e92180a957 100644--- a/packages/core/src/services/resource-manager/resource-manager.service.ts+++ b/packages/core/src/services/resource-manager/resource-manager.service.ts@@ -15,7 +15,7 @@*/import type { UniverInstanceType } from '../../common/unit';-import type { IResourceHook, IResourceManagerService, IResourceName, IResources } from './type';+import type { IResourceHook, IResourceManagerService, IResourceName, IResources, IResourceSnapshot } from './type';import { Subject } from 'rxjs';import { Disposable, toDisposable } from '../../shared/lifecycle';import { ILogService } from '../log/log.service';@@ -79,7 +79,7 @@ export class ResourceManagerService extends Disposable implements IResourceManagthis._resourceMap.delete(pluginName);}- public loadResources(unitId: string, resources?: IResources) {+ public loadResources(unitId: string, resources?: IResourceSnapshot) {this.getAllResourceHooks().forEach((hook) => {const data = this._getResourceData(resources, hook.pluginName);if (data) {diff --git a/packages/core/src/services/resource-manager/type.ts b/packages/core/src/services/resource-manager/type.tsindex e304be725b..5afa6e12e8 100644--- a/packages/core/src/services/resource-manager/type.ts+++ b/packages/core/src/services/resource-manager/type.ts@@ -20,8 +20,9 @@ import type { UniverInstanceType } from '../../common/unit';import { createIdentifier } from '../../common/di';export type IResources = Array<{ id?: string; name: string; data: string }>;+export type IResourceSnapshot = IResources | Record<string, unknown>;-type IBusinessName = 'SHEET' | 'DOC';+type IBusinessName = 'SHEET' | 'DOC' | 'SLIDE';export type IResourceName = `${IBusinessName}_${string}_PLUGIN`;export interface IResourceHook<T = any> {pluginName: IResourceName;@@ -41,7 +42,7 @@ export interface IResourceManagerService {getResources(unitId: string, type: UniverInstanceType): IResources;getResourcesByType: (unitId: string, type: UniverInstanceType) => IResources;- loadResources: (unitId: string, resources?: IResources) => void;+ loadResources: (unitId: string, resources?: IResourceSnapshot) => void;unloadResources(unitId: string, type: UniverInstanceType): void;}