@bdlite/domains 1.1.20 → 1.1.23

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.
@@ -1,4 +1,4 @@
1
- import { isUndefined } from '@bdlite/utils'
1
+ import { isUndefined } from '@bdlite/strategy'
2
2
 
3
3
  import { createObservableKit, createSubChannelKit } from '@bdlite/observable/es/create-observable-kit'
4
4
 
@@ -4,4 +4,4 @@ import { CHANNEL_NAME } from './constants'
4
4
  // 登录用户信息
5
5
  const { subscribe } = createSubChannelKit({ channelName: CHANNEL_NAME }, { relay: 1 })
6
6
 
7
- export const subscribeUser = subscribe
7
+ export const subscribeSysConfig = subscribe
@@ -0,0 +1,11 @@
1
+ export const CHANNEL_NAME = 'system_customization_config_data'
2
+
3
+ // 系统自定义数据
4
+ export const DEFAULT_USERAGREEMENT = ''
5
+ export const DEFAULT_TITLE = '数据治理平台'
6
+ export const DEFAULT_FAVICON = '/base/images/favicon.ico'
7
+ export const DEFAULT_LOGO = '/base/images/logo-fallback.svg' // '/base/images/logo.svg'
8
+ export const DEFAULT_LOGINLOGO = '/base/images/login-logo.png'
9
+ export const DEFAULT_COPYRIGHT = '© 2024 radar.qihoo.net 数据平台部 All Rights Reserved'
10
+
11
+ export const DEEFAULT_APP = 'govern' // govern: 治理平台, share:共享交换平台
@@ -0,0 +1,101 @@
1
+ import storage from '@bdlite/helpers/es/storage'
2
+ import { createObservableKit } from '@bdlite/observable/es/create-observable-kit'
3
+
4
+ import { CHANNEL_NAME, DEFAULT_USERAGREEMENT, DEEFAULT_APP, DEFAULT_TITLE, DEFAULT_FAVICON, DEFAULT_LOGO, DEFAULT_LOGINLOGO, DEFAULT_COPYRIGHT } from './constants'
5
+
6
+
7
+ const DEFAULT_CONTRACTOR_ID = null
8
+
9
+
10
+ const { getData, subscribe, publish } = createObservableKit({
11
+ contractName: '',
12
+ contactorId: DEFAULT_CONTRACTOR_ID,
13
+ logo: DEFAULT_LOGO,
14
+ title: DEFAULT_TITLE,
15
+ favicon: DEFAULT_FAVICON,
16
+ loginLogo: DEFAULT_LOGINLOGO,
17
+ copyright: DEFAULT_COPYRIGHT,
18
+ useragreement: DEFAULT_USERAGREEMENT,
19
+ app: DEEFAULT_APP,
20
+ }, null, { channelName: CHANNEL_NAME })
21
+ const _systemConfig = getData()
22
+
23
+
24
+ /**
25
+ * @function getSysConfig
26
+ */
27
+ export function getSysConfig() {
28
+ try {
29
+ const {
30
+ contractName = '',
31
+ contactorId = DEFAULT_CONTRACTOR_ID,
32
+ logo = DEFAULT_LOGO,
33
+ title = DEFAULT_TITLE,
34
+ favicon = DEFAULT_FAVICON,
35
+ loginLogo = DEFAULT_LOGINLOGO,
36
+ copyright = DEFAULT_COPYRIGHT,
37
+ useragreement = DEFAULT_USERAGREEMENT,
38
+ app = DEEFAULT_APP
39
+ } = storage.getObject(CHANNEL_NAME)
40
+
41
+ Object.assign(_systemConfig, {
42
+ contactorId, contractName,
43
+ favicon, logo, loginLogo,
44
+ title: title.trim(),
45
+ copyright: copyright.trim(),
46
+ useragreement: useragreement.trim(),
47
+ app
48
+ })
49
+ return { ..._systemConfig }
50
+ } catch (e) {
51
+ return { ..._systemConfig }
52
+ }
53
+ }
54
+
55
+ /**
56
+ * @function storeSysConfig
57
+ * @param {?object} systemConfig
58
+ */
59
+ export function storeSysConfig(systemConfig) {
60
+ if (!systemConfig) return
61
+ const { mainLogo, copyright, eula, preload = {}, contactor, contactorInfo = {} } = systemConfig
62
+ const { title, favicon, loginLogo, appRunning } = preload
63
+ Object.assign(_systemConfig, {
64
+ contactorId: contactor, contractName: contactorInfo.display || '',
65
+ favicon, loginLogo, logo: mainLogo,
66
+ title: title?.trim(), copyright: copyright?.trim(), useragreement: eula?.trim(),
67
+ app: appRunning
68
+ })
69
+ storage.appendObject(CHANNEL_NAME, _systemConfig)
70
+ publish(_systemConfig)
71
+ }
72
+
73
+ /**
74
+ * @function publishPreload
75
+ * @param {?object} config
76
+ */
77
+ export function publishPreload(config) {
78
+ if (!config) return
79
+ const { title, favicon, loginLogo, copyright, eula } = config
80
+ Object.assign(_systemConfig, {
81
+ favicon, loginLogo,
82
+ title: title?.trim(), copyright: copyright?.trim(), useragreement: eula?.trim()
83
+ })
84
+ publish(_systemConfig)
85
+ }
86
+
87
+
88
+ /**
89
+ * @function subscribeSysConfig
90
+ * @param {function | object} mountedFunOrConfig
91
+ * @param {?function} unmountedFun
92
+ * @returns {function} unsubscribe
93
+ */
94
+ export const subscribeSysConfig = subscribe
95
+
96
+ /**
97
+ * @function publishSysConfig
98
+ */
99
+ export function publishSysConfig() {
100
+ publish(getSysConfig())
101
+ }
@@ -1,5 +1,6 @@
1
1
  import { createObservableKit, createSubChannelKit } from '@bdlite/observable/es/create-observable-kit'
2
- import { LOGIN_CHANNEL_NAME } from './constants'
2
+
3
+ const LOGIN_CHANNEL_NAME = 'userlogin'
3
4
 
4
5
  const _timestamp = new Date().getTime()
5
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bdlite/domains",
3
- "version": "1.1.20",
3
+ "version": "1.1.23",
4
4
  "description": "A domains entity collection library driven by @bdlite/observable",
5
5
  "keywords": [
6
6
  "DDD",
@@ -20,12 +20,14 @@
20
20
  ],
21
21
  "license": "MIT",
22
22
  "peerDependencies": {
23
- "@bdlite/observable": "^1.0.0",
23
+ "@bdlite/helpers": "^1.1.0",
24
+ "@bdlite/observable": "^1.1.20",
24
25
  "@bdlite/strategy": "^1.1.0"
25
26
  },
26
27
  "dependencies": {
28
+ "@bdlite/helpers": "^1.1.22",
27
29
  "@bdlite/observable": "^1.1.20",
28
- "@bdlite/strategy": "^1.1.20"
30
+ "@bdlite/strategy": "^1.1.22"
29
31
  },
30
32
  "devDependencies": {
31
33
  "@rollup/plugin-babel": "6.0.4",
@@ -38,5 +40,5 @@
38
40
  "rollup-plugin-typescript2": "^0.29.0",
39
41
  "typescript": "^4.4.3"
40
42
  },
41
- "gitHead": "fcfa775c4da2daada3c63aa020bb7a3a968dfd40"
43
+ "gitHead": "e737ed039e465ede352a425de20ed7c56f41b95c"
42
44
  }
@@ -1,2 +0,0 @@
1
- export const CHANNEL_NAME = 'user'
2
- export const LOGIN_CHANNEL_NAME = 'userlogin'
package/es/user/index.js DELETED
@@ -1,48 +0,0 @@
1
- import { createObservableKit } from '@bdlite/observable/es/create-observable-kit'
2
- import { CHANNEL_NAME } from './constants'
3
-
4
- // 登录用户信息
5
- const { getData, subscribe, publish } = createObservableKit({ id: null, name: '', account: '', email: '' }, null, { channelName: CHANNEL_NAME })
6
- const _userInfo = getData()
7
-
8
- export const subscribeUser = subscribe
9
-
10
- /**
11
- * @function showRules
12
- * @param {?string} defaultName
13
- * @param {?string} defaultEmail
14
- * @returns {object} { showName, showEmail }
15
- */
16
- export const getShowRules = userInfo => (defaultName = '', defaultEmail = '') => {
17
- const { email, account, name, mobile, username } = userInfo
18
- const showEmail = email || defaultEmail
19
- const showName = name || mobile || username || account || defaultName
20
- return { showName, showEmail }
21
- }
22
-
23
- /**
24
- * @function storeUser
25
- * @param {?object} user
26
- */
27
- export function storeUser(user) {
28
- if (!user) return
29
- const { username = '', mobile = '', name = '', account = '', email = '', ...rest } = user
30
- Object.assign(_userInfo, { username, mobile, name, account, email, ...rest })
31
- publish({ ..._userInfo })
32
- }
33
-
34
- /**
35
- * @function getUser
36
- * @returns {object} userInfo
37
- */
38
- export function getUser() {
39
- return { ..._userInfo }
40
- }
41
-
42
- /**
43
- * @function getUserId
44
- * @returns {?number} id
45
- */
46
- export function getUserId() {
47
- return _userInfo.id
48
- }