Feature: add custom short url server

#69

ISSUES CLOSED: #69
This commit is contained in:
萌萌哒赫萝
2023-07-11 20:07:33 -07:00
parent 3b3c70a53f
commit d4a22f9e63
16 changed files with 167 additions and 38 deletions

View File

@@ -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]

View File

@@ -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'))