🐛 Fix(custom): fix window.prompt usage

This commit is contained in:
Kuingsmile
2025-08-10 16:07:25 +08:00
parent bfb7222b37
commit 66469ae2cf

View File

@@ -1490,6 +1490,61 @@
</div> </div>
</div> </div>
</div> </div>
<!-- Create Folder Dialog -->
<div
v-if="isShowCreateFolderDialog"
class="modal-overlay"
@click="isShowCreateFolderDialog = false"
>
<div
class="modal-container"
style="width: 400px;"
@click.stop
>
<div class="modal-header">
<h3 class="modal-title">
{{ t('pages.manage.bucket.createFolder') }}
</h3>
<button
class="modal-close"
@click="isShowCreateFolderDialog = false"
>
<XIcon class="action-icon" />
</button>
</div>
<div class="modal-content">
<div class="form-group">
<label class="form-label">
{{ t('pages.manage.bucket.inputFolderTitle') }}
</label>
<input
ref="folderNameInput"
v-model="newFolderName"
type="text"
class="form-input"
:placeholder="t('pages.manage.bucket.inputFolderTitle')"
@keyup.enter="confirmCreateFolder"
>
</div>
</div>
<div class="modal-footer">
<button
class="action-button secondary"
@click="isShowCreateFolderDialog = false"
>
{{ t('common.cancel') }}
</button>
<button
class="action-button primary"
:disabled="!newFolderName.trim()"
@click="confirmCreateFolder"
>
{{ t('common.confirm') }}
</button>
</div>
</div>
</div>
</div> </div>
</template> </template>
@@ -1519,7 +1574,7 @@ import {
} from 'lucide-vue-next' } from 'lucide-vue-next'
import { marked } from 'marked' import { marked } from 'marked'
import { v4 as uuidv4 } from 'uuid' import { v4 as uuidv4 } from 'uuid'
import { computed, onBeforeMount, onBeforeUnmount, reactive, ref, watch } from 'vue' import { computed, nextTick, onBeforeMount, onBeforeUnmount, reactive, ref, watch } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
@@ -1693,6 +1748,10 @@ const textfileContent = ref('')
const isShowVideoFileDialog = ref(false) const isShowVideoFileDialog = ref(false)
const videoFileUrl = ref('') const videoFileUrl = ref('')
const videoPlayerHeaders = ref({}) const videoPlayerHeaders = ref({})
// 创建文件夹相关
const isShowCreateFolderDialog = ref(false)
const newFolderName = ref('')
const folderNameInput = ref()
// 重命名相关 // 重命名相关
const isShowRenameFileIcon = computed(() => const isShowRenameFileIcon = computed(() =>
['tcyun', 'aliyun', 'qiniu', 'upyun', 's3plist', 'webdavplist', 'local', 'sftp'].includes(currentPicBedName.value) ['tcyun', 'aliyun', 'qiniu', 'upyun', 's3plist', 'webdavplist', 'local', 'sftp'].includes(currentPicBedName.value)
@@ -2300,6 +2359,8 @@ async function resetParam (force: boolean = false) {
isShowImagePreview.value = false isShowImagePreview.value = false
previewedImage.value = '' previewedImage.value = ''
isShowFileInfo.value = false isShowFileInfo.value = false
isShowCreateFolderDialog.value = false
newFolderName.value = ''
lastChoosed.value = -1 lastChoosed.value = -1
layoutStyle.value = 'grid' layoutStyle.value = 'grid'
fileSortExtReverse.value = false fileSortExtReverse.value = false
@@ -2583,27 +2644,40 @@ function handleCheckAllChange () {
} }
async function handleCreateFolder () { async function handleCreateFolder () {
const value = window.prompt(`${t('pages.manage.bucket.inputFolderTitle')}\n${t('pages.manage.bucket.createFolder')}`) newFolderName.value = ''
if (value) { isShowCreateFolderDialog.value = true
try { await nextTick()
let formatedPath = value if (folderNameInput.value) {
formatedPath = trimPath(formatedPath) folderNameInput.value.focus()
const param = { }
// tcyun }
bucketName: configMap.bucketName,
region: configMap.bucketConfig.Location, async function confirmCreateFolder () {
key: currentPrefix.value.slice(1) + formatedPath + '/', const value = newFolderName.value.trim()
githubBranch: currentCustomDomain.value if (!value) {
} return
const res = await window.electron.triggerRPC<any>(IRPCActionType.MANAGE_CREATE_BUCKET_FOLDER, configMap.alias, param) }
if (res) {
message.success(t('pages.manage.bucket.createSuccess')) isShowCreateFolderDialog.value = false
} else {
message.error(t('pages.manage.bucket.createFailed')) try {
} let formatedPath = value
} catch (error) { formatedPath = trimPath(formatedPath)
const param = {
// tcyun
bucketName: configMap.bucketName,
region: configMap.bucketConfig.Location,
key: currentPrefix.value.slice(1) + formatedPath + '/',
githubBranch: currentCustomDomain.value
}
const res = await window.electron.triggerRPC<any>(IRPCActionType.MANAGE_CREATE_BUCKET_FOLDER, configMap.alias, param)
if (res) {
message.success(t('pages.manage.bucket.createSuccess'))
} else {
message.error(t('pages.manage.bucket.createFailed')) message.error(t('pages.manage.bucket.createFailed'))
} }
} catch (error) {
message.error(t('pages.manage.bucket.createFailed'))
} }
} }