Skip to content

Commit

Permalink
feat(packup): 完善热更新提示,加入 icon
Browse files Browse the repository at this point in the history
  • Loading branch information
gmlayer0 authored and Thysrael committed Apr 25, 2023
1 parent 81ee7a5 commit 32177e3
Show file tree
Hide file tree
Showing 8 changed files with 541 additions and 21 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
dist
dist_electron
dist_electron
src/main/update
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.DS_Store
node_modules
/dist
dist_electronupdate.asar


# local env files
Expand Down
Binary file added build/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 18 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ficus",
"version": "0.1.0",
"version": "0.0.1",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
Expand All @@ -16,11 +16,11 @@
"build:tailwind": "tailwind build src/renderer/assets/index.css -o src/renderer/assets/tailwind.css"
},
"main": "background.js",
"dependencies": {
},
"dependencies": {},
"devDependencies": {
"@babel/core": "^7.12.16",
"@babel/eslint-parser": "^7.12.16",
"@popperjs/core": "^2.11.7",
"@tailwindcss/forms": "0.2.1",
"@tailwindcss/postcss7-compat": "^2.2.17",
"@typescript-eslint/eslint-plugin": "^5.57.1",
Expand All @@ -29,22 +29,32 @@
"@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-service": "~5.0.0",
"@vue/reactivity": "^3.2.47",
"electron-log": "^5.0.0-beta.23",
"@vueuse/core": "^10.1.0",
"adm-zip": "^0.5.10",
"assert": "^2.0.0",
"autoprefixer": "9",
"chai": "^4.3.7",
"commitizen": "^4.3.0",
"commitlint": "^17.5.1",
"core-js": "^3.8.3",
"cz-conventional-changelog": "^3.3.0",
"electron": "^13.0.0",
"electron-devtools-installer": "^3.1.0",
"electron-log": "^4.0.6",
"eslint": "^8.38.0",
"eslint-plugin-vue": "^8.0.3",
"ficus-editor": "^1.0.18",
"ficus-mindmap": "0.6.10",
"fs-extra": "^11.1.1",
"husky": "^8.0.3",
"js-yaml": "^4.1.0",
"mocha": "^10.2.0",
"mousetrap": "^1.6.5",
"nyc": "^15.1.0",
"os": "^0.1.2",
"path": "^0.12.7",
"postcss": "8.x",
"request-progress": "^3.0.0",
"standard": "^17.0.0",
"tailwindcss": "2.0.4",
"unplugin-auto-import": "^0.11.4",
Expand All @@ -57,16 +67,7 @@
"vue3-eventbus": "^2.0.0",
"vuedraggable": "^4.0.1",
"vuex": "^4.1.0",
"wdio-chromedriver-service": "^8.1.1",
"@popperjs/core": "^2.11.7",
"@vueuse/core": "^10.1.0",
"chai": "^4.3.7",
"core-js": "^3.8.3",
"fs-extra": "^11.1.1",
"js-yaml": "^4.1.0",
"mousetrap": "^1.6.5",
"os": "^0.1.2",
"path": "^0.12.7"
"wdio-chromedriver-service": "^8.1.1"
},
"postcss": {
"plugins": {
Expand Down Expand Up @@ -107,5 +108,8 @@
"standard-version": {
"changelogHeader": "# Changelog\n\n所有项目的变更记录会记录在如下文件.\n",
"dryRun": true
},
"win": {
"icon": "build/icon.png"
}
}
43 changes: 42 additions & 1 deletion src/background.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

import { app, BrowserWindow, ipcMain, protocol } from 'electron'
import { app, BrowserWindow, ipcMain, protocol, dialog } from 'electron'
import { createProtocol } from 'vue-cli-plugin-electron-builder/lib'
import installExtension, { VUEJS3_DEVTOOLS } from 'electron-devtools-installer'
import {
Expand All @@ -22,6 +22,7 @@ import {
refresh,
sendTags
} from '@/main/filesystem/database'
import EAU from './main/update'

import path from 'path'
import * as url from 'url'
Expand Down Expand Up @@ -90,7 +91,47 @@ app.on('ready', async () => {
} catch (e) {
console.error('Vue Devtools failed to install:', e.toString())
}
} else {
EAU.init({
api: 'https://ficus.world/update/version.json',
server: false,
formatRes: function (res) { return res }
})

EAU.check(function (error, last, body) {
if (error) {
if (error === 'no_update_available') { return false }
dialog.showErrorBox('info', error + last + body)
return false
}

EAU.progress(function (state) {
})

dialog.showMessageBoxSync(win, {
type: 'warning',
title: '更新提醒',
buttons: ['确定'],
message: '发现软件更新,软件需要自动重启',
defaultId: 0,
cancelId: 1
})

EAU.download(function (error) {
if (error) {
dialog.showErrorBox('info', error)
return false
}
if (process.platform === 'darwin') {
app.relaunch()
app.quit()
} else {
app.quit()
}
})
})
}

ipcMain.handle('exportPDF', async (event, html) => {
const printWin = new BrowserWindow({
show: false,
Expand Down
Loading

0 comments on commit 32177e3

Please sign in to comment.