perf: 合并dev分支,解决组件无法更新数据的问题

This commit is contained in:
奔跑的面条
2022-06-27 20:37:26 +08:00
39 changed files with 525 additions and 321 deletions
+20 -3
View File
@@ -82,9 +82,21 @@ const macKeyList: Array<string> = [
macKeyboardValue.save,
]
// 处理键盘记录
const keyRecordHandle = () => {
document.onkeydown = throttle((e: KeyboardEvent) => {
if(window.$KeyboardActive) window.$KeyboardActive.add(e.key.toLocaleLowerCase())
else window.$KeyboardActive = new Set([e.key])
}, 200)
document.onkeyup = throttle((e: KeyboardEvent) => {
if(window.$KeyboardActive) window.$KeyboardActive.delete(e.key.toLocaleLowerCase())
}, 200)
}
// 初始化监听事件
export const useAddKeyboard = () => {
const switchHande = (keyboardValue: typeof winKeyboardValue, e: string) => {
const switchHandle = (keyboardValue: typeof winKeyboardValue, e: string) => {
switch (e) {
// ct+↑
case keyboardValue.up:
@@ -136,15 +148,20 @@ export const useAddKeyboard = () => {
}
}
winKeyList.forEach((key: string) => {
switchHande(winKeyboardValue, key)
switchHandle(winKeyboardValue, key)
})
macKeyList.forEach((key: string) => {
switchHande(macKeyboardValue, key)
switchHandle(macKeyboardValue, key)
})
keyRecordHandle()
}
// 卸载监听事件
export const useRemoveKeyboard = () => {
document.onkeydown = () => {};
document.onkeyup = () => {};
winKeyList.forEach((key: string) => {
keymaster.unbind(key)
})