完成备忘的更新
This commit is contained in:
parent
6c4dc01f36
commit
b66e8d8a83
|
|
@ -568,14 +568,17 @@ module.exports = class extends Base {
|
||||||
}
|
}
|
||||||
|
|
||||||
async notesAction() {
|
async notesAction() {
|
||||||
|
let params = this.get();
|
||||||
let where = {};
|
let where = {};
|
||||||
try {
|
try {
|
||||||
let keyword = this.get('keyword');
|
if (params.keyword) {
|
||||||
if (keyword) {
|
where.content = ['like', `%${params.keyword}%`]
|
||||||
where.content = ['like', `%${keyword}%`]
|
}
|
||||||
|
if (params.tagId) {
|
||||||
|
where.tagId = params.tagId;
|
||||||
}
|
}
|
||||||
let data = await this.model('notes').where(where).order("createdAt DESC").page(this.get('page'), this.get('pageSize')).countSelect();
|
let data = await this.model('notes').where(where).order("createdAt DESC").page(this.get('page'), this.get('pageSize')).countSelect();
|
||||||
this.json({ code: 0, data });
|
this.json({ code: 0, data })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.json({ code: 1, msg: error.toString() });
|
this.json({ code: 1, msg: error.toString() });
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
<!-- 百度统计 -->
|
<!-- 百度统计 -->
|
||||||
<script>
|
<script>
|
||||||
var _hmt = _hmt || [];
|
var _hmt = _hmt || [];
|
||||||
(function() {
|
(function () {
|
||||||
var hm = document.createElement("script");
|
var hm = document.createElement("script");
|
||||||
hm.src = "https://hm.baidu.com/hm.js?01351b0343ccf42968923cff21a4a851";
|
hm.src = "https://hm.baidu.com/hm.js?01351b0343ccf42968923cff21a4a851";
|
||||||
var s = document.getElementsByTagName("script")[0];
|
var s = document.getElementsByTagName("script")[0];
|
||||||
|
|
@ -26,34 +26,45 @@
|
||||||
<link href="css/externe/ngDialog-theme-default.css" rel="stylesheet" />
|
<link href="css/externe/ngDialog-theme-default.css" rel="stylesheet" />
|
||||||
<link href="css/externe/ngDialog-theme-plain.css" rel="stylesheet" />
|
<link href="css/externe/ngDialog-theme-plain.css" rel="stylesheet" />
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
window.onload = function() {
|
window.onload = function () {
|
||||||
var clipboard = new ClipboardJS(document.getElementById("clipboard"));
|
var clipboard = new ClipboardJS(document.getElementById("clipboard"));
|
||||||
clipboard.on("success", function(e) {
|
clipboard.on("success", function (e) {
|
||||||
var text = e.text.length >= 180 ? e.text.substr(0, 180) + "..." : e.text;
|
var text = e.text.length >= 180 ? e.text.substr(0, 180) + "..." : e.text;
|
||||||
toastr.success(text + "<br/>已复制到您的剪切板", "提示");
|
toastr.success(text + "<br/>已复制到您的剪切板", "提示");
|
||||||
e.clearSelection();
|
e.clearSelection();
|
||||||
});
|
});
|
||||||
clipboard.on("error", function(e) {
|
clipboard.on("error", function (e) {
|
||||||
var text = e.text.length >= 180 ? e.text.substr(0, 180) + "..." : e.text;
|
var text = e.text.length >= 180 ? e.text.substr(0, 180) + "..." : e.text;
|
||||||
toastr.error(text + "<br/>复制失败", "提示");
|
toastr.error(text + "<br/>复制失败", "提示");
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
let resizeContainer = () => {
|
||||||
|
let count = 1;
|
||||||
|
let id = setInterval(() => {
|
||||||
|
if (count++ >= 100) {
|
||||||
|
clearInterval(id);
|
||||||
|
}
|
||||||
|
$("#js-container").css("left", ($(window).width() - $("#js-container").width()) / 2);
|
||||||
|
}, 10);
|
||||||
|
};
|
||||||
|
window.onresize = resizeContainer;
|
||||||
|
resizeContainer();
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body ng-app="bookmarkApp">
|
<body ng-app="bookmarkApp">
|
||||||
<div class="ui container">
|
<div class="ui container" id="js-container" style="position: absolute;left: 86;">
|
||||||
<!-- directive:菜单 -->
|
<!-- directive:菜单 -->
|
||||||
<menus></menus>
|
<menus></menus>
|
||||||
<div class="ui container" style="width:100%;height:2px"></div>
|
<div class="ui container" style="width: 100%; height: 2px;"></div>
|
||||||
<div class="ui container">
|
<div class="ui container">
|
||||||
<div ui-view></div>
|
<div ui-view></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui container" style="width:100%;height:10px"></div>
|
<div class="ui container" style="width: 100%; height: 10px;"></div>
|
||||||
<div class="foot" style="margin-bottom:10px;">
|
<div class="foot" style="margin-bottom: 10px;">
|
||||||
<div class="ui segment container">我爱佳佳与这个世界 | Copyleft ©All Rights Reserved LCQ | <a href="http://m.mybookmark.cn/">移动设备访问</a> | 联系我(QQ:530485521) | <a href="https://github.com/luchenqun/my-bookmark" target="_blank">网站源码</a> | V1.5.0 | <span>加载失败,请按F5!(●'◡'●)</span><br /></div>
|
<div class="ui segment container">我爱佳佳与这个世界 | Copyleft ©All Rights Reserved LCQ | <a href="http://m.mybookmark.cn/">移动设备访问</a> | 联系我(QQ:530485521) | <a href="https://github.com/luchenqun/my-bookmark" target="_blank">网站源码</a> | V1.5.0 | <span>加载失败,请按F5!(●'◡'●)</span><br /></div>
|
||||||
<!-- 主要用来配合clipboard.min.js复制文本的 -->
|
<!-- 主要用来配合clipboard.min.js复制文本的 -->
|
||||||
<div id="clipboard" data-clipboard-text="i love this world and jiajia!" style="opacity:0;cursor:default">
|
<div id="clipboard" data-clipboard-text="i love this world and jiajia!" style="opacity: 0; cursor: default;">
|
||||||
<span>Copy</span>
|
<span>Copy</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ body {
|
||||||
background-repeat: repeat;
|
background-repeat: repeat;
|
||||||
background-position: top left;
|
background-position: top left;
|
||||||
background-attachment: scroll;
|
background-attachment: scroll;
|
||||||
padding: 50px;
|
padding-top: 50px;
|
||||||
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
|
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -235,7 +235,7 @@ app.controller('editCtr', ['$scope', '$state', '$timeout', '$document', 'ngDialo
|
||||||
async function getTags() {
|
async function getTags() {
|
||||||
let tags = await get('tags');
|
let tags = await get('tags');
|
||||||
tags.sort((a, b) => {
|
tags.sort((a, b) => {
|
||||||
if (a.last_use > b.last_use) return -1;
|
if (a.lastUse > b.lastUse) return -1;
|
||||||
return 1;
|
return 1;
|
||||||
})
|
})
|
||||||
tags.forEach((tag) => {
|
tags.forEach((tag) => {
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,9 @@ app.controller('noteCtr', ['$scope', '$state', '$stateParams', '$filter', '$wind
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const perPageItems = 35;
|
|
||||||
var dialog = null;
|
var dialog = null;
|
||||||
$scope.hoverNote = null;
|
$scope.hoverNote = null;
|
||||||
$scope.loadBusy = false;
|
$scope.loading = false;
|
||||||
$scope.add = false;
|
$scope.add = false;
|
||||||
$scope.edit = false;
|
$scope.edit = false;
|
||||||
$scope.preContent = '';
|
$scope.preContent = '';
|
||||||
|
|
@ -26,14 +25,12 @@ app.controller('noteCtr', ['$scope', '$state', '$stateParams', '$filter', '$wind
|
||||||
|
|
||||||
var timeagoInstance = timeago();
|
var timeagoInstance = timeago();
|
||||||
|
|
||||||
get('user').then(user => {
|
|
||||||
pubSubService.publish('Common.menuActive', {
|
pubSubService.publish('Common.menuActive', {
|
||||||
login: true,
|
login: true,
|
||||||
index: dataService.LoginIndexNote
|
index: dataService.LoginIndexNote
|
||||||
});
|
});
|
||||||
|
|
||||||
getTags();
|
getTags();
|
||||||
getNotes();
|
|
||||||
});
|
|
||||||
|
|
||||||
$scope.changeCurrentPage = function (currentPage) {
|
$scope.changeCurrentPage = function (currentPage) {
|
||||||
currentPage = parseInt(currentPage) || 0;
|
currentPage = parseInt(currentPage) || 0;
|
||||||
|
|
@ -236,9 +233,7 @@ app.controller('noteCtr', ['$scope', '$state', '$stateParams', '$filter', '$wind
|
||||||
$scope.totalItems = 0;
|
$scope.totalItems = 0;
|
||||||
updateSelectTag(id);
|
updateSelectTag(id);
|
||||||
|
|
||||||
if ($scope.add || $scope.edit) {
|
if (!($scope.add || $scope.edit)) {
|
||||||
|
|
||||||
} else {
|
|
||||||
$scope.currentPage = 1;
|
$scope.currentPage = 1;
|
||||||
getNotes($scope.currentTagId);
|
getNotes($scope.currentTagId);
|
||||||
}
|
}
|
||||||
|
|
@ -287,7 +282,6 @@ app.controller('noteCtr', ['$scope', '$state', '$stateParams', '$filter', '$wind
|
||||||
tag.clicked = false;
|
tag.clicked = false;
|
||||||
if (tag.id == tagId) {
|
if (tag.id == tagId) {
|
||||||
tag.clicked = true;
|
tag.clicked = true;
|
||||||
t = tag;
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -310,29 +304,33 @@ app.controller('noteCtr', ['$scope', '$state', '$stateParams', '$filter', '$wind
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let count = 1;
|
||||||
async function getNotes(tagId) {
|
async function getNotes(tagId) {
|
||||||
$scope.notes = [];
|
$scope.notes = [];
|
||||||
$scope.loadBusy = true;
|
$scope.loading = true;
|
||||||
var params = {
|
var params = {
|
||||||
page: $scope.currentPage,
|
page: $scope.currentPage,
|
||||||
pageSize: perPageItems,
|
pageSize: 35,
|
||||||
keyword: $scope.keyword,
|
keyword: $scope.keyword,
|
||||||
tagId: tagId || $scope.currentTagId
|
tagId: tagId || $scope.currentTagId
|
||||||
};
|
};
|
||||||
|
// if (count++ % 2) return;
|
||||||
|
|
||||||
try {
|
|
||||||
let reply = await get("notes", params);
|
let reply = await get("notes", params);
|
||||||
$scope.notes = reply.data;
|
$timeout(function () {
|
||||||
$scope.notes.forEach((note) => {
|
let notes = reply.data;
|
||||||
|
notes.forEach((note) => {
|
||||||
note.brief = note.content || "";
|
note.brief = note.content || "";
|
||||||
while (note.brief.indexOf("\n") > 0) {
|
while (note.brief.indexOf("\n") > 0) {
|
||||||
note.brief = note.brief.replace(/\n/g, "");
|
note.brief = note.brief.replace(/\n/g, "");
|
||||||
}
|
}
|
||||||
note.brief = " " + note.brief.substring(0, 200) + (note.content.length > 200 ? " ......" : "");
|
note.brief = " " + note.brief.substring(0, 200) + (note.content.length > 200 ? " ......" : "");
|
||||||
})
|
})
|
||||||
|
|
||||||
|
$scope.notes = notes;
|
||||||
$scope.totalPages = reply.totalPages;
|
$scope.totalPages = reply.totalPages;
|
||||||
$scope.totalItems = reply.count;
|
$scope.totalItems = reply.count;
|
||||||
$timeout(function () {
|
|
||||||
timeagoInstance.cancel();
|
timeagoInstance.cancel();
|
||||||
timeagoInstance.render(document.querySelectorAll('.need_to_be_rendered'), 'zh_CN');
|
timeagoInstance.render(document.querySelectorAll('.need_to_be_rendered'), 'zh_CN');
|
||||||
// 如果需要增加书签
|
// 如果需要增加书签
|
||||||
|
|
@ -340,43 +338,47 @@ app.controller('noteCtr', ['$scope', '$state', '$stateParams', '$filter', '$wind
|
||||||
$scope.key = null;
|
$scope.key = null;
|
||||||
$scope.showAddNote();
|
$scope.showAddNote();
|
||||||
}
|
}
|
||||||
}, 100)
|
$scope.loading = false;
|
||||||
$scope.loadBusy = false;
|
|
||||||
if ($scope.totalItems == 0) {
|
if ($scope.totalItems == 0) {
|
||||||
$(".js-note").removeClass("hidden");
|
$(".js-note").removeClass("hidden");
|
||||||
}
|
}
|
||||||
transition();
|
})
|
||||||
} catch (error) {
|
|
||||||
$scope.notes = [];
|
|
||||||
$scope.loadBusy = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getTags() {
|
async function updateTags(_tags) {
|
||||||
$scope.loadBusy = true;
|
let tags = JSON.parse(JSON.stringify(_tags));
|
||||||
$scope.tags = []
|
$scope.loading = true;
|
||||||
|
$scope.tags = [];
|
||||||
|
|
||||||
let tags = await get('tags', { noteCount: true });
|
|
||||||
let find = false;
|
let find = false;
|
||||||
tags.forEach((tag) => {
|
tags.forEach((tag) => {
|
||||||
$scope.tags.push(tag);
|
|
||||||
if (tag.id == $scope.currentTagId) {
|
if (tag.id == $scope.currentTagId) {
|
||||||
find = true; // 如果是删了分类返回来,那么要重新默认选中第一个分类
|
find = true; // 如果是删了分类返回来,那么要重新默认选中第一个分类
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (!find) $scope.currentTagId = null;
|
if (!find) $scope.currentTagId = null;
|
||||||
$scope.loadBusy = false;
|
|
||||||
|
$timeout(() => {
|
||||||
|
$scope.loading = false;
|
||||||
|
$scope.tags = tags;
|
||||||
|
getNotes();
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
$('.js-note-card').transition('hide');
|
async function getTags() {
|
||||||
|
// 通过缓存tags,如果回来的tags跟缓存的一致,那么这个时间差就省下来了
|
||||||
function transition() {
|
let tags = JSON.parse(localStorage.getItem("tags") || "[]");
|
||||||
var className = 'js-note-card';
|
if (tags.length > 0) {
|
||||||
$('.' + className).transition('hide');
|
get('tags').then((_tags) => {
|
||||||
$('.' + className).transition({
|
if (JSON.stringify(tags) != JSON.stringify(_tags)) {
|
||||||
animation: dataService.animation(),
|
localStorage.setItem("tags", JSON.stringify(tags));
|
||||||
duration: 500,
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
tags = await get('tags');
|
||||||
|
localStorage.setItem("tags", JSON.stringify(tags));
|
||||||
|
}
|
||||||
|
updateTags(tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
function toPos(id) {
|
function toPos(id) {
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ app.controller('settingsCtr', ['$scope', '$stateParams', '$filter', '$state', '$
|
||||||
$scope.form[index] = true;
|
$scope.form[index] = true;
|
||||||
if (index == 0 || index == 1 || index == 4) {
|
if (index == 0 || index == 1 || index == 4) {
|
||||||
let user = await get('user', { full: true });
|
let user = await get('user', { full: true });
|
||||||
let tags = await get('tags', { bookmarkCount: true, noteCount: true });
|
let tags = await get('tags');
|
||||||
$timeout(() => {
|
$timeout(() => {
|
||||||
$scope.user = user
|
$scope.user = user
|
||||||
$scope.quickUrl = objKeySort(JSON.parse($scope.user.quickUrl || '{}'));
|
$scope.quickUrl = objKeySort(JSON.parse($scope.user.quickUrl || '{}'));
|
||||||
|
|
|
||||||
|
|
@ -387,14 +387,14 @@ app.controller('tagsCtr', ['$scope', '$filter', '$state', '$window', '$statePara
|
||||||
// 通过缓存tags,如果回来的tags跟缓存的一致,那么这个时间差就省下来了
|
// 通过缓存tags,如果回来的tags跟缓存的一致,那么这个时间差就省下来了
|
||||||
let tags = JSON.parse(localStorage.getItem("tags") || "[]");
|
let tags = JSON.parse(localStorage.getItem("tags") || "[]");
|
||||||
if (tags.length > 0) {
|
if (tags.length > 0) {
|
||||||
get('tags', { bookmarkCount: true }).then((_tags) => {
|
get('tags').then((_tags) => {
|
||||||
if (JSON.stringify(tags) != JSON.stringify(_tags)) {
|
if (JSON.stringify(tags) != JSON.stringify(_tags)) {
|
||||||
localStorage.setItem("tags", JSON.stringify(tags));
|
localStorage.setItem("tags", JSON.stringify(tags));
|
||||||
updateTags(tags);
|
updateTags(tags);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
tags = await get('tags', { bookmarkCount: true });
|
tags = await get('tags');
|
||||||
localStorage.setItem("tags", JSON.stringify(tags));
|
localStorage.setItem("tags", JSON.stringify(tags));
|
||||||
}
|
}
|
||||||
updateTags(tags);
|
updateTags(tags);
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
<div class="ui segment js-note-card" style="padding:14px 0px 0px 0px;">
|
<div class="ui segment js-note-card" style="padding:14px 0px 0px 0px;" ng-show="!loading || tags.length > 0">
|
||||||
<div class="ui container" style="padding-left:14px">
|
<div class="ui container" style="padding-left:14px">
|
||||||
<div class="ui label" style="margin:3px 15px 8px 0px;cursor:default;" ng-class="{green:tag.clicked}" ng-repeat="tag in tags" ng-click="clickTag(tag.id)" ng-show="tag.noteCount || add">{{ tag.name }} ({{ tag.noteCount || 0 }})</div>
|
<div class="ui label" style="margin:3px 15px 8px 0px;cursor:default;" ng-class="{green:tag.clicked}" ng-repeat="tag in tags" ng-click="clickTag(tag.id)" ng-show="tag.noteCount || add">{{ tag.name }} ({{ tag.noteCount || 0 }})</div>
|
||||||
<div class="ui label" style="margin:3px 15px 8px 0px;cursor:default;" ng-click="showAddNote()" data-tooltip="点击添加备忘。你也可以在任意界面按快捷键A(不区分大小写)增加备忘录。">
|
<div class="ui label" style="margin:3px 15px 8px 0px;cursor:default;" ng-click="showAddNote()" data-tooltip="点击添加备忘。你也可以在任意界面按快捷键A(不区分大小写)增加备忘录。">
|
||||||
<i class="plus icon" style="margin-right:0px;"></i>
|
<i class="plus icon" style="margin-right:0px;"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui container" style="padding-left:14px;padding-bottom:14px">
|
<div class="ui container" style="padding-left:14px;padding-bottom:14px" ng-show="add">
|
||||||
<div class="ui form" ng-show="add">
|
<div class="ui form" >
|
||||||
<div class="required field">
|
<div class="required field">
|
||||||
<label>内容</label>
|
<label>内容</label>
|
||||||
<textarea rows="12" placeholder="" ng-model="content" id="noteedit"></textarea>
|
<textarea rows="12" placeholder="" ng-model="content" id="noteedit"></textarea>
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui vertical segment" ng-repeat="note in notes" ng-click="noteClick(note)" ng-mouseover="setHoverNote(note)" ng-mouseleave="setHoverNote(null)" id="{{note.id}}" style="margin:0px;padding-top:10px;padding-bottom: 10px;">
|
<div class="ui vertical segment" ng-repeat="note in notes" ng-click="noteClick(note)" ng-mouseover="setHoverNote(note)" ng-mouseleave="setHoverNote(null)" id="{{note.id}}" style="margin:0px;padding:10px 0px;">
|
||||||
<pre class="note-content" title="单击查看详情,C复制,D删除,E编辑" style="margin:0px;padding-left:14px;padding-right:14px" ng-if="!note.detail">{{ note.brief }}</pre>
|
<pre class="note-content" title="单击查看详情,C复制,D删除,E编辑" style="margin:0px;padding-left:14px;padding-right:14px" ng-if="!note.detail">{{ note.brief }}</pre>
|
||||||
<pre class="note-content" title="双击复制" ng-dblclick="copy(note.content)" style="margin:0px; font-size:16px;padding:60px 14px;" ng-if="note.detail">{{ note.content }}</pre>
|
<pre class="note-content" title="双击复制" ng-dblclick="copy(note.content)" style="margin:0px; font-size:16px;padding:60px 14px;" ng-if="note.detail">{{ note.content }}</pre>
|
||||||
<div class="ui right aligned grid" ng-show="note.detail">
|
<div class="ui right aligned grid" ng-show="note.detail">
|
||||||
|
|
@ -63,6 +63,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui massive text centered inline loader js-hot-loader" ng-class="{active:loadBusy, disabled:!loadBusy}">
|
<div class="ui massive text centered inline loader js-hot-loader" style="margin-top: 10px;" ng-class="{active:loading, disabled:!loading}">
|
||||||
正在加载中...
|
正在加载中...
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue