mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-20 07:39:53 +08:00
✨ Feature: add tencent-cos options for url
ISSUES CLOSED: #862, #863, #865, #524, #845, #732
This commit is contained in:
@@ -41,7 +41,7 @@ export const uploadClipboardFiles = async (): Promise<string> => {
|
||||
trayWindow?.webContents?.send('clipboardFiles', [])
|
||||
trayWindow?.webContents?.send('uploadFiles', img)
|
||||
if (windowManager.has(IWindowList.SETTING_WINDOW)) {
|
||||
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents.send('updateGallery')
|
||||
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents?.send('updateGallery')
|
||||
}
|
||||
return handleUrlEncode(img[0].imgUrl as string)
|
||||
} else {
|
||||
@@ -81,7 +81,7 @@ export const uploadChoosedFiles = async (webContents: WebContents, files: IFileW
|
||||
// trayWindow just be created in mac/windows, not in linux
|
||||
windowManager.get(IWindowList.TRAY_WINDOW)?.webContents?.send('uploadFiles', imgs)
|
||||
if (windowManager.has(IWindowList.SETTING_WINDOW)) {
|
||||
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents.send('updateGallery')
|
||||
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents?.send('updateGallery')
|
||||
}
|
||||
return result
|
||||
} else {
|
||||
|
||||
@@ -9,14 +9,23 @@ const LOG_PATH = path.join(STORE_PATH, '/picgo.log')
|
||||
// since the error may occur in picgo-core
|
||||
// so we can't use the log from picgo
|
||||
export const loggerWriter = (error: Error) => {
|
||||
let log = `${dayjs().format('YYYY-MM-DD HH:mm:ss')} [PicGo ERROR] startup error`
|
||||
if (error?.stack) {
|
||||
log += `\n------Error Stack Begin------\n${util.format(error.stack)}\n-------Error Stack End-------\n`
|
||||
} else {
|
||||
const msg = JSON.stringify(error)
|
||||
log += `${msg}\n`
|
||||
try {
|
||||
const time = dayjs().format('YYYY-MM-DD HH:mm:ss')
|
||||
let log = `${time} [PicGo ERROR] process error begin`
|
||||
if (error?.stack) {
|
||||
log += `\n------Error Stack Begin------\n${util.format(error.stack)}\n-------Error Stack End-------\n`
|
||||
} else {
|
||||
const msg = JSON.stringify(error)
|
||||
log += `${msg}\n`
|
||||
}
|
||||
log += `${time} [PicGo ERROR] process error end`
|
||||
if (!fse.existsSync(LOG_PATH)) {
|
||||
fse.ensureFileSync(LOG_PATH)
|
||||
}
|
||||
fse.appendFileSync(LOG_PATH, log)
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
fse.appendFileSync(LOG_PATH, log)
|
||||
}
|
||||
|
||||
const handleProcessError = (error: Error) => {
|
||||
|
||||
@@ -35,6 +35,11 @@ const updateShortKeyFromVersion212 = (db: typeof ConfigStore, shortKeyConfig: IS
|
||||
|
||||
const migrateGalleryFromVersion230 = async (configDB: typeof ConfigStore, galleryDB: DBStore, picgo: PicGoCore) => {
|
||||
const originGallery: ImgInfo[] = configDB.get('uploaded')
|
||||
// if hasMigrate, we don't need to migrate
|
||||
const hasMigrate: boolean = configDB.get('__migrateUploaded')
|
||||
if (hasMigrate) {
|
||||
return
|
||||
}
|
||||
const configPath = configDB.getConfigPath()
|
||||
const configBakPath = path.join(path.dirname(configPath), 'config.bak.json')
|
||||
// migrate gallery from config to gallery db
|
||||
@@ -44,7 +49,8 @@ const migrateGalleryFromVersion230 = async (configDB: typeof ConfigStore, galler
|
||||
}
|
||||
await galleryDB.insertMany(originGallery)
|
||||
picgo.saveConfig({
|
||||
uploaded: []
|
||||
uploaded: [],
|
||||
__migrateUploaded: true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ router.post('/upload', async ({
|
||||
// upload with clipboard
|
||||
logger.info('[PicGo Server] upload clipboard file')
|
||||
const res = await uploadClipboardFiles()
|
||||
logger.info('[PicGo Server] upload result:', res)
|
||||
if (res) {
|
||||
handleResponse({
|
||||
response,
|
||||
@@ -51,6 +52,7 @@ router.post('/upload', async ({
|
||||
})
|
||||
const win = windowManager.getAvailableWindow()
|
||||
const res = await uploadChoosedFiles(win.webContents, pathList)
|
||||
logger.info('[PicGo Server] upload result', res.join(' ; '))
|
||||
if (res.length) {
|
||||
handleResponse({
|
||||
response,
|
||||
|
||||
@@ -270,6 +270,11 @@ export default class extends Vue {
|
||||
</script>
|
||||
<style lang='stylus'>
|
||||
$darwinBg = transparentify(#172426, #000, 0.7)
|
||||
.setting-list-scroll
|
||||
height 425px
|
||||
overflow-y auto
|
||||
overflow-x hidden
|
||||
margin-right 0!important
|
||||
.picgo-fade
|
||||
&-enter,
|
||||
&-leave,
|
||||
|
||||
@@ -147,8 +147,13 @@
|
||||
></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
:label="$T('SETTINGS_USE_BUILTIN_CLIPBOARD_UPLOAD')"
|
||||
>
|
||||
<div class="el-form-item__custom-label" slot="label">
|
||||
{{ $T('SETTINGS_USE_BUILTIN_CLIPBOARD_UPLOAD') }}
|
||||
<el-tooltip class="item" effect="dark" :content="$T('BUILTIN_CLIPBOARD_TIPS')" placement="right">
|
||||
<i class="el-icon-question"></i>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
<el-switch
|
||||
v-model="form.useBuiltinClipboard"
|
||||
:active-text="$T('SETTINGS_OPEN')"
|
||||
@@ -811,6 +816,9 @@ export default class extends Vue {
|
||||
color #eee
|
||||
flex-basis: 50%
|
||||
flex-shrink: 0
|
||||
.el-form-item__custom-label
|
||||
display flex
|
||||
align-items center
|
||||
.el-button-group
|
||||
width 100%
|
||||
.el-button
|
||||
@@ -824,9 +832,7 @@ export default class extends Vue {
|
||||
&.is-active
|
||||
color #409EFF
|
||||
.el-icon-question
|
||||
font-size 20px
|
||||
float right
|
||||
margin-top 9px
|
||||
margin-left 4px
|
||||
color #eee
|
||||
cursor pointer
|
||||
transition .2s color ease-in-out
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div id="tcyun-view">
|
||||
<el-row :gutter="16">
|
||||
<el-row :gutter="16" class="setting-list-scroll">
|
||||
<el-col :span="16" :offset="4">
|
||||
<div class="view-title">
|
||||
腾讯云COS设置
|
||||
@@ -74,6 +74,11 @@
|
||||
>
|
||||
<el-input v-model="form.customUrl" @keyup.native.enter="confirm" placeholder="例如https://xxxx.com"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="设定网址后缀"
|
||||
>
|
||||
<el-input v-model="form.options" @keyup.native.enter="confirm" placeholder="例如?imageMogr2"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button-group>
|
||||
<el-button type="primary" @click="confirm" round>确定</el-button>
|
||||
@@ -90,12 +95,13 @@ import { ipcRenderer } from 'electron'
|
||||
import { Component, Vue } from 'vue-property-decorator'
|
||||
import mixin from '@/utils/ConfirmButtonMixin'
|
||||
import { OPEN_URL } from '#/events/constants'
|
||||
import { ITcyunConfig } from 'picgo/dist/types'
|
||||
@Component({
|
||||
name: 'tcyun',
|
||||
mixins: [mixin]
|
||||
})
|
||||
export default class extends Vue {
|
||||
form: ITcYunConfig = {
|
||||
form: ITcyunConfig = {
|
||||
secretId: '',
|
||||
secretKey: '',
|
||||
bucket: '',
|
||||
@@ -103,11 +109,12 @@ export default class extends Vue {
|
||||
area: '',
|
||||
path: '',
|
||||
customUrl: '',
|
||||
version: 'v4'
|
||||
version: 'v5',
|
||||
options: ''
|
||||
}
|
||||
|
||||
async created () {
|
||||
const config = await this.getConfig<ITcYunConfig>('picBed.tcyun')
|
||||
const config = await this.getConfig<ITcyunConfig>('picBed.tcyun')
|
||||
if (config) {
|
||||
this.form = Object.assign({}, config)
|
||||
}
|
||||
|
||||
@@ -67,21 +67,23 @@
|
||||
<script lang="ts">
|
||||
import { Component, Vue } from 'vue-property-decorator'
|
||||
import mixin from '@/utils/ConfirmButtonMixin'
|
||||
import { IUpyunConfig } from 'picgo/dist/types'
|
||||
@Component({
|
||||
name: 'upyun',
|
||||
mixins: [mixin]
|
||||
})
|
||||
export default class extends Vue {
|
||||
form: IUpYunConfig = {
|
||||
form: IUpyunConfig = {
|
||||
bucket: '',
|
||||
operator: '',
|
||||
password: '',
|
||||
options: '',
|
||||
url: '',
|
||||
path: ''
|
||||
}
|
||||
|
||||
async created () {
|
||||
const config = await this.getConfig<IUpYunConfig>('picBed.upyun')
|
||||
const config = await this.getConfig<IUpyunConfig>('picBed.upyun')
|
||||
if (config) {
|
||||
this.form = Object.assign({}, config)
|
||||
}
|
||||
|
||||
@@ -107,6 +107,7 @@ export const EN: ILocales = {
|
||||
SETTINGS_NOT_CONFIG_OPTIONS: 'Not Config Options',
|
||||
SETTINGS_USE_BUILTIN_CLIPBOARD_UPLOAD: 'Use Builtin Clipboard to Upload',
|
||||
SETTINGS_CHOOSE_LANGUAGE: 'Choose Language',
|
||||
BUILTIN_CLIPBOARD_TIPS: 'Use builtin clipboard function to upload instead of using scripts',
|
||||
|
||||
// shortcut page
|
||||
SHORTCUT_NAME: 'Shortcut Name',
|
||||
|
||||
@@ -106,6 +106,7 @@ export const ZH_CN = {
|
||||
SETTINGS_NOT_CONFIG_OPTIONS: '暂无配置项',
|
||||
SETTINGS_USE_BUILTIN_CLIPBOARD_UPLOAD: '使用内置剪贴板上传',
|
||||
SETTINGS_CHOOSE_LANGUAGE: '选择语言',
|
||||
BUILTIN_CLIPBOARD_TIPS: '使用内置剪贴板函数而不是调用脚本获取剪贴板图片',
|
||||
|
||||
// shortcut page
|
||||
SHORTCUT_NAME: '快捷键名称',
|
||||
|
||||
3
src/universal/types/types.d.ts
vendored
3
src/universal/types/types.d.ts
vendored
@@ -287,7 +287,8 @@ interface ITcYunConfig {
|
||||
area: string,
|
||||
path: string,
|
||||
customUrl: string,
|
||||
version: 'v4' | 'v5'
|
||||
version: 'v4' | 'v5',
|
||||
options: string
|
||||
}
|
||||
|
||||
interface IUpYunConfig {
|
||||
|
||||
Reference in New Issue
Block a user