mirror of
https://github.com/kuaifan/dootask.git
synced 2026-02-06 13:15:35 +00:00
perf: 优化快捷键设置
This commit is contained in:
parent
37ccf4dacb
commit
211f9f0c15
@ -297,7 +297,7 @@ export default {
|
|||||||
key: 'manifest',
|
key: 'manifest',
|
||||||
url: $A.apiUrl("../manifest")
|
url: $A.apiUrl("../manifest")
|
||||||
})
|
})
|
||||||
$A.bindScreenshotKey($A.jsonParse(window.localStorage.getItem("__keyboard:data__")) || {});
|
$A.bindScreenshotKey(this.$store.state.cacheKeyboard);
|
||||||
//
|
//
|
||||||
this.$Electron.sendMessage('setMenuLanguage', {
|
this.$Electron.sendMessage('setMenuLanguage', {
|
||||||
openInBrowser: this.$L("在浏览器中打开"),
|
openInBrowser: this.$L("在浏览器中打开"),
|
||||||
|
|||||||
@ -236,10 +236,6 @@ export default {
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
enterSend: {
|
|
||||||
type: [String, Boolean],
|
|
||||||
default: null
|
|
||||||
},
|
|
||||||
emojiBottom: {
|
emojiBottom: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
@ -386,13 +382,15 @@ export default {
|
|||||||
|
|
||||||
'cacheDialogs',
|
'cacheDialogs',
|
||||||
'dialogMsgs',
|
'dialogMsgs',
|
||||||
|
|
||||||
|
'cacheKeyboard',
|
||||||
]),
|
]),
|
||||||
|
|
||||||
isEnterSend({enterSend}) {
|
isEnterSend({cacheKeyboard}) {
|
||||||
if (typeof enterSend === "boolean") {
|
if (this.$isEEUiApp) {
|
||||||
return enterSend;
|
return cacheKeyboard.send_button_app === 'enter';
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return cacheKeyboard.send_button_desktop === 'enter';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -495,11 +493,6 @@ export default {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
separateSendButton() {
|
|
||||||
return $A.jsonParse(window.localStorage.getItem("__keyboard:data__"))?.separate_send_button !== 'close';
|
|
||||||
},
|
|
||||||
|
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
// Watch content change
|
// Watch content change
|
||||||
@ -669,11 +662,6 @@ export default {
|
|||||||
shortKey: true,
|
shortKey: true,
|
||||||
handler: _ => {
|
handler: _ => {
|
||||||
if (!this.isEnterSend) {
|
if (!this.isEnterSend) {
|
||||||
if (this.separateSendButton) {
|
|
||||||
const length = this.quill.getSelection(true).index;
|
|
||||||
this.quill.insertText(length, "\r\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
this.onSend();
|
this.onSend();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -685,11 +673,6 @@ export default {
|
|||||||
shiftKey: false,
|
shiftKey: false,
|
||||||
handler: _ => {
|
handler: _ => {
|
||||||
if (this.isEnterSend) {
|
if (this.isEnterSend) {
|
||||||
if (this.separateSendButton) {
|
|
||||||
const length = this.quill.getSelection(true).index;
|
|
||||||
this.quill.insertText(length, "\r\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
this.onSend();
|
this.onSend();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -798,9 +781,18 @@ export default {
|
|||||||
if (e.key === '\r\r' && e.keyCode === 229) {
|
if (e.key === '\r\r' && e.keyCode === 229) {
|
||||||
const length = this.quill.getSelection(true).index;
|
const length = this.quill.getSelection(true).index;
|
||||||
this.quill.insertText(length, "\r\n");
|
this.quill.insertText(length, "\r\n");
|
||||||
|
//
|
||||||
|
this.keyTimer && clearTimeout(this.keyTimer)
|
||||||
|
this.keyTimer = setTimeout(_ => {
|
||||||
|
this.$refs.editor.firstChild.childNodes.forEach(child => {
|
||||||
|
if (/^\r+/.test(child.innerHTML)) {
|
||||||
|
child.innerHTML = child.innerHTML.replace(/^\r+/, "") || "<br>"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}, 200)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!this.separateSendButton) {
|
if (this.$isEEUiApp && this.cacheKeyboard.send_button_app === 'enter') {
|
||||||
this.quill.root.setAttribute('enterkeyhint', 'send')
|
this.quill.root.setAttribute('enterkeyhint', 'send')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@ -28,13 +28,21 @@
|
|||||||
</div>
|
</div>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</template>
|
</template>
|
||||||
<FormItem :label="$L('发送按钮')" prop="anonMessage">
|
<FormItem v-if="$isEEUiApp" :label="$L('发送按钮')">
|
||||||
<RadioGroup v-model="formData.separate_send_button">
|
<RadioGroup v-model="formData.send_button_app">
|
||||||
<Radio label="open">{{$L('开启')}}</Radio>
|
<Radio label="button">{{$L('开启')}}</Radio>
|
||||||
<Radio label="close">{{$L('关闭')}}</Radio>
|
<Radio label="enter">{{$L('关闭')}}</Radio>
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
<div class="form-tip">{{$L('开启后,发送消息时键盘上的发送按钮会被替换成换行')}}</div>
|
<div class="form-tip">{{$L('开启后,发送消息时键盘上的发送按钮会被替换成换行')}}</div>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
<FormItem v-else-if="$Electron" :label="$L('发送按钮')">
|
||||||
|
<RadioGroup v-model="formData.send_button_desktop" vertical>
|
||||||
|
<Radio label="enter">Enter {{$L('发送')}}</Radio>
|
||||||
|
<Radio label="button" class="input-box">
|
||||||
|
{{mateName}}<div class="input-box-push">+</div>Enter {{$L('发送')}}
|
||||||
|
</Radio>
|
||||||
|
</RadioGroup>
|
||||||
|
</FormItem>
|
||||||
</Form>
|
</Form>
|
||||||
<div class="setting-footer">
|
<div class="setting-footer">
|
||||||
<Button :loading="loadIng > 0" type="primary" @click="submitForm">{{$L('保存')}}</Button>
|
<Button :loading="loadIng > 0" type="primary" @click="submitForm">{{$L('保存')}}</Button>
|
||||||
@ -67,7 +75,8 @@ export default {
|
|||||||
|
|
||||||
formData: {
|
formData: {
|
||||||
screenshot_key: '',
|
screenshot_key: '',
|
||||||
separate_send_button: 'open'
|
send_button_app: '',
|
||||||
|
send_button_desktop: '',
|
||||||
},
|
},
|
||||||
|
|
||||||
ruleData: {
|
ruleData: {
|
||||||
@ -98,29 +107,26 @@ export default {
|
|||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
initData() {
|
initData() {
|
||||||
this.formData = Object.assign({
|
this.formData = $A.cloneJSON(this.$store.state.cacheKeyboard);
|
||||||
screenshot_key: '',
|
|
||||||
separate_send_button: 'open',
|
|
||||||
}, $A.jsonParse(window.localStorage.getItem("__keyboard:data__")) || {});
|
|
||||||
//
|
|
||||||
this.formData_bak = $A.cloneJSON(this.formData);
|
this.formData_bak = $A.cloneJSON(this.formData);
|
||||||
},
|
},
|
||||||
|
|
||||||
submitForm() {
|
submitForm() {
|
||||||
this.$refs.formData.validate((valid) => {
|
this.$refs.formData.validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
window.localStorage.setItem("__keyboard:data__", $A.jsonStringify(this.formData));
|
this.$store.dispatch('handleKeyboard', this.formData).then((data) => {
|
||||||
if (this.$Electron) {
|
if (this.$Electron) {
|
||||||
$A.bindScreenshotKey(this.formData);
|
$A.bindScreenshotKey(data);
|
||||||
}
|
}
|
||||||
$A.messageSuccess('保存成功');
|
$A.messageSuccess('保存成功');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
resetForm() {
|
resetForm() {
|
||||||
this.formData = $A.cloneJSON(this.formData_bak);
|
this.formData = $A.cloneJSON(this.formData_bak);
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
21
resources/assets/js/store/actions.js
vendored
21
resources/assets/js/store/actions.js
vendored
@ -57,6 +57,9 @@ export default {
|
|||||||
// 主题皮肤
|
// 主题皮肤
|
||||||
await dispatch("synchTheme")
|
await dispatch("synchTheme")
|
||||||
|
|
||||||
|
// Keyboard
|
||||||
|
await dispatch("handleKeyboard")
|
||||||
|
|
||||||
// 客户端ID
|
// 客户端ID
|
||||||
if (!state.clientId) {
|
if (!state.clientId) {
|
||||||
state.clientId = $A.randomString(6)
|
state.clientId = $A.randomString(6)
|
||||||
@ -826,6 +829,24 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理快捷键配置
|
||||||
|
* @param state
|
||||||
|
* @param newData
|
||||||
|
* @returns {Promise<unknown>}
|
||||||
|
*/
|
||||||
|
handleKeyboard({state}, newData) {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
const data = $A.isJson(newData) ? newData : ($A.jsonParse(window.localStorage.getItem("__keyboard:data__")) || {})
|
||||||
|
data.screenshot_key = (data.screenshot_key || "").trim().toLowerCase()
|
||||||
|
data.send_button_app = data.send_button_app || 'button' // button, enter 移动端发送按钮,默认 button (页面按钮发送)
|
||||||
|
data.send_button_desktop = data.send_button_desktop || 'enter' // button, enter 桌面端发送按钮,默认 enter (键盘回车发送)
|
||||||
|
window.localStorage.setItem("__keyboard:data__", $A.jsonStringify(data))
|
||||||
|
state.cacheKeyboard = data
|
||||||
|
resolve(data)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 清除缓存
|
* 清除缓存
|
||||||
* @param state
|
* @param state
|
||||||
|
|||||||
3
resources/assets/js/store/state.js
vendored
3
resources/assets/js/store/state.js
vendored
@ -77,6 +77,9 @@ export default {
|
|||||||
// ServerUrl
|
// ServerUrl
|
||||||
cacheServerUrl: "",
|
cacheServerUrl: "",
|
||||||
|
|
||||||
|
// keyboard
|
||||||
|
cacheKeyboard: {},
|
||||||
|
|
||||||
// Ajax
|
// Ajax
|
||||||
ajaxWsReady: false,
|
ajaxWsReady: false,
|
||||||
ajaxWsListener: [],
|
ajaxWsListener: [],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user