|
144 | 144 | <div |
145 | 145 | class="drop-zone" |
146 | 146 | :class="{ 'has-file': !!form.file_path, 'drag-over': isDragOver }" |
147 | | - @click="pickFileOrFolder" |
| 147 | + @click="pickFile" |
148 | 148 | @dragover.prevent="isDragOver = true" |
149 | 149 | @dragleave.prevent="isDragOver = false" |
150 | 150 | @drop.prevent="onDrop" |
|
167 | 167 | <span class="dz-upload-icon" v-html="uploadIcon" /> |
168 | 168 | <span class="dz-text">{{ t('addModal.file.dragHint') }}</span> |
169 | 169 | <span class="dz-hint">{{ t('addModal.file.orBrowse') }}</span> |
| 170 | + <div class="file-choice-actions" @click.stop> |
| 171 | + <button type="button" class="file-choice-btn" @click="pickFile"> |
| 172 | + <span v-html="uploadIcon" />{{ t('addModal.file.chooseFile') }} |
| 173 | + </button> |
| 174 | + <button type="button" class="file-choice-btn" @click="pickFolder"> |
| 175 | + <span v-html="folderIcon" />{{ t('addModal.file.chooseFolder') }} |
| 176 | + </button> |
| 177 | + </div> |
170 | 178 | </template> |
171 | 179 | </div> |
172 | 180 | <div class="path-row"> |
|
176 | 184 | :placeholder="t('addModal.file.placeholder')" |
177 | 185 | @change="onPathChange" |
178 | 186 | /> |
179 | | - <button class="browse-btn" @click.stop="pickFileOrFolder" v-html="folderIcon" :title="t('addModal.file.browse')" /> |
| 187 | + <button class="browse-btn" @click.stop="pickFile" v-html="folderIcon" :title="t('addModal.file.browse')" /> |
180 | 188 | </div> |
181 | 189 | </div> |
182 | 190 |
|
@@ -614,9 +622,14 @@ async function createDocument() { |
614 | 622 | } |
615 | 623 |
|
616 | 624 | // ── 单个文件操作 ──────────────────────────────────────── |
617 | | -async function pickFileOrFolder() { |
618 | | - const selection = await window.api.files.pickFileOrFolder() |
619 | | - if (selection) applyPathSelection(selection.path, selection.isDirectory) |
| 625 | +async function pickFile() { |
| 626 | + const path = await window.api.files.pickFile() |
| 627 | + if (path) applyPathSelection(path, false) |
| 628 | +} |
| 629 | +
|
| 630 | +async function pickFolder() { |
| 631 | + const path = await window.api.files.pickFolder() |
| 632 | + if (path) applyPathSelection(path, true) |
620 | 633 | } |
621 | 634 |
|
622 | 635 | function onDrop(e: DragEvent) { |
@@ -721,7 +734,6 @@ async function submitWebpage() { |
721 | 734 | } |
722 | 735 | } |
723 | 736 |
|
724 | | -// ── 文件夹操作 ────────────────────────────────────────── |
725 | 737 | // ── 扫描目录操作 ──────────────────────────────────────── |
726 | 738 | async function pickScanDir() { |
727 | 739 | const path = await window.api.files.pickFolder() |
@@ -1111,6 +1123,11 @@ const scanDirIcon = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor |
1111 | 1123 | color: var(--text-3); |
1112 | 1124 | } |
1113 | 1125 |
|
| 1126 | +.file-choice-actions { display: flex; gap: 8px; margin-top: 4px; } |
| 1127 | +.file-choice-btn { display: inline-flex; align-items: center; gap: 5px; padding: 6px 9px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface-2); color: var(--text-2); font: inherit; font-size: 12px; cursor: pointer; } |
| 1128 | +.file-choice-btn:hover { border-color: var(--accent); color: var(--text); } |
| 1129 | +.file-choice-btn :deep(svg) { width: 14px; height: 14px; } |
| 1130 | +
|
1114 | 1131 | .spinner { |
1115 | 1132 | width: 24px; |
1116 | 1133 | height: 24px; |
|
0 commit comments