1 Star 0 Fork 32

caiguocn / cnode-electron

forked from 塔塔兔子 / cnode-electron 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
SYS_Channel.js 2.05 KB
一键复制 编辑 原始数据 按行查看 历史
塔塔兔子 提交于 2016-04-26 15:44 . 提交cnode-electron
/**
* 渲染进程与主进程通信
*/
'use strict';
if (typeof require === 'function') {
const ipcRenderer = require('electron').ipcRenderer;
const notifier = require('node-notifier');
const fs = require('fs');
const nconf = require('nconf');
const path = require('path');
const authorfile = nconf.file({
file: __dirname + '/author.json'
});
const audio = new Audio('./sound/money.wav');
/**
* 读取登录信息
* @return {[type]} [description]
*/
window.getloginconfig = function() {
const config = JSON.parse(fs.readFileSync(__dirname + '/author.json', 'utf-8'));
return config;
}
/**
* 登录成功
* @param {[type]} data [description]
* @return {[type]} [description]
*/
window.sendloginsuccess = function(data) {
const authorinfo = data;
authorfile.set('islogin', true);
authorfile.set('user', {
accesstoken: authorinfo.accesstoken,
avatar_url: authorinfo.avatar_url,
loginname: authorinfo.loginname,
});
authorfile.save(function() {
})
}
/**
* 登出成功
* @param {[type]} data [description]
* @return {[type]} [description]
*/
window.logoutsuccess = function() {
authorfile.set('islogin', false);
authorfile.set('user', {
});
authorfile.save(function() {
})
}
/**
* 用户消息通知
* @return {[type]} [description]
*/
window.sendusermessage = function(data) {
audio.currentTime = 0;
audio.play();
const nc = new notifier.NotificationCenter();
nc.notify({
'title': 'cnod通知',
'subtitle': data.author.loginname + '回复:',
'message': data.reply.content,
'appIcon': data.author.avatar_url,
'open': 'https://cnodejs.org/topic/' + data.topic.id + '#' + data.reply.id,
});
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/busun/cnode-electron.git
git@gitee.com:busun/cnode-electron.git
busun
cnode-electron
cnode-electron
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891