Skip to content

Commit

Permalink
Merge pull request #14 from qishibo/dev
Browse files Browse the repository at this point in the history
Auto Updater
  • Loading branch information
qishibo authored Apr 26, 2019
2 parents 92532de + 4a57eca commit d809a89
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build/webpack.base.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = {
? config.build.assetsPublicPath
: config.dev.assetsPublicPath
},
target: 'node-webkit',
target: 'electron-renderer',
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
Expand Down
48 changes: 45 additions & 3 deletions pack/electron/electron-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function createWindow() {
mainWindow = new BrowserWindow({
width: 1100,
height: 728,
icon: 'icons/icon.png',
icon: `${__dirname}/icons/icon.png`,
autoHideMenuBar: true,
webPreferences: {
nodeIntegration: true,
Expand All @@ -21,9 +21,10 @@ function createWindow() {

// and load the index.html of the app.
if (APP_ENV === 'production') {
mainWindow.loadFile('index.html');
// mainWindow.loadFile('index.html');
mainWindow.loadURL(`file://${__dirname}/index.html?version=${app.getVersion()}`);
} else {
mainWindow.loadURL('http://localhost:9988/');
mainWindow.loadURL(`http://localhost:9988/?version=${app.getVersion()}`);
}

// Open the DevTools.
Expand All @@ -42,11 +43,52 @@ function createWindow() {
// contents.findInPage('133');
}

function checkUpdate() {
if (APP_ENV !== 'production') {
return true;
}

const { autoUpdater } = require("electron-updater");

// auto update
autoUpdater.on('checking-for-update', () => {
console.log('Checking for update...');
});

autoUpdater.on('update-available', (info) => {
console.log('Update available...', info);
});

autoUpdater.on('update-not-available', (info) => {
console.log('Update not available...', info);
});

autoUpdater.on('error', (err) => {
console.log('Error in auto-updater... Download manual, please... ' + err);
});

autoUpdater.on('download-progress', (progressObj) => {
let log_message = `Downloading...${progressObj.bytesPerSecond}, ${progressObj.percent}%, ${progressObj.transferred}/${progressObj.total}`;
console.log(log_message);
});

autoUpdater.on('update-downloaded', (info) => {
console.log('Update downloaded...');
// autoUpdater.quitAndInstall();
});

autoUpdater.checkForUpdates();
}


// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow);

// check update
app.on('ready', checkUpdate);

// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On macOS it is common for applications and their menu bar
Expand Down
13 changes: 11 additions & 2 deletions pack/electron/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
{
"name": "another-redis-manager",
"version": "1.1.4",
"version": "1.1.5",
"description": "A faster, better and more stable redis desktop manager.",
"author": "qii404.me",
"private": true,
"main": "electron-main.js",
"dependencies": {
"electron-updater": "^4.0.6"
},
"publish": [{
"provider": "github",
"owner": "qishibo",
"repo": "AnotherRedisDesktopManager"
}],
"repository": "github:qishibo/AnotherRedisDesktopManager",
"build": {
"appId" : "me.qii404.another-redis-desktop-manager",
"appId": "me.qii404.another-redis-desktop-manager",
"productName": "Another.Redis.Dsektop.Manager",
"artifactName": "${productName}.${version}.${ext}",
"copyright": "Copyright © 2019 qii404.me",
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"lint:init": "eslint --init",
"asar": "node_modules/.bin/asar pack dist dist/app.asar --unpack-dir \"{app.asar,build-apps,app.asar.unpacked}\"",
"pack:prepare": "npm run build; cp -r pack/electron/* dist; sed -i \"s/const APP_ENV = 'dev'/const APP_ENV = 'production'/g\" dist/electron-main.js;",
"pack:linux": "node_modules/.bin/electron-builder --project=dist -l",
"pack:win": "docker run --rm -it --env ELECTRON_CACHE=\"/root/.cache/electron\" --env ELECTRON_BUILDER_CACHE=\"/root/.cache/electron-builder\" -v ${PWD}:/project -v ~/.cache/electron:/root/.cache/electron -v ~/.cache/electron-builder:/root/.cache/electron-builder electronuserland/builder:wine sh -c \"node_modules/.bin/electron-builder --project=dist -w\"",
"pack:mac": "node_modules/.bin/electron-builder --project=dist -m"
"pack:linux": "node_modules/.bin/electron-builder --project=dist -l -p never",
"pack:win": "docker run --rm -it --env GH_TOKEN=$GH_TOKEN --env ELECTRON_CACHE=\"/root/.cache/electron\" --env ELECTRON_BUILDER_CACHE=\"/root/.cache/electron-builder\" -v ${PWD}:/project -v ~/.cache/electron:/root/.cache/electron -v ~/.cache/electron-builder:/root/.cache/electron-builder electronuserland/builder:wine sh -c \"node_modules/.bin/electron-builder --project=dist -w -p never\"",
"pack:mac": "node_modules/.bin/electron-builder --project=dist -m -p never"
},
"dependencies": {
"axios": "^0.18.0",
Expand Down
1 change: 1 addition & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ body {
padding: 8px;
margin: 0;
box-sizing: border-box;
/*font: caption;*/
}
.wrap-container {
height: 100%;
Expand Down
7 changes: 7 additions & 0 deletions src/components/Setting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
<el-button icon="el-icon-download" @click="showImportDialog">{{ $t('message.import') }}</el-button>
</el-form-item>

<el-form-item :label="$t('message.pre_version')">
<el-tag type="info">{{ appVersion }}</el-tag>
<small><a style="color: grey" href="https://github.com/qishibo/AnotherRedisDesktopManager/releases" target="blank">{{ $t('message.manual_update') }}</a></small>
</el-form-item>

<el-dialog
width="400px"
:title="$t('message.select_import_file')"
Expand Down Expand Up @@ -49,6 +54,8 @@ export default {
form: {},
importConnectionVisible: false,
connectionFileContent: '',
appVersion: (new URL(window.location.href)).searchParams.get('version'),
electronVersion: process.versions.electron,
};
},
props: ['settingDialog'],
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/langs/cn.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ const cn = {
open_new_tab: '新窗口打开',
exact_search: '精确搜索',
enter_to_exec: '输入Redis命令后,按Enter键执行',
pre_version: '当前版本',
manual_update: '手动更新',
},
};

Expand Down
2 changes: 2 additions & 0 deletions src/i18n/langs/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ const en = {
open_new_tab: 'Open In New Tab',
exact_search: 'Exact Search',
enter_to_exec: 'Press Enter To Execute Redis Commands',
pre_version: 'Version',
manual_update: 'Manual Update',
},
};

Expand Down

0 comments on commit d809a89

Please sign in to comment.