mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-20 15:50:04 +08:00
Added: windows support
This commit is contained in:
@@ -34,7 +34,8 @@ const uploadFailed = () => {
|
||||
}
|
||||
|
||||
function createTray () {
|
||||
tray = new Tray(`${__static}/menubar.png`)
|
||||
const menubarPic = process.platform === 'darwin' ? `${__static}/menubar.png` : `${__static}/menubar-nodarwin.png`
|
||||
tray = new Tray(menubarPic)
|
||||
const contextMenu = Menu.buildFromTemplate([
|
||||
{
|
||||
label: '关于',
|
||||
@@ -110,21 +111,32 @@ function createTray () {
|
||||
tray.popUpContextMenu(contextMenu)
|
||||
})
|
||||
tray.on('click', () => {
|
||||
let img = clipboard.readImage()
|
||||
let obj = []
|
||||
if (!img.isEmpty()) {
|
||||
// 从剪贴板来的图片默认转为png
|
||||
const imgUrl = 'data:image/png;base64,' + Buffer.from(img.toPNG(), 'binary').toString('base64')
|
||||
obj.push({
|
||||
width: img.getSize().width,
|
||||
height: img.getSize().height,
|
||||
imgUrl
|
||||
})
|
||||
if (process.platform === 'darwin') {
|
||||
let img = clipboard.readImage()
|
||||
let obj = []
|
||||
if (!img.isEmpty()) {
|
||||
// 从剪贴板来的图片默认转为png
|
||||
const imgUrl = 'data:image/png;base64,' + Buffer.from(img.toPNG(), 'binary').toString('base64')
|
||||
obj.push({
|
||||
width: img.getSize().width,
|
||||
height: img.getSize().height,
|
||||
imgUrl
|
||||
})
|
||||
}
|
||||
toggleWindow()
|
||||
setTimeout(() => {
|
||||
window.webContents.send('clipboardFiles', obj)
|
||||
}, 0)
|
||||
} else {
|
||||
window.hide()
|
||||
if (settingWindow === null) {
|
||||
createSettingWindow()
|
||||
settingWindow.show()
|
||||
} else {
|
||||
settingWindow.show()
|
||||
settingWindow.focus()
|
||||
}
|
||||
}
|
||||
toggleWindow()
|
||||
setTimeout(() => {
|
||||
window.webContents.send('clipboardFiles', obj)
|
||||
}, 0)
|
||||
})
|
||||
|
||||
tray.on('drag-enter', () => {
|
||||
@@ -188,7 +200,7 @@ const createWindow = () => {
|
||||
}
|
||||
|
||||
const createSettingWindow = () => {
|
||||
settingWindow = new BrowserWindow({
|
||||
const options = {
|
||||
height: 450,
|
||||
width: 800,
|
||||
show: false,
|
||||
@@ -196,14 +208,20 @@ const createSettingWindow = () => {
|
||||
center: true,
|
||||
fullscreenable: false,
|
||||
resizable: false,
|
||||
title: 'Pic',
|
||||
title: 'PicGo',
|
||||
vibrancy: 'ultra-dark',
|
||||
transparent: true,
|
||||
titleBarStyle: 'hidden',
|
||||
webPreferences: {
|
||||
backgroundThrottling: false
|
||||
}
|
||||
})
|
||||
}
|
||||
if (process.platform === 'win32') {
|
||||
options.show = true
|
||||
options.frame = false
|
||||
options.backgroundColor = '#3f3c37'
|
||||
}
|
||||
settingWindow = new BrowserWindow(options)
|
||||
|
||||
settingWindow.loadURL(settingWinURL)
|
||||
|
||||
@@ -351,6 +369,11 @@ if (isSecondInstance) {
|
||||
app.quit()
|
||||
}
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
console.log(pkg.build.appId)
|
||||
app.setAppUserModelId(pkg.build.appId)
|
||||
}
|
||||
|
||||
app.on('ready', () => {
|
||||
createWindow()
|
||||
createTray()
|
||||
|
||||
@@ -2,8 +2,12 @@
|
||||
<div id="setting-page">
|
||||
<div class="fake-title-bar">
|
||||
PicGo - {{ version }}
|
||||
<div class="handle-bar" v-if="os === 'win32'">
|
||||
<i class="el-icon-minus" @click="minimizeWindow"></i>
|
||||
<i class="el-icon-close" @click="closeWindow"></i>
|
||||
</div>
|
||||
</div>
|
||||
<el-row style="padding-top: 22px;">
|
||||
<el-row style="padding-top: 22px;" class="main-content">
|
||||
<el-col :span="5">
|
||||
<el-menu
|
||||
class="picgo-sidebar"
|
||||
@@ -64,7 +68,8 @@
|
||||
<script>
|
||||
import pkg from '../../../package.json'
|
||||
import { remote } from 'electron'
|
||||
const { Menu, dialog } = remote
|
||||
import os from 'os'
|
||||
const { Menu, dialog, BrowserWindow } = remote
|
||||
export default {
|
||||
name: 'setting-page',
|
||||
data () {
|
||||
@@ -72,10 +77,12 @@ export default {
|
||||
version: pkg.version,
|
||||
defaultActive: 'upload',
|
||||
menu: null,
|
||||
visible: false
|
||||
visible: false,
|
||||
os: ''
|
||||
}
|
||||
},
|
||||
created () {
|
||||
this.os = os.platform()
|
||||
this.buildMenu()
|
||||
},
|
||||
methods: {
|
||||
@@ -84,6 +91,14 @@ export default {
|
||||
name: index
|
||||
})
|
||||
},
|
||||
minimizeWindow () {
|
||||
const window = BrowserWindow.getFocusedWindow()
|
||||
window.minimize()
|
||||
},
|
||||
closeWindow () {
|
||||
const window = BrowserWindow.getFocusedWindow()
|
||||
window.close()
|
||||
},
|
||||
buildMenu () {
|
||||
const _this = this
|
||||
const template = [
|
||||
@@ -128,6 +143,23 @@ export default {
|
||||
font-size 12px
|
||||
line-height h
|
||||
position fixed
|
||||
z-index 100
|
||||
.handle-bar
|
||||
position absolute
|
||||
top 2px
|
||||
right 4px
|
||||
width 40px
|
||||
z-index 10000
|
||||
-webkit-app-region no-drag
|
||||
i
|
||||
cursor pointer
|
||||
font-size 16px
|
||||
.el-icon-minus
|
||||
&:hover
|
||||
color #409EFF
|
||||
.el-icon-close
|
||||
&:hover
|
||||
color #F15140
|
||||
.picgo-sidebar
|
||||
height calc(100vh - 22px)
|
||||
.el-menu
|
||||
@@ -160,6 +192,12 @@ export default {
|
||||
right 0
|
||||
top 18px
|
||||
background active-color
|
||||
.main-content
|
||||
padding-top 22px
|
||||
position relative
|
||||
z-index 10
|
||||
.el-dialog__body
|
||||
padding 20px
|
||||
.support
|
||||
text-align center
|
||||
&-title
|
||||
|
||||
Reference in New Issue
Block a user