@gm-pc/react 1.15.0-alpha.2 → 1.16.0-alpha.0
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gm-pc/react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.0-alpha.0",
|
|
4
4
|
"description": "观麦前端基础组件库",
|
|
5
5
|
"author": "liyatang <liyatang@qq.com>",
|
|
6
6
|
"homepage": "https://github.com/gmfe/gm-pc#readme",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@gm-common/hooks": "^2.10.0",
|
|
26
26
|
"@gm-common/tool": "^2.10.0",
|
|
27
|
-
"@gm-pc/locales": "^1.
|
|
27
|
+
"@gm-pc/locales": "^1.16.0-alpha.0",
|
|
28
28
|
"big.js": "^6.0.1",
|
|
29
29
|
"classnames": "^2.2.5",
|
|
30
30
|
"lodash": "^4.17.19",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"react-router-dom": "^5.2.0",
|
|
49
49
|
"react-window": "^1.8.5"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "c4060bd47a903111e49c5d7185599d43c175e6f9"
|
|
52
52
|
}
|
|
@@ -10,7 +10,7 @@ type Noop = () => void
|
|
|
10
10
|
* 根据情况可以考虑使用useWindowEffect来替换useEffect,功能: 窗口激活时、deps更新时,触发fn执行; 窗口失活时执行fn返回的销毁函数; 如果子窗口为失活状态,不观察deps的更新;
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
|
-
export default function useWindowEffect(fn: () => Noop | void, deps: Array<any>) {
|
|
13
|
+
export default function useWindowEffect(fn: () => Noop | void, deps: Array<any> = []) {
|
|
14
14
|
const browser = useContext(BrowserContext)
|
|
15
15
|
/** hook所在窗口 */
|
|
16
16
|
const browserWindow = useContext(BrowserWindowContext)
|
|
@@ -37,19 +37,15 @@ export default function useWindowEffect(fn: () => Noop | void, deps: Array<any>)
|
|
|
37
37
|
const deactivate = pre?.path === browserWindow.path
|
|
38
38
|
if (activate) {
|
|
39
39
|
cb.current = fn()
|
|
40
|
-
console.log('activate', browserWindow.path)
|
|
41
40
|
}
|
|
42
41
|
if (deactivate) {
|
|
43
42
|
cb.current && cb.current()
|
|
44
|
-
console.log('deactivate', browserWindow.path)
|
|
45
43
|
}
|
|
46
44
|
}
|
|
47
45
|
// { fireImmediately: true }
|
|
48
46
|
)
|
|
49
47
|
cb.current = fn()
|
|
50
|
-
console.log('effect', browserWindow.path, deps)
|
|
51
48
|
return () => {
|
|
52
|
-
console.log('dispose', browserWindow.path)
|
|
53
49
|
dispose()
|
|
54
50
|
cb.current && cb.current()
|
|
55
51
|
}
|
|
@@ -55,6 +55,12 @@ class VBrowser implements VBrowser {
|
|
|
55
55
|
return this.windows[this.activeIndex] as VBrowserWindow | undefined
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
private _histories: VBrowserWindow[] = []
|
|
59
|
+
/** 窗口打开/切换记录,最多10, 不包含当前 */
|
|
60
|
+
get histories() {
|
|
61
|
+
return this._histories
|
|
62
|
+
}
|
|
63
|
+
|
|
58
64
|
/** 切换已打开窗口 */
|
|
59
65
|
switchWindow(w: number | VBrowserWindow) {
|
|
60
66
|
const oldWindow = this.activeWindow
|
|
@@ -79,6 +85,9 @@ class VBrowser implements VBrowser {
|
|
|
79
85
|
}
|
|
80
86
|
setTimeout(() => this._scrollToActiveTab(), 100)
|
|
81
87
|
|
|
88
|
+
if (oldWindow) {
|
|
89
|
+
this._histories = [...[...this._histories, oldWindow].slice(-10)]
|
|
90
|
+
}
|
|
82
91
|
this.props.onChange &&
|
|
83
92
|
this.props.onChange(oldWindow, this.windows[this.activeIndex], this.windows)
|
|
84
93
|
this._stash()
|
|
@@ -165,8 +174,11 @@ class VBrowser implements VBrowser {
|
|
|
165
174
|
// #endregion
|
|
166
175
|
}
|
|
167
176
|
|
|
168
|
-
/**
|
|
169
|
-
close(i
|
|
177
|
+
/** 关闭子窗口, 不指定则关闭当前窗口 */
|
|
178
|
+
close(i?: number | VBrowserWindow) {
|
|
179
|
+
if (i === undefined) {
|
|
180
|
+
i = this.activeIndex
|
|
181
|
+
}
|
|
170
182
|
if (typeof i !== 'number') {
|
|
171
183
|
i = this.windows.findIndex((item) => item.path === (i as VBrowserWindow).path)
|
|
172
184
|
}
|
|
@@ -233,6 +245,11 @@ class VBrowser implements VBrowser {
|
|
|
233
245
|
this.open(windows[activeIndex])
|
|
234
246
|
}
|
|
235
247
|
|
|
248
|
+
/** 清除后重新进入无法恢复已开窗口 */
|
|
249
|
+
deleteStash() {
|
|
250
|
+
sessionStorage.removeItem(STORAGE_KEY)
|
|
251
|
+
}
|
|
252
|
+
|
|
236
253
|
/** 隐藏标签栏 */
|
|
237
254
|
hideTabs() {
|
|
238
255
|
this._hidingTabs = true
|