@@ -3,10 +3,11 @@ import { Options } from 'request-promise-native'
3
3
import { IBuildInEvent } from '../../utils/enum'
4
4
import { ILocalesKey } from '../../i18n/zh-CN'
5
5
6
- const postOptions = ( fileName : string , image : Buffer , apiToken : string ) : Options => {
6
+ const postOptions = ( fileName : string , image : Buffer , apiToken : string , backupDomain = '' ) : Options => {
7
+ const domain = backupDomain || 'sm.ms'
7
8
return {
8
9
method : 'POST' ,
9
- url : ' https://sm.ms /api/v2/upload' ,
10
+ url : ` https://${ domain } /api/v2/upload` ,
10
11
headers : {
11
12
contentType : 'multipart/form-data' ,
12
13
'User-Agent' : 'PicGo' ,
@@ -33,7 +34,7 @@ const handle = async (ctx: IPicGo): Promise<IPicGo> => {
33
34
if ( ! image && img . base64Image ) {
34
35
image = Buffer . from ( img . base64Image , 'base64' )
35
36
}
36
- const postConfig = postOptions ( img . fileName , image , smmsConfig ?. token )
37
+ const postConfig = postOptions ( img . fileName , image , smmsConfig ?. token , smmsConfig . backupDomain )
37
38
let body = await ctx . Request . request ( postConfig )
38
39
body = JSON . parse ( body )
39
40
if ( body . code === 'success' ) {
@@ -66,6 +67,16 @@ const config = (ctx: IPicGo): IPluginConfig[] => {
66
67
get alias ( ) { return ctx . i18n . translate < ILocalesKey > ( 'PICBED_SMMS_TOKEN' ) } ,
67
68
default : userConfig . token || '' ,
68
69
required : true
70
+ } ,
71
+ {
72
+ name : 'backupDomain' ,
73
+ get message ( ) {
74
+ return ctx . i18n . translate < ILocalesKey > ( 'PICBED_SMMS_BACKUP_DOMAIN' )
75
+ } ,
76
+ type : 'input' ,
77
+ get alias ( ) { return ctx . i18n . translate < ILocalesKey > ( 'PICBED_SMMS_BACKUP_DOMAIN' ) } ,
78
+ default : userConfig . backupDomain || '' ,
79
+ required : false
69
80
}
70
81
]
71
82
return config
0 commit comments