Feature(custom): optimize the logic of second picbed upload, and fix a bug of local picbed

This commit is contained in:
Kuingsmile
2026-01-12 21:13:21 +08:00
parent a57afd4161
commit e69ebd95ac
19 changed files with 142 additions and 165 deletions

View File

@@ -10,12 +10,14 @@ interface getPicBedType {
defaultPicBed: string
defaultConfigName: string
defaultId: string
defaultConfig: IStringKeyMap
}
const _picBeds = ref<IPicBedType[]>([])
const _defaultPicBed = ref<string>('')
const _defaultConfigName = ref<string>('')
const _defaultPicBedId = ref<string>('')
const _defaultConfigG = ref<IStringKeyMap>({})
export function usePicBed() {
const updatePicBeds = async () => {
@@ -25,6 +27,7 @@ export function usePicBed() {
_defaultPicBed.value = result.defaultPicBed
_defaultConfigName.value = result.defaultConfigName
_defaultPicBedId.value = result.defaultId
_defaultConfigG.value = result.defaultConfig
}
}
return {
@@ -32,6 +35,7 @@ export function usePicBed() {
defaultPicBedG: readonly(_defaultPicBed),
defaultConfigNameG: readonly(_defaultConfigName),
defaultIdG: readonly(_defaultPicBedId),
defaultConfigG: readonly(_defaultConfigG),
updatePicBeds,
}
}

View File

@@ -841,6 +841,7 @@
"availablePlaceholdersTitle": "Use these placeholders to customize link format",
"c1nToken": "C1N Token",
"cfWorkerHost": "CF Worker Address",
"chooseSecondPicBedMode": "Choose Second Image Bed Mode",
"chooseShowedPicBed": "Please select the image bed to display in the menu",
"clipboardAndNotification": "Clipboard and Notification",
"copySuccess": "Copy Successful: {content}",
@@ -888,6 +889,10 @@
"year2": "Year, 2 Digits",
"year4": "Year, 4 Digits"
},
"secondPicBedMode": {
"backup": "Backup Mode",
"seperate": "Separate Mode"
},
"setSecondPicBed": "Set Second Image Bed",
"setSecondPicBedDesc": "Configure secondary image bed for backup",
"shortUrlServer": "Short URL Service",

View File

@@ -836,6 +836,7 @@
"availablePlaceholdersTitle": "使用以下占位符自定义链接格式",
"c1nToken": "C1N Token",
"cfWorkerHost": "CF Worker 地址",
"chooseSecondPicBedMode": "选择第二图床模式",
"chooseShowedPicBed": "请选择显示在菜单的图床",
"clipboardAndNotification": "剪贴板和通知",
"copySuccess": "复制成功: {content}",
@@ -883,6 +884,10 @@
"year2": "年份2位数",
"year4": "年份4位数"
},
"secondPicBedMode": {
"backup": "备份模式",
"seperate": "独立模式"
},
"setSecondPicBed": "设置第二图床",
"setSecondPicBedDesc": "配置用于备份的第二图床",
"shortUrlServer": "短链接服务",

View File

@@ -836,6 +836,7 @@
"availablePlaceholdersTitle": "使用以下占位符自定義鏈接格式",
"c1nToken": "C1N Token",
"cfWorkerHost": "CF Worker 地址",
"chooseSecondPicBedMode": "選擇第二圖床模式",
"chooseShowedPicBed": "請選擇顯示在菜單的圖床",
"clipboardAndNotification": "剪貼板和通知",
"copySuccess": "複製成功: {content}",
@@ -883,6 +884,10 @@
"year2": "年份2位數",
"year4": "年份4位數"
},
"secondPicBedMode": {
"backup": "備份模式",
"seperate": "獨立模式"
},
"setSecondPicBed": "設置第二圖床",
"setSecondPicBedDesc": "配置用於備份的第二圖床",
"shortUrlServer": "短鏈接服務",

View File

@@ -388,6 +388,18 @@
</svg>
</div>
</div>
<div class="system-option-card">
<div class="system-option-header">
<Settings2Icon :size="18" />
<span>{{ t('pages.settings.upload.chooseSecondPicBedMode') }}</span>
</div>
<select v-model="currentSecondMode" class="form-select">
<option v-for="item in secondModeList" :key="item.value" :value="item.value">
{{ item.label }}
</option>
</select>
</div>
</div>
</div>
@@ -1757,6 +1769,7 @@ import {
RotateCcw,
Server,
Settings,
Settings2Icon,
Store,
} from 'lucide-vue-next'
import { marked } from 'marked'
@@ -1810,6 +1823,11 @@ const languageList = [
{ label: 'English', value: 'en' },
]
const secondModeList = [
{ label: t('pages.settings.upload.secondPicBedMode.backup'), value: 'backup' },
{ label: t('pages.settings.upload.secondPicBedMode.seperate'), value: 'seperate' },
]
const formOfSetting = ref<ISettingForm>({
showUpdateTip: true,
autoStart: false,
@@ -1900,6 +1918,12 @@ const addWatch = () => {
)
})
watch(currentSecondMode, newVal => {
if (newVal) {
saveConfig({ [configPaths.settings.secondPicBedMode]: newVal })
}
})
watch(currentLanguage, newVal => {
if (newVal) {
handleLanguageChange(newVal)
@@ -1959,6 +1983,7 @@ function copyPlaceholder(placeholder: string) {
}
const currentLanguage = ref()
const currentSecondMode = ref()
const currentStartMode = ref()
const currentShortUrlServer = ref()
@@ -2079,6 +2104,7 @@ async function initData() {
formOfSetting.value.autoImportPicBed = initArray(settings.autoImportPicBed || [], [])
currentLanguage.value = settings.language || 'zh-CN'
currentStartMode.value = settings.startMode || ISartMode.QUIET
currentSecondMode.value = settings.secondPicBedMode || 'backup'
if (osGlobal.value === 'darwin' && currentStartMode.value === ISartMode.MINI) {
currentStartMode.value = ISartMode.QUIET
saveConfig(configPaths.settings.startMode, ISartMode.QUIET)

View File

@@ -86,7 +86,7 @@
@drop.prevent="onDrop"
@dragover.prevent="dragover = true"
@dragleave.prevent="dragover = false"
@click="openUplodWindow"
@click="openUploadWindow"
>
<div class="upload-content">
<div class="upload-icon">
@@ -709,12 +709,10 @@ const taskQueueStatus = reactive<IUploadTaskQueueStatus>({
const filteredTasks = computed(() => {
let tasks = taskQueueStatus.tasks
// Filter by status
if (taskFilter.value !== 'all') {
tasks = tasks.filter(t => t.status === taskFilter.value)
}
// Filter by search query
if (taskSearchQuery.value) {
const query = taskSearchQuery.value.toLowerCase()
tasks = tasks.filter(t => t.fileName.toLowerCase().includes(query))
@@ -823,8 +821,6 @@ function onDrop(e: DragEvent) {
}
function handleURLDrag(items: DataTransferItemList, dataTransfer: DataTransfer) {
// text/html
// Use this data to get a more precise URL
const urlString = dataTransfer.getData(items[1].type)
const urlMatch = urlString.match(/<img.*src="(.*?)"/)
if (urlMatch) {
@@ -838,7 +834,7 @@ function handleURLDrag(items: DataTransferItemList, dataTransfer: DataTransfer)
}
}
function openUplodWindow() {
function openUploadWindow() {
fileInput.value?.click()
}

View File

@@ -58,7 +58,7 @@ html, body {
align-items: center;
gap: 0.5rem;
flex-wrap: wrap;
max-width: calc(100% - 300px); /* Leave space for header-actions */
max-width: calc(100% - 300px);
}
.provider-button {
@@ -164,8 +164,6 @@ html, body {
.picbed-badge.is-active {
border-color: var(--color-accent);
color: var(--color-accent);
background: var(--color-accent-soft, rgb(59 130 246 / 10%));
font-weight: 600;
}
@@ -464,7 +462,6 @@ html, body {
/* Quick Actions Card */
.card-header {
border-bottom: 1px solid var(--color-border-secondary);
padding: 1rem 1.5rem;
}
@@ -605,7 +602,7 @@ html, body {
.format-button {
border: 1px solid var(--color-border);
border-radius: var(--radius-md);
padding: 0.4rem 0.75rem;
padding: 0.5rem 0.75rem;
font-size: 0.7rem;
font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
font-weight: 500;
@@ -637,7 +634,7 @@ html, body {
.toggle-button {
border: none;
padding: 0.625rem 0.875rem;
padding: 0.325rem 0.675rem;
font-size: 0.8rem;
font-family: inherit;
font-weight: 500;

View File

@@ -172,6 +172,7 @@ export const configPaths = {
autoImportPicBed: 'settings.autoImportPicBed',
galleryPicBedFilter: 'settings.galleryPicBedFilter',
enableSecondUploader: 'settings.enableSecondUploader',
secondPicBedMode: 'settings.secondPicBedMode',
},
needReload: 'needReload',
picgoPlugins: 'picgoPlugins',