mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-06-12 03:00:29 +08:00
✨ Feature: add webPath for webdav picBed manage
This commit is contained in:
0
src/main/manage/apis/local.ts
Normal file
0
src/main/manage/apis/local.ts
Normal 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))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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']
|
||||
|
||||
@@ -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')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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'),
|
||||
|
||||
3
src/universal/types/i18n.d.ts
vendored
3
src/universal/types/i18n.d.ts
vendored
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user