Skip to content

Commit

Permalink
chore: 升级部分包
Browse files Browse the repository at this point in the history
  • Loading branch information
lumozx committed Dec 9, 2019
1 parent c7c1a91 commit b226a12
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 94 deletions.
4 changes: 3 additions & 1 deletion electron-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ const output = process.platform === 'darwin' ? `package-${process.env.CHANNEL}`

try {
rimraf.sync(output);
} catch (e) {}
} catch (e) {
console.log(e)
}

builder.build({
config: {
Expand Down
11 changes: 8 additions & 3 deletions fe/modules/index/Index.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div id="index">
<div class="drag-bar-mac" style="-webkit-app-region: drag;" @dblclick.stop="full($event)">
<div class="traffic-lights mac" style="-webkit-app-region: no-drag;">
<div class="traffic-lights mac">
<span class="close" @click="close">
<img src="../../assets/img/mac-traffic-light-close.svg" class="normal">
<img src="../../assets/img/mac-traffic-light-close-hover.svg" class="hover">
Expand All @@ -17,7 +17,7 @@
</div>
</div>
<div class="drag-bar-win" style="-webkit-app-region: drag;" @dblclick.stop="full($event)">
<div class="traffic-lights" style="-webkit-app-region: no-drag">
<div class="traffic-lights">
<span class="minimize" @click="minimize">
<img src="../../assets/img/win-minimize.svg">
</span>
Expand Down Expand Up @@ -828,7 +828,12 @@ body.win .welcome-page:before {
right: 0;
height: 10px;
}
.traffic-lights {
-webkit-app-region: no-drag;
}
.traffic-lights * {
-webkit-app-region: no-drag;
}
.traffic-lights.mac {
position: absolute;
left: 0;
Expand Down
2 changes: 1 addition & 1 deletion fe/modules/index/pub/Welcome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,4 @@ export default {
margin-left: 40px;
}
</style>
</style>
14 changes: 4 additions & 10 deletions fe/modules/preference/Preference.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const { testProxy } = electron.remote.require('./native/proxy')
async function getConfig() {
const proxyConfig = await mainDb.getProxyConfig()
const serverConfig = await mainDb.getServerConfig()
const cacheSize = await getCacheSize()
const cacheSize = await session.getCacheSize()
const downloadConfig = await mainDb.getDownloadConfig()
const hotkeyConfig = await mainDb.getHotKeyConfig()
const isAutoLaunch = autoLaunch.isEnabled()
Expand All @@ -48,13 +48,7 @@ async function getConfig() {
isAutoLaunch,
}
}
async function getCacheSize() {
return new Promise((resolve) => {
session.getCacheSize((size) => {
resolve(size)
})
})
}
export default {
name: "preference",
components: {
Expand Down Expand Up @@ -128,7 +122,7 @@ export default {
async onRestore() {
mainDb.restore()
autoLaunch.disable()
const config = await getConfig()
const config = await getConfig()
this.proxyConfig = config.proxyConfig
this.serverConfig = {
enablePrivate: config.serverConfig. enablePrivate,
Expand Down Expand Up @@ -271,4 +265,4 @@ ul {
color: #3B3B3B;
}
</style>
</style>
16 changes: 5 additions & 11 deletions fe/modules/preference/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,11 @@ webFrame.setZoomFactor(1)
webFrame.setVisualZoomLevelLimits(1, 1)
webFrame.setLayoutZoomLevelLimits(0, 0)

async function getCacheSize() {
return new Promise((resolve) => {
session.getCacheSize((size) => {
resolve(size)
})
})
}

async function getConfig() {
const proxyConfig = await mainDb.getProxyConfig()
const serverConfig = await mainDb.getServerConfig()
const cacheSize = await getCacheSize()
const cacheSize = await session.getCacheSize()
const downloadConfig = await mainDb.getDownloadConfig()
const hotkeyConfig = await mainDb.getHotKeyConfig()
const isAutoLaunch = autoLaunch.isEnabled()
Expand All @@ -37,11 +31,11 @@ async function getConfig() {
}
}
async function render () {
const res = await getConfig()
const res = await getConfig()
await store.commit('SAVR_CON',res)
new Vue({
store,
store,
render: h => h(Preference)
}).$mount('#preference')
}
render()
render()
2 changes: 1 addition & 1 deletion fe/modules/preference/pub/Server.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ export default {

<style scoped>
</style>
</style>
15 changes: 7 additions & 8 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const electron = require('electron');
const pkg = require('./package.json');
const Menu = require('./native/menu');
const Update = require('./native/update');
const path = require('path');
const download = require('./download');
const preference = require('./preference');
const mainDb = require('./native/mainDb');
Expand Down Expand Up @@ -70,8 +69,8 @@ class Main {
await this._createWindow();
download.initWindow();
preference.initWindow();
const u = new Update(this.mainWindow);
const m = new Menu(this.mainWindow);
new Update(this.mainWindow);
new Menu(this.mainWindow);
}

async _createWindow () {
Expand All @@ -94,8 +93,8 @@ class Main {
});
this.mainWindow.mainDb = mainDb;
const webContents = this.mainWindow.webContents;
const userAgent = webContents.getUserAgent() + ' rishiqing-pc/' + pkg.version;
webContents.setUserAgent(userAgent);
const userAgent = webContents.userAgent + ' rishiqing-pc/' + pkg.version;
webContents.userAgent = userAgent;
pkg.env === 'dev' ? this.mainWindow.loadURL(`http://localhost:8080/index`) : this.mainWindow.loadURL(`file://${__dirname}/dist/index/index.html`);
// 打开调试窗口
if (pkg.env === 'dev' || pkg.env === 'debug') {
Expand Down Expand Up @@ -138,7 +137,7 @@ class Main {
this.mainWindow.hide();
}
e.preventDefault();
}
}
}

_onNewWindow (event, url, frameName, disposition, options) {
Expand All @@ -150,7 +149,7 @@ class Main {
options.webPreferences = Object.assign({}, options.webPreferences, {
plugins: true,
webSecurity: false,
nodeIntegration: false,
nodeIntegration: true,
minimumFontSize: 12
});
}
Expand All @@ -161,4 +160,4 @@ class Main {
}
}

new Main();
new Main();
6 changes: 4 additions & 2 deletions native/mainDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ const { EventEmitter } = require('events');
const env = require('../common/env');

const ServerConfigOfficiel = {
dev: 'http://beta.rishiqing.com',
beta: 'https://beta.rishiqing.com',
debug: 'http://beta.rishiqing.com',
release: 'https://www.rishiqing.com'
};

Expand Down Expand Up @@ -122,7 +124,7 @@ class MainDb {
return Object.assign({}, Status, config);
}

updateWindowSize (data) { // { width, height }
updateWindowSize (data) { // { width, height }
this.db.update({ type: 'main-window-size' }, { $set: Object.assign({ version: VERSION.windowSize }, data) }, { upsert: true });
}

Expand Down Expand Up @@ -169,4 +171,4 @@ class MainDb {
}
}

module.exports = new MainDb();
module.exports = new MainDb();
5 changes: 3 additions & 2 deletions native/menu/icon.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const {
systemPreferences,
nativeImage,
nativeTheme
} = require('electron');
const { EventEmitter } = require('events');
const path = require('path');
Expand All @@ -27,7 +28,7 @@ class Icon {
getImage() {
let tray_icon;
if (env.isMac) {
if (systemPreferences.isDarkMode()) {
if (nativeTheme.shouldUseDarkColors) {
tray_icon = '../../res/tray_mac_drak_mode@2x.png';
} else {
tray_icon = '../../res/tray_mac@2x.png';
Expand All @@ -48,4 +49,4 @@ class Icon {
}
}

module.exports = new Icon();
module.exports = new Icon();
60 changes: 32 additions & 28 deletions native/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,35 +68,36 @@ class Util {
}
}

clearCache() {
dialog.showMessageBox({
async clearCache() {
const res = dialog.showMessageBox({
type: 'warning',
buttons: ['确定', '取消'],
defaultId: 0,
title: '确认清除缓存?',
message: '清除缓存可能导致您退出日事清账号,需要重启后生效'
}, function(response) {
if (response === 1) return;
if (response === 0) {
// 只清除cookies,会清除用户的登录状态
session.defaultSession.clearStorageData({
storages: ['cookies'] // 清理 cookie
})
// 清除网络缓存文件
session.defaultSession.clearCache(function() {
const notify = new Notification({
title: '缓存已清理',
body: '需要重启软件后生效'
});
notify.show();
})
}
})
if(res.response === 1) {
return
}
if(res.response === 0) {
// 只清除cookies,会清除用户的登录状态
session.defaultSession.clearStorageData({
storages: ['cookies'] // 清理 cookie
})
// 清除网络缓存文件
session.defaultSession.clearCache(function() {
const notify = new Notification({
title: '缓存已清理',
body: '需要重启软件后生效'
});
notify.show();
})
}
}

// 给定一个server链接,测试这个server是否可用
testServer(server) {
return new Promise(function(resolve, reject) {
return new Promise(function(resolve) {
const testUrl = url.resolve(server, '/task/login/authAjax');
const request = net.request(testUrl);
let isTimeout = false
Expand All @@ -113,7 +114,9 @@ class Util {
response.on('data', (chunk) => {
try{
data = JSON.parse(chunk.toString())
} catch(e) {}
} catch(e) {
console.log(e)
}
})
response.on('end', () => {
clearTimeout(timer)
Expand Down Expand Up @@ -142,20 +145,21 @@ class Util {
});
}

showNetworkErrorDialog(message) {
dialog.showMessageBox(this.mainWindow, {
async showNetworkErrorDialog(message) {
const res = await dialog.showMessageBox(this.mainWindow, {
type: 'error',
defaultId: 0,
cancelId: 1,
buttons: ['打开偏好设置', '取消'],
message: `${message}`
}, function(result) {
if (result === 1) return;
if (result === 0) {
preference.open()
}
})
if(res.response === 1) {
return
}
if(res.response === 0) {
preference.open()
}
}
}

module.exports = new Util();
module.exports = new Util();

0 comments on commit b226a12

Please sign in to comment.