增加一个搜索历史表
This commit is contained in:
parent
787b551696
commit
03d5807cc2
|
|
@ -68,6 +68,7 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
|
||||||
} else {
|
} else {
|
||||||
$window.open('http://www.baidu.com/s?tn=mybookmark.cn&ch=3&ie=utf-8&wd=' + encodeURIComponent(searchWord), '_blank');
|
$window.open('http://www.baidu.com/s?tn=mybookmark.cn&ch=3&ie=utf-8&wd=' + encodeURIComponent(searchWord), '_blank');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果第一个显示的搜索分类跟关键字跟列表一样,那么不要更新
|
// 如果第一个显示的搜索分类跟关键字跟列表一样,那么不要更新
|
||||||
var newItem = {
|
var newItem = {
|
||||||
t: searchOption,
|
t: searchOption,
|
||||||
|
|
@ -85,6 +86,7 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
|
||||||
}
|
}
|
||||||
|
|
||||||
var datas = [];
|
var datas = [];
|
||||||
|
$scope.searchHistory.slice(0, 15); // 最多保留15个历史记录
|
||||||
$scope.searchHistory.forEach((item, index) => {
|
$scope.searchHistory.forEach((item, index) => {
|
||||||
datas.push({
|
datas.push({
|
||||||
t: item.t,
|
t: item.t,
|
||||||
|
|
@ -93,8 +95,12 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
|
||||||
})
|
})
|
||||||
|
|
||||||
var parmes = {
|
var parmes = {
|
||||||
searchHistory: JSON.stringify(datas),
|
searchHistory: JSON.stringify(data),
|
||||||
};
|
};
|
||||||
|
// 大于30的不保存到数据库
|
||||||
|
if (searchWord.length >= 30) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
bookmarkService.updateSearchHistory(parmes)
|
bookmarkService.updateSearchHistory(parmes)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (data.retCode == 0) {
|
if (data.retCode == 0) {
|
||||||
|
|
@ -161,7 +167,7 @@ app.controller('menuCtr', ['$scope', '$stateParams', '$state', '$window', '$time
|
||||||
.popup({
|
.popup({
|
||||||
on: 'focus'
|
on: 'focus'
|
||||||
});
|
});
|
||||||
}, 1000)
|
}, 500)
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
toastr.error('获取信息失败。错误信息:' + JSON.stringify(err), "错误");
|
toastr.error('获取信息失败。错误信息:' + JSON.stringify(err), "错误");
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ CREATE TABLE `users` (
|
||||||
`created_at` datetime DEFAULT now(), -- 创建时间
|
`created_at` datetime DEFAULT now(), -- 创建时间
|
||||||
`last_login` datetime DEFAULT NULL, -- 最后一次登录时间
|
`last_login` datetime DEFAULT NULL, -- 最后一次登录时间
|
||||||
`show_style` char(16) NOT NULL DEFAULT 'navigate', -- 显示风格
|
`show_style` char(16) NOT NULL DEFAULT 'navigate', -- 显示风格
|
||||||
`search_history` varchar(255) DEFAULT NULL, -- 历史搜索记录
|
`search_history` varchar(512) DEFAULT NULL, -- 历史搜索记录
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `username` (`username`),
|
UNIQUE KEY `username` (`username`),
|
||||||
UNIQUE KEY `email` (`email`)
|
UNIQUE KEY `email` (`email`)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue