diff --git a/src/domain/UserInfo.ts b/src/domain/UserInfo.ts index ff76eef..1dc26da 100644 --- a/src/domain/UserInfo.ts +++ b/src/domain/UserInfo.ts @@ -1,6 +1,7 @@ import { Remesh } from 'remesh' import { forkJoin, from, map, merge, tap } from 'rxjs' import Storage from './externs/Storage' +import { isEmpty } from '@/utils' const UserInfoDomain = Remesh.domain({ name: 'UserInfoDomain', @@ -49,7 +50,12 @@ const UserInfoDomain = Remesh.domain({ darkMode: from(storage.get(storageKeys.USER_INFO_DARK_MODE)) }).pipe( 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) } else { return SetUserInfoCommand(null) diff --git a/src/utils/index.ts b/src/utils/index.ts index d9f9ded..45b6364 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -5,3 +5,4 @@ export { default as createElement } from './createElement' export { default as getSiteInfo } from './getSiteInfo' export { default as chunk } from './chunk' export { default as compressImage } from './compressImage' +export { default as isEmpty } from './isEmpty' diff --git a/src/utils/isEmpty.ts b/src/utils/isEmpty.ts new file mode 100644 index 0000000..67b20ec --- /dev/null +++ b/src/utils/isEmpty.ts @@ -0,0 +1,6 @@ +/** 检查是否是空值 */ +const isEmpty = (value: any) => { + return value === undefined || value === null || value === '' +} + +export default isEmpty