🐛 Fix(custom): fix drag upload of upload page

This commit is contained in:
Kuingsmile
2025-08-11 14:59:25 +08:00
parent 112c08d92c
commit 0bf435a0da
10 changed files with 4189 additions and 4200 deletions

View File

@@ -122,7 +122,7 @@ if (db.get(configPaths.settings.miniWindowOntop)) {
}
const renameWindowOptions = {
height: 250,
height: 270,
width: 350,
show: true,
fullscreenable: false,

View File

@@ -3,12 +3,12 @@ import path from 'node:path'
import db from '@core/datastore'
import logger from '@core/picgo/logger'
import axios from 'axios'
import { clipboard, dialog, Notification, Tray } from 'electron'
import { clipboard, Notification, Tray } from 'electron'
import FormData from 'form-data'
import fs from 'fs-extra'
import { isReactive, isRef, toRaw, unref } from 'vue'
import type { IHTTPProxy, IPrivateShowNotificationOption, IShowMessageBoxResult, IStringKeyMap } from '#/types/types'
import type { IHTTPProxy, IPrivateShowNotificationOption, IStringKeyMap } from '#/types/types'
import { configPaths } from '~/utils/configPaths'
import { IShortUrlServer } from '~/utils/enum'
@@ -87,17 +87,6 @@ export const showNotification = (
notification.show()
}
export const showMessageBox = (options: any) => {
return new Promise<IShowMessageBoxResult>(resolve => {
dialog.showMessageBox(options).then(res => {
resolve({
result: res.response,
checkboxChecked: res.checkboxChecked
})
})
})
}
/**
* macOS public.file-url will get encoded file path,
* so we need to decode it
@@ -142,7 +131,7 @@ export const getClipboardFilePath = (): string => {
const c1nApi = 'https://c1n.cn/link/short'
const generateC1NShortUrl = async (url: string) => {
const createC1NShortUrl = async (url: string) => {
const c1nToken = db.get(configPaths.settings.c1nToken) || ''
if (!c1nToken) {
logger.warn('c1n token is not set')
@@ -165,7 +154,7 @@ const generateC1NShortUrl = async (url: string) => {
return url
}
const generateYOURLSShortUrl = async (url: string) => {
const createYOURLSShortLink = async (url: string) => {
let domain = db.get(configPaths.settings.yourlsDomain) || ''
const signature = db.get(configPaths.settings.yourlsSignature) || ''
@@ -197,7 +186,7 @@ const generateYOURLSShortUrl = async (url: string) => {
return url
}
const generateCFWORKERShortUrl = async (url: string) => {
const createShortUrlForCFWorker = async (url: string) => {
let cfWorkerHost = db.get(configPaths.settings.cfWorkerHost) || ''
cfWorkerHost = cfWorkerHost.replace(/\/$/, '')
if (!cfWorkerHost) {
@@ -217,7 +206,7 @@ const generateCFWORKERShortUrl = async (url: string) => {
return url
}
const generateSinkShortUrl = async (url: string) => {
const createShortUrlFromSink = async (url: string) => {
let sinkDomain = db.get(configPaths.settings.sinkDomain) || ''
const sinkToken = db.get(configPaths.settings.sinkToken) || ''
if (!sinkDomain || !sinkToken) {
@@ -249,13 +238,13 @@ export const generateShortUrl = async (url: string) => {
const server = db.get(configPaths.settings.shortUrlServer) || IShortUrlServer.C1N
switch (server) {
case IShortUrlServer.C1N:
return generateC1NShortUrl(url)
return createC1NShortUrl(url)
case IShortUrlServer.YOURLS:
return generateYOURLSShortUrl(url)
return createYOURLSShortLink(url)
case IShortUrlServer.CFWORKER:
return generateCFWORKERShortUrl(url)
return createShortUrlForCFWorker(url)
case IShortUrlServer.SINK:
return generateSinkShortUrl(url)
return createShortUrlFromSink(url)
default:
return url
}

View File

@@ -4,10 +4,11 @@ import https from 'node:https'
import path from 'node:path'
import querystring from 'node:querystring'
import { DeleteObjectCommand, S3Client, S3ClientConfig } from '@aws-sdk/client-s3'
import type { S3ClientConfig } from '@aws-sdk/client-s3'
import { DeleteObjectCommand, S3Client } from '@aws-sdk/client-s3'
import { NodeHttpHandler } from '@smithy/node-http-handler'
import axios from 'axios'
import { ISftpPlistConfig } from 'piclist'
import type { ISftpPlistConfig } from 'piclist'
import type { IObj, IStringKeyMap } from '#/types/types'
import { getAgent } from '~/manage/utils/common'

View File

@@ -19,6 +19,7 @@ import { getConfig } from '@/utils/dataSender'
import { pageReloadCount } from '@/utils/global'
import { useAppStore } from './hooks/useAppStore'
useATagClick()
const store = useStore()

View File

@@ -6,7 +6,6 @@ export function useATagClick () {
const handleATagClick = (e: MouseEvent) => {
if (e.target instanceof HTMLAnchorElement) {
if (e.target.href) {
// avoid opening localhost development URLs in external browser
if (!e.target.href.startsWith('http://localhost:3000')) {
e.preventDefault()
window.electron.sendRPC(IRPCActionType.OPEN_URL, e.target.href)
@@ -14,9 +13,11 @@ export function useATagClick () {
}
}
}
onMounted(() => {
document.addEventListener('click', handleATagClick)
})
onUnmounted(() => {
document.removeEventListener('click', handleATagClick)
})

View File

@@ -389,7 +389,7 @@
"picBedConfigs": {
"title": "Config",
"viewDoc": "View Document",
"copyAPI": "Copy API Address",
"copyAPI": "Copy Upload API",
"noConfigOptions": "No Config Options",
"setSuccess": "Set Success",
"setFailedInfo": "Set Failed, Please Check If Config Options Are Correct",

View File

@@ -384,7 +384,7 @@
"picBedConfigs": {
"title": "配置",
"viewDoc": "查看文档",
"copyAPI": "复制API地址",
"copyAPI": "复制上传API",
"noConfigOptions": "暂无配置项",
"setSuccess": "设置成功",
"setFailedInfo": "设置失败, 请检查配置项是否正确",

View File

@@ -384,7 +384,7 @@
"picBedConfigs": {
"title": "配置",
"viewDoc": "查看文件",
"copyAPI": "複製 API 位址",
"copyAPI": "複製上傳API",
"noConfigOptions": "暫無配置項",
"setSuccess": "設定成功",
"setFailedInfo": "設定失敗,請檢查配置項是否正確",

View File

@@ -53,7 +53,3 @@ app.use(pinia)
app.use(hljsVuePlugin)
app.use(VueVideoPlayer)
app.mount('#app')
export {
i18n
}

View File

@@ -41,6 +41,7 @@
<!-- Main Upload Card -->
<div class="upload-card main-card">
<div
id="upload-area"
class="upload-zone"
:class="{ 'drag-active': dragover }"
@drop.prevent="onDrop"