Feature: add webPath for webdav picBed manage

This commit is contained in:
萌萌哒赫萝
2023-08-06 02:06:37 -07:00
parent 4827dcdca8
commit 33b36d63c6
13 changed files with 75 additions and 36 deletions

View File

@@ -67,7 +67,7 @@
"mitt": "^3.0.0",
"node-ssh-no-cpu-features": "^1.0.1",
"nodejs-file-downloader": "^4.12.1",
"piclist": "^0.8.10",
"piclist": "^0.8.11",
"pinia": "^2.1.4",
"pinia-plugin-persistedstate": "^3.1.0",
"qiniu": "^7.9.0",

View File

@@ -624,6 +624,9 @@ 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_CONSTANT_LOCAL_BUCKET_DESC: Special Configuration
MANAGE_CONSTANT_LOCAL_BUCKET_PLACEHOLDER: 'bucket1'
MANAGE_CONSTANT_LOCAL_BUCKET_TOOLTIP: This cannot be modified, only for software compatibility consideration
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

View File

@@ -627,6 +627,9 @@ MANAGE_CONSTANT_LOCAL_WEB_PATH_TOOLTIP: '用于拼接网址'
MANAGE_CONSTANT_LOCAL_EXPLAIN: '本地存储配置'
MANAGE_CONSTANT_LOCAL_REFER_TEXT: '配置教程请参考: '
MANAGE_CONSTANT_LOCAL_BASE_DIR_RULE_MESSAGE: 起始目录不能为空
MANAGE_CONSTANT_LOCAL_BUCKET_DESC: 特殊配置
MANAGE_CONSTANT_LOCAL_BUCKET_PLACEHOLDER: '例如bucket1'
MANAGE_CONSTANT_LOCAL_BUCKET_TOOLTIP: 此处不可修改,仅为软件兼容性考虑
MANAGE_LOGIN_PAGE_PANE_NAME: 已保存配置
MANAGE_LOGIN_PAGE_PANE_DESC: 点击图标和别名可查看详情,点击进入可查看文件页面,点击删除可删除配置

View File

@@ -624,6 +624,9 @@ MANAGE_CONSTANT_LOCAL_WEB_PATH_TOOLTIP: '用於拼接網址'
MANAGE_CONSTANT_LOCAL_EXPLAIN: '本地配置'
MANAGE_CONSTANT_LOCAL_REFER_TEXT: '配置教程請參考: '
MANAGE_CONSTANT_LOCAL_BASE_DIR_RULE_MESSAGE: 起始目錄不能為空
MANAGE_CONSTANT_LOCAL_BUCKET_DESC: 特殊配置
MANAGE_CONSTANT_LOCAL_BUCKET_PLACEHOLDER: '例如bucket1'
MANAGE_CONSTANT_LOCAL_BUCKET_TOOLTIP: 此處不可修改,僅為軟體相容性考量
MANAGE_LOGIN_PAGE_PANE_NAME: 已保存配置
MANAGE_LOGIN_PAGE_PANE_DESC: 點擊圖標和別名可查看詳情,點擊進入可查看檔案頁面,點擊刪除可刪除配置

View File

View File

@@ -52,7 +52,7 @@ class WebdavplistApi {
logParam = (error:any, method: string) =>
this.logger.error(formatError(error, { class: 'WebdavplistApi', method }))
formatFolder (item: FileStat, urlPrefix: string) {
formatFolder (item: FileStat, urlPrefix: string, isWebPath = false) {
return {
...item,
key: item.filename.replace(/^\/+/, ''),
@@ -64,11 +64,11 @@ class WebdavplistApi {
checked: false,
isImage: false,
match: false,
url: `${urlPrefix}${item.filename}`
url: isWebPath ? urlPrefix : `${urlPrefix}${item.filename}`
}
}
formatFile (item: FileStat, urlPrefix: string) {
formatFile (item: FileStat, urlPrefix: string, isWebPath = false) {
return {
...item,
key: item.filename.replace(/^\/+/, ''),
@@ -80,7 +80,7 @@ class WebdavplistApi {
checked: false,
match: false,
isImage: isImage(item.basename),
url: `${urlPrefix}${item.filename}`
url: isWebPath ? urlPrefix : `${urlPrefix}${item.filename}`
}
}
@@ -137,8 +137,13 @@ class WebdavplistApi {
async getBucketListBackstage (configMap: IStringKeyMap): Promise<any> {
const window = windowManager.get(IWindowList.SETTING_WINDOW)!
const { prefix, customUrl, cancelToken } = configMap
const urlPrefix = customUrl || this.endpoint
const { prefix, customUrl, cancelToken, baseDir } = configMap
let urlPrefix = customUrl || this.endpoint
urlPrefix = urlPrefix.replace(/\/+$/, '')
let webPath = configMap.webPath || ''
if (webPath && customUrl && webPath !== '/') {
webPath = webPath.replace(/^\/+/, '').replace(/\/+$/, '')
}
const cancelTask = [false]
ipcMain.on('cancelLoadingFileList', (_evt: IpcMainEvent, token: string) => {
if (token === cancelToken) {
@@ -160,10 +165,12 @@ class WebdavplistApi {
if (this.isRequestSuccess(res.status)) {
if (res.data && res.data.length) {
res.data.forEach((item: FileStat) => {
const relativePath = path.relative(baseDir, item.filename)
const relative = webPath && urlPrefix + `/${path.join(webPath, relativePath)}`.replace(/\\/g, '/').replace(/\/+/g, '/')
if (item.type === 'directory') {
result.fullList.push(this.formatFolder(item, urlPrefix))
result.fullList.push(this.formatFolder(item, webPath ? relative : urlPrefix, !!webPath))
} else {
result.fullList.push(this.formatFile(item, urlPrefix))
result.fullList.push(this.formatFile(item, webPath ? relative : urlPrefix, !!webPath))
}
})
}

View File

@@ -2792,10 +2792,14 @@ async function getBucketFileListBackStage () {
currentPage: currentPage.value,
cancelToken: cancelToken.value,
cdnUrl: configMap.cdnUrl
}
} as IStringKeyMap
isLoadingData.value = true
const fileTransferStore = useFileTransferStore()
fileTransferStore.resetFileTransferList()
if (currentPicBedName.value === 'webdavplist') {
param.baseDir = configMap.baseDir
param.webPath = configMap.webPath
}
ipcRenderer.send('getBucketListBackstage', configMap.alias, param)
ipcRenderer.on('refreshFileTransferList', (evt: IpcRendererEvent, data) => {
fileTransferStore.refreshFileTransferList(data)

View File

@@ -61,24 +61,24 @@
/>
</el-table>
<template #reference>
<el-tooltip
effect="light"
:content="item.alias"
placement="top"
:disabled="item.alias.length <= 15"
<el-button
style="width: 100%; text-align: center;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;"
>
<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>
<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.length > 15 ? item.alias.slice(0, 8) + '...' + item.alias.slice(-6) : item.alias }}
</el-button>
</el-tooltip>
</el-tooltip>
</el-button>
</template>
</el-popover>
<br>

View File

@@ -319,7 +319,8 @@ const urlMap : IStringKeyMap = {
tcyun: 'https://console.cloud.tencent.com/cos',
upyun: 'https://console.upyun.com',
s3plist: 'https://aws.amazon.com/cn/s3/',
webdavplist: 'https://baike.baidu.com/item/WebDAV/4610909'
webdavplist: 'https://baike.baidu.com/item/WebDAV/4610909',
local: 'https://piclist.cn'
}
const openPicBedUrl = () => shell.openExternal(urlMap[currentPagePicBedConfig.picBedName])
@@ -417,6 +418,7 @@ const handleSelectMenu = (bucketName: string) => {
const alias = currentAlias.value
const cdnUrl = manageStore.config.picBed[currentAlias.value].customUrl
const bucketConfig = bucketList.value[bucketName]
const webPath = manageStore.config.picBed[currentAlias.value].webPath || ''
const configMap = {
prefix,
bucketName,
@@ -424,7 +426,9 @@ const handleSelectMenu = (bucketName: string) => {
picBedName,
alias,
bucketConfig,
cdnUrl
cdnUrl,
baseDir: prefix,
webPath
}
currentSelectedBucket.value = bucketName
router.push({
@@ -450,7 +454,8 @@ const menuTitleMap:IStringKeyMap = {
smms: galleryT,
imgur: galleryT,
github: repositoryT,
webdavplist: ''
webdavplist: '',
local: ''
}
const showNewIconList = ['aliyun', 'qiniu', 'tcyun']

View File

@@ -28,16 +28,17 @@ export class FileCacheDb extends Dexie {
imgur: Table<IFileCache, string>
s3plist: Table<IFileCache, string>
webdavplist: Table<IFileCache, string>
localplist: Table<IFileCache, string>
local: Table<IFileCache, string>
sftpplist: Table<IFileCache, string>
constructor () {
super('bucketFileDb')
const tableNames = ['tcyun', 'aliyun', 'qiniu', 'github', 'smms', 'upyun', 'imgur', 's3plist', 'webdavplist', 'localplist']
const tableNames = ['tcyun', 'aliyun', 'qiniu', 'github', 'smms', 'upyun', 'imgur', 's3plist', 'webdavplist', 'local', 'sftpplist']
const tableNamesMap = tableNames.reduce((acc, cur) => {
acc[cur] = '&key, value'
return acc
}, {} as IStringKeyMap)
this.version(3).stores(tableNamesMap)
this.version(4).stores(tableNamesMap)
this.tcyun = this.table('tcyun')
this.aliyun = this.table('aliyun')
this.qiniu = this.table('qiniu')
@@ -47,7 +48,8 @@ export class FileCacheDb extends Dexie {
this.imgur = this.table('imgur')
this.s3plist = this.table('s3plist')
this.webdavplist = this.table('webdavplist')
this.localplist = this.table('localplist')
this.local = this.table('local')
this.sftpplist = this.table('sftpplist')
}
}

View File

@@ -819,6 +819,15 @@ export const supportedPicBedList: IStringKeyMap = {
}
]
},
bucketName: {
required: true,
description: $T('MANAGE_CONSTANT_LOCAL_BUCKET_DESC'),
placeholder: $T('MANAGE_CONSTANT_LOCAL_BUCKET_PLACEHOLDER'),
type: 'string',
default: 'local',
disabled: true,
tooltip: $T('MANAGE_CONSTANT_LOCAL_BUCKET_TOOLTIP')
},
webPath: {
required: false,
description: $T('MANAGE_CONSTANT_LOCAL_WEB_PATH'),

View File

@@ -585,6 +585,9 @@ interface ILocales {
MANAGE_CONSTANT_LOCAL_EXPLAIN: string
MANAGE_CONSTANT_LOCAL_REFER_TEXT: string
MANAGE_CONSTANT_LOCAL_BASE_DIR_RULE_MESSAGE: string
MANAGE_CONSTANT_LOCAL_BUCKET_DESC: string
MANAGE_CONSTANT_LOCAL_BUCKET_PLACEHOLDER: string
MANAGE_CONSTANT_LOCAL_BUCKET_TOOLTIP: string
MANAGE_LOGIN_PAGE_PANE_NAME: string
MANAGE_LOGIN_PAGE_PANE_DESC: string
MANAGE_LOGIN_PAGE_PANE_LOADING: string

View File

@@ -11048,10 +11048,10 @@ performance-now@^2.1.0:
resolved "https://registry.npmmirror.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
integrity sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==
piclist@^0.8.10:
version "0.8.10"
resolved "https://registry.npmjs.org/piclist/-/piclist-0.8.10.tgz#efd7eddbe66023f375a7d687d4466a9031999aea"
integrity sha512-VLoLZywOoV6lGJN8u8Llr6B63OzT8k8yE5QF40JV3nwNK1jyGRLRZ/57/HIXsGFojWgoDerj3hmVuJOX556NFA==
piclist@^0.8.11:
version "0.8.11"
resolved "https://registry.npmjs.org/piclist/-/piclist-0.8.11.tgz#0fd6d690f9eb9099cea161d0d38d24d81df3a7cc"
integrity sha512-rgUw4x7gk3IpfzG8kONW7oQddWhylkWNSSucavQqlZeR6/XDPXZj+BBy0enzyi8GM/em0U456HHhP3ncJJjxnQ==
dependencies:
"@picgo/i18n" "^1.0.0"
"@picgo/store" "^2.0.4"