mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-08-07 22:44:10 +08:00
@@ -7,6 +7,7 @@ import GithubApi from './github'
|
||||
import UpyunApi from './upyun'
|
||||
import AwsS3Api from './awss3'
|
||||
import WebdavApi from './webdav'
|
||||
import LocalApi from './local'
|
||||
|
||||
const apiMap: IStringKeyMap = {
|
||||
smms: SmmsApi,
|
||||
@@ -17,7 +18,8 @@ const apiMap: IStringKeyMap = {
|
||||
github: GithubApi,
|
||||
upyun: UpyunApi,
|
||||
'aws-s3': AwsS3Api,
|
||||
webdavplist: WebdavApi
|
||||
webdavplist: WebdavApi,
|
||||
local: LocalApi
|
||||
}
|
||||
|
||||
export default class ALLApi {
|
||||
|
||||
23
src/renderer/apis/local.ts
Normal file
23
src/renderer/apis/local.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import fs from 'fs-extra'
|
||||
|
||||
interface IConfigMap {
|
||||
hash: string
|
||||
}
|
||||
|
||||
export default class LocalApi {
|
||||
static async delete (configMap: IConfigMap): Promise<boolean> {
|
||||
const { hash } = configMap
|
||||
if (!hash) {
|
||||
console.error('SmmsApi.delete: invalid params')
|
||||
return false
|
||||
}
|
||||
|
||||
try {
|
||||
await fs.remove(hash)
|
||||
return true
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3663,7 +3663,6 @@ const columns: Column<any>[] = [
|
||||
]
|
||||
|
||||
onBeforeMount(async () => {
|
||||
console.log('onBeforeMount')
|
||||
await manageStore.refreshConfig()
|
||||
showLoadingPage.value = true
|
||||
await initCustomUrlList()
|
||||
|
||||
@@ -661,7 +661,7 @@ function remove (item: ImgInfo) {
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
const file = await $$db.getById(item.id!)
|
||||
const picBedsCanbeDeleted = ['smms', 'github', 'imgur', 'tcyun', 'aliyun', 'qiniu', 'upyun', 'aws-s3', 'webdavplist']
|
||||
const picBedsCanbeDeleted = ['smms', 'github', 'imgur', 'tcyun', 'aliyun', 'qiniu', 'upyun', 'aws-s3', 'webdavplist', 'local']
|
||||
if (await getConfig('settings.deleteCloudFile')) {
|
||||
if (item.type !== undefined && picBedsCanbeDeleted.includes(item.type)) {
|
||||
const result = await ALLApi.delete(item)
|
||||
@@ -771,7 +771,7 @@ function multiRemove () {
|
||||
const files: IResult<ImgInfo>[] = []
|
||||
const imageIDList = Object.keys(choosedList)
|
||||
const isDeleteCloudFile = await getConfig('settings.deleteCloudFile')
|
||||
const picBedsCanbeDeleted = ['smms', 'github', 'imgur', 'tcyun', 'aliyun', 'qiniu', 'upyun', 'aws-s3', 'webdavplist']
|
||||
const picBedsCanbeDeleted = ['smms', 'github', 'imgur', 'tcyun', 'aliyun', 'qiniu', 'upyun', 'aws-s3', 'webdavplist', 'local']
|
||||
if (isDeleteCloudFile) {
|
||||
for (let i = 0; i < imageIDList.length; i++) {
|
||||
const key = imageIDList[i]
|
||||
|
||||
@@ -373,6 +373,49 @@
|
||||
@change="handleUseShortUrl"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="form.useShortUrl"
|
||||
:label="$T('SETTINGS_SHORT_URL_SERVER')"
|
||||
>
|
||||
<el-select
|
||||
v-model="form.shortUrlServer"
|
||||
size="small"
|
||||
style="width: 50%"
|
||||
:placeholder="$T('SETTINGS_SHORT_URL_SERVER')"
|
||||
@change="handleShortUrlServerChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in shortUrlServerList"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="form.useShortUrl && form.shortUrlServer === 'yourls'"
|
||||
:label="$T('SETTINGS_SHORT_URL_YOURLS_DOMAIN')"
|
||||
>
|
||||
<el-input
|
||||
v-model="form.yourlsDomain"
|
||||
size="small"
|
||||
style="width: 50%"
|
||||
:placeholder="$T('SETTINGS_SHORT_URL_YOURLS_DOMAIN')"
|
||||
@change="handleYourlsDomainChange"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="form.useShortUrl && form.shortUrlServer === 'yourls'"
|
||||
:label="$T('SETTINGS_SHORT_URL_YOURLS_SIGNATURE')"
|
||||
>
|
||||
<el-input
|
||||
v-model="form.yourlsSignature"
|
||||
size="small"
|
||||
style="width: 50%"
|
||||
:placeholder="$T('SETTINGS_SHORT_URL_YOURLS_SIGNATURE')"
|
||||
@change="handleYourlsSignatureChange"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
:label="$T('SETTINGS_ENCODE_OUTPUT_URL')"
|
||||
>
|
||||
@@ -1376,6 +1419,16 @@ import { buildInRenameFormatTable } from '../manage/utils/common'
|
||||
const imageProcessDialogVisible = ref(false)
|
||||
const activeName = ref<'system' | 'syncAndConfigure' | 'upload' | 'advanced' | 'upadte'>('system')
|
||||
|
||||
const shortUrlServerList = [{
|
||||
label: 'c1n',
|
||||
value: 'c1n'
|
||||
},
|
||||
{
|
||||
label: 'yourls',
|
||||
value: 'yourls'
|
||||
}
|
||||
]
|
||||
|
||||
const waterMarkPositionMap = new Map([
|
||||
['north', $T('UPLOAD_PAGE_IMAGE_PROCESS_POSITION_TOP')],
|
||||
['northeast', $T('UPLOAD_PAGE_IMAGE_PROCESS_POSITION_TOP_RIGHT')],
|
||||
@@ -1489,6 +1542,9 @@ const form = reactive<ISettingForm>({
|
||||
encodeOutputURL: false,
|
||||
isAutoListenClipboard: false,
|
||||
useShortUrl: false,
|
||||
shortUrlServer: 'c1n',
|
||||
yourlsDomain: '',
|
||||
yourlsSignature: '',
|
||||
deleteLocalFile: false
|
||||
})
|
||||
|
||||
@@ -1638,6 +1694,9 @@ async function initData () {
|
||||
form.customMiniIcon = settings.customMiniIcon || ''
|
||||
form.isHideDock = settings.isHideDock || false
|
||||
form.useShortUrl = settings.useShortUrl || false
|
||||
form.shortUrlServer = settings.shortUrlServer || 'c1n'
|
||||
form.yourlsDomain = settings.yourlsDomain || ''
|
||||
form.yourlsSignature = settings.yourlsSignature || ''
|
||||
form.deleteLocalFile = settings.deleteLocalFile || false
|
||||
currentLanguage.value = settings.language ?? 'zh-CN'
|
||||
currentStartMode.value = settings.startMode || 'quiet'
|
||||
@@ -1955,6 +2014,18 @@ function handleUseShortUrl (val: ICheckBoxValueType) {
|
||||
}
|
||||
}
|
||||
|
||||
function handleShortUrlServerChange (val: string) {
|
||||
saveConfig('settings.shortUrlServer', val)
|
||||
}
|
||||
|
||||
function handleYourlsDomainChange (val: string) {
|
||||
saveConfig('settings.yourlsDomain', val)
|
||||
}
|
||||
|
||||
function handleYourlsSignatureChange (val: string) {
|
||||
saveConfig('settings.yourlsSignature', val)
|
||||
}
|
||||
|
||||
function confirmLogLevelSetting () {
|
||||
if (form.logLevel.length === 0) {
|
||||
return $message.error($T('TIPS_PLEASE_CHOOSE_LOG_LEVEL'))
|
||||
|
||||
Reference in New Issue
Block a user