完成几个模块的前后台改造
This commit is contained in:
parent
8fea4e8167
commit
e088df6cb4
|
|
@ -68,8 +68,8 @@ CREATE TABLE `hot_bookmarks` (
|
|||
`description` varchar(4096) DEFAULT NULL, -- 描述(自己添加)
|
||||
`url` varchar(1024) DEFAULT NULL, -- 链接(url)
|
||||
`favCount` smallint DEFAULT 1, -- 总共收藏人数(favCount)
|
||||
`created_by` varchar(64) DEFAULT NULL, -- 创建者(sourceName)
|
||||
`created_at` bigint DEFAULT 0, -- 创建时间(updatetime)
|
||||
`createdBy` varchar(64) DEFAULT NULL, -- 创建者(sourceName)
|
||||
`createdAt` bigint DEFAULT 0, -- 创建时间(updatetime)
|
||||
`lastClick` bigint DEFAULT 0, -- 最后一次点击时间(createtime)
|
||||
`snapUrl` varchar(1024) DEFAULT NULL, -- 截图链接(imageList[0])
|
||||
`faviconUrl` varchar(1024) DEFAULT NULL, -- icon链接(sourceLogo)
|
||||
|
|
|
|||
|
|
@ -47,26 +47,59 @@ module.exports = class extends Base {
|
|||
let post = this.post();
|
||||
post.password = md5(post.password); // 进行密码加密
|
||||
|
||||
let data = await this.model('users').where({ username: post.username, password: post.password }).find();
|
||||
if (think.isEmpty(data)) {
|
||||
let user = await this.model('users').where({ username: post.username, password: post.password }).find();
|
||||
if (think.isEmpty(user)) {
|
||||
this.json({ code: 2, msg: "账号或者密码错误" });
|
||||
} else {
|
||||
delete data.password;
|
||||
delete user.password;
|
||||
const token = await this.session('user', {
|
||||
id: data.id,
|
||||
username: data.username
|
||||
id: user.id,
|
||||
username: user.username
|
||||
});
|
||||
data.token = token;
|
||||
this.json({ code: 0, data, msg: "登陆成功" });
|
||||
user.token = token;
|
||||
this.json({ code: 0, data: user, msg: "登陆成功" });
|
||||
}
|
||||
} catch (error) {
|
||||
this.json({ code: 1, data: '', msg: error.toString() });
|
||||
}
|
||||
}
|
||||
|
||||
// 登出
|
||||
async logoutAction() {
|
||||
await this.session(null);
|
||||
this.json({ code: 0, data: '', msg: "退出成功" });
|
||||
}
|
||||
|
||||
async updateUserAction() {
|
||||
let user = this.post();
|
||||
try {
|
||||
let data = await this.model('users').where({ id: this.ctx.state.user.id }).update(user);
|
||||
this.json({ code: 0, data });
|
||||
} catch (error) {
|
||||
this.json({ code: 1, msg: error.toString() });
|
||||
}
|
||||
}
|
||||
|
||||
async resetUserPwdAction() {
|
||||
let old = md5(this.post("old"));
|
||||
let password = md5(this.post("password"));
|
||||
|
||||
try {
|
||||
let user = await this.model('users').where({ id: this.ctx.state.user.id, password: old }).find();
|
||||
if (!think.isEmpty(user)) {
|
||||
let data = await this.model('users').where({ id: this.ctx.state.user.id }).update({ password });
|
||||
this.json({ code: 0, data, msg: "密码更新成功!" });
|
||||
} else {
|
||||
this.json({ code: 0, data: 0, msg: "旧密码认证失败!" });
|
||||
}
|
||||
} catch (error) {
|
||||
this.json({ code: 1, msg: error.toString() });
|
||||
}
|
||||
}
|
||||
|
||||
// 通过session获取自己信息
|
||||
async ownAction() {
|
||||
let full = this.get().full;
|
||||
let full = this.get("full");
|
||||
if (full) {
|
||||
let data = await this.model('users').where({ id: this.ctx.state.user.id }).find();
|
||||
delete data.password;
|
||||
|
|
@ -105,6 +138,52 @@ module.exports = class extends Base {
|
|||
}
|
||||
}
|
||||
|
||||
// 更新分类
|
||||
async updateTagAction() {
|
||||
let tag = this.post();
|
||||
try {
|
||||
let data = await this.model('tags').where({
|
||||
userId: this.ctx.state.user.id,
|
||||
id: tag.id
|
||||
}).update(tag);
|
||||
this.json({ code: 0, data });
|
||||
} catch (error) {
|
||||
this.json({ code: 1, msg: error.toString() });
|
||||
}
|
||||
}
|
||||
|
||||
// 批量更新排序
|
||||
async updateTagSortAction() {
|
||||
let tags = this.post("tags");
|
||||
try {
|
||||
let data = 0;
|
||||
for (const tag of tags) {
|
||||
let count = await this.model('tags').where({
|
||||
userId: this.ctx.state.user.id,
|
||||
id: tag.id
|
||||
}).update(tag);
|
||||
data += count;
|
||||
}
|
||||
this.json({ code: 0, data, msg: '分类排序更新成功!' });
|
||||
} catch (error) {
|
||||
this.json({ code: 1, msg: error.toString() });
|
||||
}
|
||||
}
|
||||
|
||||
// 删除分类
|
||||
async delTagAction() {
|
||||
let id = this.post("id");
|
||||
let tagId = id;
|
||||
let userId = this.ctx.state.user.id;
|
||||
try {
|
||||
let data = await this.model("tags").where({ id, userId }).delete();
|
||||
data = await this.model("bookmarks").where({ tagId, userId }).delete();
|
||||
this.json({ code: 0, data, msg: `分类删除成功` });
|
||||
} catch (error) {
|
||||
this.json({ code: 1, msg: error.toString() });
|
||||
}
|
||||
}
|
||||
|
||||
// 获取书签
|
||||
// @todo 如果是自己的任意获取,如果是别人的必须公开才能获取
|
||||
async bookmarkAction() {
|
||||
|
|
@ -122,6 +201,20 @@ module.exports = class extends Base {
|
|||
let bookmark = this.post();
|
||||
bookmark.userId = this.ctx.state.user.id;
|
||||
try {
|
||||
// 没有分类的直接放未分类里面
|
||||
if (!bookmark.tagId) {
|
||||
const name = "未分类";
|
||||
let tag = await this.model("tags").where({ name }).find();
|
||||
if (!think.isEmpty(tag)) {
|
||||
bookmark.tagId = tag.id;
|
||||
} else {
|
||||
let tagId = await this.model("tags").add({
|
||||
userId: this.ctx.state.user.id,
|
||||
name
|
||||
});
|
||||
bookmark.tagId = tagId;
|
||||
}
|
||||
}
|
||||
let res = await this.model("bookmarks").add(bookmark);
|
||||
this.json({ code: 0, data: res, msg: `书签 ${bookmark.title} 添加成功` });
|
||||
} catch (error) {
|
||||
|
|
@ -129,6 +222,18 @@ module.exports = class extends Base {
|
|||
}
|
||||
}
|
||||
|
||||
// 删除书签
|
||||
async delBookmarkAction() {
|
||||
let bookmark = this.post();
|
||||
bookmark.userId = this.ctx.state.user.id;
|
||||
try {
|
||||
let data = await this.model("bookmarks").where(bookmark).delete();
|
||||
this.json({ code: 0, data, msg: `书签删除成功` });
|
||||
} catch (error) {
|
||||
this.json({ code: 1, msg: error.toString() });
|
||||
}
|
||||
}
|
||||
|
||||
// 根据书签id获取书签
|
||||
async getBookmarksByTagAction() {
|
||||
let tagId = this.get("tagId");
|
||||
|
|
@ -171,6 +276,32 @@ module.exports = class extends Base {
|
|||
}
|
||||
}
|
||||
|
||||
// 快速跳转到网页
|
||||
async shortcutBookmarkAction() {
|
||||
let url = this.post("url");
|
||||
try {
|
||||
let bookmark = await this.model('bookmarks').where({
|
||||
userId: this.ctx.state.user.id,
|
||||
url
|
||||
}).find();
|
||||
|
||||
if (!think.isEmpty(bookmark)) {
|
||||
await this.model('bookmarks').where({
|
||||
userId: this.ctx.state.user.id,
|
||||
id: bookmark.id
|
||||
}).update({
|
||||
clickCount: ['exp', 'clickCount+1'],
|
||||
lastClick: ['exp', 'NOW()']
|
||||
});
|
||||
this.json({ code: 0, data: true });
|
||||
} else {
|
||||
this.json({ code: 0, data: false });
|
||||
}
|
||||
} catch (error) {
|
||||
this.json({ code: 1, msg: error.toString() });
|
||||
}
|
||||
}
|
||||
|
||||
// 更新书签
|
||||
async updateBookmarkAction() {
|
||||
let bookmark = this.post();
|
||||
|
|
@ -281,6 +412,10 @@ module.exports = class extends Base {
|
|||
async notesAction() {
|
||||
let where = {};
|
||||
try {
|
||||
let searchWord = this.get('searchWord');
|
||||
if (searchWord) {
|
||||
where.content = ['like', `%${searchWord}%`]
|
||||
}
|
||||
let data = await this.model('notes').where(where).order("createdAt DESC").page(this.get('page'), this.get('pageSize')).countSelect();
|
||||
this.json({ code: 0, data });
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -86,7 +86,6 @@
|
|||
<script src="scripts/controllers/bookmark-info-controller.js"></script>
|
||||
<script src="scripts/controllers/search-controller.js"></script>
|
||||
<script src="scripts/controllers/weixin-article-controller.js"></script>
|
||||
<script src="scripts/controllers/praise-controller.js"></script>
|
||||
<script src="scripts/controllers/note-controller.js"></script>
|
||||
<script src="scripts/externe/semantic.min.js"></script>
|
||||
<script src="scripts/externe/calendar.min.js"></script>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
app.controller('adviceCtr', ['$scope', '$state', '$timeout', 'bookmarkService', 'pubSubService', 'dataService', function ($scope, $state, $timeout, bookmarkService, pubSubService, dataService) {
|
||||
app.controller('adviceCtr', ['$scope', '$state', '$timeout', 'pubSubService', 'dataService', function ($scope, $state, $timeout, pubSubService, dataService) {
|
||||
console.log("Hello adviceCtr");
|
||||
if (dataService.smallDevice()) {
|
||||
$window.location = "http://m.mybookmark.cn/#/tags";
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
app.controller('bookmarkInfoCtr', ['$scope', '$state', '$timeout', '$sce', '$window', '$filter', '$document', '$timeout', 'bookmarkService', 'pubSubService', 'dataService', function ($scope, $state, $timeout, $sce, $window, $filter, $document, $timeout, bookmarkService, pubSubService, dataService) {
|
||||
app.controller('bookmarkInfoCtr', ['$scope', '$state', '$timeout', '$sce', '$window', '$filter', '$document', '$timeout', 'pubSubService', 'dataService', function ($scope, $state, $timeout, $sce, $window, $filter, $document, $timeout, pubSubService, dataService) {
|
||||
console.log("Hello bookmarkInfoCtr");
|
||||
$scope.bookmark = {}
|
||||
$scope.content = '';
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
app.controller('bookmarksCtr', ['$scope', '$state', '$stateParams', '$filter', '$window', '$timeout', '$document', 'ngDialog', 'bookmarkService', 'pubSubService', 'dataService', function ($scope, $state, $stateParams, $filter, $window, $timeout, $document, ngDialog, bookmarkService, pubSubService, dataService) {
|
||||
app.controller('bookmarksCtr', ['$scope', '$state', '$stateParams', '$filter', '$window', '$timeout', '$document', 'ngDialog', 'pubSubService', 'dataService', function ($scope, $state, $stateParams, $filter, $window, $timeout, $document, ngDialog, pubSubService, dataService) {
|
||||
console.log("Hello bookmarksCtr...", $stateParams);
|
||||
if (dataService.smallDevice()) {
|
||||
$window.location = "http://m.mybookmark.cn/#/tags";
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
app.controller('editCtr', ['$scope', '$state', '$timeout', '$document', 'ngDialog', 'bookmarkService', 'pubSubService', 'dataService', function ($scope, $state, $timeout, $document, ngDialog, bookmarkService, pubSubService, dataService) {
|
||||
app.controller('editCtr', ['$scope', '$state', '$timeout', '$document', 'ngDialog', 'pubSubService', 'dataService', function ($scope, $state, $timeout, $document, ngDialog, pubSubService, dataService) {
|
||||
console.log("Hello editCtr");
|
||||
var maxSelections = 3;
|
||||
var dialog = null;
|
||||
|
|
@ -92,13 +92,14 @@ app.controller('editCtr', ['$scope', '$state', '$timeout', '$document', 'ngDialo
|
|||
console.log("add bookmark", params);
|
||||
|
||||
if ($scope.add) {
|
||||
await post('addBookmark', params);
|
||||
let id = await post('addBookmark', params);
|
||||
$('.ui.modal.js-add-bookmark').modal('hide');
|
||||
params.id = id;
|
||||
pubSubService.publish('EditCtr.inserBookmarsSuccess', params);
|
||||
} else {
|
||||
await post('updateBookmark', params);
|
||||
$('.ui.modal.js-add-bookmark').modal('hide');
|
||||
pubSubService.publish('EditCtr.inserBookmarsSuccess', data);
|
||||
pubSubService.publish('EditCtr.inserBookmarsSuccess', params);
|
||||
toastr.success('[ ' + params.title + ' ] 更新成功,将自动重新更新书签!', "提示");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
app.controller('homeCtr', ['$scope', '$stateParams', '$filter', '$state', '$window', 'bookmarkService', 'pubSubService', 'dataService', function ($scope, $stateParams, $filter, $state, $window, bookmarkService, pubSubService, dataService) {
|
||||
app.controller('homeCtr', ['$scope', '$stateParams', '$filter', '$state', '$window', 'pubSubService', 'dataService', function ($scope, $stateParams, $filter, $state, $window, pubSubService, dataService) {
|
||||
console.log('Hello homeCtr......');
|
||||
if (dataService.smallDevice()) {
|
||||
$window.location = "http://m.mybookmark.cn/#/tags";
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
app.controller('loginCtr', ['$scope', '$filter', '$state', '$http', '$cookieStore', '$window', 'bookmarkService', 'pubSubService', 'dataService', function ($scope, $filter, $state, $http, $cookieStore, $window, bookmarkService, pubSubService, dataService) {
|
||||
app.controller('loginCtr', ['$scope', '$filter', '$state', '$http', '$cookieStore', '$window', 'pubSubService', 'dataService', function ($scope, $filter, $state, $http, $cookieStore, $window, pubSubService, dataService) {
|
||||
console.log("Hello loginCtr...", $cookieStore.get("username"));
|
||||
if (dataService.smallDevice()) {
|
||||
$window.location = "http://m.mybookmark.cn/#/tags";
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$timeout', '$document', 'pubSubService', 'bookmarkService', 'dataService', function ($scope, $stateParams, $state, $window, $timeout, $document, pubSubService, bookmarkService, dataService) {
|
||||
app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$timeout', '$document', 'pubSubService', 'dataService', function ($scope, $stateParams, $state, $window, $timeout, $document, pubSubService, dataService) {
|
||||
console.log("Hello menuCtr")
|
||||
$scope.login = false; /**< 是否登陆 */
|
||||
$scope.selectLoginIndex = 0; /**< 默认登陆之后的选择的菜单索引,下表从 0 开始 */
|
||||
|
|
@ -26,11 +26,18 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
|
|||
$scope.loginMenus = dataService.loginMenus; // 登陆之后显示的菜单数据。uiSerf:内部跳转链接。
|
||||
$scope.notLoginMenus = dataService.notLoginMenus; // 未登陆显示的菜单数据
|
||||
|
||||
get('own').then(user => {
|
||||
get('own', { full: true }).then(user => {
|
||||
$scope.user = user;
|
||||
if ($scope.user.username === 'lcq') {
|
||||
$scope.loginMenus[dataService.LoginIndexHot].show = false;
|
||||
}
|
||||
$timeout(() => {
|
||||
$scope.searchHistory = JSON.parse(user.searchHistory || '[]');
|
||||
$scope.quickUrl = JSON.parse(user.quickUrl || '{}');
|
||||
$scope.searchHistory.forEach((item, index) => {
|
||||
$scope.searchIcon(item);
|
||||
})
|
||||
if ($scope.user.username === 'lcq') {
|
||||
$scope.loginMenus[dataService.LoginIndexHot].show = false;
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
$scope.toggleReady = function (ready) {
|
||||
|
|
@ -178,14 +185,12 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
|
|||
});
|
||||
}
|
||||
|
||||
$scope.logout = function () {
|
||||
bookmarkService.logout({})
|
||||
.then((data) => {
|
||||
console.log('logout..........', data)
|
||||
$scope.login = false;
|
||||
$state.go('login', {})
|
||||
})
|
||||
.catch((err) => console.log('logout err', err));
|
||||
$scope.logout = async function () {
|
||||
await post('logout');
|
||||
axios.defaults.headers.common['Authorization'] = "";
|
||||
localStorage.setItem("authorization", "");
|
||||
$scope.login = false;
|
||||
$state.go('login', {});
|
||||
}
|
||||
|
||||
$scope.star = function () {
|
||||
|
|
@ -218,8 +223,8 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
|
|||
$('.ui.menu a.item:eq(' + index + ')').addClass('selected');
|
||||
}
|
||||
|
||||
function saveHistory() {
|
||||
var datas = [];
|
||||
async function saveHistory() {
|
||||
let datas = [];
|
||||
$scope.searchHistory = $scope.searchHistory.slice(0, 15); // 最多保留15个历史记录
|
||||
$scope.searchHistory.forEach((item, index) => {
|
||||
datas.push({
|
||||
|
|
@ -227,41 +232,9 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
|
|||
d: item.d,
|
||||
})
|
||||
})
|
||||
|
||||
var parmes = {
|
||||
searchHistory: JSON.stringify(datas),
|
||||
};
|
||||
bookmarkService.updateSearchHistory(parmes)
|
||||
.then((data) => {
|
||||
if (data.retCode == 0) {
|
||||
// toastr.success('历史搜索更新成功', "提示");
|
||||
} else {
|
||||
toastr.error('历史搜索更新失败。错误信息:' + data.msg, "错误");
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
toastr.error('历史搜索更新失败。错误信息:' + JSON.stringify(err), "错误");
|
||||
});
|
||||
await post("updateUser", { searchHistory: JSON.stringify(datas) });
|
||||
}
|
||||
|
||||
(async () => {
|
||||
let user = await get('own', { full: true });
|
||||
$scope.searchHistory = JSON.parse(user.search_history || '[]');
|
||||
$scope.quickUrl = JSON.parse(user.quick_url || '{}');
|
||||
$scope.searchHistory.forEach((item, index) => {
|
||||
$scope.searchIcon(item)
|
||||
})
|
||||
$timeout(function () {
|
||||
var showStyle = (user && user.show_style) || 'navigate';
|
||||
if (showStyle) {
|
||||
$('.js-bookmark-dropdown' + ' .radio.checkbox').checkbox('set unchecked');
|
||||
$('.js-radio-' + showStyle).checkbox('set checked');
|
||||
$('.js-bookmark-dropdown' + ' .field.item').removeClass('active selected');
|
||||
$('.js-field-' + showStyle).addClass('active selected');
|
||||
}
|
||||
}, 1000)
|
||||
})();
|
||||
|
||||
$timeout(function () {
|
||||
$('.suggest')
|
||||
.popup({
|
||||
|
|
@ -273,13 +246,12 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
|
|||
}, 1000)
|
||||
|
||||
// 在输入文字的时候也会触发,所以不要用Ctrl,Shift之类的按键
|
||||
$document.bind("keydown", function (event) {
|
||||
$scope.$apply(function () {
|
||||
$document.bind("keydown", async function (event) {
|
||||
$scope.$apply(async function () {
|
||||
var key = event.key.toUpperCase();
|
||||
if (key == 'CONTROL' || key == 'SHIFT' || key == 'ALT') {
|
||||
// 有时候没有检测到keyup,会一直按无效,干脆过个3秒就认为你抬起来了。反正你按下我还是会给你标记为true的。
|
||||
$scope.longPress = true;
|
||||
// 有时候没有检测到keyup,会一直按无效,干脆过个3秒就认为你抬起来了
|
||||
// 反正你按下我还是会给你标记为true的。
|
||||
$timeout(function () {
|
||||
$scope.longPress = false;
|
||||
}, 3000)
|
||||
|
|
@ -335,22 +307,11 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
|
|||
var url = $scope.quickUrl[key];
|
||||
if (url) {
|
||||
$window.open(url, '_blank');
|
||||
var params = {
|
||||
url: url,
|
||||
let data = await post('shortcutBookmark', { url });
|
||||
if (!data) {
|
||||
toastr.info('网址:' + url + "还没添加到你的书签系统,请添加!", "警告");
|
||||
pubSubService.publish('TagCtr.storeBookmark', { url });
|
||||
}
|
||||
bookmarkService.jumpQuickUrl(params)
|
||||
.then((data) => {
|
||||
if (!data.id) {
|
||||
toastr.info('网址:' + url + "还没添加到你的书签系统,请添加!", "警告");
|
||||
var bookmark = {
|
||||
url: url
|
||||
}
|
||||
pubSubService.publish('TagCtr.storeBookmark', bookmark);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
app.controller('noteCtr', ['$scope', '$state', '$stateParams', '$filter', '$window', '$timeout', '$document', 'ngDialog', 'bookmarkService', 'pubSubService', 'dataService', function ($scope, $state, $stateParams, $filter, $window, $timeout, $document, ngDialog, bookmarkService, pubSubService, dataService) {
|
||||
app.controller('noteCtr', ['$scope', '$state', '$stateParams', '$filter', '$window', '$timeout', '$document', 'ngDialog', 'pubSubService', 'dataService', function ($scope, $state, $stateParams, $filter, $window, $timeout, $document, ngDialog, pubSubService, dataService) {
|
||||
console.log("Hello noteCtr...", $stateParams);
|
||||
if (dataService.smallDevice()) {
|
||||
$window.location = "http://m.mybookmark.cn/#/tags";
|
||||
|
|
|
|||
|
|
@ -22,28 +22,27 @@ app.controller('searchCtr', ['$scope', '$state', '$stateParams', '$filter', '$wi
|
|||
$scope.bookmarkCount = 0;
|
||||
$scope.tags = []
|
||||
$scope.totalPages = 0;
|
||||
$scope.currentPage = 1;
|
||||
$scope.page = 1;
|
||||
$scope.inputPage = '';
|
||||
$scope.loading = false;
|
||||
$scope.waitDelBookmark = {};
|
||||
$scope.searchHotBookmarks = false;
|
||||
var timeagoInstance = timeago();
|
||||
|
||||
$scope.changeCurrentPage = function (currentPage) {
|
||||
currentPage = parseInt(currentPage) || 0;
|
||||
console.log(currentPage);
|
||||
if (currentPage <= $scope.totalPages && currentPage >= 1) {
|
||||
$scope.currentPage = currentPage;
|
||||
$scope.changeCurrentPage = async function (page) {
|
||||
page = parseInt(page) || 0;
|
||||
console.log(page);
|
||||
if (page <= $scope.totalPages && page >= 1) {
|
||||
$scope.page = page;
|
||||
$scope.inputPage = '';
|
||||
$scope.search();
|
||||
}
|
||||
}
|
||||
|
||||
bookmarkService.getTags({})
|
||||
.then((data) => {
|
||||
$scope.tags = data;
|
||||
})
|
||||
.catch((err) => console.log('getTags err', err));
|
||||
get('tags').then((tags) => {
|
||||
$scope.tags = tags;
|
||||
})
|
||||
|
||||
// 默认登陆
|
||||
pubSubService.publish('Common.menuActive', {
|
||||
login: true,
|
||||
|
|
@ -52,7 +51,7 @@ app.controller('searchCtr', ['$scope', '$state', '$stateParams', '$filter', '$wi
|
|||
|
||||
var searchParams = {
|
||||
searchWord: $scope.searchWord,
|
||||
currentPage: 1,
|
||||
page: 1,
|
||||
perPageItems: perPageItems,
|
||||
userRange: '1', // 默认搜索自己的书签
|
||||
}
|
||||
|
|
@ -80,7 +79,7 @@ app.controller('searchCtr', ['$scope', '$state', '$stateParams', '$filter', '$wi
|
|||
}
|
||||
}
|
||||
|
||||
$scope.delBookmark = function (bookmark) {
|
||||
$scope.delBookmark = async function (bookmark) {
|
||||
$scope.waitDelBookmark = $.extend(true, {}, bookmark); // 利用jQuery执行深度拷贝
|
||||
dialog = ngDialog.open({
|
||||
template: './views/dialog-del-bookmark.html',
|
||||
|
|
@ -89,67 +88,41 @@ app.controller('searchCtr', ['$scope', '$state', '$stateParams', '$filter', '$wi
|
|||
});
|
||||
}
|
||||
|
||||
$scope.confirmDelBookmark = function (bookmarkId) {
|
||||
var params = {
|
||||
id: bookmarkId
|
||||
}
|
||||
ngDialog.close(dialog);
|
||||
bookmarkService.delBookmark(params)
|
||||
.then((data) => {
|
||||
$("#" + bookmarkId).transition({
|
||||
animation: dataService.animation(),
|
||||
duration: 500,
|
||||
onComplete: function () {
|
||||
$("#" + bookmarkId).remove();
|
||||
}
|
||||
});
|
||||
toastr.success($scope.waitDelBookmark.title + ' 书签删除成功!', "提示");
|
||||
})
|
||||
.catch((err) => {
|
||||
toastr.error($scope.waitDelBookmark.title + ' 书签删除失败!错误提示:' + JSON.stringify(err), "提示");
|
||||
});
|
||||
$scope.confirmDelBookmark = async function (id) {
|
||||
await post("delBookmark", { id })
|
||||
$("#" + id).transition({
|
||||
animation: dataService.animation(),
|
||||
duration: 500,
|
||||
onComplete: function () {
|
||||
$("#" + id).remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$scope.editBookmark = function (id) {
|
||||
$scope.editBookmark = async function (id) {
|
||||
pubSubService.publish('bookmarksCtr.editBookmark', { id });
|
||||
}
|
||||
|
||||
$scope.detailBookmark = function (bookmark) {
|
||||
$scope.detailBookmark = async function (bookmark) {
|
||||
pubSubService.publish('TagCtr.showBookmarkInfo', bookmark);
|
||||
}
|
||||
|
||||
$scope.storeBookmark = function (bookmark) {
|
||||
$scope.storeBookmark = async function (bookmark) {
|
||||
var b = $.extend(true, {}, bookmark); // 利用jQuery执行深度拷贝
|
||||
pubSubService.publish('TagCtr.storeBookmark', b);
|
||||
}
|
||||
|
||||
$scope.favoriteBookmark = function (b) {
|
||||
var bookmark = {}
|
||||
bookmark.description = '';
|
||||
bookmark.title = b.title;
|
||||
bookmark.url = b.url;
|
||||
bookmark.public = 1;
|
||||
bookmark.click_count = 1;
|
||||
|
||||
bookmarkService.favoriteBookmark(bookmark)
|
||||
.then((data) => {
|
||||
pubSubService.publish('EditCtr.inserBookmarsSuccess', data);
|
||||
if (data.title) {
|
||||
toastr.success('[ ' + data.title + ' ] 收藏成功!', "提示");
|
||||
} else {
|
||||
toastr.error('[ ' + bookmark.title + ' ] 收藏失败!', "提示");
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
toastr.error('[ ' + bookmark.title + ' ] 收藏失败,' + JSON.stringify(err), "提示");
|
||||
});
|
||||
$scope.favoriteBookmark = async function (bookmark) {
|
||||
let id = await post("addBookmark", bookmark);
|
||||
let bookmark = await get("bookmark", { id });
|
||||
pubSubService.publish('EditCtr.inserBookmarsSuccess', bookmark);
|
||||
}
|
||||
|
||||
$scope.copy = function (url) {
|
||||
$scope.copy = async function (url) {
|
||||
dataService.clipboard(url);
|
||||
}
|
||||
|
||||
$scope.search = function (page) {
|
||||
$scope.search = async function (page) {
|
||||
var params = {}
|
||||
params.userRange = $('.js-user-range').dropdown('get value');
|
||||
if (params.userRange == '1') {
|
||||
|
|
@ -185,14 +158,14 @@ app.controller('searchCtr', ['$scope', '$state', '$stateParams', '$filter', '$wi
|
|||
params.dateClickBegin = $scope.dateClickBegin;
|
||||
params.dateClickEnd = $scope.dateClickEnd;
|
||||
}
|
||||
params.currentPage = page ? page : $scope.currentPage;
|
||||
params.page = page ? page : $scope.page;
|
||||
params.perPageItems = perPageItems;
|
||||
|
||||
$scope.currentPage = params.currentPage;
|
||||
$scope.page = params.page;
|
||||
searchBookmarks(params)
|
||||
console.log('search..', page, 'params = ', params)
|
||||
}
|
||||
$scope.updateCreateDate = function () {
|
||||
$scope.updateCreateDate = async function () {
|
||||
console.log($scope.dateCreateBegin, $scope.dateCreateEnd);
|
||||
if ($scope.dateCreateBegin && $scope.dateCreateEnd) {
|
||||
$('.js-create-date').dropdown('hide');
|
||||
|
|
@ -201,7 +174,7 @@ app.controller('searchCtr', ['$scope', '$state', '$stateParams', '$filter', '$wi
|
|||
}
|
||||
}
|
||||
|
||||
$scope.updateClickDate = function () {
|
||||
$scope.updateClickDate = async function () {
|
||||
console.log($scope.dateClickBegin, $scope.dateClickEnd);
|
||||
if ($scope.dateClickBegin && $scope.dateClickEnd) {
|
||||
$('.js-click-date').dropdown('hide');
|
||||
|
|
@ -210,13 +183,13 @@ app.controller('searchCtr', ['$scope', '$state', '$stateParams', '$filter', '$wi
|
|||
}
|
||||
}
|
||||
|
||||
$scope.updateTagsSelect = function () {
|
||||
$scope.updateTagsSelect = async function () {
|
||||
$('.ui.dropdown.js-search-tags .text').removeClass('default');
|
||||
var text = $('.ui.dropdown.js-search-tags .text').text().replace('selected', '个已选');
|
||||
$('.ui.dropdown.js-search-tags .text').text(text);
|
||||
}
|
||||
|
||||
$scope.setHoverBookmark = function (bookmark) {
|
||||
$scope.setHoverBookmark = async function (bookmark) {
|
||||
$scope.hoverBookmark = bookmark;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
app.controller('settingsCtr', ['$scope', '$stateParams', '$filter', '$state', '$window', '$timeout', 'bookmarkService', 'pubSubService', 'dataService', function ($scope, $stateParams, $filter, $state, $window, $timeout, bookmarkService, pubSubService, dataService) {
|
||||
app.controller('settingsCtr', ['$scope', '$stateParams', '$filter', '$state', '$window', '$timeout', 'pubSubService', 'dataService', function ($scope, $stateParams, $filter, $state, $window, $timeout, pubSubService, dataService) {
|
||||
console.log('Hello settingsCtr......', $stateParams);
|
||||
if (dataService.smallDevice()) {
|
||||
$window.location = "http://m.mybookmark.cn/#/tags";
|
||||
|
|
@ -12,153 +12,56 @@ app.controller('settingsCtr', ['$scope', '$stateParams', '$filter', '$state', '$
|
|||
$scope.passwordNew2 = "";
|
||||
$scope.user = {};
|
||||
$scope.tagCnt = 0;
|
||||
$scope.bookmarkCnt = 0;
|
||||
$scope.loadShowStyle = false;
|
||||
$scope.bookmarkCount = 0;
|
||||
$scope.form[($stateParams && $stateParams.formIndex) || 0] = true;
|
||||
$scope.key = '';
|
||||
$scope.url = '';
|
||||
$scope.quickUrl = {};
|
||||
$scope.updateLogs = [];
|
||||
$scope.logsUrl = 'https://github.com/luchenqun/my-bookmark/commits/master';
|
||||
$scope.loadingLogs = false;
|
||||
|
||||
$scope.getUpdateLog = function (url) {
|
||||
if ($scope.updateLogs.length > 0 && url == 'https://github.com/luchenqun/my-bookmark/commits/master') {
|
||||
toastr.warning('没有更早的日志可供您查看了!', "错误");
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.loadingLogs = true;
|
||||
bookmarkService.getUpdateLog({
|
||||
url: url
|
||||
})
|
||||
.then((data) => {
|
||||
Array.prototype.push.apply($scope.updateLogs, data.updateLogs);
|
||||
$scope.logsUrl = data.oldUrl;
|
||||
$scope.loadingLogs = false;
|
||||
})
|
||||
.catch((err) => {
|
||||
toastr.error('获取更新日志失败。错误信息:' + JSON.stringify(err), "错误");
|
||||
$scope.loadingLogs = false;
|
||||
});
|
||||
}
|
||||
|
||||
$scope.changeForm = function (index) {
|
||||
$scope.changeForm = async function (index) {
|
||||
console.log("changeForm = ", index);
|
||||
$scope.form = $scope.form.map(() => false);
|
||||
$scope.form[index] = true;
|
||||
$scope.updateLogs = [];
|
||||
|
||||
if (index == 0 || index == 1 || index == 4) {
|
||||
$scope.loadShowStyle = true;
|
||||
bookmarkService.userInfo({})
|
||||
.then((data) => {
|
||||
$scope.user = data;
|
||||
if (index == 0) {
|
||||
updateShowStyle(($scope.user && $scope.user.show_style) || 'navigate');
|
||||
$scope.loadShowStyle = false;
|
||||
}
|
||||
if (index == 4) {
|
||||
function objKeySort(obj) {
|
||||
var newkey = Object.keys(obj).sort();
|
||||
var newObj = {};
|
||||
for (var i = 0; i < newkey.length; i++) {
|
||||
newObj[newkey[i]] = obj[newkey[i]];
|
||||
}
|
||||
return newObj;//返回排好序的新对象
|
||||
}
|
||||
|
||||
$scope.quickUrl = objKeySort(JSON.parse($scope.user.quick_url || '{}'));
|
||||
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
dataService.netErrorHandle(err, $state)
|
||||
$scope.loadShowStyle = false;
|
||||
});
|
||||
}
|
||||
|
||||
if (index == 1) {
|
||||
bookmarkService.getTags({})
|
||||
.then((data) => {
|
||||
$scope.tagCnt = data.length;
|
||||
$scope.bookmarkCnt = 0;
|
||||
data.forEach((tag) => {
|
||||
$scope.bookmarkCnt += tag.cnt;
|
||||
})
|
||||
})
|
||||
.catch((err) => {
|
||||
dataService.netErrorHandle(err, $state)
|
||||
});
|
||||
}
|
||||
|
||||
if (index == 5) {
|
||||
$scope.logsUrl = 'https://github.com/luchenqun/my-bookmark/commits/master'
|
||||
$scope.getUpdateLog($scope.logsUrl);
|
||||
let user = await get('own', { full: true });
|
||||
let tags = await get('tags', { bookmarkCount: true, noteCount: true });
|
||||
$timeout(() => {
|
||||
$scope.user = user
|
||||
$scope.quickUrl = objKeySort(JSON.parse($scope.user.quickUrl || '{}'));
|
||||
$scope.bookmarkCount = 0;
|
||||
$scope.tagCnt = tags.length;
|
||||
for (const tag of tags) {
|
||||
$scope.bookmarkCount += tag.bookmarkCount;
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
$scope.changeForm($scope.form.indexOf(true)); // 马上调用一次
|
||||
|
||||
$scope.resetPassword = function () {
|
||||
$scope.resetPassword = async function () {
|
||||
if (!$scope.passwordOrgin || !$scope.passwordNew1 || !$scope.passwordNew2) {
|
||||
toastr.error('原密码跟新密码不能为空', "错误");
|
||||
return;
|
||||
}
|
||||
|
||||
if ($scope.passwordNew1 == $scope.passwordNew2) {
|
||||
var parmes = {
|
||||
passwordNew: $scope.passwordNew1,
|
||||
passwordOrgin: $scope.passwordOrgin,
|
||||
};
|
||||
await post('resetUserPwd', { old: $scope.passwordOrgin, password: $scope.passwordNew1 });
|
||||
await post('logout');
|
||||
|
||||
bookmarkService.resetPassword(parmes)
|
||||
.then((data) => {
|
||||
if (data.retCode == 0) {
|
||||
toastr.success('密码更新成功,请重新登陆!', "提示");
|
||||
// 注销登陆
|
||||
bookmarkService.logout({})
|
||||
.then((data) => {
|
||||
console.log('logout..........', data)
|
||||
pubSubService.publish('Common.menuActive', {
|
||||
login: false,
|
||||
index: dataService.NotLoginIndexLogin
|
||||
});
|
||||
$state.go('login', {})
|
||||
})
|
||||
.catch((err) => console.log('logout err', err));
|
||||
} else {
|
||||
toastr.error('密码更新失败。错误信息:' + data.msg, "错误");
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
toastr.error('密码更新失败。错误信息:' + JSON.stringify(err), "错误");
|
||||
});
|
||||
axios.defaults.headers.common['Authorization'] = "";
|
||||
localStorage.setItem("authorization", "");
|
||||
pubSubService.publish('Common.menuActive', {
|
||||
login: false,
|
||||
index: dataService.NotLoginIndexLogin
|
||||
});
|
||||
$state.go('login', {})
|
||||
} else {
|
||||
toastr.error('新密码两次输入不一致', "错误");
|
||||
}
|
||||
}
|
||||
|
||||
$scope.updateDefaultShowStyle = function (showStyle) {
|
||||
console.log(showStyle)
|
||||
var parmes = {
|
||||
showStyle: showStyle,
|
||||
};
|
||||
bookmarkService.updateShowStyle(parmes)
|
||||
.then((data) => {
|
||||
if (data.retCode == 0) {
|
||||
toastr.success('书签默认显示风格配置更新成功', "提示");
|
||||
} else {
|
||||
toastr.error('书签默认显示风格配置。错误信息:' + data.msg, "错误");
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
toastr.error('书签默认显示风格配置。错误信息:' + JSON.stringify(err), "错误");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$scope.quickKey = function (key) {
|
||||
$scope.quickKey = async function (key) {
|
||||
key = key.toUpperCase();
|
||||
console.log('key = ', key);
|
||||
if (!(key >= 'A' && key <= 'Z')) {
|
||||
|
|
@ -170,7 +73,7 @@ app.controller('settingsCtr', ['$scope', '$stateParams', '$filter', '$state', '$
|
|||
});
|
||||
}
|
||||
|
||||
$scope.addQuickUrl = function () {
|
||||
$scope.addQuickUrl = async function () {
|
||||
if ($scope.url == '' || $scope.key == '') {
|
||||
toastr.warning('快捷键或者网站地址为空!', "警告");
|
||||
}
|
||||
|
|
@ -208,35 +111,20 @@ app.controller('settingsCtr', ['$scope', '$stateParams', '$filter', '$state', '$
|
|||
$scope.key = '';
|
||||
}
|
||||
|
||||
$scope.delUrl = function (key) {
|
||||
$scope.delUrl = async function (key) {
|
||||
delete $scope.quickUrl[key];
|
||||
saveQuickUrl();
|
||||
}
|
||||
|
||||
$scope.jumpCommit = function (url) {
|
||||
$window.open(url, '_blank');
|
||||
}
|
||||
|
||||
$scope.exportBookmark = function () {
|
||||
$scope.exportBookmark = async function () {
|
||||
var userId = $scope.user && $scope.user.id;
|
||||
if (userId) {
|
||||
// toastr.warning('功能正在开发中,敬请期待......', '提示');
|
||||
// return;
|
||||
$window.open("api/download?userId=" + userId + "&type=exportbookmark");
|
||||
} else {
|
||||
toastr.warning('用户信息无法获取到,请尝试按刷新网页再尝试!', '提示');
|
||||
}
|
||||
}
|
||||
|
||||
function updateShowStyle(showStyle) {
|
||||
setTimeout(function () {
|
||||
if (showStyle) {
|
||||
$('.js-default-show-style' + ' .radio.checkbox').checkbox('set unchecked');
|
||||
$('.js-radio-default-' + showStyle).checkbox('set checked');
|
||||
}
|
||||
}, 100)
|
||||
}
|
||||
|
||||
setTimeout(function () {
|
||||
$("#fileuploader").uploadFile({
|
||||
url: "/api/uploadBookmarkFile",
|
||||
|
|
@ -265,24 +153,18 @@ app.controller('settingsCtr', ['$scope', '$stateParams', '$filter', '$state', '$
|
|||
index: dataService.LoginIndexSettings
|
||||
});
|
||||
|
||||
function saveQuickUrl() {
|
||||
var parmes = {
|
||||
quickUrl: JSON.stringify($scope.quickUrl),
|
||||
};
|
||||
bookmarkService.updateQuickUrl(parmes)
|
||||
.then((data) => {
|
||||
if (data.retCode == 0) {
|
||||
toastr.success('全局快捷键更新成功', "提示");
|
||||
pubSubService.publish('Settings.quickUrl', {
|
||||
quickUrl: $scope.quickUrl
|
||||
});
|
||||
} else {
|
||||
toastr.error('全局快捷键更新失败。错误信息:' + data.msg, "错误");
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
toastr.error('全局快捷键更新失败。错误信息:' + JSON.stringify(err), "错误");
|
||||
});
|
||||
async function saveQuickUrl() {
|
||||
await post("updateUser", { quickUrl: JSON.stringify($scope.quickUrl) });
|
||||
toastr.success('全局快捷键更新成功', "提示");
|
||||
}
|
||||
|
||||
function objKeySort(obj) {
|
||||
var newkey = Object.keys(obj).sort();
|
||||
var newObj = {};
|
||||
for (var i = 0; i < newkey.length; i++) {
|
||||
newObj[newkey[i]] = obj[newkey[i]];
|
||||
}
|
||||
return newObj;//返回排好序的新对象
|
||||
}
|
||||
|
||||
dataService.transition('.js-segment-settings');
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
app.controller('tagsCtr', ['$scope', '$filter', '$state', '$window', '$stateParams', '$timeout', '$document', 'ngDialog', 'bookmarkService', 'pubSubService', 'dataService', function ($scope, $filter, $state, $window, $stateParams, $timeout, $document, ngDialog, bookmarkService, pubSubService, dataService) {
|
||||
app.controller('tagsCtr', ['$scope', '$filter', '$state', '$window', '$stateParams', '$timeout', '$document', 'ngDialog', 'pubSubService', 'dataService', function ($scope, $filter, $state, $window, $stateParams, $timeout, $document, ngDialog, pubSubService, dataService) {
|
||||
console.log("Hello tagsCtr...", $stateParams);
|
||||
if (dataService.smallDevice()) {
|
||||
$window.location = "http://m.mybookmark.cn/#/tags";
|
||||
|
|
@ -119,33 +119,23 @@ app.controller('tagsCtr', ['$scope', '$filter', '$state', '$window', '$statePara
|
|||
});
|
||||
}
|
||||
|
||||
$scope.confirmDelBookmark = function (bookmarkId) {
|
||||
var params = {
|
||||
id: bookmarkId
|
||||
}
|
||||
$scope.confirmDelBookmark = async function (id) {
|
||||
ngDialog.close(dialog);
|
||||
bookmarkService.delBookmark(params)
|
||||
.then((data) => {
|
||||
$("#" + bookmarkId).transition({
|
||||
animation: dataService.animation(),
|
||||
duration: 500,
|
||||
onComplete: function () {
|
||||
$("#" + bookmarkId).remove();
|
||||
}
|
||||
});
|
||||
// 更新分类里面含有书签的数量
|
||||
$scope.tags.forEach((t1) => {
|
||||
$scope.waitDelBookmark.tags.forEach((t2) => {
|
||||
if (t1.id == t2.id) {
|
||||
t1.bookmarkCount--;
|
||||
}
|
||||
})
|
||||
})
|
||||
toastr.success($scope.waitDelBookmark.title + ' 书签删除成功!', "提示");
|
||||
})
|
||||
.catch((err) => {
|
||||
toastr.error($scope.waitDelBookmark.title + ' 书签删除失败!错误提示:' + JSON.stringify(err), "提示");
|
||||
});
|
||||
await post("delBookmark", { id })
|
||||
$("#" + id).transition({
|
||||
animation: dataService.animation(),
|
||||
duration: 500,
|
||||
onComplete: function () {
|
||||
$("#" + id).remove();
|
||||
}
|
||||
});
|
||||
|
||||
// 更新分类里面含有书签的数量
|
||||
$scope.tags.forEach((tag) => {
|
||||
if (tag.id == $scope.waitDelBookmark.tagId) {
|
||||
tag.bookmarkCount--;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
$scope.editBookmark = function (id) {
|
||||
|
|
@ -193,49 +183,31 @@ app.controller('tagsCtr', ['$scope', '$filter', '$state', '$window', '$statePara
|
|||
tag.edit = true;
|
||||
}
|
||||
|
||||
$scope.updateTagShow = function (tag, show) {
|
||||
var params = {
|
||||
id: tag.id,
|
||||
show: show,
|
||||
}
|
||||
bookmarkService.updateTagShow(params)
|
||||
.then((data) => {
|
||||
if (data.retCode == 0) {
|
||||
toastr.success(tag.name + ' 更新成功!', "提示");
|
||||
tag.show = show;
|
||||
} else {
|
||||
toastr.error(tag.name + ' 更新失败!错误提示:' + data.msg, "提示");
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
toastr.error(tag.name + ' 更新失败!错误提示:' + err, "提示");
|
||||
});
|
||||
$scope.updateTagShow = async function (tag, show) {
|
||||
await post("updateTag", { id: tag.id, show });
|
||||
toastr.success(tag.name + ' 更新成功!', "提示");
|
||||
$timeout(() => {
|
||||
tag.show = show;
|
||||
});
|
||||
}
|
||||
|
||||
$scope.updateTag = function (tag) {
|
||||
$scope.updateTag = async function (tag) {
|
||||
if (tag.name == tag.oldName) {
|
||||
toastr.warning('您没有编辑分类', "警告");
|
||||
return;
|
||||
}
|
||||
tag.edit = false;
|
||||
var params = {
|
||||
id: tag.id,
|
||||
name: tag.name,
|
||||
}
|
||||
} else {
|
||||
tag.edit = false;
|
||||
var params = {
|
||||
id: tag.id,
|
||||
name: tag.name,
|
||||
}
|
||||
|
||||
bookmarkService.updateTagName(params)
|
||||
.then((data) => {
|
||||
if (data.retCode == 0) {
|
||||
toastr.success(tag.name + ' 更新成功!', "提示");
|
||||
} else {
|
||||
toastr.error(tag.name + ' 更新失败!错误提示:' + data.msg, "提示");
|
||||
$scope.backTag(tag);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
toastr.error(tag.name + ' 更新失败!错误提示:' + err, "提示");
|
||||
try {
|
||||
await post('updateTag', params);
|
||||
toastr.success(tag.name + ' 更新成功!', "提示");
|
||||
} catch (error) {
|
||||
$scope.backTag(tag);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$scope.delTag = function (tag) {
|
||||
|
|
@ -248,43 +220,31 @@ app.controller('tagsCtr', ['$scope', '$filter', '$state', '$window', '$statePara
|
|||
});
|
||||
}
|
||||
|
||||
$scope.confirmDelTag = function (tagId, tagName) {
|
||||
$scope.confirmDelTag = async function (id, tagName) {
|
||||
ngDialog.close(dialog);
|
||||
var params = {
|
||||
del: (tagName == '未分类' || tagName == "收藏") ? false : true,
|
||||
id: tagId,
|
||||
}
|
||||
bookmarkService.delTag(params)
|
||||
.then((data) => {
|
||||
if (data.retCode == 0) {
|
||||
toastr.success('[ ' + tagName + ' ]分类删除成功!', "提示");
|
||||
var index = -1;
|
||||
$scope.tags.forEach((tag, i) => {
|
||||
if (tag.id == tagId) {
|
||||
index = i;
|
||||
if (tagName == '未分类' || tagName == "收藏") {
|
||||
toastr.error('默认分类不允许删除', "提示");
|
||||
} else {
|
||||
await post("delTag", { id });
|
||||
|
||||
let index = 0;
|
||||
for (const tag of $scope.tags) {
|
||||
if (tag.id == id) {
|
||||
$("#tag" + id).transition({
|
||||
animation: dataService.animation(),
|
||||
duration: 500,
|
||||
onComplete: function () {
|
||||
$("#tag" + id).remove();
|
||||
$scope.tags.splice(index, 1);
|
||||
}
|
||||
})
|
||||
if (index !== -1 && tagName != '未分类' && tagName != "收藏") {
|
||||
$("#tag" + tagId).transition({
|
||||
animation: dataService.animation(),
|
||||
duration: 500,
|
||||
onComplete: function () {
|
||||
$("#tag" + tagId).remove();
|
||||
$scope.tags.splice(index, 1);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
getTags();
|
||||
}
|
||||
} else {
|
||||
toastr.error('[ ' + tagName + ' ]分类删除失败!' + data.msg, "提示");
|
||||
getTags();
|
||||
});
|
||||
break;
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
toastr.error('分类删除失败!错误提示:' + JSON.stringify(err), "提示");
|
||||
getTags();
|
||||
});
|
||||
index++;
|
||||
}
|
||||
|
||||
getTags();
|
||||
}
|
||||
}
|
||||
|
||||
$scope.showAddTag = function () {
|
||||
|
|
@ -301,7 +261,7 @@ app.controller('tagsCtr', ['$scope', '$filter', '$state', '$window', '$statePara
|
|||
}
|
||||
}
|
||||
|
||||
$scope.addTag = function (tag) {
|
||||
$scope.addTag = async function (tag) {
|
||||
console.log(tag);
|
||||
if ($scope.tags.length >= 30) {
|
||||
toastr.error('标签个数总数不能超过30个!不允许再添加新分类,如有需求,请联系管理员。', "提示");
|
||||
|
|
@ -319,17 +279,7 @@ app.controller('tagsCtr', ['$scope', '$filter', '$state', '$window', '$statePara
|
|||
|
||||
if (tag) {
|
||||
ngDialog.close(dialog);
|
||||
|
||||
var tags = [];
|
||||
tags.push(tag);
|
||||
bookmarkService.addTags(tags)
|
||||
.then((data) => {
|
||||
toastr.success('[ ' + tag + ' ]插入分类成功!将自动更新分类信息<br />注意:分类页面只有分类下面有书签才显示分类', "提示");
|
||||
getTags();
|
||||
})
|
||||
.catch((err) => {
|
||||
toastr.warning('[ ' + tag + ' ]插入分类失败:' + JSON.stringify(err), "提示");
|
||||
});
|
||||
await post("addTag", { name: tag })
|
||||
} else {
|
||||
toastr.warning('您可能没有输入分类或者输入的分类有误', "提示");
|
||||
}
|
||||
|
|
@ -345,41 +295,27 @@ app.controller('tagsCtr', ['$scope', '$filter', '$state', '$window', '$statePara
|
|||
$scope.tags.forEach((tag, index) => {
|
||||
$scope.tagsIndex[index] = {
|
||||
id: tag.id,
|
||||
index: index,
|
||||
sort: index,
|
||||
}
|
||||
})
|
||||
console.log('storeTagIndex');
|
||||
}
|
||||
|
||||
$scope.updateTagIndex = function () {
|
||||
$scope.updateTagIndex = async function () {
|
||||
// 要开个timer,因为释放鼠标模型还没更新
|
||||
setTimeout(function () {
|
||||
var needUpdate = false;
|
||||
for (var i = 0; i < $scope.tags.length; i++) {
|
||||
if ($scope.tags[i].id != $scope.tagsIndex[i].id) {
|
||||
setTimeout(async () => {
|
||||
let needUpdate = false;
|
||||
for (let index = 0; index < $scope.tags.length; index++) {
|
||||
if ($scope.tags[index].id != $scope.tagsIndex[index].id) {
|
||||
needUpdate = true;
|
||||
}
|
||||
$scope.tagsIndex[i] = {
|
||||
id: $scope.tags[i].id,
|
||||
index: i,
|
||||
$scope.tagsIndex[index] = {
|
||||
id: $scope.tags[index].id,
|
||||
sort: index,
|
||||
}
|
||||
}
|
||||
if (needUpdate) {
|
||||
bookmarkService.updateTagsIndex($scope.tagsIndex)
|
||||
.then((data) => {
|
||||
if (data.retCode == 0) {
|
||||
toastr.success('分类排序更新成功!', "提示");
|
||||
} else {
|
||||
toastr.error('分类排序更新失败!', "提示");
|
||||
getTags();
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
toastr.error('分类排序更新失败!错误提示:' + JSON.stringify(err), "提示");
|
||||
getTags();
|
||||
});
|
||||
await post('updateTagSort', { tags: $scope.tagsIndex });
|
||||
}
|
||||
console.log('updateTagIndex needUpdate = ' + needUpdate)
|
||||
}, 300)
|
||||
}
|
||||
|
||||
|
|
@ -454,18 +390,12 @@ app.controller('tagsCtr', ['$scope', '$filter', '$state', '$window', '$statePara
|
|||
if (bookmark.id == data.id) {
|
||||
bookmark.title = data.title;
|
||||
bookmark.url = data.url;
|
||||
bookmark.tags = data.tags;
|
||||
bookmark.description = data.description;
|
||||
find = true;
|
||||
// if ($scope.order[bookmark.type - 1]) {
|
||||
// dataService.transition('#' + bookmark.id, {
|
||||
// duration: 1000,
|
||||
// });
|
||||
// }
|
||||
}
|
||||
})
|
||||
if (!find) {
|
||||
if (data.tags.map((tag) => tag.id).indexOf($scope.currentTagId) >= 0) {
|
||||
if ($scope.tags.map((tag) => tag.id).indexOf($scope.currentTagId) >= 0) {
|
||||
if (!$scope.editMode) {
|
||||
$scope.getBookmarks(null, null, null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,9 +13,6 @@
|
|||
<i class="{{ item.icon }}" style="cursor:default;"></i>
|
||||
<span style="color: #7B77C5">{{ item.d}}</span>
|
||||
</div>
|
||||
<!-- <div class="center aligned two wide column" style="margin: -10px 0px 0px 0px;padding:0px;">
|
||||
<div style="cursor:default;float: right;" ng-click="delHistory(item.t, item.d)">删除</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="row" style="height: 20px;background: #f2f2f2" ng-click="delHistory()">
|
||||
<div class="center aligned sixteen wide column" style="margin: -10px 0px 0px 0px;padding:0px;">
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
<a class="item" ng-class="{active:form[2]}" ng-click="changeForm(2)">上传导出 </a>
|
||||
<a class="item" ng-class="{active:form[3]}" ng-click="changeForm(3)">网站说明 </a>
|
||||
<a class="item" ng-class="{active:form[4]}" ng-click="changeForm(4)">全局链接 </a>
|
||||
<a class="item" ng-class="{active:form[5]}" ng-click="changeForm(5)">更新日志 </a>
|
||||
<a class="item" ng-class="{active:form[6]}" ng-click="changeForm(6)">请喝咖啡 </a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -29,42 +28,19 @@
|
|||
<input type="password" placeholder="" ng-model="passwordNew2" />
|
||||
</div>
|
||||
<button class="ui button" type="submit" ng-click="resetPassword()">重置密码</button>
|
||||
<h4 class="ui horizontal divider header">
|
||||
书签默认显示方式配置
|
||||
</h4>
|
||||
<div class="inline fields js-default-show-style" ng-show="!loadShowStyle">
|
||||
<div class="field" ng-click="updateDefaultShowStyle('navigate')">
|
||||
<div class="ui radio checkbox js-radio-default-navigate">
|
||||
<input type="radio" name="default-show-style" checked="checked" />
|
||||
<label>导航</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field" ng-click="updateDefaultShowStyle('table')">
|
||||
<div class="ui radio checkbox js-radio-default-table">
|
||||
<input type="radio" name="default-show-style" />
|
||||
<label>表格</label>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="field" ng-click="updateDefaultShowStyle('card')">
|
||||
<div class="ui radio checkbox js-radio-default-card">
|
||||
<input type="radio" name="default-show-style">
|
||||
<label>卡片</label>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
</form>
|
||||
<div class="ui four statistics" style="margin-top:30px;" ng-show="form[1]">
|
||||
<div class="statistic">
|
||||
<div class="text value">
|
||||
{{user.created_at.substring(0, 4)}}<br />
|
||||
{{user.created_at.substring(5, 10)}}
|
||||
{{user.createdAt.substring(0, 4)}}<br />
|
||||
{{user.createdAt.substring(5, 10)}}
|
||||
</div>
|
||||
<div class="label">注册时间</div>
|
||||
</div>
|
||||
<div class="statistic">
|
||||
<div class="text value">
|
||||
{{user.last_login.substring(0, 4)}}<br />
|
||||
{{user.last_login.substring(5, 10)}}
|
||||
{{user.lastLogin.substring(0, 4)}}<br />
|
||||
{{user.lastLogin.substring(5, 10)}}
|
||||
</div>
|
||||
<div class="label">最近登陆</div>
|
||||
</div>
|
||||
|
|
@ -78,34 +54,11 @@
|
|||
<div class="statistic">
|
||||
<div class="value">
|
||||
<i class="bookmark icon"></i>
|
||||
{{ bookmarkCnt }}
|
||||
{{ bookmarkCount }}
|
||||
</div>
|
||||
<div class="label">书签数目</div>
|
||||
</div>
|
||||
</div>
|
||||
<table class="ui celled table" ng-if="form[1]" ng-show="user.activeUsers.length > 0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="4">
|
||||
用户活跃度排名
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>用户名</th>
|
||||
<th>邮箱</th>
|
||||
<th>注册时间</th>
|
||||
<th>最后登陆</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="activeUser in user.activeUsers">
|
||||
<td>{{ activeUser.username }}</td>
|
||||
<td>{{ activeUser.email }}</td>
|
||||
<td>{{ activeUser.created_at }}</td>
|
||||
<td>{{ activeUser.last_login }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<form class="ui form" ng-show="form[2]">
|
||||
<h2 class="ui dividing header">上传浏览器书签到系统</h2>
|
||||
<div id="fileuploader" style="min-width:100px">点我上传</div>
|
||||
|
|
@ -198,20 +151,6 @@
|
|||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="ui container js-p-info" ng-show="form[5]">
|
||||
<div class="ui message" ng-repeat="updateLog in updateLogs">
|
||||
<div class="header">{{ updateLog.date }}</div>
|
||||
<ul class="list" style="cursor: default;">
|
||||
<li ng-repeat="log in updateLog.logs">
|
||||
<span title="点击可查看代码变化" ng-click="jumpCommit(log.href)">{{log.commit}}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div ng-show="loadingLogs"><img class="ui centered medium image" src="/images/loading.gif" /></div>
|
||||
<button class="fluid ui button" ng-click="getUpdateLog(logsUrl)" ng-show="!loadingLogs">
|
||||
更早日志
|
||||
</button>
|
||||
</div>
|
||||
<div class="ui container js-p-info" ng-show="form[6]">
|
||||
<h3 class="ui dividing header">赞赏说明</h3>
|
||||
<p>赞赏金额主要用于服务器的租用与域名的费用,对于赞赏有以下几点说明:</p>
|
||||
|
|
|
|||
Loading…
Reference in New Issue