Skip to content

Commit

Permalink
refactor(editor): service中state改完使用shallowReactive
Browse files Browse the repository at this point in the history
  • Loading branch information
roymondchen committed Jan 9, 2025
1 parent 1bcefdb commit 552df3a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/editor/src/services/componentList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
* limitations under the License.
*/

import { reactive } from 'vue';
import { shallowReactive } from 'vue';

import type { ComponentGroup, ComponentGroupState } from '@editor/type';

import BaseService from './BaseService';

class ComponentList extends BaseService {
private state = reactive<ComponentGroupState>({
private state = shallowReactive<ComponentGroupState>({
list: [],
});

Expand Down
4 changes: 2 additions & 2 deletions packages/editor/src/services/dep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { reactive } from 'vue';
import { reactive, shallowReactive } from 'vue';

import type { DepExtendedData, Id, MNode, Target, TargetNode } from '@tmagic/core';
import { DepTargetType, Watcher } from '@tmagic/core';
Expand All @@ -40,7 +40,7 @@ type StateKey = keyof State;
const idleTask = new IdleTask<{ node: TargetNode; deep: boolean; target: Target }>();

class Dep extends BaseService {
private state = reactive<State>({
private state = shallowReactive<State>({
collecting: false,
});

Expand Down
4 changes: 2 additions & 2 deletions packages/editor/src/services/stageOverlay.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { reactive } from 'vue';
import { shallowReactive } from 'vue';
import type { Writable } from 'type-fest';

import StageCore from '@tmagic/stage';
Expand All @@ -17,7 +17,7 @@ const canUsePluginMethods = {
type SyncMethodName = Writable<(typeof canUsePluginMethods)['sync']>;

class StageOverlay extends BaseService {
private state: StageOverlayState = reactive({
private state: StageOverlayState = shallowReactive({
wrapDiv: document.createElement('div'),
sourceEl: null,
contentEl: null,
Expand Down
4 changes: 2 additions & 2 deletions packages/editor/src/services/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

import { reactive } from 'vue';
import { shallowReactive } from 'vue';
import type { Writable } from 'type-fest';

import { convertToNumber } from '@tmagic/utils';
Expand All @@ -26,7 +26,7 @@ import type { AsyncHookPlugin, StageRect, UiState } from '@editor/type';

import BaseService from './BaseService';

const state = reactive<UiState>({
const state = shallowReactive<UiState>({
uiSelectMode: false,
showSrc: false,
showStylePanel: true,
Expand Down

0 comments on commit 552df3a

Please sign in to comment.