@bdlite/domains 1.1.31 → 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 -115
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createSubChannelKit } from '@bdlite/observable/es/create-observable-kit'
|
|
2
|
-
import { CHANNEL_NAME } from '../constants'
|
|
3
|
-
|
|
4
|
-
const { subscribe } = createSubChannelKit({ channelName: CHANNEL_NAME }, { relay: 1 })
|
|
5
|
-
|
|
1
|
+
import { createSubChannelKit } from '@bdlite/observable/es/create-observable-kit'
|
|
2
|
+
import { CHANNEL_NAME } from '../constants'
|
|
3
|
+
|
|
4
|
+
const { subscribe } = createSubChannelKit({ channelName: CHANNEL_NAME }, { relay: 1 })
|
|
5
|
+
|
|
6
6
|
export const subscribeLayout = subscribe
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createSubChannelKit } from '@bdlite/observable/es/create-observable-kit'
|
|
2
|
-
import { MENU_ITEM_CHANNEL_NAME } from '../constants'
|
|
3
|
-
|
|
4
|
-
const { subscribe } = createSubChannelKit({ channelName: MENU_ITEM_CHANNEL_NAME }, { relay: 1 })
|
|
5
|
-
|
|
1
|
+
import { createSubChannelKit } from '@bdlite/observable/es/create-observable-kit'
|
|
2
|
+
import { MENU_ITEM_CHANNEL_NAME } from '../constants'
|
|
3
|
+
|
|
4
|
+
const { subscribe } = createSubChannelKit({ channelName: MENU_ITEM_CHANNEL_NAME }, { relay: 1 })
|
|
5
|
+
|
|
6
6
|
export const subscribeMenuItem = subscribe
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createSubChannelKit } from '@bdlite/observable/es/create-observable-kit'
|
|
2
|
-
import { MENU_CHANNEL_NAME } from '../constants'
|
|
3
|
-
|
|
4
|
-
const { subscribe } = createSubChannelKit({ channelName: MENU_CHANNEL_NAME }, { relay: 1 })
|
|
5
|
-
|
|
1
|
+
import { createSubChannelKit } from '@bdlite/observable/es/create-observable-kit'
|
|
2
|
+
import { MENU_CHANNEL_NAME } from '../constants'
|
|
3
|
+
|
|
4
|
+
const { subscribe } = createSubChannelKit({ channelName: MENU_CHANNEL_NAME }, { relay: 1 })
|
|
5
|
+
|
|
6
6
|
export const subscribeMenu = subscribe
|
package/es/layout/constants.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
export const CHANNEL_NAME = 'domainsLayout'
|
|
2
|
-
export const MENU_CHANNEL_NAME = 'domainsMenu'
|
|
3
|
-
export const MENU_ITEM_CHANNEL_NAME = 'domainsMenuItem'
|
|
4
|
-
|
|
5
|
-
// 初始值
|
|
6
|
-
export const LAYOUT_MODE = {
|
|
7
|
-
HEADER: 'header',
|
|
8
|
-
SIDER: 'sider',
|
|
9
|
-
BOTH: 'both',
|
|
10
|
-
}
|
|
11
|
-
export const DEFAULT_LAYOUT_MODE = LAYOUT_MODE.HEADER
|
|
12
|
-
|
|
13
|
-
export const LAYOUT_THEME = {
|
|
14
|
-
DARK: 'dark',
|
|
15
|
-
LIGHT: 'light',
|
|
16
|
-
}
|
|
17
|
-
export const DEFAULT_LAYOUT_THEME = LAYOUT_THEME.DARK
|
|
18
|
-
|
|
19
|
-
export const DEFAULT_LAYOUT_DATA = {
|
|
20
|
-
systemName: '', showFooter: false,
|
|
21
|
-
theme: DEFAULT_LAYOUT_THEME,
|
|
22
|
-
layoutMode: DEFAULT_LAYOUT_MODE,
|
|
1
|
+
export const CHANNEL_NAME = 'domainsLayout'
|
|
2
|
+
export const MENU_CHANNEL_NAME = 'domainsMenu'
|
|
3
|
+
export const MENU_ITEM_CHANNEL_NAME = 'domainsMenuItem'
|
|
4
|
+
|
|
5
|
+
// 初始值
|
|
6
|
+
export const LAYOUT_MODE = {
|
|
7
|
+
HEADER: 'header',
|
|
8
|
+
SIDER: 'sider',
|
|
9
|
+
BOTH: 'both',
|
|
10
|
+
}
|
|
11
|
+
export const DEFAULT_LAYOUT_MODE = LAYOUT_MODE.HEADER
|
|
12
|
+
|
|
13
|
+
export const LAYOUT_THEME = {
|
|
14
|
+
DARK: 'dark',
|
|
15
|
+
LIGHT: 'light',
|
|
16
|
+
}
|
|
17
|
+
export const DEFAULT_LAYOUT_THEME = LAYOUT_THEME.DARK
|
|
18
|
+
|
|
19
|
+
export const DEFAULT_LAYOUT_DATA = {
|
|
20
|
+
systemName: '', showFooter: false,
|
|
21
|
+
theme: DEFAULT_LAYOUT_THEME,
|
|
22
|
+
layoutMode: DEFAULT_LAYOUT_MODE,
|
|
23
23
|
}
|
package/es/layout/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { isObject } from '@bdlite/strategy'
|
|
2
|
-
import { createObservableKit } from '@bdlite/observable/es/create-observable-kit'
|
|
3
|
-
import { CHANNEL_NAME, DEFAULT_LAYOUT_DATA } from './constants'
|
|
4
|
-
|
|
5
|
-
const { getData, subscribe, publish } = createObservableKit(DEFAULT_LAYOUT_DATA, null, { channelName: CHANNEL_NAME })
|
|
6
|
-
|
|
7
|
-
export const subscribeLayout = subscribe
|
|
8
|
-
|
|
9
|
-
export function publishLayout(data = {}) {
|
|
10
|
-
if (isObject(data)) {
|
|
11
|
-
publish({ ...getData(), ...data })
|
|
12
|
-
}
|
|
1
|
+
import { isObject } from '@bdlite/strategy'
|
|
2
|
+
import { createObservableKit } from '@bdlite/observable/es/create-observable-kit'
|
|
3
|
+
import { CHANNEL_NAME, DEFAULT_LAYOUT_DATA } from './constants'
|
|
4
|
+
|
|
5
|
+
const { getData, subscribe, publish } = createObservableKit(DEFAULT_LAYOUT_DATA, null, { channelName: CHANNEL_NAME })
|
|
6
|
+
|
|
7
|
+
export const subscribeLayout = subscribe
|
|
8
|
+
|
|
9
|
+
export function publishLayout(data = {}) {
|
|
10
|
+
if (isObject(data)) {
|
|
11
|
+
publish({ ...getData(), ...data })
|
|
12
|
+
}
|
|
13
13
|
}
|
package/es/layout/menu-item.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { isObject } from '@bdlite/strategy'
|
|
2
|
-
import { createObservableKit } from '@bdlite/observable/es/create-observable-kit'
|
|
3
|
-
import { MENU_ITEM_CHANNEL_NAME } from './constants'
|
|
4
|
-
|
|
5
|
-
const { getData, subscribe, publish } = createObservableKit({ selectedItem: {}, iframeUrl: '' }, null, { channelName: MENU_ITEM_CHANNEL_NAME })
|
|
6
|
-
|
|
7
|
-
export const subscribeMenuItem = subscribe
|
|
8
|
-
|
|
9
|
-
export const getMenuData = getData
|
|
10
|
-
|
|
11
|
-
export function publishMenuItem(data = {}) {
|
|
12
|
-
if (isObject(data)) {
|
|
13
|
-
publish({ ...getData(), ...data })
|
|
14
|
-
}
|
|
1
|
+
import { isObject } from '@bdlite/strategy'
|
|
2
|
+
import { createObservableKit } from '@bdlite/observable/es/create-observable-kit'
|
|
3
|
+
import { MENU_ITEM_CHANNEL_NAME } from './constants'
|
|
4
|
+
|
|
5
|
+
const { getData, subscribe, publish } = createObservableKit({ selectedItem: {}, iframeUrl: '' }, null, { channelName: MENU_ITEM_CHANNEL_NAME })
|
|
6
|
+
|
|
7
|
+
export const subscribeMenuItem = subscribe
|
|
8
|
+
|
|
9
|
+
export const getMenuData = getData
|
|
10
|
+
|
|
11
|
+
export function publishMenuItem(data = {}) {
|
|
12
|
+
if (isObject(data)) {
|
|
13
|
+
publish({ ...getData(), ...data })
|
|
14
|
+
}
|
|
15
15
|
}
|
package/es/layout/menu.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { isObject } from '@bdlite/strategy'
|
|
2
|
-
import { createObservableKit } from '@bdlite/observable/es/create-observable-kit'
|
|
3
|
-
import { MENU_CHANNEL_NAME } from './constants'
|
|
4
|
-
|
|
5
|
-
const initialData = { menu: [], globalOpenTarget: '', isPreviewMode: false }
|
|
6
|
-
const { getData, subscribe, publish } = createObservableKit(initialData, null, { channelName: MENU_CHANNEL_NAME })
|
|
7
|
-
|
|
8
|
-
export const subscribeMenu = subscribe
|
|
9
|
-
|
|
10
|
-
export function publishMenu(data = {}) {
|
|
11
|
-
if (isObject(data)) {
|
|
12
|
-
publish({ ...getData(), ...data })
|
|
13
|
-
}
|
|
14
|
-
}
|
|
1
|
+
import { isObject } from '@bdlite/strategy'
|
|
2
|
+
import { createObservableKit } from '@bdlite/observable/es/create-observable-kit'
|
|
3
|
+
import { MENU_CHANNEL_NAME } from './constants'
|
|
4
|
+
|
|
5
|
+
const initialData = { menu: [], globalOpenTarget: '', isPreviewMode: false }
|
|
6
|
+
const { getData, subscribe, publish } = createObservableKit(initialData, null, { channelName: MENU_CHANNEL_NAME })
|
|
7
|
+
|
|
8
|
+
export const subscribeMenu = subscribe
|
|
9
|
+
|
|
10
|
+
export function publishMenu(data = {}) {
|
|
11
|
+
if (isObject(data)) {
|
|
12
|
+
publish({ ...getData(), ...data })
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
15
|
export const getMenuData = getData
|
package/es/portrait-selector.js
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { isUndefined } from '@bdlite/strategy'
|
|
2
|
-
|
|
3
|
-
import { createObservableKit, createSubChannelKit } from '@bdlite/observable/es/create-observable-kit'
|
|
4
|
-
|
|
5
|
-
const CHANNEL_NAME = 'portrait-selector'
|
|
6
|
-
const CURRENT_CHANNEL_NAME = `${CHANNEL_NAME}-current`
|
|
7
|
-
const OPERATE_CHANNEL_NAME = `${CHANNEL_NAME}-operate`
|
|
8
|
-
|
|
9
|
-
const { subscribe: subscribeCur } = createSubChannelKit({ channelName: CURRENT_CHANNEL_NAME }, { relay: 1 })
|
|
10
|
-
const { subscribe: subscribeOp } = createSubChannelKit({ channelName: OPERATE_CHANNEL_NAME })
|
|
11
|
-
let currentKit = null
|
|
12
|
-
|
|
13
|
-
export const subscribeCurrent = subscribeCur
|
|
14
|
-
export const subscribeOperate = subscribeOp
|
|
15
|
-
|
|
16
|
-
export function publishCurrent(data) {
|
|
17
|
-
if (!currentKit) {
|
|
18
|
-
currentKit = createObservableKit({}, null, { channelName: CURRENT_CHANNEL_NAME })
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (isUndefined(data.id)) {
|
|
22
|
-
currentKit.observable.error(new Error('tableId is undefined.'))
|
|
23
|
-
} else {
|
|
24
|
-
currentKit.observable.next(data)
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @function operateItem
|
|
31
|
-
* @param {object} item
|
|
32
|
-
*/
|
|
33
|
-
export function operateItem(item = {}) {
|
|
34
|
-
let { observable } = createObservableKit({}, null, { channelName: OPERATE_CHANNEL_NAME })
|
|
35
|
-
|
|
36
|
-
if (isUndefined(item.id)) {
|
|
37
|
-
observable.error(new Error('tableId is undefined.'))
|
|
38
|
-
} else {
|
|
39
|
-
observable.next(item)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
observable.close() // 如果按需创建,一定要调用close,因为事件会一直被监听
|
|
43
|
-
observable = null
|
|
1
|
+
import { isUndefined } from '@bdlite/strategy'
|
|
2
|
+
|
|
3
|
+
import { createObservableKit, createSubChannelKit } from '@bdlite/observable/es/create-observable-kit'
|
|
4
|
+
|
|
5
|
+
const CHANNEL_NAME = 'portrait-selector'
|
|
6
|
+
const CURRENT_CHANNEL_NAME = `${CHANNEL_NAME}-current`
|
|
7
|
+
const OPERATE_CHANNEL_NAME = `${CHANNEL_NAME}-operate`
|
|
8
|
+
|
|
9
|
+
const { subscribe: subscribeCur } = createSubChannelKit({ channelName: CURRENT_CHANNEL_NAME }, { relay: 1 })
|
|
10
|
+
const { subscribe: subscribeOp } = createSubChannelKit({ channelName: OPERATE_CHANNEL_NAME })
|
|
11
|
+
let currentKit = null
|
|
12
|
+
|
|
13
|
+
export const subscribeCurrent = subscribeCur
|
|
14
|
+
export const subscribeOperate = subscribeOp
|
|
15
|
+
|
|
16
|
+
export function publishCurrent(data) {
|
|
17
|
+
if (!currentKit) {
|
|
18
|
+
currentKit = createObservableKit({}, null, { channelName: CURRENT_CHANNEL_NAME })
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (isUndefined(data.id)) {
|
|
22
|
+
currentKit.observable.error(new Error('tableId is undefined.'))
|
|
23
|
+
} else {
|
|
24
|
+
currentKit.observable.next(data)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @function operateItem
|
|
31
|
+
* @param {object} item
|
|
32
|
+
*/
|
|
33
|
+
export function operateItem(item = {}) {
|
|
34
|
+
let { observable } = createObservableKit({}, null, { channelName: OPERATE_CHANNEL_NAME })
|
|
35
|
+
|
|
36
|
+
if (isUndefined(item.id)) {
|
|
37
|
+
observable.error(new Error('tableId is undefined.'))
|
|
38
|
+
} else {
|
|
39
|
+
observable.next(item)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
observable.close() // 如果按需创建,一定要调用close,因为事件会一直被监听
|
|
43
|
+
observable = null
|
|
44
44
|
}
|
package/es/sider/constants.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const PLUGIN_CHANNEL_NAME = 'sider-plugin';
|
|
2
|
-
|
|
1
|
+
export const PLUGIN_CHANNEL_NAME = 'sider-plugin';
|
|
2
|
+
|
|
3
3
|
export const DEFAULT_TOP_SHOW = true;
|
package/es/sider/plugin.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { isObject } from '@bdlite/strategy'
|
|
2
|
-
import { createObservableKit } from '@bdlite/observable/es/create-observable-kit'
|
|
3
|
-
|
|
4
|
-
import { DEFAULT_TOP_SHOW } from './constants'
|
|
5
|
-
|
|
6
|
-
const { getData, subscribe, publish } = createObservableKit({ topShow: DEFAULT_TOP_SHOW })
|
|
7
|
-
|
|
8
|
-
export const subscribeSiderPluginStatus = subscribe
|
|
9
|
-
export function publishSiderPluginStatus(data) {
|
|
10
|
-
if (isObject(data)) {
|
|
11
|
-
publish({ ...getData(), ...data })
|
|
12
|
-
}
|
|
1
|
+
import { isObject } from '@bdlite/strategy'
|
|
2
|
+
import { createObservableKit } from '@bdlite/observable/es/create-observable-kit'
|
|
3
|
+
|
|
4
|
+
import { DEFAULT_TOP_SHOW } from './constants'
|
|
5
|
+
|
|
6
|
+
const { getData, subscribe, publish } = createObservableKit({ topShow: DEFAULT_TOP_SHOW })
|
|
7
|
+
|
|
8
|
+
export const subscribeSiderPluginStatus = subscribe
|
|
9
|
+
export function publishSiderPluginStatus(data) {
|
|
10
|
+
if (isObject(data)) {
|
|
11
|
+
publish({ ...getData(), ...data })
|
|
12
|
+
}
|
|
13
13
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { createSubChannelKit } from '@bdlite/observable/es/create-observable-kit'
|
|
2
|
-
import { CHANNEL_NAME } from './constants'
|
|
3
|
-
|
|
4
|
-
// 登录用户信息
|
|
5
|
-
const { subscribe } = createSubChannelKit({ channelName: CHANNEL_NAME }, { relay: 1 })
|
|
6
|
-
|
|
1
|
+
import { createSubChannelKit } from '@bdlite/observable/es/create-observable-kit'
|
|
2
|
+
import { CHANNEL_NAME } from './constants'
|
|
3
|
+
|
|
4
|
+
// 登录用户信息
|
|
5
|
+
const { subscribe } = createSubChannelKit({ channelName: CHANNEL_NAME }, { relay: 1 })
|
|
6
|
+
|
|
7
7
|
export const subscribeSysConfig = subscribe
|
|
@@ -1,11 +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
|
-
|
|
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
11
|
export const DEEFAULT_APP = 'govern' // govern: 治理平台, share:共享交换平台
|
|
@@ -1,116 +1,121 @@
|
|
|
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
|
-
|
|
21
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
* @function
|
|
113
|
-
*/
|
|
114
|
-
export
|
|
115
|
-
|
|
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
|
+
loginTypes : '1,2,3,4,5,6'
|
|
21
|
+
}, null, { channelName: CHANNEL_NAME })
|
|
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
|
+
loginTypes = '1,2,3,4,5,6'
|
|
40
|
+
} = storage.getObject(CHANNEL_NAME)
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
...getData(),
|
|
44
|
+
contactorId, contractName,
|
|
45
|
+
favicon, logo, loginLogo,
|
|
46
|
+
title: title.trim(),
|
|
47
|
+
copyright: copyright.trim(),
|
|
48
|
+
useragreement: useragreement.trim(),
|
|
49
|
+
app,
|
|
50
|
+
loginTypes
|
|
51
|
+
}
|
|
52
|
+
} catch (e) {
|
|
53
|
+
return { ...getData() }
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @function storeSysConfig
|
|
59
|
+
* @param {?object} systemConfig
|
|
60
|
+
*/
|
|
61
|
+
export function storeSysConfig(systemConfig) {
|
|
62
|
+
if (!systemConfig) return
|
|
63
|
+
const { mainLogo, copyright, eula, preload = {}, contactor, contactorInfo = {} } = systemConfig
|
|
64
|
+
const { title, favicon, loginLogo, appRunning, loginTypes } = preload
|
|
65
|
+
const nextConfig = {
|
|
66
|
+
...getData(),
|
|
67
|
+
contactorId: contactor, contractName: contactorInfo?.display || '',
|
|
68
|
+
favicon, loginLogo, logo: mainLogo,
|
|
69
|
+
title: title?.trim(), copyright: copyright?.trim(), useragreement: eula?.trim(),
|
|
70
|
+
app: appRunning,
|
|
71
|
+
loginTypes
|
|
72
|
+
}
|
|
73
|
+
storage.appendObject(CHANNEL_NAME, nextConfig)
|
|
74
|
+
publish(nextConfig)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @function storePreload
|
|
79
|
+
* @param {?object} config
|
|
80
|
+
*/
|
|
81
|
+
export function storePreload(config) {
|
|
82
|
+
if (!config) return
|
|
83
|
+
const { title, favicon, loginLogo, copyright, eula, appRunning, loginTypes } = config
|
|
84
|
+
const nextConfig = {
|
|
85
|
+
...getData(),
|
|
86
|
+
favicon, loginLogo, app: appRunning,
|
|
87
|
+
title: title?.trim(), copyright: copyright?.trim(), useragreement: eula?.trim(), loginTypes
|
|
88
|
+
}
|
|
89
|
+
storage.appendObject(CHANNEL_NAME, nextConfig)
|
|
90
|
+
publish(nextConfig)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @function publishPreload
|
|
95
|
+
* @param {?object} config
|
|
96
|
+
*/
|
|
97
|
+
export function publishPreload(config) {
|
|
98
|
+
if (!config) return
|
|
99
|
+
const { title, favicon, loginLogo, copyright, eula, loginTypes } = config
|
|
100
|
+
publish({
|
|
101
|
+
...getData(),
|
|
102
|
+
favicon, loginLogo,
|
|
103
|
+
title: title?.trim(), copyright: copyright?.trim(), useragreement: eula?.trim(), loginTypes
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @function subscribeSysConfig
|
|
110
|
+
* @param {function | object} mountedFunOrConfig
|
|
111
|
+
* @param {?function} unmountedFun
|
|
112
|
+
* @returns {function} unsubscribe
|
|
113
|
+
*/
|
|
114
|
+
export const subscribeSysConfig = subscribe
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* @function publishSysConfig
|
|
118
|
+
*/
|
|
119
|
+
export function publishSysConfig() {
|
|
120
|
+
publish(getSysConfig())
|
|
116
121
|
}
|
package/es/team/index.js
CHANGED
|
@@ -1,115 +1,115 @@
|
|
|
1
|
-
import { isObject } from '@bdlite/strategy'
|
|
2
|
-
import storage from '@bdlite/helpers/es/storage'
|
|
3
|
-
import { createObservableKit } from '@bdlite/observable/es/create-observable-kit'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export const DEFAULT_TEAM_STATUS = { hide: true }
|
|
7
|
-
export const DEFALUT_CURRENT_TEAM = { id: null, teamId: null, teamName: '' }
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const KEY = 'team_data'
|
|
11
|
-
|
|
12
|
-
const { getData: getStateData, subscribe: subscribeState, publish: publishState } = createObservableKit(DEFAULT_TEAM_STATUS)
|
|
13
|
-
|
|
14
|
-
const { getData, subscribe, publish } = createObservableKit({ ...DEFALUT_CURRENT_TEAM })
|
|
15
|
-
const { subscribe: subscribeCache, publish: publishCache } = createObservableKit({ ...DEFALUT_CURRENT_TEAM })
|
|
16
|
-
|
|
17
|
-
let _isCleared = false
|
|
18
|
-
let _currentTeam = getData()
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @function subscribeTeam
|
|
24
|
-
* @param {function | object} mountedFunOrConfig callback | { cache = false, ...config }
|
|
25
|
-
* @param {?function} unmountedFun
|
|
26
|
-
* @returns {function} unsubscribe
|
|
27
|
-
*/
|
|
28
|
-
export function subscribeTeam(mountedFunOrConfig, unmountedFun) {
|
|
29
|
-
if (isObject(mountedFunOrConfig)) {
|
|
30
|
-
const { cache = false, ...config } = mountedFunOrConfig
|
|
31
|
-
return cache ? subscribeCache(config, unmountedFun) : subscribe(config, unmountedFun)
|
|
32
|
-
}
|
|
33
|
-
return subscribe(mountedFunOrConfig, unmountedFun)
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* @function publishTeam
|
|
39
|
-
* @param {?object} { cache = false, all = false }
|
|
40
|
-
*/
|
|
41
|
-
export function publishTeam({ cache = false, all = false } = {}) {
|
|
42
|
-
const team = getTeam()
|
|
43
|
-
|
|
44
|
-
if (all) {
|
|
45
|
-
publishCache(team)
|
|
46
|
-
publish(team)
|
|
47
|
-
return
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (cache) {
|
|
51
|
-
publishCache(team)
|
|
52
|
-
} else {
|
|
53
|
-
publish(team)
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* @function subscribeTeamStatus
|
|
59
|
-
* @param {function | object} mountedFunOrConfig
|
|
60
|
-
* @param {?function} unmountedFun
|
|
61
|
-
* @returns {function} unsubscribe
|
|
62
|
-
*/
|
|
63
|
-
export const subscribeTeamStatus = subscribeState
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* @function publishTeamStatus
|
|
67
|
-
* @param {?object} nextState
|
|
68
|
-
*/
|
|
69
|
-
export function publishTeamStatus(nextState = {}) {
|
|
70
|
-
publishState({ ...getStateData(), ...nextState })
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* @function showTeamSelector
|
|
75
|
-
* @param {?boolean} show
|
|
76
|
-
*/
|
|
77
|
-
export function showTeamSelector(show = true) {
|
|
78
|
-
publishTeamStatus({ hide: !show })
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
export function storeTeam(teamId = '', teamName = '', leaderName = '') {
|
|
84
|
-
const name = `${teamName}`
|
|
85
|
-
Object.assign(_currentTeam, { id: teamId, teamId, leaderName }, name ? { teamName: name } : {})
|
|
86
|
-
storage.appendObject(KEY, _currentTeam)
|
|
87
|
-
_isCleared = false
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export function clearTeam({ stayStored = false } = {}) {
|
|
91
|
-
_currentTeam = { ...DEFALUT_CURRENT_TEAM }
|
|
92
|
-
_isCleared = true
|
|
93
|
-
|
|
94
|
-
if (!stayStored) {
|
|
95
|
-
storage.remove(KEY)
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export function getTeam() {
|
|
100
|
-
if (_currentTeam.teamId === null && !_isCleared) {
|
|
101
|
-
Object.assign(_currentTeam, storage.getObject(KEY))
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const { teamId, teamName = '', ...rest } = _currentTeam
|
|
105
|
-
|
|
106
|
-
if(teamId == 'null'){
|
|
107
|
-
return { teamId: '', teamName, ...rest }
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return { teamId, teamName, ...rest }
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export function getTeamId() {
|
|
114
|
-
return getTeam().teamId
|
|
1
|
+
import { isObject } from '@bdlite/strategy'
|
|
2
|
+
import storage from '@bdlite/helpers/es/storage'
|
|
3
|
+
import { createObservableKit } from '@bdlite/observable/es/create-observable-kit'
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export const DEFAULT_TEAM_STATUS = { hide: true }
|
|
7
|
+
export const DEFALUT_CURRENT_TEAM = { id: null, teamId: null, teamName: '' }
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
const KEY = 'team_data'
|
|
11
|
+
|
|
12
|
+
const { getData: getStateData, subscribe: subscribeState, publish: publishState } = createObservableKit(DEFAULT_TEAM_STATUS)
|
|
13
|
+
|
|
14
|
+
const { getData, subscribe, publish } = createObservableKit({ ...DEFALUT_CURRENT_TEAM })
|
|
15
|
+
const { subscribe: subscribeCache, publish: publishCache } = createObservableKit({ ...DEFALUT_CURRENT_TEAM })
|
|
16
|
+
|
|
17
|
+
let _isCleared = false
|
|
18
|
+
let _currentTeam = getData()
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @function subscribeTeam
|
|
24
|
+
* @param {function | object} mountedFunOrConfig callback | { cache = false, ...config }
|
|
25
|
+
* @param {?function} unmountedFun
|
|
26
|
+
* @returns {function} unsubscribe
|
|
27
|
+
*/
|
|
28
|
+
export function subscribeTeam(mountedFunOrConfig, unmountedFun) {
|
|
29
|
+
if (isObject(mountedFunOrConfig)) {
|
|
30
|
+
const { cache = false, ...config } = mountedFunOrConfig
|
|
31
|
+
return cache ? subscribeCache(config, unmountedFun) : subscribe(config, unmountedFun)
|
|
32
|
+
}
|
|
33
|
+
return subscribe(mountedFunOrConfig, unmountedFun)
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @function publishTeam
|
|
39
|
+
* @param {?object} { cache = false, all = false }
|
|
40
|
+
*/
|
|
41
|
+
export function publishTeam({ cache = false, all = false } = {}) {
|
|
42
|
+
const team = getTeam()
|
|
43
|
+
|
|
44
|
+
if (all) {
|
|
45
|
+
publishCache(team)
|
|
46
|
+
publish(team)
|
|
47
|
+
return
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (cache) {
|
|
51
|
+
publishCache(team)
|
|
52
|
+
} else {
|
|
53
|
+
publish(team)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @function subscribeTeamStatus
|
|
59
|
+
* @param {function | object} mountedFunOrConfig
|
|
60
|
+
* @param {?function} unmountedFun
|
|
61
|
+
* @returns {function} unsubscribe
|
|
62
|
+
*/
|
|
63
|
+
export const subscribeTeamStatus = subscribeState
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @function publishTeamStatus
|
|
67
|
+
* @param {?object} nextState
|
|
68
|
+
*/
|
|
69
|
+
export function publishTeamStatus(nextState = {}) {
|
|
70
|
+
publishState({ ...getStateData(), ...nextState })
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @function showTeamSelector
|
|
75
|
+
* @param {?boolean} show
|
|
76
|
+
*/
|
|
77
|
+
export function showTeamSelector(show = true) {
|
|
78
|
+
publishTeamStatus({ hide: !show })
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
export function storeTeam(teamId = '', teamName = '', leaderName = '') {
|
|
84
|
+
const name = `${teamName}`
|
|
85
|
+
Object.assign(_currentTeam, { id: teamId, teamId, leaderName }, name ? { teamName: name } : {})
|
|
86
|
+
storage.appendObject(KEY, _currentTeam)
|
|
87
|
+
_isCleared = false
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function clearTeam({ stayStored = false } = {}) {
|
|
91
|
+
_currentTeam = { ...DEFALUT_CURRENT_TEAM }
|
|
92
|
+
_isCleared = true
|
|
93
|
+
|
|
94
|
+
if (!stayStored) {
|
|
95
|
+
storage.remove(KEY)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function getTeam() {
|
|
100
|
+
if (_currentTeam.teamId === null && !_isCleared) {
|
|
101
|
+
Object.assign(_currentTeam, storage.getObject(KEY))
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const { teamId, teamName = '', ...rest } = _currentTeam
|
|
105
|
+
|
|
106
|
+
if(teamId == 'null'){
|
|
107
|
+
return { teamId: '', teamName, ...rest }
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return { teamId, teamName, ...rest }
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function getTeamId() {
|
|
114
|
+
return getTeam().teamId
|
|
115
115
|
}
|
package/es/user/login.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { createObservableKit, createSubChannelKit } from '@bdlite/observable/es/create-observable-kit'
|
|
2
|
-
|
|
3
|
-
const LOGIN_CHANNEL_NAME = 'userlogin'
|
|
4
|
-
|
|
5
|
-
const _timestamp = new Date().getTime()
|
|
6
|
-
|
|
7
|
-
const obOptions = { relay: 0 }
|
|
8
|
-
const channelOptions = { useSession: false }
|
|
9
|
-
|
|
10
|
-
// 登录用户状态
|
|
11
|
-
const { publish } = createObservableKit({ timestamp: _timestamp, noLogin: true }, obOptions, { channelName: LOGIN_CHANNEL_NAME, channelOptions })
|
|
12
|
-
const { subscribe } = createSubChannelKit({ channelName: LOGIN_CHANNEL_NAME, channelOptions }, obOptions)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export const subscribeLoginStatus = subscribe
|
|
16
|
-
|
|
17
|
-
export function publishLoginStatus({ fromLoginPage, ...rest }) {
|
|
18
|
-
if (fromLoginPage) {
|
|
19
|
-
publish({ fromLoginPage, timestamp: _timestamp, ...rest })
|
|
20
|
-
} else {
|
|
21
|
-
publish(rest)
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function getTimestamp() {
|
|
26
|
-
return _timestamp
|
|
1
|
+
import { createObservableKit, createSubChannelKit } from '@bdlite/observable/es/create-observable-kit'
|
|
2
|
+
|
|
3
|
+
const LOGIN_CHANNEL_NAME = 'userlogin'
|
|
4
|
+
|
|
5
|
+
const _timestamp = new Date().getTime()
|
|
6
|
+
|
|
7
|
+
const obOptions = { relay: 0 }
|
|
8
|
+
const channelOptions = { useSession: false }
|
|
9
|
+
|
|
10
|
+
// 登录用户状态
|
|
11
|
+
const { publish } = createObservableKit({ timestamp: _timestamp, noLogin: true }, obOptions, { channelName: LOGIN_CHANNEL_NAME, channelOptions })
|
|
12
|
+
const { subscribe } = createSubChannelKit({ channelName: LOGIN_CHANNEL_NAME, channelOptions }, obOptions)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
export const subscribeLoginStatus = subscribe
|
|
16
|
+
|
|
17
|
+
export function publishLoginStatus({ fromLoginPage, ...rest }) {
|
|
18
|
+
if (fromLoginPage) {
|
|
19
|
+
publish({ fromLoginPage, timestamp: _timestamp, ...rest })
|
|
20
|
+
} else {
|
|
21
|
+
publish(rest)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function getTimestamp() {
|
|
26
|
+
return _timestamp
|
|
27
27
|
}
|
package/es/workspace/index.js
CHANGED
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
import { isObject } from '@bdlite/strategy'
|
|
2
|
-
import storage from '@bdlite/helpers/es/storage'
|
|
3
|
-
import { createObservableKit } from '@bdlite/observable/es/create-observable-kit'
|
|
4
|
-
|
|
5
|
-
export const DEFALUT_CURRENT_PROJECT = { id: null, projectId: null, key: '', projectName: '' }
|
|
6
|
-
|
|
7
|
-
const KEY = 'project_data'
|
|
8
|
-
|
|
9
|
-
const { subscribe: cacheSubscribe, publish: cachePublish } = createObservableKit({ ...DEFALUT_CURRENT_PROJECT })
|
|
10
|
-
const { getData: getProjectData, subscribe, publish: projectPublish } = createObservableKit({ ...DEFALUT_CURRENT_PROJECT })
|
|
11
|
-
|
|
12
|
-
let _isCleared = false
|
|
13
|
-
let _currentProject = getProjectData()
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @function subscribeProject
|
|
18
|
-
* @param {function | object} mountedFunOrConfig callback | { cache = false, ...config }
|
|
19
|
-
* @param {?function} unmountedFun
|
|
20
|
-
* @returns {function} unsubscribe
|
|
21
|
-
*/
|
|
22
|
-
export function subscribeProject(mountedFunOrConfig, unmountedFun) {
|
|
23
|
-
if (isObject(mountedFunOrConfig)) {
|
|
24
|
-
const { cache = false, ...config } = mountedFunOrConfig
|
|
25
|
-
return cache ? cacheSubscribe(config, unmountedFun) : subscribe(config, unmountedFun)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return subscribe(mountedFunOrConfig, unmountedFun)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @function publishProject
|
|
33
|
-
* @param {?object} { cache = false, all = false }
|
|
34
|
-
*/
|
|
35
|
-
export function publishProject({ cache = false, all = false } = {}) {
|
|
36
|
-
const project = getProject()
|
|
37
|
-
|
|
38
|
-
if (all) {
|
|
39
|
-
cachePublish(project)
|
|
40
|
-
projectPublish(project)
|
|
41
|
-
return
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (cache) {
|
|
45
|
-
cachePublish(project)
|
|
46
|
-
} else {
|
|
47
|
-
projectPublish(project)
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
function isValidId(id) {
|
|
54
|
-
return id !== '' && id !== 'null'
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// 项目/应用/工作空间
|
|
58
|
-
export function storeProject(projectId = '', rest) {
|
|
59
|
-
if (isObject(rest)) {
|
|
60
|
-
const { teamId, projectName, orgName = '', name = '', ..._rest } = rest
|
|
61
|
-
Object.assign(_currentProject, {
|
|
62
|
-
id: projectId,
|
|
63
|
-
projectId,
|
|
64
|
-
teamId, name, orgName,
|
|
65
|
-
projectName: projectName || name || orgName,
|
|
66
|
-
..._rest
|
|
67
|
-
})
|
|
68
|
-
} else {
|
|
69
|
-
Object.assign(_currentProject, { id: projectId, projectId })
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
storage.appendObject(KEY, _currentProject)
|
|
73
|
-
_isCleared = false
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function getProject() {
|
|
77
|
-
if (_currentProject.projectId !== null || _isCleared) return { ..._currentProject }
|
|
78
|
-
|
|
79
|
-
const { projectId = '', rest } = storage.getObject(KEY)
|
|
80
|
-
Object.assign(_currentProject, { ...rest })
|
|
81
|
-
isValidId(projectId) && Object.assign(_currentProject, { projectId })
|
|
82
|
-
return { ..._currentProject }
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export function getProjectId() {
|
|
86
|
-
return getProject().projectId;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
export function clearProjectData({ stayStored = false } = {}) {
|
|
91
|
-
_isCleared = true
|
|
92
|
-
_currentProject = { ...DEFALUT_CURRENT_PROJECT }
|
|
93
|
-
|
|
94
|
-
if (!stayStored) {
|
|
95
|
-
storage.remove(KEY)
|
|
96
|
-
}
|
|
1
|
+
import { isObject } from '@bdlite/strategy'
|
|
2
|
+
import storage from '@bdlite/helpers/es/storage'
|
|
3
|
+
import { createObservableKit } from '@bdlite/observable/es/create-observable-kit'
|
|
4
|
+
|
|
5
|
+
export const DEFALUT_CURRENT_PROJECT = { id: null, projectId: null, key: '', projectName: '' }
|
|
6
|
+
|
|
7
|
+
const KEY = 'project_data'
|
|
8
|
+
|
|
9
|
+
const { subscribe: cacheSubscribe, publish: cachePublish } = createObservableKit({ ...DEFALUT_CURRENT_PROJECT })
|
|
10
|
+
const { getData: getProjectData, subscribe, publish: projectPublish } = createObservableKit({ ...DEFALUT_CURRENT_PROJECT })
|
|
11
|
+
|
|
12
|
+
let _isCleared = false
|
|
13
|
+
let _currentProject = getProjectData()
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @function subscribeProject
|
|
18
|
+
* @param {function | object} mountedFunOrConfig callback | { cache = false, ...config }
|
|
19
|
+
* @param {?function} unmountedFun
|
|
20
|
+
* @returns {function} unsubscribe
|
|
21
|
+
*/
|
|
22
|
+
export function subscribeProject(mountedFunOrConfig, unmountedFun) {
|
|
23
|
+
if (isObject(mountedFunOrConfig)) {
|
|
24
|
+
const { cache = false, ...config } = mountedFunOrConfig
|
|
25
|
+
return cache ? cacheSubscribe(config, unmountedFun) : subscribe(config, unmountedFun)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return subscribe(mountedFunOrConfig, unmountedFun)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @function publishProject
|
|
33
|
+
* @param {?object} { cache = false, all = false }
|
|
34
|
+
*/
|
|
35
|
+
export function publishProject({ cache = false, all = false } = {}) {
|
|
36
|
+
const project = getProject()
|
|
37
|
+
|
|
38
|
+
if (all) {
|
|
39
|
+
cachePublish(project)
|
|
40
|
+
projectPublish(project)
|
|
41
|
+
return
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (cache) {
|
|
45
|
+
cachePublish(project)
|
|
46
|
+
} else {
|
|
47
|
+
projectPublish(project)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
function isValidId(id) {
|
|
54
|
+
return id !== '' && id !== 'null'
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 项目/应用/工作空间
|
|
58
|
+
export function storeProject(projectId = '', rest) {
|
|
59
|
+
if (isObject(rest)) {
|
|
60
|
+
const { teamId, projectName, orgName = '', name = '', ..._rest } = rest
|
|
61
|
+
Object.assign(_currentProject, {
|
|
62
|
+
id: projectId,
|
|
63
|
+
projectId,
|
|
64
|
+
teamId, name, orgName,
|
|
65
|
+
projectName: projectName || name || orgName,
|
|
66
|
+
..._rest
|
|
67
|
+
})
|
|
68
|
+
} else {
|
|
69
|
+
Object.assign(_currentProject, { id: projectId, projectId })
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
storage.appendObject(KEY, _currentProject)
|
|
73
|
+
_isCleared = false
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function getProject() {
|
|
77
|
+
if (_currentProject.projectId !== null || _isCleared) return { ..._currentProject }
|
|
78
|
+
|
|
79
|
+
const { projectId = '', rest } = storage.getObject(KEY)
|
|
80
|
+
Object.assign(_currentProject, { ...rest })
|
|
81
|
+
isValidId(projectId) && Object.assign(_currentProject, { projectId })
|
|
82
|
+
return { ..._currentProject }
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function getProjectId() {
|
|
86
|
+
return getProject().projectId;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
export function clearProjectData({ stayStored = false } = {}) {
|
|
91
|
+
_isCleared = true
|
|
92
|
+
_currentProject = { ...DEFALUT_CURRENT_PROJECT }
|
|
93
|
+
|
|
94
|
+
if (!stayStored) {
|
|
95
|
+
storage.remove(KEY)
|
|
96
|
+
}
|
|
97
97
|
}
|
package/package.json
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@bdlite/domains",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "A domains entity collection library driven by @bdlite/observable",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"DDD",
|
|
7
|
-
"domains",
|
|
8
|
-
"observable",
|
|
9
|
-
"Observable"
|
|
10
|
-
],
|
|
11
|
-
"scripts": {},
|
|
12
|
-
"module": "es/index.js",
|
|
13
|
-
"main": "es/index.js",
|
|
14
|
-
"files": [
|
|
15
|
-
"es",
|
|
16
|
-
"README.md"
|
|
17
|
-
],
|
|
18
|
-
"authors": [
|
|
19
|
-
"Shirley Xie <yexinxie@163.com>"
|
|
20
|
-
],
|
|
21
|
-
"license": "MIT",
|
|
22
|
-
"peerDependencies": {
|
|
23
|
-
"@bdlite/helpers": "^1.1.24",
|
|
24
|
-
"@bdlite/observable": "^1.1.20",
|
|
25
|
-
"@bdlite/strategy": "^1.1.25"
|
|
26
|
-
},
|
|
27
|
-
"dependencies": {
|
|
28
|
-
"@bdlite/helpers": "^1.1.
|
|
29
|
-
"@bdlite/observable": "^1.1.25",
|
|
30
|
-
"@bdlite/strategy": "^1.1.25"
|
|
31
|
-
},
|
|
32
|
-
"devDependencies": {
|
|
33
|
-
"@rollup/plugin-babel": "6.0.4",
|
|
34
|
-
"@rollup/plugin-eslint": "9.0.5",
|
|
35
|
-
"@typescript-eslint/eslint-plugin": "^5.60.1",
|
|
36
|
-
"@typescript-eslint/parser": "^5.60.1",
|
|
37
|
-
"eslint": "^8.43.0",
|
|
38
|
-
"husky": "^8.0.0",
|
|
39
|
-
"rollup": "4.9.5",
|
|
40
|
-
"rollup-plugin-typescript2": "^0.29.0",
|
|
41
|
-
"typescript": "^4.4.3"
|
|
42
|
-
},
|
|
43
|
-
"gitHead": "bed20dd584017cfa425c66edd505bc74c5d7ab13"
|
|
44
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@bdlite/domains",
|
|
3
|
+
"version": "1.1.34",
|
|
4
|
+
"description": "A domains entity collection library driven by @bdlite/observable",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"DDD",
|
|
7
|
+
"domains",
|
|
8
|
+
"observable",
|
|
9
|
+
"Observable"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {},
|
|
12
|
+
"module": "es/index.js",
|
|
13
|
+
"main": "es/index.js",
|
|
14
|
+
"files": [
|
|
15
|
+
"es",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"authors": [
|
|
19
|
+
"Shirley Xie <yexinxie@163.com>"
|
|
20
|
+
],
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"@bdlite/helpers": "^1.1.24",
|
|
24
|
+
"@bdlite/observable": "^1.1.20",
|
|
25
|
+
"@bdlite/strategy": "^1.1.25"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@bdlite/helpers": "^1.1.27",
|
|
29
|
+
"@bdlite/observable": "^1.1.25",
|
|
30
|
+
"@bdlite/strategy": "^1.1.25"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@rollup/plugin-babel": "6.0.4",
|
|
34
|
+
"@rollup/plugin-eslint": "9.0.5",
|
|
35
|
+
"@typescript-eslint/eslint-plugin": "^5.60.1",
|
|
36
|
+
"@typescript-eslint/parser": "^5.60.1",
|
|
37
|
+
"eslint": "^8.43.0",
|
|
38
|
+
"husky": "^8.0.0",
|
|
39
|
+
"rollup": "4.9.5",
|
|
40
|
+
"rollup-plugin-typescript2": "^0.29.0",
|
|
41
|
+
"typescript": "^4.4.3"
|
|
42
|
+
},
|
|
43
|
+
"gitHead": "bed20dd584017cfa425c66edd505bc74c5d7ab13"
|
|
44
|
+
}
|