Skip to content
This repository has been archived by the owner on Feb 11, 2023. It is now read-only.

Commit

Permalink
限制同一时刻只能存在一个应用实例
Browse files Browse the repository at this point in the history
  • Loading branch information
nashaofu committed May 31, 2017
1 parent 7ee4be5 commit 33db4e0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: node_js
node_js:
- "node"

dist: trusty
sudo: required

cache:
Expand All @@ -14,12 +15,15 @@ install:
script:
- npm run build

before_deploy:
- zip -o -r ./dingtalk-x86_64.zip ./dist/*

deploy:
provider: releases
api_key:
secure: "${token}"
file:
- "dist/dingtalk-0.0.1-x86_64.AppImage"
- "dingtalk-x86_64.zip"
skip_cleanup: true
on:
branches: master
Expand Down
12 changes: 12 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ class App {
initialize() {
// 应用准备完毕
this.app.on('ready', () => {
// 同时只能运行一个人实例
const shouldQuit = this.app.makeSingleInstance(() => {
if (this.$window) {
this.$window.show()
this.$window.focus()
}
return true
})
if (shouldQuit) {
this.app.quit()
return
}
this.createWindow()
this.createTray()
})
Expand Down

0 comments on commit 33db4e0

Please sign in to comment.