chore(form): fix null value detection problem
This commit is contained in:
parent
f55a7f479d
commit
92ba396ec0
3 changed files with 14 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
import { Remesh } from 'remesh'
|
import { Remesh } from 'remesh'
|
||||||
import { forkJoin, from, map, merge, tap } from 'rxjs'
|
import { forkJoin, from, map, merge, tap } from 'rxjs'
|
||||||
import Storage from './externs/Storage'
|
import Storage from './externs/Storage'
|
||||||
|
import { isEmpty } from '@/utils'
|
||||||
|
|
||||||
const UserInfoDomain = Remesh.domain({
|
const UserInfoDomain = Remesh.domain({
|
||||||
name: 'UserInfoDomain',
|
name: 'UserInfoDomain',
|
||||||
|
@ -49,7 +50,12 @@ const UserInfoDomain = Remesh.domain({
|
||||||
darkMode: from(storage.get<UserInfo['darkMode']>(storageKeys.USER_INFO_DARK_MODE))
|
darkMode: from(storage.get<UserInfo['darkMode']>(storageKeys.USER_INFO_DARK_MODE))
|
||||||
}).pipe(
|
}).pipe(
|
||||||
map((userInfo) => {
|
map((userInfo) => {
|
||||||
if (userInfo.id && userInfo.name && userInfo.avatar && userInfo.darkMode) {
|
if (
|
||||||
|
!isEmpty(userInfo.id) &&
|
||||||
|
!isEmpty(userInfo.name) &&
|
||||||
|
!isEmpty(userInfo.avatar) &&
|
||||||
|
!isEmpty(userInfo.darkMode)
|
||||||
|
) {
|
||||||
return SetUserInfoCommand(userInfo as UserInfo)
|
return SetUserInfoCommand(userInfo as UserInfo)
|
||||||
} else {
|
} else {
|
||||||
return SetUserInfoCommand(null)
|
return SetUserInfoCommand(null)
|
||||||
|
|
|
@ -5,3 +5,4 @@ export { default as createElement } from './createElement'
|
||||||
export { default as getSiteInfo } from './getSiteInfo'
|
export { default as getSiteInfo } from './getSiteInfo'
|
||||||
export { default as chunk } from './chunk'
|
export { default as chunk } from './chunk'
|
||||||
export { default as compressImage } from './compressImage'
|
export { default as compressImage } from './compressImage'
|
||||||
|
export { default as isEmpty } from './isEmpty'
|
||||||
|
|
6
src/utils/isEmpty.ts
Normal file
6
src/utils/isEmpty.ts
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
/** 检查是否是空值 */
|
||||||
|
const isEmpty = (value: any) => {
|
||||||
|
return value === undefined || value === null || value === ''
|
||||||
|
}
|
||||||
|
|
||||||
|
export default isEmpty
|
Loading…
Reference in a new issue