Skip to content

Commit 06a7a01

Browse files
committed
✨ Ctrl+Enter确定导入 #537
1 parent 74d71fa commit 06a7a01

2 files changed

Lines changed: 21 additions & 7 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "scriptcat",
3-
"version": "1.0.0-beta.1",
3+
"version": "1.1.0-beta",
44
"description": "脚本猫,一个可以执行用户脚本的浏览器扩展,万物皆可脚本化,让你的浏览器可以做更多的事情!",
55
"author": "CodFrm",
66
"license": "GPLv3",

src/pages/components/layout/MainLayout.tsx

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ const MainLayout: React.FC<{
129129
});
130130
});
131131

132+
const handleImport = async () => {
133+
const urls = importRef.current!.dom.value.split("\n").filter((v) => v);
134+
importByUrlsLocal(urls);
135+
setImportVisible(false);
136+
};
137+
132138
return (
133139
<ConfigProvider
134140
renderEmpty={() => {
@@ -147,16 +153,24 @@ const MainLayout: React.FC<{
147153
<Modal
148154
title={t("import_link")}
149155
visible={importVisible}
150-
onOk={async () => {
151-
const urls = importRef.current!.dom.value.split("\n").filter((v) => v);
152-
importByUrlsLocal(urls);
153-
setImportVisible(false);
154-
}}
156+
onOk={handleImport}
155157
onCancel={() => {
156158
setImportVisible(false);
157159
}}
158160
>
159-
<Input.TextArea ref={importRef} rows={8} placeholder={t("import_script_placeholder")} defaultValue="" />
161+
<Input.TextArea
162+
ref={importRef}
163+
rows={8}
164+
placeholder={t("import_script_placeholder")}
165+
defaultValue=""
166+
onKeyDown={(e) => {
167+
console.log(e);
168+
if (e.ctrlKey && e.key === "Enter") {
169+
e.preventDefault();
170+
handleImport();
171+
}
172+
}}
173+
/>
160174
</Modal>
161175
<div className="flex row items-center">
162176
<img style={{ height: "40px" }} src="/assets/logo.png" alt="ScriptCat" />

0 commit comments

Comments
 (0)