mirror of
https://github.com/leanote/desktop-app.git
synced 2026-01-13 07:03:04 +08:00
Electron windows下没有notification #18
This commit is contained in:
@@ -601,6 +601,15 @@ function log(o) {
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div><!-- /.modal -->
|
||||
|
||||
<!-- notification -->
|
||||
<div id="notify">
|
||||
<div class="alert alert-dismissible alert-warning" role="alert">
|
||||
<button type="button" class="close" ><span aria-hidden="true">×</span></button>
|
||||
<strong class="title">Warning!</strong>:
|
||||
<span class="body">Better check yourself, you're not looking too good.</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- modal 静态区域, 隐藏区域 -->
|
||||
<div class="display: hidden" id="hiddenZone">
|
||||
|
||||
@@ -123,13 +123,9 @@ function Menu() {
|
||||
|
||||
FileService.download(curPath, targetPath, function(ok, msg) {
|
||||
if(ok) {
|
||||
new window.Notification(getMsg('Info'), {
|
||||
body: getMsg('Image saved successful!'),
|
||||
});
|
||||
Notify.show({title: 'Info', body: 'Image saved successful!'});
|
||||
} else {
|
||||
new window.Notification(getMsg('Warning'), {
|
||||
body: getMsg(msg || 'Image saved failure!'),
|
||||
});
|
||||
Notify.show({type: 'warning', title: 'Warning', body: 'Image saved failed!'});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -138,13 +134,7 @@ function Menu() {
|
||||
});
|
||||
|
||||
} else {
|
||||
// alert会死?
|
||||
// alert('File not exists');
|
||||
// https://github.com/nwjs/nw.js/wiki/Notification
|
||||
var notification = new window.Notification('Warning', {
|
||||
body: getMsg('File not exists'),
|
||||
// icon: appIcon
|
||||
});
|
||||
Notify.show({type: 'warning', title: 'Warning', body: 'File not exists!'});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2364,17 +2364,9 @@ var Attach = {
|
||||
if(curAttach) {
|
||||
FileService.download(curAttach.Path, targetPath, function(ok, msg) {
|
||||
if(!ok) {
|
||||
// TODO 提示下载成功
|
||||
var notification = new window.Notification(getMsg('Warning'), {
|
||||
body: getMsg('File saved failure!'),
|
||||
// icon: appIcon
|
||||
});
|
||||
Notify.show({type: 'warning', title: 'Warning', body: 'File saved failed!'});
|
||||
} else {
|
||||
// TODO 提示下载成功
|
||||
var notification = new window.Notification(getMsg('Info'), {
|
||||
body: getMsg('File saved successful!'),
|
||||
// icon: appIcon
|
||||
});
|
||||
Notify.show({title: 'Info', body: 'File saved successful!'});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -2387,11 +2379,6 @@ var Attach = {
|
||||
|
||||
});
|
||||
|
||||
// 下载
|
||||
$('#downloadFileInput').change(function(e) {
|
||||
|
||||
});
|
||||
|
||||
// make link
|
||||
self.attachListO.on("click", ".link-attach", function(e) {
|
||||
e.stopPropagation();
|
||||
|
||||
@@ -1630,11 +1630,12 @@ var Pren = {
|
||||
|
||||
init: function() {
|
||||
var me = this;
|
||||
var isMac_ = isMac();
|
||||
// 初始化menu
|
||||
me.fullScreen = new gui.MenuItem(
|
||||
{
|
||||
label: getMsg('Toggle Fullscreen'),
|
||||
accelerator: 'command+=',
|
||||
accelerator: isMac_ ? 'command+=' : 'ctrl+=',
|
||||
click: function() {
|
||||
me.toggleFullscreen();
|
||||
}
|
||||
@@ -1642,7 +1643,7 @@ var Pren = {
|
||||
me.pren = new gui.MenuItem(
|
||||
{
|
||||
label: getMsg('Toggle Presentation'),
|
||||
accelerator: 'command+p',
|
||||
accelerator: isMac_ ? 'command+p' : 'ctrl+p',
|
||||
click: function() {
|
||||
me.togglePren();
|
||||
}
|
||||
@@ -1650,7 +1651,7 @@ var Pren = {
|
||||
me.view = new gui.MenuItem(
|
||||
{
|
||||
label: getMsg('Toggle View'),
|
||||
accelerator: 'command+e',
|
||||
accelerator: isMac_ ? 'command+e' : 'ctrl+e',
|
||||
click: function() {
|
||||
me.togglePren(true);
|
||||
}
|
||||
@@ -1944,6 +1945,7 @@ function userMenu() {
|
||||
this.menu.append(new gui.MenuItem({ type: 'separator' }));
|
||||
|
||||
this.menu.append(Pren.pren);
|
||||
this.menu.append(Pren.view);
|
||||
this.menu.append(Pren.fullScreen);
|
||||
|
||||
height = 270;
|
||||
|
||||
@@ -1472,7 +1472,7 @@ function switchAccount() {
|
||||
var win = new BrowserWindow({ width: 278, height: 316, show: true, frame: false, resizable: false });
|
||||
win.loadUrl('file://' + __dirname + '/login.html');
|
||||
} else {
|
||||
var win = new BrowserWindow({ width: 278, height: 516, show: true, frame: true, resizable: false });
|
||||
var win = new BrowserWindow({ width: 278, height: 416, show: true, frame: true, resizable: false });
|
||||
win.loadUrl('file://' + __dirname + '/login.html');
|
||||
}
|
||||
gui.getCurrentWindow().close();
|
||||
@@ -1567,6 +1567,74 @@ var Loading = {
|
||||
}
|
||||
};
|
||||
|
||||
// 通知
|
||||
var Notify = {
|
||||
$el : $('#notify'),
|
||||
interval: null,
|
||||
defaultTimeout: 3000,
|
||||
isMac: isMac(),
|
||||
init: function() {
|
||||
var me = this;
|
||||
|
||||
this.$alert = this.$el.find('.alert');
|
||||
this.$title = this.$el.find('.title');
|
||||
this.$body = this.$el.find('.body');
|
||||
|
||||
this.$el.click(function() {
|
||||
me.hide();
|
||||
});
|
||||
|
||||
this.$el.hover(function() {
|
||||
me.clearInterval();
|
||||
}, function() {
|
||||
me.startInterval(me.defaultTimeout);
|
||||
});
|
||||
},
|
||||
show: function(param) { // type, title, body, timeout) {
|
||||
var me = this;
|
||||
|
||||
var type = param.type || 'info';
|
||||
var title = param.title || 'Info';
|
||||
var body = param.body || '';
|
||||
var timeout = param.timeout || this.defaultTimeout;
|
||||
|
||||
// 不管哪个平台, 都使用自带的
|
||||
var useLocal = param.useLocal;
|
||||
|
||||
if(!useLocal && me.isMac) {
|
||||
new window.Notification(getMsg(title), {
|
||||
body: getMsg(body),
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if(!me.inited) {
|
||||
me.init();
|
||||
me.inited = true;
|
||||
}
|
||||
this.$alert.attr('class', 'alert alert-dismissible alert-' + (type || 'info'));
|
||||
this.$title.html(getMsg(title));
|
||||
this.$body.html(getMsg(body));
|
||||
|
||||
this.$alert.addClass('alert-show');
|
||||
this.startInterval(timeout);
|
||||
},
|
||||
startInterval: function(timeout) {
|
||||
var me = this;
|
||||
me.interval = setTimeout(function() {
|
||||
me.hide();
|
||||
}, timeout);
|
||||
},
|
||||
clearInterval: function() {
|
||||
clearInterval(this.interval);
|
||||
this.interval = null;
|
||||
},
|
||||
hide: function() {
|
||||
this.clearInterval();
|
||||
this.$alert.removeClass('alert-show');
|
||||
}
|
||||
};
|
||||
|
||||
var onClose = function(afterFunc) {
|
||||
try {
|
||||
// 先保存之前改变的
|
||||
|
||||
@@ -233,16 +233,16 @@
|
||||
"Setting": "设置",
|
||||
|
||||
"Insert link into content": "插件附件链接到笔记中",
|
||||
"Save as": "保存为",
|
||||
"Save as": "另存为",
|
||||
|
||||
"Search results": "搜索结果",
|
||||
|
||||
"Image saved successful!": "图片保存成功!",
|
||||
"Image saved failure!": "图片保存失败!",
|
||||
"File saved failure!": "文件保存失败!",
|
||||
"File saved successful!": "文件保存成功",
|
||||
"Image saved failed!": "图片保存失败!",
|
||||
"File saved failed!": "文件保存失败!",
|
||||
"File saved successful!": "文件保存成功!",
|
||||
|
||||
"File not exists": "文件不存在",
|
||||
"File not exists!": "文件不存在!",
|
||||
"Error": "错误",
|
||||
"Cut": "剪切",
|
||||
"Copy": "复制",
|
||||
|
||||
@@ -233,16 +233,16 @@
|
||||
"Setting": "設置",
|
||||
|
||||
"Insert link into content": "插件附件鏈接到筆記中",
|
||||
"Save as": "保存為",
|
||||
"Save as": "另存為",
|
||||
|
||||
"Search results": "搜索結果",
|
||||
|
||||
"Image saved successful!": "圖片保存成功!",
|
||||
"Image saved failure!": "圖片保存失敗!",
|
||||
"File saved failure!": "文件保存失敗!",
|
||||
"File saved successful!": "文件保存成功",
|
||||
"Image saved failed!": "圖片保存失敗!",
|
||||
"File saved failed!": "文件保存失敗!",
|
||||
"File saved successful!": "文件保存成功!",
|
||||
|
||||
"File not exists": "文件不存在",
|
||||
"File not exists!": "文件不存在!",
|
||||
"Error": "錯誤",
|
||||
"Cut": "剪切",
|
||||
"Copy": "復制",
|
||||
|
||||
1
src/public/min/config-min.js
vendored
Normal file
1
src/public/min/config-min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var Config={plugins:["theme","import_evernote","export_pdf","langs"],langs:[{filename:"en-us",name:"English"},{filename:"zh-cn",name:"简体中文"},{filename:"zh-hk",name:"繁体中文"}],lang:"zh-hk",theme:"pebbles"};
|
||||
@@ -67,13 +67,9 @@ define(function() {
|
||||
if(targetPath && me.downloadPdfPath) {
|
||||
Api.fileService.download(me.downloadPdfPath, targetPath, function(ok, msg) {
|
||||
if(ok) {
|
||||
new window.Notification(getMsg('Info'), {
|
||||
body: getMsg('plugin.export_pdf.exportSuccess')
|
||||
});
|
||||
Notify.show({title: 'Info', body: getMsg('plugin.export_pdf.exportSuccess')});
|
||||
} else {
|
||||
new window.Notification(getMsg('Warning'), {
|
||||
body: getMsg('plugin.export_pdf.exportFailure')
|
||||
});
|
||||
Notify.show({type: 'warning', title: 'Warning', body: getMsg('plugin.export_pdf.exportFailure')});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -85,13 +81,7 @@ define(function() {
|
||||
m = getMsg('plugin.export_pdf.notExists');
|
||||
}
|
||||
|
||||
// alert会死?
|
||||
// alert('File not exists');
|
||||
// https://github.com/nwjs/nw.js/wiki/Notification
|
||||
var notification = new window.Notification(getMsg('Warning'), {
|
||||
body: getMsg('plugin.export_pdf.exportFailure') + m
|
||||
// icon: appIcon
|
||||
});
|
||||
Notify.show({type: 'warning', title: 'Warning', body: getMsg('plugin.export_pdf.exportFailure') + m});
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
|
||||
@@ -1901,5 +1901,28 @@ img::selection {
|
||||
}
|
||||
}
|
||||
|
||||
// notify
|
||||
#notify {
|
||||
position: fixed;
|
||||
right: 0px;
|
||||
bottom: 0;
|
||||
z-index: 9999;
|
||||
height: 100px;
|
||||
cursor: pointer;
|
||||
.alert {
|
||||
box-shadow: 0 0 20px rgba(0,0,0,0.1);
|
||||
position: absolute;
|
||||
width: 250px;
|
||||
right: -250px;
|
||||
bottom: 0;
|
||||
opacity: 0;
|
||||
transition: opacity 0.5s, right 0.5s;
|
||||
}
|
||||
.alert.alert-show {
|
||||
opacity: 1;
|
||||
right: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
@import '../css/traffic.less';
|
||||
@import '../css/ani.less';
|
||||
|
||||
@@ -1675,6 +1675,27 @@ img::selection {
|
||||
#mdEditor.read-only .preview-container {
|
||||
left: 10px;
|
||||
}
|
||||
#notify {
|
||||
position: fixed;
|
||||
right: 0px;
|
||||
bottom: 0;
|
||||
z-index: 9999;
|
||||
height: 100px;
|
||||
cursor: pointer;
|
||||
}
|
||||
#notify .alert {
|
||||
box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
|
||||
position: absolute;
|
||||
width: 250px;
|
||||
right: -250px;
|
||||
bottom: 0;
|
||||
opacity: 0;
|
||||
transition: opacity 0.5s, right 0.5s;
|
||||
}
|
||||
#notify .alert.alert-show {
|
||||
opacity: 1;
|
||||
right: 5px;
|
||||
}
|
||||
.win-tool {
|
||||
padding: 5px;
|
||||
position: absolute;
|
||||
|
||||
Reference in New Issue
Block a user