@@ -170,18 +170,36 @@ const handleSorterChange = (sorter: SortState) => {
170170 });
171171};
172172mtimeCol .sortOrder = ` descend ` ;
173- const showModal = shallowRef (false );
174- const text = shallowRef (` ` );
173+ const showImportModal = shallowRef (false );
174+ const textImportValue = shallowRef (` ` );
175175const importNetwork = useTask (async () => {
176- const urls = text .value
176+ const urls = textImportValue .value
177177 .trim ()
178178 .split (` \n ` )
179179 .map ((u ) => u .trim ())
180180 .filter ((u ) => toValidURL (u ));
181181 if (urls .length == 0 ) return ;
182182 await importFromNetwork (urls );
183183 await updateSnapshots ();
184- text .value = ` ` ;
184+ textImportValue .value = ` ` ;
185+ });
186+
187+ useEventListener (document .body , ' paste' , (e ) => {
188+ const target = e .target as HTMLElement ;
189+ if (
190+ target instanceof HTMLInputElement ||
191+ target instanceof HTMLTextAreaElement ||
192+ (target .className || ' ' ).includes (' input' )
193+ ) {
194+ return ;
195+ }
196+ const dataTransfer = e .clipboardData ;
197+ if (! dataTransfer ) return ;
198+ const text = (dataTransfer .getData (' text' ) || ' ' ).trim ();
199+ if (text .startsWith (' https://' ) || text .startsWith (' http://' )) {
200+ textImportValue .value = text ;
201+ showImportModal .value = true ;
202+ }
185203});
186204
187205const checkedRowKeys = shallowRef <number []>([]);
@@ -338,9 +356,19 @@ const settingsDlgShow = shallowRef(false);
338356 </template >
339357 <div class =" whitespace-nowrap" >支持拖拽文件到页面任意位置</div >
340358 </NTooltip >
341- <NButton @click =" showModal = true" :loading =" importNetwork.loading" >
342- 导入网络文件
343- </NButton >
359+ <NTooltip placement =" left" >
360+ <template #trigger >
361+ <NButton
362+ @click =" showImportModal = true"
363+ :loading =" importNetwork.loading"
364+ >
365+ 导入网络文件
366+ </NButton >
367+ </template >
368+ <div class =" whitespace-nowrap" >
369+ 支持任意位置粘贴(Ctrl+V)文本触发导入
370+ </div >
371+ </NTooltip >
344372 </NSpace >
345373 </NPopover >
346374 <NTooltip >
@@ -401,7 +429,7 @@ const settingsDlgShow = shallowRef(false);
401429 />
402430 </div >
403431 <NModal
404- v-model:show =" showModal "
432+ v-model:show =" showImportModal "
405433 preset =" dialog"
406434 title =" 导入网络文件"
407435 :showIcon =" false"
@@ -410,13 +438,13 @@ const settingsDlgShow = shallowRef(false);
410438 style =" width : 800px "
411439 @positiveClick =" importNetwork.invoke"
412440 :loading =" importNetwork.loading"
413- @afterLeave =" text = ``"
441+ @afterLeave =" textImportValue = ``"
414442 >
415443 <NInput
416- :value =" text "
444+ :value =" textImportValue "
417445 @update:value ="
418446 if (!importNetwork.loading) {
419- text = $event;
447+ textImportValue = $event;
420448 }
421449 "
422450 type =" textarea"
0 commit comments