mirror of
https://github.com/yuruotong1/autoMate.git
synced 2026-03-22 04:57:18 +08:00
快捷键注册
This commit is contained in:
@@ -5,7 +5,8 @@ export const config = {
|
|||||||
search: {
|
search: {
|
||||||
id: 0,
|
id: 0,
|
||||||
options: {
|
options: {
|
||||||
hash: ''
|
hash: '',
|
||||||
|
openDevTools: true,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
config: {
|
config: {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { useStore } from "@renderer/store/useStore"
|
|||||||
export default() => {
|
export default() => {
|
||||||
const setError = useStore(state => state.setError)
|
const setError = useStore(state => state.setError)
|
||||||
const register = async ()=>{
|
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)
|
const isBind = await window.api.shortCut(ret.shortCut)
|
||||||
isBind || setError("注册失败")
|
isBind || setError("注册失败")
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
export default async ({request})=>{
|
export default async ({request})=>{
|
||||||
|
console.log("request", request)
|
||||||
const formData = await request.formData()
|
const formData = await request.formData()
|
||||||
|
console.log("data:", formData)
|
||||||
const data = Object.fromEntries(formData)
|
const data = Object.fromEntries(formData)
|
||||||
|
|
||||||
const isRegistered = await window.api.shortCut(data.shortCut)
|
const isRegistered = await window.api.shortCut(data.shortCut)
|
||||||
if (isRegistered){
|
if (isRegistered){
|
||||||
return window.api.sql(`update config set content=@content where id = 1`,
|
return window.api.sql(`update config set content=@content where id = 1`,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export const Setting = () => {
|
|||||||
<h5>快捷键定义</h5>
|
<h5>快捷键定义</h5>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
name="shortcut"
|
name="shortCut"
|
||||||
defaultValue={config.shortCut}
|
defaultValue={config.shortCut}
|
||||||
readOnly
|
readOnly
|
||||||
onKeyDown={(e) => {
|
onKeyDown={(e) => {
|
||||||
@@ -26,8 +26,10 @@ export const Setting = () => {
|
|||||||
|
|
||||||
}}
|
}}
|
||||||
onKeyUp={(e) => {
|
onKeyUp={(e) => {
|
||||||
submit(e.currentTarget.form, {method: 'POST'})
|
|
||||||
setKeys([])
|
setKeys([])
|
||||||
|
console.log("keys", e.currentTarget.value)
|
||||||
|
submit(e.currentTarget.form, {method: 'POST'})
|
||||||
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
Reference in New Issue
Block a user