Feature: add remote file delete , picBed management

First version of PicList.
In album, you can delete remote file now.
Add picBed management
function.
This commit is contained in:
萌萌哒赫萝
2023-02-15 23:36:47 +08:00
parent 7421322475
commit efeadb8fb8
355 changed files with 12428 additions and 883 deletions

View File

@@ -8,7 +8,7 @@
import { useStore } from '@/hooks/useStore'
import { onBeforeMount, onMounted, onUnmounted } from 'vue'
import { getConfig } from './utils/dataSender'
import type { IConfig } from 'picgo'
import type { IConfig } from 'piclist'
import bus from './utils/bus'
import { FORCE_UPDATE } from '~/universal/events/constants'

View File

@@ -0,0 +1,25 @@
import OSS from 'ali-oss'
export default class AliyunApi {
static async delete (configMap: IStringKeyMap): Promise<boolean> {
const { fileName, config: { accessKeyId, accessKeySecret, bucket, area, path } } = configMap
try {
const client = new OSS({
accessKeyId,
accessKeySecret,
bucket,
region: area
})
let key
if (path === '/' || !path) {
key = fileName
} else {
key = `${path.replace(/^\//, '').replace(/\/$/, '')}/${fileName}`
}
const result = await client.delete(key) as any
return result.res.status === 204
} catch (error) {
return false
}
}
}

View File

@@ -0,0 +1,27 @@
import SmmsApi from './smms'
import TcyunApi from './tcyun'
import AliyunApi from './aliyun'
import QiniuApi from './qiniu'
import ImgurApi from './imgur'
import GithubApi from './github'
import UpyunApi from './upyun'
const apiMap: IStringKeyMap = {
smms: SmmsApi,
tcyun: TcyunApi,
aliyun: AliyunApi,
qiniu: QiniuApi,
imgur: ImgurApi,
github: GithubApi,
upyun: UpyunApi
}
export default class ALLApi {
static async delete (configMap: IStringKeyMap): Promise<boolean> {
if (apiMap[configMap.type] !== undefined) {
return await apiMap[configMap.type].delete(configMap)
} else {
return false
}
}
}

View File

@@ -0,0 +1,31 @@
import { Octokit } from '@octokit/rest'
export default class GithubApi {
static async delete (configMap: IStringKeyMap): Promise<boolean> {
const { fileName, hash, config: { repo, token, branch, path } } = configMap
const owner = repo.split('/')[0]
const repoName = repo.split('/')[1]
const octokit = new Octokit({
auth: token
})
let key
if (path === '/' || !path) {
key = fileName
} else {
key = `${path.replace(/^\//, '').replace(/\/$/, '')}/${fileName}`
}
try {
const result = await octokit.rest.repos.deleteFile({
owner,
repo: repoName,
path: key,
message: `delete ${fileName} by PicList`,
sha: hash,
branch
})
return result.status === 200
} catch (error) {
return false
}
}
}

View File

@@ -0,0 +1,21 @@
import axios from 'axios'
export default class ImgurApi {
static async delete (configMap: IStringKeyMap): Promise<boolean> {
const clientId = configMap.config.clientId
const { hash } = configMap
const fullUrl = `https://api.imgur.com/3/image/${hash}`
const headers = {
Authorization: `Client-ID ${clientId}`
}
try {
const res = await axios.delete(fullUrl, {
headers,
timeout: 10000
})
return res.status === 200
} catch (error) {
return false
}
}
}

View File

@@ -0,0 +1,33 @@
import Qiniu from 'qiniu'
export default class QiniuApi {
static async delete (configMap: IStringKeyMap): Promise<boolean> {
const { fileName, config: { accessKey, secretKey, bucket, path } } = configMap
const mac = new Qiniu.auth.digest.Mac(accessKey, secretKey)
const qiniuConfig = new Qiniu.conf.Config()
try {
const bucketManager = new Qiniu.rs.BucketManager(mac, qiniuConfig)
let key = ''
if (path === '/' || !path) {
key = fileName
} else {
key = `${path.replace(/^\//, '').replace(/\/$/, '')}/${fileName}`
}
const res = await new Promise((resolve, reject) => {
bucketManager.delete(bucket, key, (err, respBody, respInfo) => {
if (err) {
reject(err)
} else {
resolve({
respBody,
respInfo
})
}
})
}) as any
return res && res.respInfo.statusCode === 200
} catch (error) {
return false
}
}
}

23
src/renderer/apis/smms.ts Normal file
View File

@@ -0,0 +1,23 @@
import axios from 'axios'
export default class SmmsApi {
static async delete (configMap: IStringKeyMap): Promise<boolean> {
const { hash, config: { token } } = configMap
if (!hash || !token) {
return false
} else {
const res = await axios.get(
`https://smms.app/api/v2/delete/${hash}`, {
headers: {
Authorization: token
},
params: {
hash,
format: 'json'
},
timeout: 10000
})
return res.status === 200
}
}
}

View File

@@ -0,0 +1,27 @@
import COS from 'cos-nodejs-sdk-v5'
export default class TcyunApi {
static async delete (configMap: IStringKeyMap): Promise<boolean> {
const { fileName, config: { secretId, secretKey, bucket, area, path } } = configMap
try {
const cos = new COS({
SecretId: secretId,
SecretKey: secretKey
})
let key
if (path === '/' || !path) {
key = `/${fileName}`
} else {
key = `/${path.replace(/^\//, '').replace(/\/$/, '')}${fileName}`
}
const result = await cos.deleteObject({
Bucket: bucket,
Region: area,
Key: key
})
return result.statusCode === 204
} catch (error) {
return false
}
}
}

View File

@@ -0,0 +1,22 @@
// @ts-ignore
import Upyun from 'upyun'
export default class UpyunApi {
static async delete (configMap: IStringKeyMap): Promise<boolean> {
const { fileName, config: { bucket, operator, password, path } } = configMap
try {
const service = new Upyun.Service(bucket, operator, password)
const client = new Upyun.Client(service)
let key
if (path === '/' || !path) {
key = fileName
} else {
key = `${path.replace(/^\//, '').replace(/\/$/, '')}/${fileName}`
}
const result = await client.deleteFile(key)
return result
} catch (error) {
return false
}
}
}

View File

@@ -51,11 +51,11 @@
</el-icon>
<span>{{ $T('UPLOAD_AREA') }}</span>
</el-menu-item>
<el-menu-item :index="routerConfig.MANAGE_MAIN_PAGE">
<el-menu-item :index="routerConfig.MANAGE_LOGIN_PAGE">
<el-icon>
<PictureFilled />
<PieChart />
</el-icon>
<span>{{ $T('PICBEDS_MANAGE') }}</span>
<span>管理页面</span>
</el-menu-item>
<el-menu-item :index="routerConfig.GALLERY_PAGE">
<el-icon>
@@ -105,8 +105,8 @@
</el-icon>
</el-col>
<el-col
:span="19"
:offset="5"
:span="21"
:offset="3"
style="height: 100%"
class="main-wrapper"
:class="{ 'darwin': os === 'darwin' }"
@@ -133,7 +133,7 @@
width="70%"
top="10vh"
>
{{ $T('PICGO_SPONSOR_TEXT') }}
{{ $T('PICLIST_SPONSOR_TEXT') }}
<el-row class="support">
<el-col :span="12">
<img
@@ -219,10 +219,11 @@ import {
InfoFilled,
Minus,
CirclePlus,
Close
Close,
PieChart
} from '@element-plus/icons-vue'
import { ElMessage as $message } from 'element-plus'
import { T } from '@/i18n/index'
import { T as $T } from '@/i18n/index'
import { ref, onBeforeUnmount, Ref, onBeforeMount, watch, nextTick, reactive } from 'vue'
import { onBeforeRouteUpdate, useRouter } from 'vue-router'
import QrcodeVue from 'qrcode.vue'
@@ -299,18 +300,6 @@ const handleSelect = (index: string) => {
type
}
})
// if (this.$builtInPicBed.includes(picBed)) {
// this.$router.push({
// name: picBed
// })
// } else {
// this.$router.push({
// name: 'others',
// params: {
// type: picBed
// }
// })
// }
}
}
@@ -332,7 +321,7 @@ function openMiniWindow () {
function handleCopyPicBedConfig () {
clipboard.writeText(picBedConfigString.value)
$message.success(T('COPY_PICBED_CONFIG_SUCCEED'))
$message.success($T('COPY_PICBED_CONFIG_SUCCEED'))
}
function getPicBeds (event: IpcRendererEvent, picBeds: IPicBedType[]) {

View File

@@ -1,13 +0,0 @@
<template>
<div id="appm">
{{ test }}
</div>
</template>
<script lang="ts" setup>
const test = 'test'
</script>
<style lang="stylus">
</style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Some files were not shown because too many files have changed in this diff Show More