Skip to content

Commit

Permalink
完成配置功能。
Browse files Browse the repository at this point in the history
  • Loading branch information
oott123 committed Sep 20, 2014
1 parent 489702c commit 10864ca
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
21 changes: 13 additions & 8 deletions browser/config/config.js
Expand Up @@ -14,7 +14,7 @@ var vm = new Vue({
type: 'checkbox',
key: 'hideOnClose',
title: '点击关闭按钮时隐藏主窗口',
value: true
value: false
},{
type: 'separator',
title: '右下角浮框设置'
Expand All @@ -32,20 +32,28 @@ var vm = new Vue({
key: 'auto',
title: '仅当主窗口隐藏时显示'
}],
value: 'auto'
value: ''
},{
type: 'text',
key: 'hideTimeout',
title: '浮窗显示时间(毫秒)',
value: '8000'
value: ''
}],
configNotChanged: true
},
methods: {
setValue: function(data){
for(var x in data){
this.$data.configItems[x].value = data[x];
for(var i =0; i < this.$data.configItems.length; i++){
var datum = this.$data.configItems[i];
if(datum.key){
if(data[datum.key]){
datum.value = data[datum.key];
}
}
}
vm.$watch('configItems', function(){
this.$data.configNotChanged = false;
});
},
closeWindow: function(){
ipc.send('close-config-window');
Expand All @@ -65,9 +73,6 @@ var vm = new Vue({
}
}
});
vm.$watch('configItems', function(){
this.$data.configNotChanged = false;
});
window.onbeforeunload = function(e){
if(!vm.$data.configNotChanged)
return confirm('配置已改动但尚未保存。\n是否放弃你的修改?');
Expand Down
14 changes: 12 additions & 2 deletions main.js
Expand Up @@ -36,11 +36,15 @@ app.on('ready', function() {
},
icon: icon
});
mainWindow.loadUrl('https://wx.qq.com');
mainWindow.loadUrl('https://wx.qq.com/?lang=zh_CN');
if(debug){
mainWindow.toggleDevTools(); //测试:打开调试窗口
}
mainWindow.on('close', function(event){
var canClose = !config.items.hideOnClose;
if(canClose){
return true;
}
if(mainWindow.isVisible()){
mainWindow.hide();
event.preventDefault();
Expand Down Expand Up @@ -82,6 +86,7 @@ app.on('ready', function() {
if(debug){
cfgWindow.openDevTools(); //测试:打开调试窗口
}
cfgWindow.webContents.executeJavaScript('vm.setValue('+ JSON.stringify(config.items) +')');
}
},{
label: '退出',
Expand Down Expand Up @@ -109,6 +114,11 @@ app.on('ready', function() {
if(arg.isSend || !arg.unread){
return;
}
//检查配置
var canShow = config.items.tipWinCondition == 'always' || (config.items.tipWinCondition == 'auto' && !mainWindow.isVisible());
if(!canShow){
return;
}
//检查是否已经有了消息接口
if(closeTimeoutID){
clearTimeout(closeTimeoutID);
Expand Down Expand Up @@ -145,7 +155,7 @@ app.on('ready', function() {
}
closeTimeoutID = setTimeout(function(){
msgWindow.close();
}, 8000);
}, config.items.hideTimeout);
});
ipc.on('message-close', function(event, remainMessages){
if(remainMessages == 0){
Expand Down

0 comments on commit 10864ca

Please sign in to comment.