mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-14 23:22:40 +00:00
custom server
This commit is contained in:
45
login.html
45
login.html
@@ -6,9 +6,9 @@
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="keywords" content="leanote,leanote.com">
|
||||
<meta name="description" content="leanote, 不只是笔记!">
|
||||
<meta name="description" content="leanote, Not Just A Notebook!">
|
||||
<meta name="author" content="leanote">
|
||||
<title>登录</title>
|
||||
<title>Leanote login</title>
|
||||
<link href="public/css/bootstrap.css" rel="stylesheet">
|
||||
<link href="public/css/font-awesome-4.2.0/css/font-awesome.css" rel="stylesheet">
|
||||
<link href="public/css/index.css" rel="stylesheet">
|
||||
@@ -25,6 +25,7 @@ if(process.platform != 'darwin') {
|
||||
<div id="winTool" class="win-tool clearfix">
|
||||
<a class="tool-close-blur"></a>
|
||||
</div>
|
||||
<div class="server"><a id="customServer">Custom server</a></div>
|
||||
<section id="box" class="animated fadeInUp">
|
||||
<div class="drag"></div>
|
||||
<div>
|
||||
@@ -38,9 +39,14 @@ if(process.platform != 'darwin') {
|
||||
<div class="alert alert-danger" id="loginMsg"></div>
|
||||
|
||||
<div id="formContainer">
|
||||
<div class="form-group form-group-1 hide" id="hostGroup">
|
||||
<input type="text" placeholder="Host, http://leanote.com" class="form-control" id="host" name="host">
|
||||
</div>
|
||||
|
||||
<div class="form-group form-group-1">
|
||||
<input type="text" placeholder="Email" class="form-control" id="email" name="email" value="">
|
||||
</div>
|
||||
|
||||
<div class="form-group pwd-group">
|
||||
<input type="password" placeholder="Password" class="form-control" id="pwd" name="pwd">
|
||||
<button id="loginBtn" disabled><i class="fa fa-arrow-right"></i></button>
|
||||
@@ -71,7 +77,15 @@ win.setAlwaysOnTop(true);
|
||||
// gui.Window.focus();
|
||||
|
||||
$(function() {
|
||||
var $hostGroup = $('#hostGroup');
|
||||
var hasHost = false;
|
||||
|
||||
function isValidUrl(url) {
|
||||
return /http(s*):\/\/.+/.test(url);
|
||||
}
|
||||
|
||||
$("#email").focus();
|
||||
|
||||
if($("#email").val()) {
|
||||
$("#pwd").focus();
|
||||
}
|
||||
@@ -88,7 +102,8 @@ $(function() {
|
||||
e.preventDefault();
|
||||
var email = $("#email").val();
|
||||
var pwd = $("#pwd").val();
|
||||
var captcha = $("#captcha").val()
|
||||
var host = $('#host').val();
|
||||
|
||||
if(!email) {
|
||||
showMsg("Email is required", "email");
|
||||
return;
|
||||
@@ -102,11 +117,19 @@ $(function() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(hasHost && (!host || !isValidUrl(host))) {
|
||||
showMsg('Invalid host', 'host');
|
||||
return;
|
||||
}
|
||||
$('#loadingLogo').addClass('loading');
|
||||
hideMsg();
|
||||
// TODO show loading
|
||||
// console.log(33);
|
||||
// $("#loginBtn").html("loading...").addClass("disabled");
|
||||
ApiService.auth(email, pwd, function(ret) {
|
||||
if(!hasHost) {
|
||||
host = '';
|
||||
}
|
||||
ApiService.auth(email, pwd, host, function(ret) {
|
||||
$('#loadingLogo').removeClass('loading');
|
||||
// $("#loginBtn").html("Sign in").removeClass("disabled");
|
||||
if(ret.Ok) {
|
||||
@@ -142,10 +165,20 @@ $(function() {
|
||||
checkDisabled();
|
||||
});
|
||||
});
|
||||
|
||||
$('#customServer').click(function() {
|
||||
if($hostGroup.hasClass('hide')) {
|
||||
$hostGroup.removeClass('hide');
|
||||
hasHost = true;
|
||||
} else {
|
||||
$hostGroup.addClass('hide');
|
||||
hasHost = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
win.resizeTo(258, 326);
|
||||
win.setPosition('center');
|
||||
// win.resizeTo(268, 356);
|
||||
// win.setPosition('center');
|
||||
|
||||
// $('body').on('keydown', function(e) {
|
||||
// commonCmd(e);
|
||||
|
9
node_modules/api.js
generated
vendored
9
node_modules/api.js
generated
vendored
@@ -51,8 +51,9 @@ var Api = {
|
||||
// 是否断网
|
||||
unConnected: function(error) {
|
||||
var me = this;
|
||||
// console.log(error);
|
||||
if(error && (error.code == "ECONNREFUSED" || error.code == 'ECONNRESET')) { // socket hand up
|
||||
console.error('---------------------')
|
||||
console.error(error);
|
||||
Web.unConnected();
|
||||
return true;
|
||||
}
|
||||
@@ -79,9 +80,12 @@ var Api = {
|
||||
return url;
|
||||
},
|
||||
// 登录
|
||||
auth: function(email, pwd, callback) {
|
||||
auth: function(email, pwd, host, callback) {
|
||||
var me = this;
|
||||
|
||||
// 设置server host
|
||||
Evt.setHost(host);
|
||||
|
||||
// log({emai: email, pwd: pwd});
|
||||
console.log(this.getUrl('auth/login', {email: email, pwd: pwd}));
|
||||
// console.log('????????????')
|
||||
@@ -97,6 +101,7 @@ var Api = {
|
||||
// console.log(ret);
|
||||
if(Common.isOk(ret)) {
|
||||
ret.Pwd = pwd;
|
||||
ret['Host'] = Evt.leanoteUrl;
|
||||
User.setCurUser(ret);
|
||||
callback && callback(ret);
|
||||
} else {
|
||||
|
19
node_modules/evt.js
generated
vendored
19
node_modules/evt.js
generated
vendored
@@ -16,12 +16,27 @@ if(!fs.existsSync(dataBasePath)) {
|
||||
// dataBasePath = '';
|
||||
|
||||
var Evt = {
|
||||
// leanoteUrl: 'http://leanote.com',
|
||||
leanoteUrl: 'http://localhost:9000',
|
||||
defaultUrl: 'http://leanote.com',
|
||||
|
||||
leanoteUrl: 'http://leanote.com',
|
||||
// leanoteUrl: 'http://localhost:9000',
|
||||
|
||||
setHost: function(host) {
|
||||
if(!host) {
|
||||
this.leanoteUrl = this.defaultUrl;
|
||||
} else {
|
||||
this.leanoteUrl = host;
|
||||
}
|
||||
},
|
||||
|
||||
getHost: function() {
|
||||
return this.leanoteUrl;
|
||||
},
|
||||
|
||||
port: 8008,
|
||||
localUrl: 'http://127.0.0.1:8008',
|
||||
dataBasePath: '',
|
||||
|
||||
getImageLocalUrl: function(fileId) {
|
||||
return this.localUrl + '/api/file/getImage?fileId=' + fileId;
|
||||
},
|
||||
|
6
node_modules/user.js
generated
vendored
6
node_modules/user.js
generated
vendored
@@ -23,6 +23,7 @@ User = {
|
||||
userId: '',
|
||||
email: '',
|
||||
username: '',
|
||||
host: '', // 服务
|
||||
LastSyncUsn: -1,
|
||||
LastSyncTime: null,
|
||||
// 登录后保存当前
|
||||
@@ -33,6 +34,7 @@ User = {
|
||||
this.userId = user.UserId;
|
||||
this.email = user.Email;
|
||||
this.username = user.Username;
|
||||
this.host = user.Host; // http://leanote.com, http://localhost
|
||||
// 保存到数据库中
|
||||
this.saveCurUser(user);
|
||||
|
||||
@@ -40,6 +42,7 @@ User = {
|
||||
me.setUserDataPath();
|
||||
}
|
||||
},
|
||||
// 不同host的userId可能一样, 潜在的bug
|
||||
saveCurUser: function(user, callback) {
|
||||
// 当前用户是否在数据库中
|
||||
db.users.count({_id: user.UserId}, function(err, count) {
|
||||
@@ -101,6 +104,9 @@ User = {
|
||||
me.username = user.Username;
|
||||
me.LastSyncUsn = user.LastSyncUsn;
|
||||
me.LastSyncTime = user.LastSyncTime;
|
||||
me.host = user.Host;
|
||||
|
||||
Evt.setHost(me.host);
|
||||
|
||||
// 全局配置也在user中, 到web端
|
||||
for(var i in me.g) {
|
||||
|
@@ -23,14 +23,16 @@
|
||||
<link rel="stylesheet" href="public/css/theme/presentation.css" type="text/css" disabled id="themePresentation"/>
|
||||
<link rel="stylesheet" href="public/css/theme/writting.css" type="text/css" disabled id="themeWritting"/>
|
||||
|
||||
<!-- mdeditor -->
|
||||
<link href="public/dist/themes/default.css" rel="stylesheet" />
|
||||
|
||||
<script>
|
||||
// for windows
|
||||
if(process.platform != 'darwin') {
|
||||
document.write('<link rel="stylesheet" href="public/css/theme/windows.css" type="text/css" />');
|
||||
}
|
||||
</script>
|
||||
<!-- mdeditor -->
|
||||
<link href="public/dist/themes/default.css" rel="stylesheet" />
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
|
11
package.json
11
package.json
@@ -10,12 +10,15 @@
|
||||
"frame": true,
|
||||
"transparent": false,
|
||||
|
||||
"min_width": 258,
|
||||
"min_height": 326,
|
||||
"min_width": 268,
|
||||
"min_height": 346,
|
||||
// "width": 400, // 1100,
|
||||
// "height": 300 // 600
|
||||
"width": 258,
|
||||
"height": 326
|
||||
"width": 278,
|
||||
"height": 356
|
||||
|
||||
// width: 268px;
|
||||
// height: 346px;
|
||||
},
|
||||
"chromium-args": "--enable-smooth-scrolling"
|
||||
}
|
||||
|
@@ -326,7 +326,7 @@ input,
|
||||
#box {
|
||||
margin: 0;
|
||||
color: #000;
|
||||
padding-top: 40px;
|
||||
padding-top: 30px;
|
||||
}
|
||||
#box h1 {
|
||||
margin: auto;
|
||||
@@ -718,8 +718,8 @@ body {
|
||||
body #container {
|
||||
position: relative;
|
||||
margin: 5px auto;
|
||||
width: 248px;
|
||||
height: 316px;
|
||||
width: 268px;
|
||||
height: 346px;
|
||||
background-color: rgba(247, 249, 250, 0.99);
|
||||
border-radius: 5px;
|
||||
border: 1px solid #eee;
|
||||
@@ -762,6 +762,24 @@ btns {
|
||||
#loginBtn[disabled] .fa {
|
||||
color: #ccc;
|
||||
}
|
||||
form {
|
||||
position: relative;
|
||||
}
|
||||
#loginMsg {
|
||||
position: absolute;
|
||||
top: -30px;
|
||||
}
|
||||
.server {
|
||||
position: absolute;
|
||||
bottom: 5px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
text-align: center;
|
||||
}
|
||||
.server a {
|
||||
color: #666;
|
||||
font-size: 85%;
|
||||
}
|
||||
.win-tool {
|
||||
padding: 5px;
|
||||
position: absolute;
|
||||
|
@@ -336,7 +336,7 @@ input, .form-control {
|
||||
#box {
|
||||
margin: 0;
|
||||
color: #000;
|
||||
padding-top: 40px;
|
||||
padding-top: 30px;
|
||||
h1 {
|
||||
width: @boxWidth;;
|
||||
margin: auto;
|
||||
@@ -346,8 +346,6 @@ input, .form-control {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#boxHeader {
|
||||
border-color: #e8e8e8;
|
||||
color: #333;
|
||||
@@ -791,8 +789,8 @@ body {
|
||||
// bottom: 5px;
|
||||
// padding: 5px;
|
||||
// padding-top: 0;
|
||||
width: 248px;
|
||||
height: 316px;
|
||||
width: 268px;
|
||||
height: 346px;
|
||||
background-color: rgba(247,249,250,0.99);
|
||||
border-radius: 5px;
|
||||
border: 1px solid #eee;
|
||||
@@ -843,6 +841,26 @@ body {
|
||||
}
|
||||
}
|
||||
|
||||
form {
|
||||
position: relative;
|
||||
}
|
||||
#loginMsg {
|
||||
position: absolute;
|
||||
top: -30px;
|
||||
}
|
||||
|
||||
.server {
|
||||
position: absolute;
|
||||
bottom: 5px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
text-align: center;
|
||||
a {
|
||||
color: #666;
|
||||
font-size: 85%;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@import "traffic.less";
|
||||
|
||||
|
@@ -1219,7 +1219,7 @@ top: 4px;
|
||||
#editorContent {
|
||||
// border: 1px solid #ccc;
|
||||
// border-radius: 5px;
|
||||
padding: 5px;
|
||||
padding: 5px 10px;
|
||||
outline: none;
|
||||
margin-top: 5px;
|
||||
bottom: 5px !important;
|
||||
@@ -1744,5 +1744,10 @@ body {
|
||||
}
|
||||
//--------- end
|
||||
|
||||
// 没有starred, 没有tag
|
||||
.no-info {
|
||||
text-align: center; margin: 10px 0; opacity: 0.8;
|
||||
}
|
||||
|
||||
@import '../traffic.less';
|
||||
@import '../ani.less';
|
||||
|
@@ -55,3 +55,6 @@
|
||||
/* WebKit browsers */
|
||||
font-size: 12px;
|
||||
}
|
||||
.no-info {
|
||||
color: #fff;
|
||||
}
|
||||
|
@@ -57,4 +57,8 @@
|
||||
color: #eee !important; /* WebKit browsers */
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.no-info {
|
||||
color: #fff;
|
||||
}
|
@@ -58,3 +58,6 @@
|
||||
/* WebKit browsers */
|
||||
font-size: 12px;
|
||||
}
|
||||
.no-info {
|
||||
color: #fff;
|
||||
}
|
||||
|
@@ -62,3 +62,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
.no-info {
|
||||
color: #fff;
|
||||
}
|
@@ -1118,7 +1118,7 @@ h3 {
|
||||
cursor: pointer !important;
|
||||
}
|
||||
#editorContent {
|
||||
padding: 5px;
|
||||
padding: 5px 10px;
|
||||
outline: none;
|
||||
margin-top: 5px;
|
||||
bottom: 5px !important;
|
||||
@@ -1534,6 +1534,11 @@ body.init #pageInner {
|
||||
z-index: 1000;
|
||||
cursor: move;
|
||||
}
|
||||
.no-info {
|
||||
text-align: center;
|
||||
margin: 10px 0;
|
||||
opacity: 0.8;
|
||||
}
|
||||
.win-tool {
|
||||
padding: 5px;
|
||||
position: absolute;
|
||||
|
@@ -35,6 +35,9 @@
|
||||
#editorContent:hover ::-webkit-scrollbar-thumb {
|
||||
visibility: visible;
|
||||
}
|
||||
* {
|
||||
font-family: 'Microsoft YaHei', '微软雅黑', ' WenQuanYi Micro Hei', 'Open Sans', 'Helvetica Neue', Arial, 'Hiragino Sans GB', sans-serif;
|
||||
}
|
||||
body {
|
||||
border: none;
|
||||
border-shadow: none;
|
||||
@@ -42,10 +45,9 @@ body {
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
font-family: '微软雅黑';
|
||||
}
|
||||
* {
|
||||
font-family: '微软雅黑';
|
||||
#newMyNote * {
|
||||
font-family: 'Arial';
|
||||
}
|
||||
html,
|
||||
body,
|
||||
|
@@ -52,6 +52,11 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@fontFamily: 'Microsoft YaHei', '微软雅黑',' WenQuanYi Micro Hei','Open Sans', 'Helvetica Neue',Arial,'Hiragino Sans GB',sans-serif;
|
||||
|
||||
* {
|
||||
font-family: @fontFamily;
|
||||
}
|
||||
|
||||
body {
|
||||
border: none;
|
||||
@@ -60,11 +65,13 @@ body {
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
font-family: '微软雅黑';
|
||||
// font-family: '微软雅黑';
|
||||
}
|
||||
* {
|
||||
font-family: '微软雅黑';
|
||||
|
||||
#newMyNote * {
|
||||
font-family: 'Arial';
|
||||
}
|
||||
|
||||
html, body, #page, #pageInner, #noteList, #notebook, #leftNotebook {
|
||||
border-radius: 0;
|
||||
}
|
||||
|
3
public/dist/themes/default.css
vendored
3
public/dist/themes/default.css
vendored
@@ -1469,13 +1469,14 @@ a.input-group-addon {
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
padding: 0 3px;
|
||||
padding: 10px;
|
||||
}
|
||||
#mdEditor .preview-panel {
|
||||
left: 0;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
padding: 10px;
|
||||
}
|
||||
#mdEditor .wmd-button,
|
||||
#mdEditor .preview-button {
|
||||
|
@@ -1804,6 +1804,10 @@ Note.renderStars = function(notes) {
|
||||
var t = tt(me.starItemT, note.NoteId, note.Title || 'Untitled');
|
||||
me.starNotesO.append(t);
|
||||
}
|
||||
|
||||
if(notes.length == 0) {
|
||||
me.starNotesO.html('<p class="no-info">No Starred Note</p>');
|
||||
}
|
||||
};
|
||||
|
||||
// 点击笔记, 判断是否在star中, 如果在, 则也选中
|
||||
|
@@ -398,7 +398,7 @@ function initEditor() {
|
||||
selector : "#editorContent",
|
||||
// height: 100,//这个应该是文档的高度, 而其上层的高度是$("#content").height(),
|
||||
// parentHeight: $("#content").height(),
|
||||
content_css : ["public/css/editor/editor.css"],
|
||||
// content_css : ["public/css/editor/editor.css"],
|
||||
skin : "custom",
|
||||
language: LEA.locale, // 语言
|
||||
plugins : [
|
||||
@@ -1519,9 +1519,17 @@ function userMenu() {
|
||||
function menu() {
|
||||
var me = this;
|
||||
// this.target = '';
|
||||
var shortHost = UserInfo.Host;
|
||||
if(shortHost) {
|
||||
var ret = /http(s*):\/\/([a-zA-Z0-9\.\-]+)/.exec(shortHost);
|
||||
if(ret && ret.length == 3) {
|
||||
shortHost = ret[2];
|
||||
}
|
||||
}
|
||||
|
||||
this.menu = new gui.Menu();
|
||||
this.email = new gui.MenuItem({
|
||||
label: UserInfo.Email,
|
||||
label: UserInfo.Email + ' (' + shortHost + ')',
|
||||
enabled: false,
|
||||
click: function(e) {
|
||||
}
|
||||
|
@@ -264,6 +264,10 @@ Tag.renderTagNav = function(tags) {
|
||||
// 笔记数量先隐藏, 不准确
|
||||
$("#tagNav").append(tt('<li data-tag="?"><a> <span class="?">? <em style="display: none">(?)</em></span> <i class="tag-delete">X</i></li>', tag, classes, text, noteTag.Count));
|
||||
}
|
||||
|
||||
if(tags.length == 0) {
|
||||
$("#tagNav").html('<p class="no-info">No tag</p>');
|
||||
}
|
||||
};
|
||||
|
||||
// 添加的标签重新render到左边, 放在第一个位置
|
||||
|
@@ -417,26 +417,32 @@ function pasteImage(e) {
|
||||
// find pasted image among pasted items
|
||||
var blob;
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
if (items[i].type.indexOf("image") === 0) {
|
||||
blob = items[i].getAsFile();
|
||||
}
|
||||
}
|
||||
// console.log("paste images");
|
||||
// console.log(blob);
|
||||
// load image if there is a pasted image
|
||||
if (blob) {
|
||||
// console.log("??");
|
||||
var reader = new FileReader();
|
||||
reader.onloadend = function() {
|
||||
console.log('read end');
|
||||
console.log(reader.result);
|
||||
if(reader.result) {
|
||||
FileService.pasteImage2(reader.result, function(url) {
|
||||
insertImage(url);
|
||||
});
|
||||
}
|
||||
};
|
||||
reader.readAsDataURL(blob);
|
||||
// if (items[i].type.indexOf("image") === 0) {
|
||||
blob = items[i].getAsFile();
|
||||
console.log("paste images");
|
||||
console.log(blob);
|
||||
// load image if there is a pasted image
|
||||
if (blob) {
|
||||
// console.log("??");
|
||||
var reader = new FileReader();
|
||||
reader.onloadend = function() {
|
||||
console.log('read end');
|
||||
console.log(reader);
|
||||
console.log(reader.result);
|
||||
if(reader.result) {
|
||||
if(blob.type.indexOf('image/') === 0) { // image类型
|
||||
FileService.pasteImage2(reader.result, function(url) {
|
||||
insertImage(url);
|
||||
});
|
||||
} else {
|
||||
// 作为附件上传
|
||||
// mac下还是图片
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
reader.readAsDataURL(blob);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1376,7 +1382,11 @@ var ContextTips = {
|
||||
function switchAccount() {
|
||||
SyncService.stop();
|
||||
// location.href = 'login.html';
|
||||
var w = gui.Window.open('login.html', {frame: false, toolbar: false, resizable: false, transparent: true, width: 258, max_width: 258});
|
||||
var w = gui.Window.open('login.html', {
|
||||
frame: false, toolbar: false, resizable: false,
|
||||
transparent: true,
|
||||
width: 278,
|
||||
max_width: 278});
|
||||
// w.focus();
|
||||
// gui.Window.close();
|
||||
win.close();
|
||||
|
@@ -117,12 +117,14 @@ define("tinymce/pasteplugin/Plugin", [
|
||||
active: self.clipboard.pasteFormat == "text"
|
||||
});
|
||||
|
||||
/*
|
||||
editor.addButton('pasteCopyImage', {
|
||||
icon: 'copy',
|
||||
tooltip: "When Paste other site's image, copy it into my album as public image",
|
||||
onclick: togglePasteCopyImage,
|
||||
active: self.clipboard.copyImage === true
|
||||
});
|
||||
*/
|
||||
|
||||
editor.addMenuItem('pastetext', {
|
||||
text: 'Paste as text',
|
||||
|
@@ -1192,12 +1192,14 @@ define("tinymce/pasteplugin/Plugin", [
|
||||
active: self.clipboard.pasteFormat == "text"
|
||||
});
|
||||
|
||||
/*
|
||||
editor.addButton('pasteCopyImage', {
|
||||
icon: 'copy',
|
||||
tooltip: "When Paste other site's image, copy it into my album as public image",
|
||||
onclick: togglePasteCopyImage,
|
||||
active: self.clipboard.copyImage === true
|
||||
});
|
||||
*/
|
||||
|
||||
editor.addMenuItem('pastetext', {
|
||||
text: 'Paste as text',
|
||||
|
Reference in New Issue
Block a user