🚧 WIP: add local picbed into manage page, optimize webdav picbed
@@ -275,6 +275,7 @@ SETTINGS_SYNC_DOWNLOAD_FAILED: Download failed
|
||||
SETTINGS_SYNC_COMMON_CONFIG: Common configuration
|
||||
SETTINGS_SYNC_MANAGE_CONFIG: Manage configuration
|
||||
SETTINGS_AUTO_IMPORT: Auto import config in manage page
|
||||
SETTINGS_AUTO_IMPORT_SELECT_PICBED: Select picbed
|
||||
SETTINGS_TAB_SYSTEM: System
|
||||
SETTINGS_TAB_SYNC_CONFIG: Sync and Configuration
|
||||
SETTINGS_TAB_UPLOAD: Upload
|
||||
@@ -598,6 +599,9 @@ MANAGE_CONSTANT_WEBDAV_CUSTOM_URL_DESC: Custom Domain - Optional
|
||||
MANAGE_CONSTANT_WEBDAV_CUSTOM_URL_PLACEHOLDER: 'e.g. https://example.com'
|
||||
MANAGE_CONSTANT_WEBDAV_CUSTOM_URL_TOOLTIP: If your WebDAV server supports custom domains, please fill in
|
||||
MANAGE_CONSTANT_WEBDAV_CUSTOM_URL_RULE_MESSAGE: 'Custom domain should start with http:// or https://'
|
||||
MANAGE_CONSTANT_WEBDAV_WEB_PATH: Web Path - Optional
|
||||
MANAGE_CONSTANT_WEBDAV_WEB_PATH_PLACEHOLDER: 'e.g. test/ttc'
|
||||
MANAGE_CONSTANT_WEBDAV_WEB_PATH_TOOLTIP: 'Used to generate URL'
|
||||
MANAGE_CONSTANT_WEBDAV_PROXY_DESC: Proxy - Optional
|
||||
MANAGE_CONSTANT_WEBDAV_PROXY_PLACEHOLDER: 'e.g. http://127.0.0.1:1080'
|
||||
MANAGE_CONSTANT_WEBDAV_PROXY_TOOLTIP: If special network environment is required to access, please use proxy
|
||||
@@ -606,6 +610,21 @@ MANAGE_CONSTANT_WEBDAV_SSL_TOOLTIP: Depending on the configuration of your WebDA
|
||||
MANAGE_CONSTANT_WEBDAV_EXPLAIN: 'WebDAV Configuration'
|
||||
MANAGE_CONSTANT_WEBDAV_REFER_TEXT: 'Refer to:'
|
||||
|
||||
MANAGE_CONSTANT_LOCAL_NAME: Local
|
||||
MANAGE_CONSTANT_LOCAL_ALIAS_DESC: Alias - Required
|
||||
MANAGE_CONSTANT_LOCAL_ALIAS_PLACEHOLDER: Unique identifier for this configuration
|
||||
MANAGE_CONSTANT_LOCAL_BASE_DIR_DESC: Base directory - Required
|
||||
MANAGE_CONSTANT_LOCAL_BASE_DIR_PLACEHOLDER: 'e.g. /dir1'
|
||||
MANAGE_CONSTANT_LOCAL_CUSTOM_URL_DESC: Custom Domain - Optional
|
||||
MANAGE_CONSTANT_LOCAL_CUSTOM_URL_PLACEHOLDER: 'e.g. https://example.com'
|
||||
MANAGE_CONSTANT_LOCAL_CUSTOM_URL_TOOLTIP: If your local path supports custom domains, please fill in
|
||||
MANAGE_CONSTANT_LOCAL_WEB_PATH: Web Path - Optional
|
||||
MANAGE_CONSTANT_LOCAL_WEB_PATH_PLACEHOLDER: 'e.g. test/ttc'
|
||||
MANAGE_CONSTANT_LOCAL_WEB_PATH_TOOLTIP: 'Used to generate URL'
|
||||
MANAGE_CONSTANT_LOCAL_EXPLAIN: 'Local Configuration'
|
||||
MANAGE_CONSTANT_LOCAL_REFER_TEXT: 'Refer to:'
|
||||
MANAGE_CONSTANT_LOCAL_BASE_DIR_RULE_MESSAGE: baseDir cannot be empty
|
||||
|
||||
MANAGE_LOGIN_PAGE_PANE_NAME: Saved Config
|
||||
MANAGE_LOGIN_PAGE_PANE_DESC: Click on the icon or alias to view details, Enter to view the file page, Delete to remove the configuration
|
||||
MANAGE_LOGIN_PAGE_PANE_LOADING: Importing...
|
||||
|
||||
@@ -278,6 +278,7 @@ SETTINGS_SYNC_DOWNLOAD_FAILED: 下载失败
|
||||
SETTINGS_SYNC_COMMON_CONFIG: 通用配置
|
||||
SETTINGS_SYNC_MANAGE_CONFIG: 管理配置
|
||||
SETTINGS_AUTO_IMPORT: 管理页面自动导入配置
|
||||
SETTINGS_AUTO_IMPORT_SELECT_PICBED: 选择需要开启自动导入的图床
|
||||
SETTINGS_TAB_SYSTEM: 系统设置
|
||||
SETTINGS_TAB_SYNC_CONFIG: 同步与配置
|
||||
SETTINGS_TAB_UPLOAD: 上传设置
|
||||
@@ -601,6 +602,9 @@ MANAGE_CONSTANT_WEBDAV_CUSTOM_URL_DESC: 自定义域名-可选
|
||||
MANAGE_CONSTANT_WEBDAV_CUSTOM_URL_PLACEHOLDER: '例如:https://example.com'
|
||||
MANAGE_CONSTANT_WEBDAV_CUSTOM_URL_TOOLTIP: 如果您的WebDAV服务器支持自定义域名,请填写
|
||||
MANAGE_CONSTANT_WEBDAV_CUSTOM_URL_RULE_MESSAGE: '自定义域名请以http://或https://开头'
|
||||
MANAGE_CONSTANT_WEBDAV_WEB_PATH: 网址拼接用起始路径
|
||||
MANAGE_CONSTANT_WEBDAV_WEB_PATH_PLACEHOLDER: '例如:test/ttc'
|
||||
MANAGE_CONSTANT_WEBDAV_WEB_PATH_TOOLTIP: '用于拼接网址'
|
||||
MANAGE_CONSTANT_WEBDAV_PROXY_DESC: 代理-可选
|
||||
MANAGE_CONSTANT_WEBDAV_PROXY_PLACEHOLDER: '例如:http://127.0.0.1:1080'
|
||||
MANAGE_CONSTANT_WEBDAV_PROXY_TOOLTIP: 如果需要特殊网络环境才能访问,请使用代理
|
||||
@@ -609,6 +613,21 @@ MANAGE_CONSTANT_WEBDAV_SSL_TOOLTIP: 根据WebDAV服务器的配置,如果您
|
||||
MANAGE_CONSTANT_WEBDAV_EXPLAIN: 'WebDAV配置'
|
||||
MANAGE_CONSTANT_WEBDAV_REFER_TEXT: '配置教程请参考: '
|
||||
|
||||
MANAGE_CONSTANT_LOCAL_NAME: 本地存储
|
||||
MANAGE_CONSTANT_LOCAL_ALIAS_DESC: 配置别名-必需
|
||||
MANAGE_CONSTANT_LOCAL_ALIAS_PLACEHOLDER: 该配置的唯一标识
|
||||
MANAGE_CONSTANT_LOCAL_BASE_DIR_DESC: 起始目录-必需
|
||||
MANAGE_CONSTANT_LOCAL_BASE_DIR_PLACEHOLDER: 请填写起始目录
|
||||
MANAGE_CONSTANT_LOCAL_CUSTOM_URL_DESC: 自定义域名-可选
|
||||
MANAGE_CONSTANT_LOCAL_CUSTOM_URL_PLACEHOLDER: '例如:https://example.com'
|
||||
MANAGE_CONSTANT_LOCAL_CUSTOM_URL_TOOLTIP: 如果您的本地存储支持自定义域名,请填写
|
||||
MANAGE_CONSTANT_LOCAL_WEB_PATH: 网址拼接用起始路径
|
||||
MANAGE_CONSTANT_LOCAL_WEB_PATH_PLACEHOLDER: '例如:test/ttc'
|
||||
MANAGE_CONSTANT_LOCAL_WEB_PATH_TOOLTIP: '用于拼接网址'
|
||||
MANAGE_CONSTANT_LOCAL_EXPLAIN: '本地存储配置'
|
||||
MANAGE_CONSTANT_LOCAL_REFER_TEXT: '配置教程请参考: '
|
||||
MANAGE_CONSTANT_LOCAL_BASE_DIR_RULE_MESSAGE: 起始目录不能为空
|
||||
|
||||
MANAGE_LOGIN_PAGE_PANE_NAME: 已保存配置
|
||||
MANAGE_LOGIN_PAGE_PANE_DESC: 点击图标和别名可查看详情,点击进入可查看文件页面,点击删除可删除配置
|
||||
MANAGE_LOGIN_PAGE_PANE_LOADING: 导入配置...
|
||||
|
||||
@@ -276,6 +276,7 @@ SETTINGS_SYNC_DOWNLOAD_FAILED: 下載失敗
|
||||
SETTINGS_SYNC_COMMON_CONFIG: 通用配置
|
||||
SETTINGS_SYNC_MANAGE_CONFIG: 管理配置
|
||||
SETTINGS_AUTO_IMPORT: 管理頁面自動導入配置
|
||||
SETTINGS_AUTO_IMPORT_SELECT_PICBED: 選擇需要開啟自動導入的圖床
|
||||
SETTINGS_TAB_SYSTEM: 系統設置
|
||||
SETTINGS_TAB_SYNC_CONFIG: 同步與配置
|
||||
SETTINGS_TAB_UPLOAD: 上傳設置
|
||||
@@ -598,6 +599,9 @@ MANAGE_CONSTANT_WEBDAV_CUSTOM_URL_DESC: 自訂網域名稱-可選
|
||||
MANAGE_CONSTANT_WEBDAV_CUSTOM_URL_PLACEHOLDER: '例如:https://example.com'
|
||||
MANAGE_CONSTANT_WEBDAV_CUSTOM_URL_TOOLTIP: 如果您的WebDAV伺服器支援自訂網域名稱,請填寫
|
||||
MANAGE_CONSTANT_WEBDAV_CUSTOM_URL_RULE_MESSAGE: '自訂網域名稱請以http://或https://開頭'
|
||||
MANAGE_CONSTANT_WEBDAV_WEB_PATH: WebDAV網路路徑-可選
|
||||
MANAGE_CONSTANT_WEBDAV_WEB_PATH_PLACEHOLDER: '例如:test/ttc'
|
||||
MANAGE_CONSTANT_WEBDAV_WEB_PATH_TOOLTIP: '用於拼接網址'
|
||||
MANAGE_CONSTANT_WEBDAV_PROXY_DESC: 代理-可選
|
||||
MANAGE_CONSTANT_WEBDAV_PROXY_PLACEHOLDER: '例如:http://127.0.0.1:1080'
|
||||
MANAGE_CONSTANT_WEBDAV_PROXY_TOOLTIP: 如果需要特殊網路環境才能訪問,請使用代理
|
||||
@@ -606,6 +610,21 @@ MANAGE_CONSTANT_WEBDAV_SSL_TOOLTIP: 根據WebDAV伺服器的配置,如果您
|
||||
MANAGE_CONSTANT_WEBDAV_EXPLAIN: 'WebDAV配置'
|
||||
MANAGE_CONSTANT_WEBDAV_REFER_TEXT: '配置教程請參考: '
|
||||
|
||||
MANAGE_CONSTANT_LOCAL_NAME: 本地
|
||||
MANAGE_CONSTANT_LOCAL_ALIAS_DESC: 配置別名-必需
|
||||
MANAGE_CONSTANT_LOCAL_ALIAS_PLACEHOLDER: 該配置的唯一標識
|
||||
MANAGE_CONSTANT_LOCAL_BASE_DIR_DESC: 起始目錄-必需
|
||||
MANAGE_CONSTANT_LOCAL_BASE_DIR_PLACEHOLDER: 請填寫起始目錄
|
||||
MANAGE_CONSTANT_LOCAL_CUSTOM_URL_DESC: 自定義網域-可選
|
||||
MANAGE_CONSTANT_LOCAL_CUSTOM_URL_PLACEHOLDER: '例如:https://example.com'
|
||||
MANAGE_CONSTANT_LOCAL_CUSTOM_URL_TOOLTIP: 如果您的目錄支援自定義網域,請填寫
|
||||
MANAGE_CONSTANT_LOCAL_WEB_PATH: 網路路徑-可選
|
||||
MANAGE_CONSTANT_LOCAL_WEB_PATH_PLACEHOLDER: '例如:test/ttc'
|
||||
MANAGE_CONSTANT_LOCAL_WEB_PATH_TOOLTIP: '用於拼接網址'
|
||||
MANAGE_CONSTANT_LOCAL_EXPLAIN: '本地配置'
|
||||
MANAGE_CONSTANT_LOCAL_REFER_TEXT: '配置教程請參考: '
|
||||
MANAGE_CONSTANT_LOCAL_BASE_DIR_RULE_MESSAGE: 起始目錄不能為空
|
||||
|
||||
MANAGE_LOGIN_PAGE_PANE_NAME: 已保存配置
|
||||
MANAGE_LOGIN_PAGE_PANE_DESC: 點擊圖標和別名可查看詳情,點擊進入可查看檔案頁面,點擊刪除可刪除配置
|
||||
MANAGE_LOGIN_PAGE_PANE_LOADING: 導入配置...
|
||||
|
||||
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 17 KiB |
BIN
public/picbed/sftp.png
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 17 KiB |
56
src/renderer/components/ImageLocal.vue
Normal file
@@ -0,0 +1,56 @@
|
||||
<template>
|
||||
<el-image
|
||||
:src="isShowThumbnail && item.isImage ?
|
||||
base64Image
|
||||
: require(`../manage/pages/assets/icons/${getFileIconPath(item.fileName ?? '')}`)"
|
||||
fit="contain"
|
||||
style="height: 100px;width: 100%;margin: 0 auto;"
|
||||
>
|
||||
<template #placeholder>
|
||||
<el-icon>
|
||||
<Loading />
|
||||
</el-icon>
|
||||
</template>
|
||||
<template #error>
|
||||
<el-image
|
||||
:src="require(`../manage/pages/assets/icons/${getFileIconPath(item.fileName ?? '')}`)"
|
||||
fit="contain"
|
||||
style="height: 100px;width: 100%;margin: 0 auto;"
|
||||
/>
|
||||
</template>
|
||||
</el-image>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, onBeforeMount } from 'vue'
|
||||
import { getFileIconPath } from '@/manage/utils/common'
|
||||
import { Loading } from '@element-plus/icons-vue'
|
||||
import fs from 'fs-extra'
|
||||
|
||||
const base64Image = ref('')
|
||||
const props = defineProps(
|
||||
{
|
||||
isShowThumbnail: {
|
||||
type: Boolean,
|
||||
required: true
|
||||
},
|
||||
item: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
localPath: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
const createBase64Image = async () => {
|
||||
const base64 = await fs.readFile(props.localPath, 'base64')
|
||||
base64Image.value = `data:image/png;base64,${base64}`
|
||||
}
|
||||
|
||||
onBeforeMount(async () => {
|
||||
await createBase64Image()
|
||||
})
|
||||
</script>
|
||||
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
@@ -61,17 +61,24 @@
|
||||
/>
|
||||
</el-table>
|
||||
<template #reference>
|
||||
<el-button
|
||||
style="width: 100%; text-align: center;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;"
|
||||
<el-tooltip
|
||||
effect="light"
|
||||
:content="item.alias"
|
||||
placement="top"
|
||||
:disabled="item.alias.length <= 15"
|
||||
>
|
||||
<template #icon>
|
||||
<img
|
||||
:src="require(`./assets/${item.picBedName}.webp`)"
|
||||
style="width: 25px; height: 25px;"
|
||||
>
|
||||
</template>
|
||||
{{ item.alias }}
|
||||
</el-button>
|
||||
<el-button
|
||||
style="width: 100%; text-align: center;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;"
|
||||
>
|
||||
<template #icon>
|
||||
<img
|
||||
:src="require(`./assets/${item.picBedName}.webp`)"
|
||||
style="width: 25px; height: 25px;"
|
||||
>
|
||||
</template>
|
||||
{{ item.alias.length > 15 ? item.alias.slice(0, 8) + '...' + item.alias.slice(-6) : item.alias }}
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-popover>
|
||||
<br>
|
||||
@@ -485,9 +492,7 @@ const getAllConfigAliasArray = async () => {
|
||||
for (const key in allConfigAliasMap) {
|
||||
delete allConfigAliasMap[key]
|
||||
}
|
||||
if (!result) {
|
||||
return
|
||||
}
|
||||
if (!result) return
|
||||
let i = 0
|
||||
Object.keys(result).forEach((key) => {
|
||||
allConfigAliasMap[i] = {
|
||||
@@ -536,232 +541,218 @@ function handleConfigImport (alias: string) {
|
||||
}
|
||||
}
|
||||
|
||||
const importedNewConfig: IStringKeyMap = {}
|
||||
|
||||
async function getCurrentConfigList () {
|
||||
const configList = await getPicBedsConfig<any>('uploader') ?? {}
|
||||
const pbList = ['aliyun', 'tcyun', 'upyun', 'qiniu', 'smms', 'qiniu', 'github', 'webdavplist', 'aws-s3', 'imgur']
|
||||
const filteredConfigList = pbList.map((pb) => {
|
||||
const pbList = ['aliyun', 'tcyun', 'upyun', 'qiniu', 'smms', 'qiniu', 'github', 'webdavplist', 'aws-s3', 'imgur', 'local']
|
||||
const filteredConfigList = pbList.flatMap((pb) => {
|
||||
const config = configList[pb]
|
||||
if (config && config.configList.length > 0) {
|
||||
config.configList.forEach((item: any) => {
|
||||
item.type = pb
|
||||
})
|
||||
return config
|
||||
return config.configList.map((item: any) => ({ ...item, type: pb }))
|
||||
} else {
|
||||
return null
|
||||
return []
|
||||
}
|
||||
}).filter((config) => config && config.configList.length > 0)
|
||||
})
|
||||
await getAllConfigAliasArray()
|
||||
const promises: Promise<any>[] = []
|
||||
for (const config of filteredConfigList.flatMap((config) => config.configList)) {
|
||||
const pb = config.type
|
||||
promises.push(transUpToManage(config, pb))
|
||||
const autoImport = await getPicBedsConfig<boolean>('settings.autoImport') || false
|
||||
if (!autoImport) return
|
||||
const autoImportPicBed = initArray(await getPicBedsConfig<string | string[]>('settings.autoImportPicBed') || '', [])
|
||||
await Promise.all(filteredConfigList.flatMap((config) => transUpToManage(config, config.type, autoImportPicBed)))
|
||||
if (Object.keys(importedNewConfig).length > 0) {
|
||||
const oldConfig = await getConfig<any>('picBed')
|
||||
const newConfig = { ...oldConfig, ...importedNewConfig }
|
||||
saveConfig('picBed', newConfig)
|
||||
await manageStore.refreshConfig()
|
||||
}
|
||||
await Promise.all(promises)
|
||||
}
|
||||
|
||||
function isImported (alias: string) {
|
||||
for (const key in allConfigAliasMap) {
|
||||
if (allConfigAliasMap[key].alias === alias) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return Object.values(allConfigAliasMap).some((item) => item.alias === alias)
|
||||
}
|
||||
|
||||
async function transUpToManage (config: IUploaderConfigListItem, picBedName: string) {
|
||||
const autoImport = await getConfig<boolean>('settings.autoImport') || false
|
||||
if (!autoImport) {
|
||||
return
|
||||
function initArray (arrayT: string | string[], defaultValue: string[]) {
|
||||
if (!Array.isArray(arrayT)) {
|
||||
arrayT = arrayT ? [arrayT] : defaultValue
|
||||
}
|
||||
return arrayT
|
||||
}
|
||||
|
||||
async function transUpToManage (config: IUploaderConfigListItem, picBedName: string, autoImportPicBed: string[]) {
|
||||
const alias = `${picBedName === 'webdavplist' ? 'webdav' : picBedName}-${config._configName ?? 'Default'}-imp`
|
||||
if (!autoImportPicBed.includes(picBedName) || isImported(alias)) return
|
||||
const commonConfig = {
|
||||
alias,
|
||||
picBedName,
|
||||
paging: true
|
||||
}
|
||||
let alias: string = ''
|
||||
const resultMap: IStringKeyMap = {}
|
||||
switch (picBedName) {
|
||||
case 'smms':
|
||||
alias = `smms-${config._configName ?? 'Default'}-imp`
|
||||
if (!config.token || isImported(alias)) {
|
||||
return
|
||||
}
|
||||
resultMap.alias = alias
|
||||
resultMap.picBedName = 'smms'
|
||||
resultMap.token = config.token
|
||||
resultMap.paging = true
|
||||
saveConfig(`picBed.${resultMap.alias}`, resultMap)
|
||||
if (!config.token) return
|
||||
Object.assign(resultMap, {
|
||||
...commonConfig,
|
||||
token: config.token
|
||||
})
|
||||
break
|
||||
case 'aliyun':
|
||||
if (!config.accessKeyId || !config.accessKeySecret) {
|
||||
return
|
||||
}
|
||||
resultMap.alias = `aliyun-${config._configName ?? 'Default'}-imp`
|
||||
resultMap.picBedName = 'aliyun'
|
||||
resultMap.accessKeyId = config.accessKeyId
|
||||
resultMap.accessKeySecret = config.accessKeySecret
|
||||
resultMap.bucketName = ''
|
||||
resultMap.baseDir = '/'
|
||||
resultMap.paging = true
|
||||
resultMap.itemsPerPage = 50
|
||||
resultMap.isAutoCustomUrl = !config.customUrl
|
||||
resultMap.transformedConfig = JSON.stringify(config.customUrl
|
||||
? {
|
||||
[config.bucket]: {
|
||||
customUrl: config.customUrl
|
||||
}
|
||||
}
|
||||
: {})
|
||||
resultMap.paging = true
|
||||
saveConfig(`picBed.${resultMap.alias}`, resultMap)
|
||||
break
|
||||
case 'qiniu':
|
||||
alias = `qiniu-${config._configName ?? 'Default'}-imp`
|
||||
if (!config.accessKey || !config.secretKey || isImported(alias)) {
|
||||
return
|
||||
}
|
||||
resultMap.alias = alias
|
||||
resultMap.picBedName = 'qiniu'
|
||||
resultMap.accessKey = config.accessKey
|
||||
resultMap.secretKey = config.secretKey
|
||||
resultMap.bucketName = ''
|
||||
resultMap.baseDir = '/'
|
||||
resultMap.isAutoCustomUrl = false
|
||||
resultMap.transformedConfig = JSON.stringify({ [config.bucket]: config.url })
|
||||
resultMap.paging = true
|
||||
resultMap.itemsPerPage = 50
|
||||
saveConfig(`picBed.${resultMap.alias}`, resultMap)
|
||||
break
|
||||
case 'tcyun':
|
||||
alias = `tcyun-${config._configName ?? 'Default'}-imp`
|
||||
if (!config.secretId || !config.secretKey || config.version === 'v4' || isImported(alias)) {
|
||||
return
|
||||
}
|
||||
resultMap.alias = alias
|
||||
resultMap.picBedName = 'tcyun'
|
||||
resultMap.secretId = config.secretId
|
||||
resultMap.secretKey = config.secretKey
|
||||
resultMap.bucketName = ''
|
||||
resultMap.baseDir = '/'
|
||||
resultMap.appId = config.appId
|
||||
resultMap.isAutoCustomUrl = !config.customUrl
|
||||
resultMap.transformedConfig = JSON.stringify(config.customUrl
|
||||
? {
|
||||
[config.bucket]: {
|
||||
customUrl: config.customUrl
|
||||
}
|
||||
}
|
||||
: {})
|
||||
resultMap.paging = true
|
||||
resultMap.itemsPerPage = 50
|
||||
saveConfig(`picBed.${resultMap.alias}`, resultMap)
|
||||
break
|
||||
case 'github':
|
||||
alias = `github-${config._configName ?? 'Default'}-imp`
|
||||
if (!config.token || isImported(alias)) {
|
||||
return
|
||||
}
|
||||
resultMap.alias = alias
|
||||
resultMap.picBedName = 'github'
|
||||
resultMap.token = config.token
|
||||
resultMap.githubUsername = config.repo.split('/')[0]
|
||||
resultMap.customUrl = ''
|
||||
resultMap.proxy = ''
|
||||
resultMap.paging = true
|
||||
resultMap.itemsPerPage = 50
|
||||
saveConfig(`picBed.${resultMap.alias}`, resultMap)
|
||||
break
|
||||
case 'upyun':
|
||||
alias = `upyun-${config._configName ?? 'Default'}-imp`
|
||||
if (!config.operator || !config.password || isImported(alias)) {
|
||||
return
|
||||
}
|
||||
resultMap.alias = alias
|
||||
resultMap.picBedName = 'upyun'
|
||||
resultMap.operator = config.operator
|
||||
resultMap.password = config.password
|
||||
resultMap.bucketName = config.bucket
|
||||
resultMap.baseDir = '/'
|
||||
resultMap.customUrl = config.url
|
||||
resultMap.transformedConfig = JSON.stringify({
|
||||
[config.bucket]: {
|
||||
customUrl: config.url,
|
||||
baseDir: '/',
|
||||
area: '',
|
||||
operator: config.operator,
|
||||
password: config.password
|
||||
}
|
||||
})
|
||||
resultMap.paging = true
|
||||
resultMap.itemsPerPage = 50
|
||||
saveConfig(`picBed.${resultMap.alias}`, resultMap)
|
||||
break
|
||||
case 'webdavplist':
|
||||
alias = `webdav-${config._configName ?? 'Default'}-imp`
|
||||
if (!config.host || isImported(alias)) {
|
||||
return
|
||||
}
|
||||
resultMap.alias = alias
|
||||
resultMap.endpoint = formatEndpoint(config.host, config.sslEnabled)
|
||||
resultMap.picBedName = 'webdavplist'
|
||||
resultMap.username = config.username
|
||||
resultMap.password = config.password
|
||||
resultMap.bucketName = 'webdav'
|
||||
resultMap.baseDir = config.path || '/'
|
||||
resultMap.customUrl = config.customUrl || ''
|
||||
resultMap.sslEnabled = !!config.sslEnabled
|
||||
resultMap.proxy = ''
|
||||
resultMap.transformedConfig = JSON.stringify({
|
||||
webdav: {
|
||||
operator: '',
|
||||
password: config.password,
|
||||
baseDir: config.path || '/',
|
||||
customUrl: config.customUrl || '',
|
||||
area: ''
|
||||
}
|
||||
})
|
||||
saveConfig(`picBed.${resultMap.alias}`, resultMap)
|
||||
break
|
||||
case 'aws-s3':
|
||||
alias = `aws-s3-${config._configName ?? 'Default'}-imp`
|
||||
if (!config.accessKeyID || !config.secretAccessKey || isImported(alias)) {
|
||||
return
|
||||
}
|
||||
resultMap.alias = alias
|
||||
resultMap.picBedName = 's3plist'
|
||||
resultMap.accessKeyId = config.accessKeyID
|
||||
resultMap.secretAccessKey = config.secretAccessKey
|
||||
resultMap.endpoint = config.endpoint || ''
|
||||
resultMap.baseDir = '/'
|
||||
resultMap.bucketName = ''
|
||||
resultMap.paging = true
|
||||
resultMap.itemsPerPage = 50
|
||||
resultMap.proxy = ''
|
||||
resultMap.sslEnabled = config.endpoint ? config.endpoint.startsWith('https') : false
|
||||
resultMap.aclForUpload = 'public-read'
|
||||
resultMap.s3ForcePathStyle = config.pathStyleAccess
|
||||
resultMap.transformedConfig = JSON.stringify(
|
||||
config.urlPrefix
|
||||
if (!config.accessKeyId || !config.accessKeySecret) return
|
||||
Object.assign(resultMap, {
|
||||
...commonConfig,
|
||||
accessKeyId: config.accessKeyId,
|
||||
accessKeySecret: config.accessKeySecret,
|
||||
bucketName: '',
|
||||
baseDir: '/',
|
||||
itemsPerPage: 50,
|
||||
isAutoCustomUrl: !config.customUrl,
|
||||
transformedConfig: JSON.stringify(config.customUrl
|
||||
? {
|
||||
[config.bucketName]: {
|
||||
customUrl: config.urlPrefix
|
||||
[config.bucket]: {
|
||||
customUrl: config.customUrl
|
||||
}
|
||||
}
|
||||
: {}
|
||||
)
|
||||
saveConfig(`picBed.${resultMap.alias}`, resultMap)
|
||||
: {})
|
||||
})
|
||||
break
|
||||
case 'qiniu':
|
||||
if (!config.accessKey || !config.secretKey) return
|
||||
Object.assign(resultMap, {
|
||||
...commonConfig,
|
||||
accessKey: config.accessKey,
|
||||
secretKey: config.secretKey,
|
||||
bucketName: '',
|
||||
baseDir: '/',
|
||||
isAutoCustomUrl: false,
|
||||
transformedConfig: JSON.stringify({ [config.bucket]: config.url }),
|
||||
itemsPerPage: 50
|
||||
})
|
||||
break
|
||||
case 'tcyun':
|
||||
if (!config.secretId || !config.secretKey || config.version === 'v4') return
|
||||
Object.assign(resultMap, {
|
||||
...commonConfig,
|
||||
secretId: config.secretId,
|
||||
secretKey: config.secretKey,
|
||||
bucketName: '',
|
||||
baseDir: '/',
|
||||
appId: config.appId,
|
||||
isAutoCustomUrl: !config.customUrl,
|
||||
transformedConfig: JSON.stringify(config.customUrl
|
||||
? {
|
||||
[config.bucket]: {
|
||||
customUrl: config.customUrl
|
||||
}
|
||||
}
|
||||
: {}),
|
||||
itemsPerPage: 50
|
||||
})
|
||||
break
|
||||
case 'github':
|
||||
if (!config.token) return
|
||||
Object.assign(resultMap, {
|
||||
...commonConfig,
|
||||
token: config.token,
|
||||
githubUsername: config.repo.split('/')[0],
|
||||
customUrl: '',
|
||||
proxy: '',
|
||||
itemsPerPage: 50
|
||||
})
|
||||
break
|
||||
case 'upyun':
|
||||
if (!config.operator || !config.password) return
|
||||
Object.assign(resultMap, {
|
||||
...commonConfig,
|
||||
operator: config.operator,
|
||||
password: config.password,
|
||||
bucketName: config.bucket,
|
||||
baseDir: '/',
|
||||
customUrl: config.url,
|
||||
transformedConfig: JSON.stringify({
|
||||
[config.bucket]: {
|
||||
customUrl: config.url,
|
||||
baseDir: '/',
|
||||
area: '',
|
||||
operator: config.operator,
|
||||
password: config.password
|
||||
}
|
||||
}),
|
||||
itemsPerPage: 50
|
||||
})
|
||||
break
|
||||
case 'webdavplist':
|
||||
if (!config.host) return
|
||||
Object.assign(resultMap, {
|
||||
...commonConfig,
|
||||
endpoint: formatEndpoint(config.host, config.sslEnabled),
|
||||
username: config.username,
|
||||
password: config.password,
|
||||
bucketName: 'webdav',
|
||||
baseDir: config.path || '/',
|
||||
webPath: config.webpath || '',
|
||||
customUrl: config.customUrl || '',
|
||||
sslEnabled: !!config.sslEnabled,
|
||||
proxy: '',
|
||||
transformedConfig: JSON.stringify({
|
||||
webdav: {
|
||||
operator: '',
|
||||
password: config.password,
|
||||
baseDir: config.path || '/',
|
||||
customUrl: config.customUrl || '',
|
||||
area: ''
|
||||
}
|
||||
})
|
||||
})
|
||||
delete resultMap.paging
|
||||
break
|
||||
case 'local':
|
||||
if (!config.path) return
|
||||
Object.assign(resultMap, {
|
||||
...commonConfig,
|
||||
baseDir: config.path,
|
||||
webPath: config.webpath || '',
|
||||
customUrl: config.customUrl || ''
|
||||
})
|
||||
delete resultMap.paging
|
||||
break
|
||||
case 'aws-s3':
|
||||
if (!config.accessKeyID || !config.secretAccessKey) return
|
||||
Object.assign(resultMap, {
|
||||
...commonConfig,
|
||||
accessKeyId: config.accessKeyID,
|
||||
secretAccessKey: config.secretAccessKey,
|
||||
endpoint: config.endpoint || '',
|
||||
bucketName: '',
|
||||
baseDir: '/',
|
||||
itemsPerPage: 50,
|
||||
proxy: '',
|
||||
sslEnabled: config.endpoint ? config.endpoint.startsWith('https') : false,
|
||||
aclForUpload: 'public-read',
|
||||
s3ForcePathStyle: config.pathStyleAccess,
|
||||
transformedConfig: JSON.stringify(
|
||||
config.urlPrefix
|
||||
? {
|
||||
[config.bucketName]: {
|
||||
customUrl: config.urlPrefix
|
||||
}
|
||||
}
|
||||
: {}
|
||||
)
|
||||
})
|
||||
break
|
||||
case 'imgur':
|
||||
alias = `imgur-${config._configName ?? 'Default'}-imp`
|
||||
if (!config.username || !config.accessToken || isImported(alias)) {
|
||||
return
|
||||
}
|
||||
resultMap.alias = alias
|
||||
resultMap.picBedName = 'imgur'
|
||||
resultMap.imgurUserName = config.username
|
||||
resultMap.accessToken = config.accessToken
|
||||
resultMap.proxy = config.proxy || ''
|
||||
saveConfig(`picBed.${resultMap.alias}`, resultMap)
|
||||
if (!config.username || !config.accessToken) return
|
||||
Object.assign(resultMap, {
|
||||
...commonConfig,
|
||||
username: config.username,
|
||||
accessToken: config.accessToken,
|
||||
proxy: ''
|
||||
})
|
||||
delete resultMap.paging
|
||||
break
|
||||
default:
|
||||
return
|
||||
}
|
||||
manageStore.refreshConfig()
|
||||
importedNewConfig[alias] = resultMap
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
|
||||
@@ -712,8 +712,7 @@ export const supportedPicBedList: IStringKeyMap = {
|
||||
description: $T('MANAGE_CONSTANT_WEBDAV_BASE_DIR_DESC'),
|
||||
placeholder: $T('MANAGE_CONSTANT_WEBDAV_BASE_DIR_PLACEHOLDER'),
|
||||
type: 'string',
|
||||
default: '/',
|
||||
tooltip: baseDirTooltip
|
||||
default: '/'
|
||||
},
|
||||
customUrl: {
|
||||
required: false,
|
||||
@@ -738,6 +737,14 @@ export const supportedPicBedList: IStringKeyMap = {
|
||||
}
|
||||
]
|
||||
},
|
||||
webPath: {
|
||||
required: false,
|
||||
description: $T('MANAGE_CONSTANT_WEBDAV_WEB_PATH'),
|
||||
placeholder: $T('MANAGE_CONSTANT_WEBDAV_WEB_PATH_PLACEHOLDER'),
|
||||
type: 'string',
|
||||
tooltip: $T('MANAGE_CONSTANT_WEBDAV_WEB_PATH_TOOLTIP'),
|
||||
default: ''
|
||||
},
|
||||
proxy: {
|
||||
required: false,
|
||||
description: $T('MANAGE_CONSTANT_WEBDAV_PROXY_DESC'),
|
||||
@@ -754,8 +761,76 @@ export const supportedPicBedList: IStringKeyMap = {
|
||||
}
|
||||
},
|
||||
explain: $T('MANAGE_CONSTANT_WEBDAV_EXPLAIN'),
|
||||
options: ['alias', 'endpoint', 'username', 'password', 'bucketName', 'baseDir', 'customUrl', 'proxy', 'sslEnabled'],
|
||||
options: ['alias', 'endpoint', 'username', 'password', 'bucketName', 'baseDir', 'customUrl', 'webPath', 'proxy', 'sslEnabled'],
|
||||
refLink: 'https://pichoro.horosama.com/#/PicHoroDocs/configure?id=webdav',
|
||||
referenceText: $T('MANAGE_CONSTANT_WEBDAV_REFER_TEXT')
|
||||
},
|
||||
local: {
|
||||
name: $T('MANAGE_CONSTANT_LOCAL_NAME'),
|
||||
icon: 'local',
|
||||
configOptions: {
|
||||
alias: {
|
||||
required: true,
|
||||
description: $T('MANAGE_CONSTANT_LOCAL_ALIAS_DESC'),
|
||||
placeholder: $T('MANAGE_CONSTANT_LOCAL_ALIAS_PLACEHOLDER'),
|
||||
type: 'string',
|
||||
rule: aliasRule,
|
||||
default: 'local-A',
|
||||
tooltip: aliasTooltip
|
||||
},
|
||||
baseDir: {
|
||||
required: true,
|
||||
description: $T('MANAGE_CONSTANT_LOCAL_BASE_DIR_DESC'),
|
||||
placeholder: $T('MANAGE_CONSTANT_LOCAL_BASE_DIR_PLACEHOLDER'),
|
||||
type: 'string',
|
||||
default: '',
|
||||
rule: [
|
||||
{
|
||||
validator: (rule: any, value: any, callback: any) => {
|
||||
if (!value) {
|
||||
callback(new Error($T('MANAGE_CONSTANT_LOCAL_BASE_DIR_RULE_MESSAGE')))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
customUrl: {
|
||||
required: false,
|
||||
description: $T('MANAGE_CONSTANT_LOCAL_CUSTOM_URL_DESC'),
|
||||
placeholder: $T('MANAGE_CONSTANT_LOCAL_CUSTOM_URL_PLACEHOLDER'),
|
||||
type: 'string',
|
||||
tooltip: $T('MANAGE_CONSTANT_LOCAL_CUSTOM_URL_TOOLTIP'),
|
||||
rule: [
|
||||
{
|
||||
validator: (rule: any, value: any, callback: any) => {
|
||||
if (value) {
|
||||
if (!/^https?:\/\/.+/.test(value)) {
|
||||
callback(new Error($T('MANAGE_CONSTANT_WEBDAV_CUSTOM_URL_RULE_MESSAGE')))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
},
|
||||
trigger: 'change'
|
||||
}
|
||||
]
|
||||
},
|
||||
webPath: {
|
||||
required: false,
|
||||
description: $T('MANAGE_CONSTANT_LOCAL_WEB_PATH'),
|
||||
placeholder: $T('MANAGE_CONSTANT_LOCAL_WEB_PATH_PLACEHOLDER'),
|
||||
type: 'string',
|
||||
tooltip: $T('MANAGE_CONSTANT_LOCAL_WEB_PATH_TOOLTIP'),
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
explain: $T('MANAGE_CONSTANT_LOCAL_EXPLAIN'),
|
||||
options: ['alias', 'baseDir', 'customUrl', 'webPath'],
|
||||
refLink: 'https://piclist.cn',
|
||||
referenceText: $T('MANAGE_CONSTANT_LOCAL_REFER_TEXT')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,6 +289,26 @@
|
||||
@change="autoImportChange"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="form.autoImport"
|
||||
:label="$T('SETTINGS_AUTO_IMPORT_SELECT_PICBED')"
|
||||
>
|
||||
<el-select
|
||||
v-model="form.autoImportPicBed"
|
||||
multiple
|
||||
size="small"
|
||||
style="width: 50%"
|
||||
:placeholder="$T('SETTINGS_AUTO_IMPORT_SELECT_PICBED')"
|
||||
@change="handleAutoImportPicBedChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in picBed"
|
||||
:key="item.type"
|
||||
:label="item.name"
|
||||
:value="item.type"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
:label="$T('SETTINGS_SYNC_DELETE_CLOUD')"
|
||||
>
|
||||
@@ -1596,6 +1616,7 @@ const form = reactive<ISettingForm>({
|
||||
customMiniIcon: '',
|
||||
isHideDock: false,
|
||||
autoImport: false,
|
||||
autoImportPicBed: [],
|
||||
encodeOutputURL: false,
|
||||
isAutoListenClipboard: false,
|
||||
useShortUrl: false,
|
||||
@@ -1741,7 +1762,7 @@ async function initData () {
|
||||
form.miniWindowOntop = settings.miniWindowOntop || false
|
||||
form.autoCloseMiniWindow = settings.autoCloseMiniWindow || false
|
||||
form.autoCloseMainWindow = settings.autoCloseMainWindow || false
|
||||
form.logLevel = initLogLevel(settings.logLevel || [])
|
||||
form.logLevel = initArray(settings.logLevel || [], ['all'])
|
||||
form.autoCopyUrl = settings.autoCopy === undefined ? true : settings.autoCopy
|
||||
form.checkBetaUpdate = settings.checkBetaUpdate === undefined ? true : settings.checkBetaUpdate
|
||||
form.useBuiltinClipboard = settings.useBuiltinClipboard === undefined ? true : settings.useBuiltinClipboard
|
||||
@@ -1750,6 +1771,7 @@ async function initData () {
|
||||
form.encodeOutputURL = settings.encodeOutputURL === undefined ? false : settings.encodeOutputURL
|
||||
form.deleteCloudFile = settings.deleteCloudFile || false
|
||||
form.autoImport = settings.autoImport || false
|
||||
form.autoImportPicBed = initArray(settings.autoImportPicBed || [], [])
|
||||
form.isCustomMiniIcon = settings.isCustomMiniIcon || false
|
||||
form.customMiniIcon = settings.customMiniIcon || ''
|
||||
form.isHideDock = settings.isHideDock || false
|
||||
@@ -1795,15 +1817,15 @@ async function initData () {
|
||||
}
|
||||
}
|
||||
|
||||
function initLogLevel (logLevel: string | string[]) {
|
||||
if (!Array.isArray(logLevel)) {
|
||||
if (logLevel && logLevel.length > 0) {
|
||||
logLevel = [logLevel]
|
||||
function initArray (arrayT: string | string[], defaultValue: string[]) {
|
||||
if (!Array.isArray(arrayT)) {
|
||||
if (arrayT && arrayT.length > 0) {
|
||||
arrayT = [arrayT]
|
||||
} else {
|
||||
logLevel = ['all']
|
||||
arrayT = defaultValue
|
||||
}
|
||||
}
|
||||
return logLevel
|
||||
return arrayT
|
||||
}
|
||||
|
||||
function getPicBeds (event: Event, picBeds: IPicBedType[]) {
|
||||
@@ -1919,6 +1941,10 @@ function autoImportChange (val: ICheckBoxValueType) {
|
||||
saveConfig('settings.autoImport', val)
|
||||
}
|
||||
|
||||
function handleAutoImportPicBedChange (val: string[]) {
|
||||
saveConfig('settings.autoImportPicBed', val)
|
||||
}
|
||||
|
||||
function handleHideDockChange (val: ICheckBoxValueType) {
|
||||
if (val && currentStartMode.value === 'no-tray') {
|
||||
ElMessage.warning($T('SETTINGS_ISHIDEDOCK_TIPS'))
|
||||
|
||||
18
src/universal/types/i18n.d.ts
vendored
@@ -271,6 +271,7 @@ interface ILocales {
|
||||
SETTINGS_SYNC_COMMON_CONFIG: string
|
||||
SETTINGS_SYNC_MANAGE_CONFIG: string
|
||||
SETTINGS_AUTO_IMPORT: string
|
||||
SETTINGS_AUTO_IMPORT_SELECT_PICBED: string
|
||||
SETTINGS_TAB_SYSTEM: string
|
||||
SETTINGS_TAB_SYNC_CONFIG: string
|
||||
SETTINGS_TAB_UPLOAD: string
|
||||
@@ -560,6 +561,9 @@ interface ILocales {
|
||||
MANAGE_CONSTANT_WEBDAV_CUSTOM_URL_PLACEHOLDER: string
|
||||
MANAGE_CONSTANT_WEBDAV_CUSTOM_URL_TOOLTIP: string
|
||||
MANAGE_CONSTANT_WEBDAV_CUSTOM_URL_RULE_MESSAGE: string
|
||||
MANAGE_CONSTANT_WEBDAV_WEB_PATH: string
|
||||
MANAGE_CONSTANT_WEBDAV_WEB_PATH_PLACEHOLDER: string
|
||||
MANAGE_CONSTANT_WEBDAV_WEB_PATH_TOOLTIP: string
|
||||
MANAGE_CONSTANT_WEBDAV_PROXY_DESC: string
|
||||
MANAGE_CONSTANT_WEBDAV_PROXY_PLACEHOLDER: string
|
||||
MANAGE_CONSTANT_WEBDAV_PROXY_TOOLTIP: string
|
||||
@@ -567,6 +571,20 @@ interface ILocales {
|
||||
MANAGE_CONSTANT_WEBDAV_SSL_TOOLTIP: string
|
||||
MANAGE_CONSTANT_WEBDAV_EXPLAIN: string
|
||||
MANAGE_CONSTANT_WEBDAV_REFER_TEXT: string
|
||||
MANAGE_CONSTANT_LOCAL_NAME: string
|
||||
MANAGE_CONSTANT_LOCAL_ALIAS_DESC: string
|
||||
MANAGE_CONSTANT_LOCAL_ALIAS_PLACEHOLDER: string
|
||||
MANAGE_CONSTANT_LOCAL_BASE_DIR_DESC: string
|
||||
MANAGE_CONSTANT_LOCAL_BASE_DIR_PLACEHOLDER: string
|
||||
MANAGE_CONSTANT_LOCAL_CUSTOM_URL_DESC: string
|
||||
MANAGE_CONSTANT_LOCAL_CUSTOM_URL_PLACEHOLDER: string
|
||||
MANAGE_CONSTANT_LOCAL_CUSTOM_URL_TOOLTIP: string
|
||||
MANAGE_CONSTANT_LOCAL_WEB_PATH: string
|
||||
MANAGE_CONSTANT_LOCAL_WEB_PATH_PLACEHOLDER: string
|
||||
MANAGE_CONSTANT_LOCAL_WEB_PATH_TOOLTIP: string
|
||||
MANAGE_CONSTANT_LOCAL_EXPLAIN: string
|
||||
MANAGE_CONSTANT_LOCAL_REFER_TEXT: string
|
||||
MANAGE_CONSTANT_LOCAL_BASE_DIR_RULE_MESSAGE: string
|
||||
MANAGE_LOGIN_PAGE_PANE_NAME: string
|
||||
MANAGE_LOGIN_PAGE_PANE_DESC: string
|
||||
MANAGE_LOGIN_PAGE_PANE_LOADING: string
|
||||
|
||||
1
src/universal/types/view.d.ts
vendored
@@ -20,6 +20,7 @@ interface ISettingForm {
|
||||
customMiniIcon: string,
|
||||
isHideDock: boolean,
|
||||
autoImport: boolean,
|
||||
autoImportPicBed: string[],
|
||||
encodeOutputURL: boolean,
|
||||
isAutoListenClipboard: boolean,
|
||||
useShortUrl: boolean,
|
||||
|
||||