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
+1 -1
View File
@@ -67,7 +67,7 @@
"mitt": "^3.0.0", "mitt": "^3.0.0",
"node-ssh-no-cpu-features": "^1.0.1", "node-ssh-no-cpu-features": "^1.0.1",
"nodejs-file-downloader": "^4.12.1", "nodejs-file-downloader": "^4.12.1",
"piclist": "^0.8.10", "piclist": "^0.8.11",
"pinia": "^2.1.4", "pinia": "^2.1.4",
"pinia-plugin-persistedstate": "^3.1.0", "pinia-plugin-persistedstate": "^3.1.0",
"qiniu": "^7.9.0", "qiniu": "^7.9.0",
+3
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_EXPLAIN: 'Local Configuration'
MANAGE_CONSTANT_LOCAL_REFER_TEXT: 'Refer to:' MANAGE_CONSTANT_LOCAL_REFER_TEXT: 'Refer to:'
MANAGE_CONSTANT_LOCAL_BASE_DIR_RULE_MESSAGE: baseDir cannot be empty 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_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_DESC: Click on the icon or alias to view details, Enter to view the file page, Delete to remove the configuration
+3
View File
@@ -627,6 +627,9 @@ MANAGE_CONSTANT_LOCAL_WEB_PATH_TOOLTIP: '用于拼接网址'
MANAGE_CONSTANT_LOCAL_EXPLAIN: '本地存储配置' MANAGE_CONSTANT_LOCAL_EXPLAIN: '本地存储配置'
MANAGE_CONSTANT_LOCAL_REFER_TEXT: '配置教程请参考: ' MANAGE_CONSTANT_LOCAL_REFER_TEXT: '配置教程请参考: '
MANAGE_CONSTANT_LOCAL_BASE_DIR_RULE_MESSAGE: 起始目录不能为空 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_NAME: 已保存配置
MANAGE_LOGIN_PAGE_PANE_DESC: 点击图标和别名可查看详情,点击进入可查看文件页面,点击删除可删除配置 MANAGE_LOGIN_PAGE_PANE_DESC: 点击图标和别名可查看详情,点击进入可查看文件页面,点击删除可删除配置
+3
View File
@@ -624,6 +624,9 @@ MANAGE_CONSTANT_LOCAL_WEB_PATH_TOOLTIP: '用於拼接網址'
MANAGE_CONSTANT_LOCAL_EXPLAIN: '本地配置' MANAGE_CONSTANT_LOCAL_EXPLAIN: '本地配置'
MANAGE_CONSTANT_LOCAL_REFER_TEXT: '配置教程請參考: ' MANAGE_CONSTANT_LOCAL_REFER_TEXT: '配置教程請參考: '
MANAGE_CONSTANT_LOCAL_BASE_DIR_RULE_MESSAGE: 起始目錄不能為空 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_NAME: 已保存配置
MANAGE_LOGIN_PAGE_PANE_DESC: 點擊圖標和別名可查看詳情,點擊進入可查看檔案頁面,點擊刪除可刪除配置 MANAGE_LOGIN_PAGE_PANE_DESC: 點擊圖標和別名可查看詳情,點擊進入可查看檔案頁面,點擊刪除可刪除配置
View File
+15 -8
View File
@@ -52,7 +52,7 @@ class WebdavplistApi {
logParam = (error:any, method: string) => logParam = (error:any, method: string) =>
this.logger.error(formatError(error, { class: 'WebdavplistApi', method })) this.logger.error(formatError(error, { class: 'WebdavplistApi', method }))
formatFolder (item: FileStat, urlPrefix: string) { formatFolder (item: FileStat, urlPrefix: string, isWebPath = false) {
return { return {
...item, ...item,
key: item.filename.replace(/^\/+/, ''), key: item.filename.replace(/^\/+/, ''),
@@ -64,11 +64,11 @@ class WebdavplistApi {
checked: false, checked: false,
isImage: false, isImage: false,
match: 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 { return {
...item, ...item,
key: item.filename.replace(/^\/+/, ''), key: item.filename.replace(/^\/+/, ''),
@@ -80,7 +80,7 @@ class WebdavplistApi {
checked: false, checked: false,
match: false, match: false,
isImage: isImage(item.basename), 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> { async getBucketListBackstage (configMap: IStringKeyMap): Promise<any> {
const window = windowManager.get(IWindowList.SETTING_WINDOW)! const window = windowManager.get(IWindowList.SETTING_WINDOW)!
const { prefix, customUrl, cancelToken } = configMap const { prefix, customUrl, cancelToken, baseDir } = configMap
const urlPrefix = customUrl || this.endpoint let urlPrefix = customUrl || this.endpoint
urlPrefix = urlPrefix.replace(/\/+$/, '')
let webPath = configMap.webPath || ''
if (webPath && customUrl && webPath !== '/') {
webPath = webPath.replace(/^\/+/, '').replace(/\/+$/, '')
}
const cancelTask = [false] const cancelTask = [false]
ipcMain.on('cancelLoadingFileList', (_evt: IpcMainEvent, token: string) => { ipcMain.on('cancelLoadingFileList', (_evt: IpcMainEvent, token: string) => {
if (token === cancelToken) { if (token === cancelToken) {
@@ -160,10 +165,12 @@ class WebdavplistApi {
if (this.isRequestSuccess(res.status)) { if (this.isRequestSuccess(res.status)) {
if (res.data && res.data.length) { if (res.data && res.data.length) {
res.data.forEach((item: FileStat) => { 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') { if (item.type === 'directory') {
result.fullList.push(this.formatFolder(item, urlPrefix)) result.fullList.push(this.formatFolder(item, webPath ? relative : urlPrefix, !!webPath))
} else { } else {
result.fullList.push(this.formatFile(item, urlPrefix)) result.fullList.push(this.formatFile(item, webPath ? relative : urlPrefix, !!webPath))
} }
}) })
} }
+5 -1
View File
@@ -2792,10 +2792,14 @@ async function getBucketFileListBackStage () {
currentPage: currentPage.value, currentPage: currentPage.value,
cancelToken: cancelToken.value, cancelToken: cancelToken.value,
cdnUrl: configMap.cdnUrl cdnUrl: configMap.cdnUrl
} } as IStringKeyMap
isLoadingData.value = true isLoadingData.value = true
const fileTransferStore = useFileTransferStore() const fileTransferStore = useFileTransferStore()
fileTransferStore.resetFileTransferList() fileTransferStore.resetFileTransferList()
if (currentPicBedName.value === 'webdavplist') {
param.baseDir = configMap.baseDir
param.webPath = configMap.webPath
}
ipcRenderer.send('getBucketListBackstage', configMap.alias, param) ipcRenderer.send('getBucketListBackstage', configMap.alias, param)
ipcRenderer.on('refreshFileTransferList', (evt: IpcRendererEvent, data) => { ipcRenderer.on('refreshFileTransferList', (evt: IpcRendererEvent, data) => {
fileTransferStore.refreshFileTransferList(data) fileTransferStore.refreshFileTransferList(data)
+15 -15
View File
@@ -61,24 +61,24 @@
/> />
</el-table> </el-table>
<template #reference> <template #reference>
<el-tooltip <el-button
effect="light" style="width: 100%; text-align: center;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;"
:content="item.alias"
placement="top"
:disabled="item.alias.length <= 15"
> >
<el-button <template #icon>
style="width: 100%; text-align: center;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;" <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 }} {{ item.alias.length > 15 ? item.alias.slice(0, 8) + '...' + item.alias.slice(-6) : item.alias }}
</el-button> </el-tooltip>
</el-tooltip> </el-button>
</template> </template>
</el-popover> </el-popover>
<br> <br>
+8 -3
View File
@@ -319,7 +319,8 @@ const urlMap : IStringKeyMap = {
tcyun: 'https://console.cloud.tencent.com/cos', tcyun: 'https://console.cloud.tencent.com/cos',
upyun: 'https://console.upyun.com', upyun: 'https://console.upyun.com',
s3plist: 'https://aws.amazon.com/cn/s3/', 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]) const openPicBedUrl = () => shell.openExternal(urlMap[currentPagePicBedConfig.picBedName])
@@ -417,6 +418,7 @@ const handleSelectMenu = (bucketName: string) => {
const alias = currentAlias.value const alias = currentAlias.value
const cdnUrl = manageStore.config.picBed[currentAlias.value].customUrl const cdnUrl = manageStore.config.picBed[currentAlias.value].customUrl
const bucketConfig = bucketList.value[bucketName] const bucketConfig = bucketList.value[bucketName]
const webPath = manageStore.config.picBed[currentAlias.value].webPath || ''
const configMap = { const configMap = {
prefix, prefix,
bucketName, bucketName,
@@ -424,7 +426,9 @@ const handleSelectMenu = (bucketName: string) => {
picBedName, picBedName,
alias, alias,
bucketConfig, bucketConfig,
cdnUrl cdnUrl,
baseDir: prefix,
webPath
} }
currentSelectedBucket.value = bucketName currentSelectedBucket.value = bucketName
router.push({ router.push({
@@ -450,7 +454,8 @@ const menuTitleMap:IStringKeyMap = {
smms: galleryT, smms: galleryT,
imgur: galleryT, imgur: galleryT,
github: repositoryT, github: repositoryT,
webdavplist: '' webdavplist: '',
local: ''
} }
const showNewIconList = ['aliyun', 'qiniu', 'tcyun'] const showNewIconList = ['aliyun', 'qiniu', 'tcyun']
+6 -4
View File
@@ -28,16 +28,17 @@ export class FileCacheDb extends Dexie {
imgur: Table<IFileCache, string> imgur: Table<IFileCache, string>
s3plist: Table<IFileCache, string> s3plist: Table<IFileCache, string>
webdavplist: Table<IFileCache, string> webdavplist: Table<IFileCache, string>
localplist: Table<IFileCache, string> local: Table<IFileCache, string>
sftpplist: Table<IFileCache, string>
constructor () { constructor () {
super('bucketFileDb') 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) => { const tableNamesMap = tableNames.reduce((acc, cur) => {
acc[cur] = '&key, value' acc[cur] = '&key, value'
return acc return acc
}, {} as IStringKeyMap) }, {} as IStringKeyMap)
this.version(3).stores(tableNamesMap) this.version(4).stores(tableNamesMap)
this.tcyun = this.table('tcyun') this.tcyun = this.table('tcyun')
this.aliyun = this.table('aliyun') this.aliyun = this.table('aliyun')
this.qiniu = this.table('qiniu') this.qiniu = this.table('qiniu')
@@ -47,7 +48,8 @@ export class FileCacheDb extends Dexie {
this.imgur = this.table('imgur') this.imgur = this.table('imgur')
this.s3plist = this.table('s3plist') this.s3plist = this.table('s3plist')
this.webdavplist = this.table('webdavplist') this.webdavplist = this.table('webdavplist')
this.localplist = this.table('localplist') this.local = this.table('local')
this.sftpplist = this.table('sftpplist')
} }
} }
+9
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: { webPath: {
required: false, required: false,
description: $T('MANAGE_CONSTANT_LOCAL_WEB_PATH'), description: $T('MANAGE_CONSTANT_LOCAL_WEB_PATH'),
+3
View File
@@ -585,6 +585,9 @@ interface ILocales {
MANAGE_CONSTANT_LOCAL_EXPLAIN: string MANAGE_CONSTANT_LOCAL_EXPLAIN: string
MANAGE_CONSTANT_LOCAL_REFER_TEXT: string MANAGE_CONSTANT_LOCAL_REFER_TEXT: string
MANAGE_CONSTANT_LOCAL_BASE_DIR_RULE_MESSAGE: 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_NAME: string
MANAGE_LOGIN_PAGE_PANE_DESC: string MANAGE_LOGIN_PAGE_PANE_DESC: string
MANAGE_LOGIN_PAGE_PANE_LOADING: string MANAGE_LOGIN_PAGE_PANE_LOADING: string
+4 -4
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" resolved "https://registry.npmmirror.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
integrity sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow== integrity sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==
piclist@^0.8.10: piclist@^0.8.11:
version "0.8.10" version "0.8.11"
resolved "https://registry.npmjs.org/piclist/-/piclist-0.8.10.tgz#efd7eddbe66023f375a7d687d4466a9031999aea" resolved "https://registry.npmjs.org/piclist/-/piclist-0.8.11.tgz#0fd6d690f9eb9099cea161d0d38d24d81df3a7cc"
integrity sha512-VLoLZywOoV6lGJN8u8Llr6B63OzT8k8yE5QF40JV3nwNK1jyGRLRZ/57/HIXsGFojWgoDerj3hmVuJOX556NFA== integrity sha512-rgUw4x7gk3IpfzG8kONW7oQddWhylkWNSSucavQqlZeR6/XDPXZj+BBy0enzyi8GM/em0U456HHhP3ncJJjxnQ==
dependencies: dependencies:
"@picgo/i18n" "^1.0.0" "@picgo/i18n" "^1.0.0"
"@picgo/store" "^2.0.4" "@picgo/store" "^2.0.4"