Skip to content

Commit af291e4

Browse files
committed
✨ Feature: add tencent-cos options for url
ISSUES CLOSED: #862, #863, #865, #524, #845, #732
1 parent f1c8507 commit af291e4

File tree

13 files changed

+68
-27
lines changed

13 files changed

+68
-27
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"keycode": "^2.2.0",
4545
"lodash-id": "^0.14.0",
4646
"lowdb": "^1.0.0",
47-
"picgo": "^1.5.0-alpha.0",
47+
"picgo": "^1.5.0-alpha.3",
4848
"qrcode.vue": "^1.7.0",
4949
"shell-path": "2.1.0",
5050
"uuidv4": "^6.2.11",

src/main/apis/app/uploader/apis.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const uploadClipboardFiles = async (): Promise<string> => {
4141
trayWindow?.webContents?.send('clipboardFiles', [])
4242
trayWindow?.webContents?.send('uploadFiles', img)
4343
if (windowManager.has(IWindowList.SETTING_WINDOW)) {
44-
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents.send('updateGallery')
44+
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents?.send('updateGallery')
4545
}
4646
return handleUrlEncode(img[0].imgUrl as string)
4747
} else {
@@ -81,7 +81,7 @@ export const uploadChoosedFiles = async (webContents: WebContents, files: IFileW
8181
// trayWindow just be created in mac/windows, not in linux
8282
windowManager.get(IWindowList.TRAY_WINDOW)?.webContents?.send('uploadFiles', imgs)
8383
if (windowManager.has(IWindowList.SETTING_WINDOW)) {
84-
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents.send('updateGallery')
84+
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents?.send('updateGallery')
8585
}
8686
return result
8787
} else {

src/main/lifeCycle/errorHandler.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,23 @@ const LOG_PATH = path.join(STORE_PATH, '/picgo.log')
99
// since the error may occur in picgo-core
1010
// so we can't use the log from picgo
1111
export const loggerWriter = (error: Error) => {
12-
let log = `${dayjs().format('YYYY-MM-DD HH:mm:ss')} [PicGo ERROR] startup error`
13-
if (error?.stack) {
14-
log += `\n------Error Stack Begin------\n${util.format(error.stack)}\n-------Error Stack End-------\n`
15-
} else {
16-
const msg = JSON.stringify(error)
17-
log += `${msg}\n`
12+
try {
13+
const time = dayjs().format('YYYY-MM-DD HH:mm:ss')
14+
let log = `${time} [PicGo ERROR] process error begin`
15+
if (error?.stack) {
16+
log += `\n------Error Stack Begin------\n${util.format(error.stack)}\n-------Error Stack End-------\n`
17+
} else {
18+
const msg = JSON.stringify(error)
19+
log += `${msg}\n`
20+
}
21+
log += `${time} [PicGo ERROR] process error end`
22+
if (!fse.existsSync(LOG_PATH)) {
23+
fse.ensureFileSync(LOG_PATH)
24+
}
25+
fse.appendFileSync(LOG_PATH, log)
26+
} catch (e) {
27+
console.error(e)
1828
}
19-
fse.appendFileSync(LOG_PATH, log)
2029
}
2130

2231
const handleProcessError = (error: Error) => {

src/main/migrate/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ const updateShortKeyFromVersion212 = (db: typeof ConfigStore, shortKeyConfig: IS
3535

3636
const migrateGalleryFromVersion230 = async (configDB: typeof ConfigStore, galleryDB: DBStore, picgo: PicGoCore) => {
3737
const originGallery: ImgInfo[] = configDB.get('uploaded')
38+
// if hasMigrate, we don't need to migrate
39+
const hasMigrate: boolean = configDB.get('__migrateUploaded')
40+
if (hasMigrate) {
41+
return
42+
}
3843
const configPath = configDB.getConfigPath()
3944
const configBakPath = path.join(path.dirname(configPath), 'config.bak.json')
4045
// migrate gallery from config to gallery db
@@ -44,7 +49,8 @@ const migrateGalleryFromVersion230 = async (configDB: typeof ConfigStore, galler
4449
}
4550
await galleryDB.insertMany(originGallery)
4651
picgo.saveConfig({
47-
uploaded: []
52+
uploaded: [],
53+
__migrateUploaded: true
4854
})
4955
}
5056
}

src/main/server/routerManager.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ router.post('/upload', async ({
2424
// upload with clipboard
2525
logger.info('[PicGo Server] upload clipboard file')
2626
const res = await uploadClipboardFiles()
27+
logger.info('[PicGo Server] upload result:', res)
2728
if (res) {
2829
handleResponse({
2930
response,
@@ -51,6 +52,7 @@ router.post('/upload', async ({
5152
})
5253
const win = windowManager.getAvailableWindow()
5354
const res = await uploadChoosedFiles(win.webContents, pathList)
55+
logger.info('[PicGo Server] upload result', res.join(' ; '))
5456
if (res.length) {
5557
handleResponse({
5658
response,

src/renderer/layouts/Main.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,11 @@ export default class extends Vue {
270270
</script>
271271
<style lang='stylus'>
272272
$darwinBg = transparentify(#172426, #000, 0.7)
273+
.setting-list-scroll
274+
height 425px
275+
overflow-y auto
276+
overflow-x hidden
277+
margin-right 0!important
273278
.picgo-fade
274279
&-enter,
275280
&-leave,

src/renderer/pages/PicGoSetting.vue

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,13 @@
147147
></el-switch>
148148
</el-form-item>
149149
<el-form-item
150-
:label="$T('SETTINGS_USE_BUILTIN_CLIPBOARD_UPLOAD')"
151150
>
151+
<div class="el-form-item__custom-label" slot="label">
152+
{{ $T('SETTINGS_USE_BUILTIN_CLIPBOARD_UPLOAD') }}
153+
<el-tooltip class="item" effect="dark" :content="$T('BUILTIN_CLIPBOARD_TIPS')" placement="right">
154+
<i class="el-icon-question"></i>
155+
</el-tooltip>
156+
</div>
152157
<el-switch
153158
v-model="form.useBuiltinClipboard"
154159
:active-text="$T('SETTINGS_OPEN')"
@@ -811,6 +816,9 @@ export default class extends Vue {
811816
color #eee
812817
flex-basis: 50%
813818
flex-shrink: 0
819+
.el-form-item__custom-label
820+
display flex
821+
align-items center
814822
.el-button-group
815823
width 100%
816824
.el-button
@@ -824,9 +832,7 @@ export default class extends Vue {
824832
&.is-active
825833
color #409EFF
826834
.el-icon-question
827-
font-size 20px
828-
float right
829-
margin-top 9px
835+
margin-left 4px
830836
color #eee
831837
cursor pointer
832838
transition .2s color ease-in-out

src/renderer/pages/picbeds/TcYun.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div id="tcyun-view">
3-
<el-row :gutter="16">
3+
<el-row :gutter="16" class="setting-list-scroll">
44
<el-col :span="16" :offset="4">
55
<div class="view-title">
66
腾讯云COS设置
@@ -74,6 +74,11 @@
7474
>
7575
<el-input v-model="form.customUrl" @keyup.native.enter="confirm" placeholder="例如https://xxxx.com"></el-input>
7676
</el-form-item>
77+
<el-form-item
78+
label="设定网址后缀"
79+
>
80+
<el-input v-model="form.options" @keyup.native.enter="confirm" placeholder="例如?imageMogr2"></el-input>
81+
</el-form-item>
7782
<el-form-item>
7883
<el-button-group>
7984
<el-button type="primary" @click="confirm" round>确定</el-button>
@@ -90,24 +95,26 @@ import { ipcRenderer } from 'electron'
9095
import { Component, Vue } from 'vue-property-decorator'
9196
import mixin from '@/utils/ConfirmButtonMixin'
9297
import { OPEN_URL } from '#/events/constants'
98+
import { ITcyunConfig } from 'picgo/dist/types'
9399
@Component({
94100
name: 'tcyun',
95101
mixins: [mixin]
96102
})
97103
export default class extends Vue {
98-
form: ITcYunConfig = {
104+
form: ITcyunConfig = {
99105
secretId: '',
100106
secretKey: '',
101107
bucket: '',
102108
appId: '',
103109
area: '',
104110
path: '',
105111
customUrl: '',
106-
version: 'v4'
112+
version: 'v5',
113+
options: ''
107114
}
108115
109116
async created () {
110-
const config = await this.getConfig<ITcYunConfig>('picBed.tcyun')
117+
const config = await this.getConfig<ITcyunConfig>('picBed.tcyun')
111118
if (config) {
112119
this.form = Object.assign({}, config)
113120
}

src/renderer/pages/picbeds/UpYun.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,23 @@
6767
<script lang="ts">
6868
import { Component, Vue } from 'vue-property-decorator'
6969
import mixin from '@/utils/ConfirmButtonMixin'
70+
import { IUpyunConfig } from 'picgo/dist/types'
7071
@Component({
7172
name: 'upyun',
7273
mixins: [mixin]
7374
})
7475
export default class extends Vue {
75-
form: IUpYunConfig = {
76+
form: IUpyunConfig = {
7677
bucket: '',
7778
operator: '',
7879
password: '',
7980
options: '',
81+
url: '',
8082
path: ''
8183
}
8284
8385
async created () {
84-
const config = await this.getConfig<IUpYunConfig>('picBed.upyun')
86+
const config = await this.getConfig<IUpyunConfig>('picBed.upyun')
8587
if (config) {
8688
this.form = Object.assign({}, config)
8789
}

src/universal/i18n/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export const EN: ILocales = {
107107
SETTINGS_NOT_CONFIG_OPTIONS: 'Not Config Options',
108108
SETTINGS_USE_BUILTIN_CLIPBOARD_UPLOAD: 'Use Builtin Clipboard to Upload',
109109
SETTINGS_CHOOSE_LANGUAGE: 'Choose Language',
110+
BUILTIN_CLIPBOARD_TIPS: 'Use builtin clipboard function to upload instead of using scripts',
110111

111112
// shortcut page
112113
SHORTCUT_NAME: 'Shortcut Name',

0 commit comments

Comments
 (0)