mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-03-13 00:18:13 -04:00
Added: weibo cookie uploader support
This commit is contained in:
parent
29fb9c742e
commit
e8e78303a3
@ -28,21 +28,34 @@ const weiboUpload = async function (img, type, webContents) {
|
|||||||
password: db.read().get('picBed.weibo.password').value()
|
password: db.read().get('picBed.weibo.password').value()
|
||||||
}
|
}
|
||||||
const quality = db.read().get('picBed.weibo.quality').value()
|
const quality = db.read().get('picBed.weibo.quality').value()
|
||||||
|
const cookie = db.read().get('picBed.weibo.cookie').value()
|
||||||
|
const chooseCookie = db.read().get('picBed.weibo.chooseCookie').value()
|
||||||
const options = postOptions(formData)
|
const options = postOptions(formData)
|
||||||
const res = await rp(options)
|
let res
|
||||||
|
if (!chooseCookie) {
|
||||||
|
res = await rp(options)
|
||||||
|
}
|
||||||
webContents.send('uploadProgress', 30)
|
webContents.send('uploadProgress', 30)
|
||||||
if (res.body.retcode === 20000000) {
|
if (chooseCookie || res.body.retcode === 20000000) {
|
||||||
for (let i in res.body.data.crossdomainlist) {
|
if (res) {
|
||||||
await rp.get(res.body.data.crossdomainlist[i])
|
for (let i in res.body.data.crossdomainlist) {
|
||||||
|
await rp.get(res.body.data.crossdomainlist[i])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
webContents.send('uploadProgress', 60)
|
webContents.send('uploadProgress', 60)
|
||||||
const imgList = await img2Base64[type](img)
|
const imgList = await img2Base64[type](img)
|
||||||
|
let opt = {
|
||||||
|
formData: {
|
||||||
|
b64_data: imgList[i].base64Image
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (chooseCookie) {
|
||||||
|
opt.headers = {
|
||||||
|
Cookie: cookie
|
||||||
|
}
|
||||||
|
}
|
||||||
for (let i in imgList) {
|
for (let i in imgList) {
|
||||||
let result = await rp.post(UPLOAD_URL, {
|
let result = await rp.post(UPLOAD_URL, opt)
|
||||||
formData: {
|
|
||||||
b64_data: imgList[i].base64Image
|
|
||||||
}
|
|
||||||
})
|
|
||||||
result = result.replace(/<.*?\/>/, '').replace(/<(\w+).*?>.*?<\/\1>/, '')
|
result = result.replace(/<.*?\/>/, '').replace(/<(\w+).*?>.*?<\/\1>/, '')
|
||||||
delete imgList[i].base64Image
|
delete imgList[i].base64Image
|
||||||
const resTextJson = JSON.parse(result)
|
const resTextJson = JSON.parse(result)
|
||||||
|
@ -1,30 +1,47 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="weibo-view">
|
<div id="weibo-view">
|
||||||
<el-row :gutter="16">
|
<el-row :gutter="16">
|
||||||
<el-col :span="12" :offset="6">
|
<el-col :span="16" :offset="4">
|
||||||
<div class="view-title">
|
<div class="view-title">
|
||||||
微博图床设置
|
微博图床设置
|
||||||
</div>
|
</div>
|
||||||
<el-form
|
<el-form
|
||||||
ref="weiboForm"
|
ref="weiboForm"
|
||||||
label-position="top"
|
label-position="right"
|
||||||
label-width="80px"
|
label-width="120px"
|
||||||
|
size="small"
|
||||||
:model="form">
|
:model="form">
|
||||||
<el-form-item
|
<el-form-item
|
||||||
label="设定用户名"
|
label="设定用户名"
|
||||||
prop="username"
|
prop="username"
|
||||||
:rules="{
|
:rules="{
|
||||||
required: true, message: '用户名不能为空', trigger: 'blur'
|
required: !chooseCookie, message: '用户名不能为空', trigger: 'blur'
|
||||||
}">
|
}">
|
||||||
<el-input v-model="form.username" placeholder="用户名" @keyup.native.enter="confirm('weiboForm')"></el-input>
|
<el-input v-model="form.username" placeholder="用户名" @keyup.native.enter="confirm('weiboForm')" :disabled="chooseCookie"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item
|
<el-form-item
|
||||||
label="设定密码"
|
label="设定密码"
|
||||||
prop="password"
|
prop="password"
|
||||||
|
:rules="{required: !chooseCookie,messsage: '密码不能为空',trigger: 'blur'}">
|
||||||
|
<el-input v-model="form.password" type="password" @keyup.native.enter="confirm('weiboForm')" placeholder="密码" :disabled="chooseCookie"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item
|
||||||
|
label="使用Cookie上传"
|
||||||
|
>
|
||||||
|
<el-switch
|
||||||
|
v-model="chooseCookie"
|
||||||
|
active-text="cookie模式"
|
||||||
|
@change="handleSwitchChange"
|
||||||
|
></el-switch>
|
||||||
|
<i class="el-icon-question" @click="openWiki"></i>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item
|
||||||
|
label="设定Cookie"
|
||||||
|
prop="cookie"
|
||||||
:rules="{
|
:rules="{
|
||||||
required: true, message: '密码不能为空', trigger: 'blur'
|
required: chooseCookie, message: '密码不能为空', trigger: 'blur'
|
||||||
}">
|
}">
|
||||||
<el-input v-model="form.password" type="password" @keyup.native.enter="confirm('weiboForm')" placeholder="密码"></el-input>
|
<el-input v-model="form.cookie" @keyup.native.enter="confirm('weiboForm')" placeholder="Cookie" :disabled="!chooseCookie"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="* 图片质量">
|
<el-form-item label="* 图片质量">
|
||||||
<el-radio-group v-model="quality">
|
<el-radio-group v-model="quality">
|
||||||
@ -50,8 +67,10 @@ export default {
|
|||||||
return {
|
return {
|
||||||
form: {
|
form: {
|
||||||
username: '',
|
username: '',
|
||||||
password: ''
|
password: '',
|
||||||
|
cookie: ''
|
||||||
},
|
},
|
||||||
|
chooseCookie: false,
|
||||||
quality: 'large'
|
quality: 'large'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -61,6 +80,8 @@ export default {
|
|||||||
this.form.username = config.username
|
this.form.username = config.username
|
||||||
this.form.password = config.password
|
this.form.password = config.password
|
||||||
this.quality = config.quality || 'large'
|
this.quality = config.quality || 'large'
|
||||||
|
this.form.cookie = config.cookie
|
||||||
|
this.chooseCookie = config.chooseCookie
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -70,7 +91,9 @@ export default {
|
|||||||
this.$db.read().set('picBed.weibo', {
|
this.$db.read().set('picBed.weibo', {
|
||||||
username: this.form.username,
|
username: this.form.username,
|
||||||
password: this.form.password,
|
password: this.form.password,
|
||||||
quality: this.quality
|
quality: this.quality,
|
||||||
|
cookie: this.form.cookie,
|
||||||
|
chooseCookie: this.chooseCookie
|
||||||
}).write()
|
}).write()
|
||||||
const successNotification = new window.Notification('设置结果', {
|
const successNotification = new window.Notification('设置结果', {
|
||||||
body: '设置成功'
|
body: '设置成功'
|
||||||
@ -82,6 +105,12 @@ export default {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
handleSwitchChange () {
|
||||||
|
this.$refs['weiboForm'].resetFields()
|
||||||
|
},
|
||||||
|
openWiki () {
|
||||||
|
this.$electron.remote.shell.openExternal('https://github.com/Molunerfinn/PicGo/wiki/%E8%AF%A6%E7%BB%86%E7%AA%97%E5%8F%A3%E7%9A%84%E4%BD%BF%E7%94%A8#%E5%BE%AE%E5%8D%9A%E5%9B%BE%E5%BA%8A')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,4 +135,17 @@ export default {
|
|||||||
border-radius 19px
|
border-radius 19px
|
||||||
.el-radio-group
|
.el-radio-group
|
||||||
margin-left 25px
|
margin-left 25px
|
||||||
|
.el-switch__label
|
||||||
|
color #eee
|
||||||
|
&.is-active
|
||||||
|
color #409EFF
|
||||||
|
.el-icon-question
|
||||||
|
font-size 20px
|
||||||
|
float right
|
||||||
|
margin-top 9px
|
||||||
|
color #eee
|
||||||
|
cursor pointer
|
||||||
|
transition .2s color ease-in-out
|
||||||
|
&:hover
|
||||||
|
color #409EFF
|
||||||
</style>
|
</style>
|
@ -80,6 +80,7 @@
|
|||||||
const myNotification = new window.Notification(this.notification.title, this.notification)
|
const myNotification = new window.Notification(this.notification.title, this.notification)
|
||||||
const pasteStyle = this.$db.read().get('picBed.pasteStyle').value()
|
const pasteStyle = this.$db.read().get('picBed.pasteStyle').value()
|
||||||
this.$electron.clipboard.writeText(pasteTemplate(pasteStyle, item.imgUrl))
|
this.$electron.clipboard.writeText(pasteTemplate(pasteStyle, item.imgUrl))
|
||||||
|
console.log(pasteTemplate(pasteStyle, item.imgUrl))
|
||||||
myNotification.onclick = () => {
|
myNotification.onclick = () => {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user