mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-09-05 07:28:42 +08:00
Fixed: Chinese filename can't upload & add setting-info button
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="referrer" content="never">
|
<meta name="referrer" content="never">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
||||||
<title>PicGo</title>
|
<title>PicGo</title>
|
||||||
<% if (htmlWebpackPlugin.options.nodeModules) { %>
|
<% if (htmlWebpackPlugin.options.nodeModules) { %>
|
||||||
<!-- Add `node_modules/` to global paths so `require` works properly in development -->
|
<!-- Add `node_modules/` to global paths so `require` works properly in development -->
|
||||||
|
|||||||
+49
-25
@@ -1,10 +1,11 @@
|
|||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
import uploader from './utils/uploader.js'
|
import uploader from './utils/uploader.js'
|
||||||
import { app, BrowserWindow, Tray, Menu, Notification, clipboard, ipcMain, globalShortcut } from 'electron'
|
import { app, BrowserWindow, Tray, Menu, Notification, clipboard, ipcMain, globalShortcut, dialog } from 'electron'
|
||||||
import db from '../datastore'
|
import db from '../datastore'
|
||||||
import pasteTemplate from './utils/pasteTemplate'
|
import pasteTemplate from './utils/pasteTemplate'
|
||||||
import updateChecker from './utils/updateChecker'
|
import updateChecker from './utils/updateChecker'
|
||||||
|
import pkg from '../../package.json'
|
||||||
/**
|
/**
|
||||||
* Set `__static` path to static files in production
|
* Set `__static` path to static files in production
|
||||||
* https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html
|
* https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html
|
||||||
@@ -35,6 +36,16 @@ const uploadFailed = () => {
|
|||||||
function createTray () {
|
function createTray () {
|
||||||
tray = new Tray(`${__static}/menubar.png`)
|
tray = new Tray(`${__static}/menubar.png`)
|
||||||
const contextMenu = Menu.buildFromTemplate([
|
const contextMenu = Menu.buildFromTemplate([
|
||||||
|
{
|
||||||
|
label: '关于',
|
||||||
|
click () {
|
||||||
|
dialog.showMessageBox({
|
||||||
|
title: 'PicGo',
|
||||||
|
message: 'PicGo',
|
||||||
|
detail: `Version: ${pkg.version}\nAuthor: Molunerfinn\nGithub: https://github.com/Molunerfinn/PicGo`
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: '打开详细窗口',
|
label: '打开详细窗口',
|
||||||
click () {
|
click () {
|
||||||
@@ -173,6 +184,7 @@ const createWindow = () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
createSettingWindow()
|
createSettingWindow()
|
||||||
|
createMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
const createSettingWindow = () => {
|
const createSettingWindow = () => {
|
||||||
@@ -201,27 +213,29 @@ const createSettingWindow = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const createMenu = () => {
|
const createMenu = () => {
|
||||||
const template = [{
|
if (process.env.NODE_ENV !== 'development') {
|
||||||
label: 'Edit',
|
const template = [{
|
||||||
submenu: [
|
label: 'Edit',
|
||||||
{ label: 'Undo', accelerator: 'CmdOrCtrl+Z', selector: 'undo:' },
|
submenu: [
|
||||||
{ label: 'Redo', accelerator: 'Shift+CmdOrCtrl+Z', selector: 'redo:' },
|
{ label: 'Undo', accelerator: 'CmdOrCtrl+Z', selector: 'undo:' },
|
||||||
{ type: 'separator' },
|
{ label: 'Redo', accelerator: 'Shift+CmdOrCtrl+Z', selector: 'redo:' },
|
||||||
{ label: 'Cut', accelerator: 'CmdOrCtrl+X', selector: 'cut:' },
|
{ type: 'separator' },
|
||||||
{ label: 'Copy', accelerator: 'CmdOrCtrl+C', selector: 'copy:' },
|
{ label: 'Cut', accelerator: 'CmdOrCtrl+X', selector: 'cut:' },
|
||||||
{ label: 'Paste', accelerator: 'CmdOrCtrl+V', selector: 'paste:' },
|
{ label: 'Copy', accelerator: 'CmdOrCtrl+C', selector: 'copy:' },
|
||||||
{ label: 'Select All', accelerator: 'CmdOrCtrl+A', selector: 'selectAll:' },
|
{ label: 'Paste', accelerator: 'CmdOrCtrl+V', selector: 'paste:' },
|
||||||
{
|
{ label: 'Select All', accelerator: 'CmdOrCtrl+A', selector: 'selectAll:' },
|
||||||
label: 'Quit',
|
{
|
||||||
accelerator: 'CmdOrCtrl+Q',
|
label: 'Quit',
|
||||||
click () {
|
accelerator: 'CmdOrCtrl+Q',
|
||||||
app.quit()
|
click () {
|
||||||
|
app.quit()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
]
|
}]
|
||||||
}]
|
menu = Menu.buildFromTemplate(template)
|
||||||
menu = Menu.buildFromTemplate(template)
|
Menu.setApplicationMenu(menu)
|
||||||
Menu.setApplicationMenu(menu)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const getWindowPosition = () => {
|
const getWindowPosition = () => {
|
||||||
@@ -323,14 +337,26 @@ ipcMain.on('uploadChoosedFiles', async (evt, files) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const isSecondInstance = app.makeSingleInstance(() => {
|
||||||
|
if (settingWindow) {
|
||||||
|
if (settingWindow.isMinimized()) {
|
||||||
|
settingWindow.restore()
|
||||||
|
}
|
||||||
|
settingWindow.focus()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (isSecondInstance) {
|
||||||
|
console.log('is 2')
|
||||||
|
app.quit()
|
||||||
|
}
|
||||||
|
|
||||||
app.on('ready', () => {
|
app.on('ready', () => {
|
||||||
createWindow()
|
createWindow()
|
||||||
createTray()
|
createTray()
|
||||||
createMenu()
|
|
||||||
updateChecker()
|
updateChecker()
|
||||||
|
|
||||||
globalShortcut.register('CommandOrControl+Shift+P', () => {
|
globalShortcut.register('CommandOrControl+Shift+P', () => {
|
||||||
console.log(1)
|
|
||||||
uploadClipboardFiles()
|
uploadClipboardFiles()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -344,8 +370,6 @@ app.on('window-all-closed', () => {
|
|||||||
app.on('activate', () => {
|
app.on('activate', () => {
|
||||||
if (window === null || settingWindow === null) {
|
if (window === null || settingWindow === null) {
|
||||||
createWindow()
|
createWindow()
|
||||||
createTray()
|
|
||||||
createMenu()
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { Notification } from 'electron'
|
|||||||
|
|
||||||
function postOptions (fileName, token, imgBase64) {
|
function postOptions (fileName, token, imgBase64) {
|
||||||
const area = selectArea(db.read().get('picBed.qiniu.area').value() || 'z0')
|
const area = selectArea(db.read().get('picBed.qiniu.area').value() || 'z0')
|
||||||
const base64FileName = Buffer.from(fileName).toString('base64')
|
const base64FileName = Buffer.from(fileName, 'utf-8').toString('base64').replace(/\+/g, '-').replace(/\//g, '_')
|
||||||
return {
|
return {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: `http://upload${area}.qiniu.com/putb64/-1/key/${base64FileName}`,
|
url: `http://upload${area}.qiniu.com/putb64/-1/key/${base64FileName}`,
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ const generateSignature = (fileName) => {
|
|||||||
const password = options.password
|
const password = options.password
|
||||||
const md5Password = MD5(password)
|
const md5Password = MD5(password)
|
||||||
const date = new Date().toGMTString()
|
const date = new Date().toGMTString()
|
||||||
const uri = `/${options.bucket}/${fileName}`
|
const uri = `/${options.bucket}/${encodeURI(fileName)}`
|
||||||
const value = `PUT&${uri}&${date}`
|
const value = `PUT&${uri}&${date}`
|
||||||
const sign = crypto.createHmac('sha1', md5Password).update(value).digest('base64')
|
const sign = crypto.createHmac('sha1', md5Password).update(value).digest('base64')
|
||||||
return `UPYUN ${operator}:${sign}`
|
return `UPYUN ${operator}:${sign}`
|
||||||
@@ -24,7 +24,7 @@ const postOptions = (fileName, signature, imgBase64) => {
|
|||||||
const bucket = options.bucket
|
const bucket = options.bucket
|
||||||
return {
|
return {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
url: `https://v0.api.upyun.com/${bucket}/${fileName}`,
|
url: `https://v0.api.upyun.com/${bucket}/${encodeURI(fileName)}`,
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: signature,
|
Authorization: signature,
|
||||||
Date: new Date().toGMTString()
|
Date: new Date().toGMTString()
|
||||||
|
|||||||
@@ -34,29 +34,80 @@
|
|||||||
<i class="el-icon-ui-upyun"></i>
|
<i class="el-icon-ui-upyun"></i>
|
||||||
<span slot="title">又拍云设置</span>
|
<span slot="title">又拍云设置</span>
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
|
<i class="el-icon-setting" @click="openDialog"></i>
|
||||||
</el-menu>
|
</el-menu>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="19" :offset="5">
|
<el-col :span="19" :offset="5">
|
||||||
<router-view></router-view>
|
<router-view></router-view>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
<el-dialog
|
||||||
|
title="赞助PicGo"
|
||||||
|
:visible.sync="visible"
|
||||||
|
width="70%"
|
||||||
|
top="10vh"
|
||||||
|
>
|
||||||
|
PicGo是免费开源的软件,如果你喜欢它,对你有帮助,不妨请我喝杯咖啡?
|
||||||
|
<el-row class="support">
|
||||||
|
<el-col :span="12">
|
||||||
|
<img src="https://user-images.githubusercontent.com/12621342/34188165-e7cdf372-e56f-11e7-8732-1338c88b9bb7.jpg" alt="支付宝">
|
||||||
|
<div class="support-title">支付宝</div>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<img src="https://user-images.githubusercontent.com/12621342/34188201-212cda84-e570-11e7-9b7a-abb298699d85.jpg" alt="支付宝">
|
||||||
|
<div class="support-title">微信</div>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import pkg from '../../../package.json'
|
import pkg from '../../../package.json'
|
||||||
|
import { remote } from 'electron'
|
||||||
|
const { Menu, dialog } = remote
|
||||||
export default {
|
export default {
|
||||||
name: 'setting-page',
|
name: 'setting-page',
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
version: pkg.version,
|
version: pkg.version,
|
||||||
defaultActive: 'upload'
|
defaultActive: 'upload',
|
||||||
|
menu: null,
|
||||||
|
visible: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
created () {
|
||||||
|
this.buildMenu()
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleSelect (index) {
|
handleSelect (index) {
|
||||||
this.$router.push({
|
this.$router.push({
|
||||||
name: index
|
name: index
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
buildMenu () {
|
||||||
|
const _this = this
|
||||||
|
const template = [
|
||||||
|
{
|
||||||
|
label: '关于',
|
||||||
|
click () {
|
||||||
|
dialog.showMessageBox({
|
||||||
|
title: 'PicGo',
|
||||||
|
message: 'PicGo',
|
||||||
|
detail: `Version: ${pkg.version}\nAuthor: Molunerfinn\nGithub: https://github.com/Molunerfinn/PicGo`
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '赞助PicGo',
|
||||||
|
click () {
|
||||||
|
_this.visible = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
this.menu = Menu.buildFromTemplate(template)
|
||||||
|
},
|
||||||
|
openDialog () {
|
||||||
|
this.menu.popup(remote.getCurrentWindow)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeRouteEnter: (to, from, next) => {
|
beforeRouteEnter: (to, from, next) => {
|
||||||
@@ -83,6 +134,15 @@ export default {
|
|||||||
border-right none
|
border-right none
|
||||||
background transparent
|
background transparent
|
||||||
position fixed
|
position fixed
|
||||||
|
.el-icon-setting
|
||||||
|
position absolute
|
||||||
|
bottom 4px
|
||||||
|
left 4px
|
||||||
|
cursor pointer
|
||||||
|
color #878d99
|
||||||
|
transition .2s all ease-in-out
|
||||||
|
&:hover
|
||||||
|
color #409EFF
|
||||||
&-item
|
&-item
|
||||||
color #eee
|
color #eee
|
||||||
position relative
|
position relative
|
||||||
@@ -100,4 +160,9 @@ export default {
|
|||||||
right 0
|
right 0
|
||||||
top 18px
|
top 18px
|
||||||
background active-color
|
background active-color
|
||||||
|
.support
|
||||||
|
text-align center
|
||||||
|
&-title
|
||||||
|
text-align center
|
||||||
|
color #878d99
|
||||||
</style>
|
</style>
|
||||||
@@ -6,9 +6,13 @@ import App from './App'
|
|||||||
import router from './router'
|
import router from './router'
|
||||||
import store from './store'
|
import store from './store'
|
||||||
import db from '../datastore/index'
|
import db from '../datastore/index'
|
||||||
|
import { webFrame } from 'electron'
|
||||||
import './assets/fonts/iconfont.css'
|
import './assets/fonts/iconfont.css'
|
||||||
Vue.use(ElementUI)
|
Vue.use(ElementUI)
|
||||||
|
|
||||||
|
webFrame.setVisualZoomLevelLimits(1, 1)
|
||||||
|
webFrame.setLayoutZoomLevelLimits(0, 0)
|
||||||
|
|
||||||
if (!process.env.IS_WEB) Vue.use(require('vue-electron'))
|
if (!process.env.IS_WEB) Vue.use(require('vue-electron'))
|
||||||
Vue.http = Vue.prototype.$http = axios
|
Vue.http = Vue.prototype.$http = axios
|
||||||
Vue.prototype.$db = db
|
Vue.prototype.$db = db
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 47 KiB |
Reference in New Issue
Block a user