@bdlite/domains 1.1.33 → 1.1.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/layout/channel/index.js +5 -5
- package/es/layout/channel/menu-item.js +5 -5
- package/es/layout/channel/menu.js +5 -5
- package/es/layout/constants.js +22 -22
- package/es/layout/index.js +12 -12
- package/es/layout/menu-item.js +14 -14
- package/es/layout/menu.js +14 -14
- package/es/portrait-selector.js +43 -43
- package/es/sider/constants.js +2 -2
- package/es/sider/plugin.js +12 -12
- package/es/system-config/channel.js +6 -6
- package/es/system-config/constants.js +10 -10
- package/es/system-config/index.js +120 -116
- package/es/team/index.js +114 -114
- package/es/user/login.js +26 -26
- package/es/workspace/index.js +96 -96
- package/package.json +44 -44
- package/es/user/channel.js +0 -7
- package/es/user/constants.js +0 -11
- package/es/user/images.js +0 -3
- package/es/user/index.js +0 -118
package/es/user/index.js
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { createObservableKit } from '@bdlite/observable/es/create-observable-kit'
|
|
3
|
-
|
|
4
|
-
import { isUndefined } from '@bdlite/strategy'
|
|
5
|
-
import { checkImgExists } from '@bdlite/helpers/es/check-img-exists'
|
|
6
|
-
|
|
7
|
-
import { CHANNEL_NAME, PLACEHOLDER, DEFAULT_GENDER, AVATAR_BOY_IMG, AVATAR_GIRL_IMG, DEFAULT_AVATAR_PATH } from './constants'
|
|
8
|
-
|
|
9
|
-
// 登录用户信息
|
|
10
|
-
const { getData, subscribe, publish } = createObservableKit({ id: null, name: '', account: '', email: '' }, null, { channelName: CHANNEL_NAME })
|
|
11
|
-
const avatarOb = createObservableKit({ avatar: DEFAULT_AVATAR_PATH, gender: DEFAULT_GENDER })
|
|
12
|
-
const userShowOb = createObservableKit({ showName: PLACEHOLDER, showEmail: PLACEHOLDER })
|
|
13
|
-
|
|
14
|
-
const _userInfo = getData()
|
|
15
|
-
|
|
16
|
-
export const subscribeUser = subscribe
|
|
17
|
-
export const subscribeUserShow = userShowOb.subscribe
|
|
18
|
-
|
|
19
|
-
export const subscribeAvatar = avatarOb.subscribe
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @function showRules
|
|
23
|
-
* @param {?string} defaultName
|
|
24
|
-
* @param {?string} defaultEmail
|
|
25
|
-
* @returns {object} { showName, showEmail }
|
|
26
|
-
*/
|
|
27
|
-
export const getShowRules = userInfo => (defaultName = PLACEHOLDER, defaultEmail = PLACEHOLDER) => {
|
|
28
|
-
const { email, account, name, mobile, username } = userInfo
|
|
29
|
-
const showEmail = email || defaultEmail
|
|
30
|
-
const showName = name || mobile || username || account || defaultName
|
|
31
|
-
return { showName, showEmail }
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async function getAvatar(expandInfo = []) {
|
|
35
|
-
let avatar
|
|
36
|
-
let gender = DEFAULT_GENDER
|
|
37
|
-
|
|
38
|
-
expandInfo.forEach(item => {
|
|
39
|
-
const { infoItem, infoValue } = item || {}
|
|
40
|
-
|
|
41
|
-
if (infoItem === 'avatar') {
|
|
42
|
-
avatar = infoValue
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (infoItem === 'gender') {
|
|
46
|
-
gender = isUndefined(infoValue) ? DEFAULT_GENDER : infoValue
|
|
47
|
-
}
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
try {
|
|
51
|
-
await checkImgExists(avatar)
|
|
52
|
-
} catch (e) {
|
|
53
|
-
avatar = gender === '0' ? AVATAR_GIRL_IMG : AVATAR_BOY_IMG
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return { avatar, gender }
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* @function storeUser
|
|
61
|
-
* @param {?object} user
|
|
62
|
-
*/
|
|
63
|
-
export async function storeUser(user) {
|
|
64
|
-
if (!user) return
|
|
65
|
-
|
|
66
|
-
const {
|
|
67
|
-
username = '', mobile = '', name = '', account = '', email = '',
|
|
68
|
-
expandInfo, ...rest
|
|
69
|
-
} = user
|
|
70
|
-
|
|
71
|
-
Object.assign(_userInfo, { username, mobile, name, account, email, expandInfo, ...rest })
|
|
72
|
-
publish({ ..._userInfo })
|
|
73
|
-
|
|
74
|
-
const showData = getShowRules(_userInfo)()
|
|
75
|
-
userShowOb.publish(showData)
|
|
76
|
-
|
|
77
|
-
if (expandInfo) {
|
|
78
|
-
const avatarData = await getAvatar(expandInfo)
|
|
79
|
-
avatarOb.publish(avatarData)
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export function publishUser(user) {
|
|
84
|
-
const { username = '', mobile = '', name = '', account = '', email = '', ...rest } = user
|
|
85
|
-
Object.assign(_userInfo, { username, mobile, name, account, email, ...rest })
|
|
86
|
-
publish({ ..._userInfo })
|
|
87
|
-
|
|
88
|
-
const showData = getShowRules(_userInfo)()
|
|
89
|
-
userShowOb.publish(showData)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export async function publishAvatar(user) {
|
|
93
|
-
const { expandInfo } = user
|
|
94
|
-
|
|
95
|
-
if (!expandInfo) return
|
|
96
|
-
|
|
97
|
-
Object.assign(_userInfo, { expandInfo })
|
|
98
|
-
publish({ ..._userInfo })
|
|
99
|
-
|
|
100
|
-
const avatarData = await getAvatar(expandInfo)
|
|
101
|
-
avatarOb.publish(avatarData)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* @function getUser
|
|
106
|
-
* @returns {object} userInfo
|
|
107
|
-
*/
|
|
108
|
-
export function getUser() {
|
|
109
|
-
return { ..._userInfo }
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* @function getUserId
|
|
114
|
-
* @returns {?number} id
|
|
115
|
-
*/
|
|
116
|
-
export function getUserId() {
|
|
117
|
-
return _userInfo.id
|
|
118
|
-
}
|