Skip to content
This repository has been archived by the owner on Nov 30, 2020. It is now read-only.

Commit

Permalink
autoupdate
Browse files Browse the repository at this point in the history
  • Loading branch information
KinoriN committed Oct 14, 2019
1 parent d70e47a commit 3c06d56
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 13 deletions.
30 changes: 21 additions & 9 deletions electron/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,36 @@
import { app, BrowserWindow, ipcMain, nativeImage, Menu } from 'electron';
import { app, BrowserWindow, ipcMain, nativeImage, Menu, dialog } from 'electron';
import * as request from 'request';
import * as fs from 'fs';
import { join } from 'path';
import { autoUpdater } from 'electron-updater';
import { autoUpdater, AppUpdater } from 'electron-updater';
import { VtbInfoService, FollowListService } from './services';
import { FollowList, VtbInfo } from '../../interfaces';
import { PlayerObj } from '../../interfaces';
import { createMainWinMenu } from './mainWinMenu';
import { version } from 'punycode';
const tempPath = app.getPath('temp');

let playerObjMap = new Map<number, PlayerObj>();
let win: BrowserWindow = null;
let vtbInfosService: VtbInfoService;
const mainWindowInit = new Promise<BrowserWindow>((resolve) => {
app.on('ready', () => {
autoUpdater.setFeedURL('https://dd.center/api/update/ddmonitor/')
autoUpdater.setFeedURL('https://dd.center/api/update/ddmonitor/');
autoUpdater.autoDownload = true;
autoUpdater.checkForUpdates();
autoUpdater.on('update-downloaded', (info) => {
dialog.showMessageBox(win, <any>{
type: 'info',
title: '发现新版本:' + info.version,
message: '发现新版本:' + info.version,
detail: '更新内容:' + info.releaseNotes,
buttons: ['退出并更新', '暂不更新']
}).then(value => {
if (value.response == 0) {
autoUpdater.quitAndInstall();
}
})
})
resolve(createMainWindow());
});
});
Expand All @@ -29,21 +44,18 @@ const vtbInfosInit = new Promise<VtbInfoService>((resolve) => {
});
const createMainWindow = (): BrowserWindow => {
const win = new BrowserWindow({
width: 1200,
height: 800,
width: 1250,
height: 850,
maximizable: false,
fullscreen: false,
fullscreenable: false,
useContentSize: true,
resizable: false,
icon: 'public/icon.ico',
title: 'DD监控室',
webPreferences: {
nodeIntegration: true,
},
});
win.webContents.on('did-finish-load', () => {
win.setResizable(false);
})
// win.loadURL('http://localhost:4200');
// win.webContents.openDevTools();
win.loadURL(`file://${__dirname}/../../app/index.html`);
Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bili-dd-monitor",
"version": "0.0.7",
"version": "0.0.8",
"author": "kinori",
"scripts": {
"ng": "ng",
Expand All @@ -12,7 +12,7 @@
"lint": "ng lint",
"e2e": "ng e2e",
"electron-start": "npm run build && electron -p ./dist/electron/src/main.js",
"electron-start:dev": "npm run build:electron && electron -p ./dist/electron/src/main.js",
"electron-start:dev": "npm run build:electron && electron -p ./dist/electron/src/main.js --inspect=5858",
"dist": "electron-builder",
"release": "npm run build && npm run dist"
},
Expand Down Expand Up @@ -73,6 +73,10 @@
"directories": {
"output": "build"
},
"releaseInfo": {
"releaseName": "0.0.8",
"releaseNotes": "部署自动更新"
},
"win": {
"icon": "./public/icon256.ico"
},
Expand Down
3 changes: 3 additions & 0 deletions projects/app/src/app/app.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
background-color: white;
height: 800px;
}
.main{
height: 800px;
}
[nz-icon]{
font-size: 20px
}
4 changes: 2 additions & 2 deletions projects/app/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { NoticeService } from './services/notice.service';
styleUrls: ['./app.component.css']
})
export class AppComponent {
constructor(private noticeService:NoticeService){
constructor(private noticeService: NoticeService) {

}
}

0 comments on commit 3c06d56

Please sign in to comment.