快捷键注册

This commit is contained in:
ruotongyu 2024-06-23 17:56:00 +08:00
parent 2bd63a8023
commit 13d6e00a88
4 changed files with 9 additions and 5 deletions

View File

@ -5,7 +5,8 @@ export const config = {
search: {
id: 0,
options: {
hash: ''
hash: '',
openDevTools: true,
}
},
config: {

View File

@ -3,7 +3,7 @@ import { useStore } from "@renderer/store/useStore"
export default() => {
const setError = useStore(state => state.setError)
const register = async ()=>{
const ret = (await window.api.sql('', 'config')) as Record<string, any>
const ret = (await window.api.sql('', 'config')) as Record<string, string>
const isBind = await window.api.shortCut(ret.shortCut)
isBind || setError("注册失败")

View File

@ -1,7 +1,8 @@
export default async ({request})=>{
console.log("request", request)
const formData = await request.formData()
console.log("data:", formData)
const data = Object.fromEntries(formData)
const isRegistered = await window.api.shortCut(data.shortCut)
if (isRegistered){
return window.api.sql(`update config set content=@content where id = 1`,

View File

@ -14,7 +14,7 @@ export const Setting = () => {
<h5></h5>
<input
type="text"
name="shortcut"
name="shortCut"
defaultValue={config.shortCut}
readOnly
onKeyDown={(e) => {
@ -26,8 +26,10 @@ export const Setting = () => {
}}
onKeyUp={(e) => {
submit(e.currentTarget.form, {method: 'POST'})
setKeys([])
console.log("keys", e.currentTarget.value)
submit(e.currentTarget.form, {method: 'POST'})
}}
/>
</section>