Added: windows support

This commit is contained in:
Molunerfinn 2018-01-10 16:51:09 +08:00
parent 783adada58
commit b4c760c8cd
10 changed files with 108 additions and 28 deletions

1
.gitignore vendored
View File

@ -3,6 +3,7 @@ dist/electron/*
dist/web/* dist/web/*
build/* build/*
!build/icons !build/icons
!build/installer.nsh
coverage coverage
node_modules/ node_modules/
npm-debug.log npm-debug.log

1
.npmrc Normal file
View File

@ -0,0 +1 @@
electron_mirror="https://npm.taobao.org/mirrors/electron/"

View File

@ -24,7 +24,7 @@
PicGo目前支持了`微博图床``七牛图床``腾讯云COS``又拍云`。未来将支持更多图床。 PicGo目前支持了`微博图床``七牛图床``腾讯云COS``又拍云`。未来将支持更多图床。
暂时只支持macOS系统未来将支持windows和linux。 支持macOS、windows 64位v1.3.0以上)系统未来将支持linux。
点击此处下载[应用](https://github.com/Molunerfinn/PicGo/releases)macOS用户请下载最新版本的`dmg`文件。 点击此处下载[应用](https://github.com/Molunerfinn/PicGo/releases)macOS用户请下载最新版本的`dmg`文件。
@ -36,13 +36,14 @@ PicGo目前支持了`微博图床``七牛图床``腾讯云COS``又拍
## 开发说明 ## 开发说明
> 目前仅针对Mac平台。Windows和Linux平台并未测试。 > 目前仅针对Mac、Windows。Linux平台并未测试。
如果你想要学习、开发、修改或自行构建PicGo可以依照下面的指示 如果你想要学习、开发、修改或自行构建PicGo可以依照下面的指示
1. 你需要有node、git环境。需要了解npm的相关知识。 1. 你需要有node、git环境。需要了解npm的相关知识。
2. `git clone https://github.com/Molunerfinn/PicGo.git` 并进入项目 2. `git clone https://github.com/Molunerfinn/PicGo.git` 并进入项目
3. `npm install` 下载依赖 3. `npm install` 下载依赖
4. Mac需要有Xcode环境Windows需要有VS环境。
### 开发模式 ### 开发模式

View File

@ -28,6 +28,6 @@ install:
build_script: build_script:
#- yarn test #- yarn test
- yarn build - npm run release
test: off test: off

8
build/installer.nsh Normal file
View File

@ -0,0 +1,8 @@
!macro preInit
SetRegView 64
WriteRegExpandStr HKLM "${INSTALL_REGISTRY_KEY}" InstallLocation "C:\PicGo"
WriteRegExpandStr HKCU "${INSTALL_REGISTRY_KEY}" InstallLocation "C:\PicGo"
SetRegView 32
WriteRegExpandStr HKLM "${INSTALL_REGISTRY_KEY}" InstallLocation "C:\PicGo"
WriteRegExpandStr HKCU "${INSTALL_REGISTRY_KEY}" InstallLocation "C:\PicGo"
!macroend

View File

@ -6,6 +6,7 @@
h1.title PicGo h1.title PicGo
h2.desc 图片上传+管理新体验 h2.desc 图片上传+管理新体验
button.download(@click="goLink('https://github.com/Molunerfinn/picgo/releases')") 免费下载Mac版 button.download(@click="goLink('https://github.com/Molunerfinn/picgo/releases')") 免费下载Mac版
button.download(@click="goLink('https://github.com/Molunerfinn/picgo/releases')") 免费下载Windows版
button.download(@click="goLink('https://github.com/Molunerfinn/picgo')") 在github上查看 button.download(@click="goLink('https://github.com/Molunerfinn/picgo')") 在github上查看
h3.desc h3.desc
| 基于#[a(href="https://github.com/SimulatedGREG/electron-vue" target="_blank") electron-vue]开发 | 基于#[a(href="https://github.com/SimulatedGREG/electron-vue" target="_blank") electron-vue]开发
@ -32,7 +33,7 @@ export default {
{ {
url: 'https://ws1.sinaimg.cn/large/8700af19ly1fma907llb5j20m30ed46a', url: 'https://ws1.sinaimg.cn/large/8700af19ly1fma907llb5j20m30ed46a',
title: '精致设计', title: '精致设计',
desc: 'macOS系统下支持拖拽至menubar图标实现上传。menubar app 窗口显示最新上传的5张图片以及剪贴板里的图片。点击图片自动将上传的链接复制到剪贴板。' desc: 'macOS系统下支持拖拽至menubar图标实现上传。menubar app 窗口显示最新上传的5张图片以及剪贴板里的图片。点击图片自动将上传的链接复制到剪贴板。Windows平台不支持'
}, },
{ {
url: 'https://ws1.sinaimg.cn/large/8700af19ly1fmd56zm2nej218g0p0teb', url: 'https://ws1.sinaimg.cn/large/8700af19ly1fmd56zm2nej218g0p0teb',
@ -42,7 +43,7 @@ export default {
{ {
url: 'https://ws1.sinaimg.cn/large/8700af19ly1fmd5ck9m0wj20lr0cxmzs', url: 'https://ws1.sinaimg.cn/large/8700af19ly1fmd5ck9m0wj20lr0cxmzs',
title: '可选图床', title: '可选图床',
desc: '目前支持微博图床和七牛图床。未来将支持更多。方便不同图床的上传需求。' desc: '目前支持微博图床、七牛图床、腾讯云COS、又拍云。未来将支持更多。方便不同图床的上传需求。'
}, },
{ {
url: 'https://ws1.sinaimg.cn/large/8700af19gy1fmayjwttnbj218g0p0q4e', url: 'https://ws1.sinaimg.cn/large/8700af19gy1fmayjwttnbj218g0p0q4e',
@ -172,6 +173,8 @@ h1
text-decoration none text-decoration none
color #fff color #fff
@media (max-width: 768px) @media (max-width: 768px)
#header
padding 10vh
#container #container
.display-list .display-list
&__item &__item

View File

@ -29,7 +29,7 @@
}, },
"build": { "build": {
"productName": "PicGo", "productName": "PicGo",
"appId": "org.simulatedgreg.electron-vue", "appId": "com.molunerfinn.picgo",
"directories": { "directories": {
"output": "build" "output": "build"
}, },
@ -58,7 +58,12 @@
} }
}, },
"win": { "win": {
"icon": "build/icons/icon.ico" "icon": "build/icons/icon.ico",
"target": "nsis"
},
"nsis": {
"oneClick": false,
"allowToChangeInstallationDirectory": true
}, },
"linux": { "linux": {
"icon": "build/icons" "icon": "build/icons"

View File

@ -34,7 +34,8 @@ const uploadFailed = () => {
} }
function createTray () { 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([ const contextMenu = Menu.buildFromTemplate([
{ {
label: '关于', label: '关于',
@ -110,6 +111,7 @@ function createTray () {
tray.popUpContextMenu(contextMenu) tray.popUpContextMenu(contextMenu)
}) })
tray.on('click', () => { tray.on('click', () => {
if (process.platform === 'darwin') {
let img = clipboard.readImage() let img = clipboard.readImage()
let obj = [] let obj = []
if (!img.isEmpty()) { if (!img.isEmpty()) {
@ -125,6 +127,16 @@ function createTray () {
setTimeout(() => { setTimeout(() => {
window.webContents.send('clipboardFiles', obj) window.webContents.send('clipboardFiles', obj)
}, 0) }, 0)
} else {
window.hide()
if (settingWindow === null) {
createSettingWindow()
settingWindow.show()
} else {
settingWindow.show()
settingWindow.focus()
}
}
}) })
tray.on('drag-enter', () => { tray.on('drag-enter', () => {
@ -188,7 +200,7 @@ const createWindow = () => {
} }
const createSettingWindow = () => { const createSettingWindow = () => {
settingWindow = new BrowserWindow({ const options = {
height: 450, height: 450,
width: 800, width: 800,
show: false, show: false,
@ -196,14 +208,20 @@ const createSettingWindow = () => {
center: true, center: true,
fullscreenable: false, fullscreenable: false,
resizable: false, resizable: false,
title: 'Pic', title: 'PicGo',
vibrancy: 'ultra-dark', vibrancy: 'ultra-dark',
transparent: true, transparent: true,
titleBarStyle: 'hidden', titleBarStyle: 'hidden',
webPreferences: { webPreferences: {
backgroundThrottling: false backgroundThrottling: false
} }
}) }
if (process.platform === 'win32') {
options.show = true
options.frame = false
options.backgroundColor = '#3f3c37'
}
settingWindow = new BrowserWindow(options)
settingWindow.loadURL(settingWinURL) settingWindow.loadURL(settingWinURL)
@ -351,6 +369,11 @@ if (isSecondInstance) {
app.quit() app.quit()
} }
if (process.platform === 'win32') {
console.log(pkg.build.appId)
app.setAppUserModelId(pkg.build.appId)
}
app.on('ready', () => { app.on('ready', () => {
createWindow() createWindow()
createTray() createTray()

View File

@ -2,8 +2,12 @@
<div id="setting-page"> <div id="setting-page">
<div class="fake-title-bar"> <div class="fake-title-bar">
PicGo - {{ version }} 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;"> </div>
<el-row style="padding-top: 22px;" class="main-content">
<el-col :span="5"> <el-col :span="5">
<el-menu <el-menu
class="picgo-sidebar" class="picgo-sidebar"
@ -64,7 +68,8 @@
<script> <script>
import pkg from '../../../package.json' import pkg from '../../../package.json'
import { remote } from 'electron' import { remote } from 'electron'
const { Menu, dialog } = remote import os from 'os'
const { Menu, dialog, BrowserWindow } = remote
export default { export default {
name: 'setting-page', name: 'setting-page',
data () { data () {
@ -72,10 +77,12 @@ export default {
version: pkg.version, version: pkg.version,
defaultActive: 'upload', defaultActive: 'upload',
menu: null, menu: null,
visible: false visible: false,
os: ''
} }
}, },
created () { created () {
this.os = os.platform()
this.buildMenu() this.buildMenu()
}, },
methods: { methods: {
@ -84,6 +91,14 @@ export default {
name: index name: index
}) })
}, },
minimizeWindow () {
const window = BrowserWindow.getFocusedWindow()
window.minimize()
},
closeWindow () {
const window = BrowserWindow.getFocusedWindow()
window.close()
},
buildMenu () { buildMenu () {
const _this = this const _this = this
const template = [ const template = [
@ -128,6 +143,23 @@ export default {
font-size 12px font-size 12px
line-height h line-height h
position fixed 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 .picgo-sidebar
height calc(100vh - 22px) height calc(100vh - 22px)
.el-menu .el-menu
@ -160,6 +192,12 @@ export default {
right 0 right 0
top 18px top 18px
background active-color background active-color
.main-content
padding-top 22px
position relative
z-index 10
.el-dialog__body
padding 20px
.support .support
text-align center text-align center
&-title &-title

BIN
static/menubar-nodarwin.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 744 B