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(protect): fix protect performance (#3520)
VicKund8b92711919b
diff --git a/packages/sheets/src/model/range-protection-render.model.ts b/packages/sheets/src/model/range-protection-render.model.tsindex e0417ca160..371693c9bc 100644--- a/packages/sheets/src/model/range-protection-render.model.ts+++ b/packages/sheets/src/model/range-protection-render.model.ts@@ -15,16 +15,16 @@*/import { Inject, IPermissionService, LifecycleStages, LRUMap, OnLifecycle, Range } from '@univerjs/core';-import { filter, map } from 'rxjs/operators';-import type { UnitAction } from '@univerjs/protocol';import { UnitObject } from '@univerjs/protocol';-+import { filter, map } from 'rxjs/operators';import type { IRange } from '@univerjs/core';-import type { getDefaultRangePermission, IRangePermissionPoint } from '../services/permission/range-permission/util';-import { getAllRangePermissionPoint } from '../services/permission/range-permission/util';+import type { UnitAction } from '@univerjs/protocol';+import { getAllRangePermissionPoint } from '../services/permission/range-permission/util';import { RangeProtectionRuleModel } from './range-protection-rule.model';+import type { getDefaultRangePermission, IRangePermissionPoint } from '../services/permission/range-permission/util';+export type ICellPermission = Record<UnitAction, boolean> & { ruleId?: string; ranges?: IRange[] };@OnLifecycle(LifecycleStages.Ready, RangeProtectionRenderModel)@@ -80,16 +80,16 @@ export class RangeProtectionRenderModel {}public getCellInfo(unitId: string, subUnitId: string, row: number, col: number) {- const key = this._createKey(unitId, subUnitId, row, col);- const cacheValue = this._cache.get(key);- if (cacheValue) {- return cacheValue;- }const ruleMap = this._selectionProtectionRuleModel.getSubunitRuleList(unitId, subUnitId);const defaultV: ICellPermission[] = [];if (!ruleMap || !ruleMap.length) {return defaultV;}+ const key = this._createKey(unitId, subUnitId, row, col);+ const cacheValue = this._cache.get(key);+ if (cacheValue) {+ return cacheValue;+ }const result: ICellPermission[] = [];for (const rule of ruleMap) {if (rule.ranges.some((range) => range.startRow <= row && range.endRow >= row && range.startColumn <= col && range.endColumn >= col)) {