Skip to content

Commit

Permalink
feat: 修改类型判断方法
Browse files Browse the repository at this point in the history
  • Loading branch information
chengweiw authored and boyongjiong committed Nov 11, 2024
1 parent f1884a2 commit b5528ad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 2 additions & 4 deletions packages/core/src/model/GraphModel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { find, forEach, map, merge } from 'lodash-es'
import { find, forEach, map, merge, isBoolean } from 'lodash-es'
import { action, computed, observable } from 'mobx'
import {
BaseEdgeModel,
Expand Down Expand Up @@ -1424,9 +1424,7 @@ export class GraphModel {
updateBackgroundOptions(
options: boolean | Partial<LFOptions.BackgroundConfig>,
) {
if (typeof options === 'boolean') {
this.background = options
} else if (typeof this.background === 'boolean') {
if (isBoolean(options) || isBoolean(this.background)) {
this.background = options
} else {
this.background = {
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/view/overlay/BackgroundOverlay.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component } from 'preact/compat'
import { isObject } from 'lodash-es'
import { Options as LFOptions } from '../../options'
import { observer } from '../..'

Expand All @@ -22,7 +23,7 @@ export class BackgroundOverlay extends Component<IProps> {
return (
<div className="lf-background">
<div
style={typeof background === 'object' ? background : {}}
style={isObject(background) ? background : {}}
className="lf-background-area"
/>
</div>
Expand Down

0 comments on commit b5528ad

Please sign in to comment.