Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
13786834a0 | |||
|
e0dccb6fd2 | ||
845b1b077e | |||
|
bb62066b82 | ||
63f1c9a54e | |||
|
c9156f12d1 | ||
325401e198 | |||
|
5126e31867 |
19
README.md
19
README.md
@ -22,9 +22,25 @@
|
|||||||
|
|
||||||
帮助文档:[点击跳转](https://blog.fleyx.com/blog/detail/20220329/)
|
帮助文档:[点击跳转](https://blog.fleyx.com/blog/detail/20220329/)
|
||||||
|
|
||||||
|
- 支持从 chrome,edge,firefox 等浏览器导入书签数据。
|
||||||
|
- 支持从 OneEnv 导入书签数据
|
||||||
|
- 树型多级目录支持
|
||||||
|
- 支持导出标准 html 书签文件
|
||||||
|
- 强大的检索功能,支持拼音检索
|
||||||
|
- 支持浏览器插件,安装插件以后可右键添加书签
|
||||||
|
|
||||||
# 更新日志
|
# 更新日志
|
||||||
|
|
||||||
## 2023-08-13
|
## 1.4.1
|
||||||
|
|
||||||
|
- 修复书签名过长无法导入问题
|
||||||
|
|
||||||
|
## 1.4
|
||||||
|
|
||||||
|
- 优化首图加载逻辑
|
||||||
|
- 支持 OneEnv 备份文件导入
|
||||||
|
|
||||||
|
## 1.3
|
||||||
|
|
||||||
![pic](https://s3.fleyx.com/picbed/2023/08/Snipaste_2023-08-13_15-01-20.png)
|
![pic](https://s3.fleyx.com/picbed/2023/08/Snipaste_2023-08-13_15-01-20.png)
|
||||||
|
|
||||||
@ -32,7 +48,6 @@
|
|||||||
|
|
||||||
位置:右上角个人中心-管理搜索引擎
|
位置:右上角个人中心-管理搜索引擎
|
||||||
|
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
- [x] 主页功能
|
- [x] 主页功能
|
||||||
|
@ -43,6 +43,7 @@ import java.io.File;
|
|||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.SocketTimeoutException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
@ -280,11 +281,14 @@ public class BookmarkServiceImpl implements BookmarkService {
|
|||||||
bookmark.setUserId(userId);
|
bookmark.setUserId(userId);
|
||||||
bookmark.setCreateTime(System.currentTimeMillis());
|
bookmark.setCreateTime(System.currentTimeMillis());
|
||||||
bookmark.setAddTime(bookmark.getCreateTime());
|
bookmark.setAddTime(bookmark.getCreateTime());
|
||||||
bookmark.setIcon(getIconPath(bookmark.getUrl(), bookmark.getIcon(), bookmark.getIconUrl()));
|
bookmark.setIcon(bookmark.getType() == 1 ? "" : getIconPath(bookmark.getUrl(), bookmark.getIcon(), bookmark.getIconUrl(), true));
|
||||||
//文件夹和书签都建立搜索key
|
//文件夹和书签都建立搜索key
|
||||||
pinYinService.changeBookmark(bookmark);
|
pinYinService.changeBookmark(bookmark);
|
||||||
bookmarkDao.insertOne(bookmark);
|
bookmarkDao.insertOne(bookmark);
|
||||||
userApi.versionPlus(userId);
|
userApi.versionPlus(userId);
|
||||||
|
if (StrUtil.isEmpty(bookmark.getIcon()) && bookmark.getType() == 0) {
|
||||||
|
updateIconAsync(bookmark.getBookmarkId(), bookmark.getUrl(), userId);
|
||||||
|
}
|
||||||
return bookmark;
|
return bookmark;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,13 +298,33 @@ public class BookmarkServiceImpl implements BookmarkService {
|
|||||||
bookmark.setUserId(userId);
|
bookmark.setUserId(userId);
|
||||||
if (bookmark.getType() == 0) {
|
if (bookmark.getType() == 0) {
|
||||||
pinYinService.changeBookmark(bookmark);
|
pinYinService.changeBookmark(bookmark);
|
||||||
bookmark.setIcon(getIconPath(bookmark.getUrl(), null, null));
|
bookmark.setIcon(getIconPath(bookmark.getUrl(), null, null, true));
|
||||||
|
if (StrUtil.isEmpty(bookmark.getIcon())) {
|
||||||
|
updateIconAsync(bookmark.getBookmarkId(), bookmark.getUrl(), userId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
bookmarkDao.editBookmark(bookmark);
|
bookmarkDao.editBookmark(bookmark);
|
||||||
userApi.versionPlus(userId);
|
userApi.versionPlus(userId);
|
||||||
return bookmark.getIcon();
|
return bookmark.getIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 异步更新书签icon
|
||||||
|
*
|
||||||
|
* @param id 书签id
|
||||||
|
* @param url 书签url
|
||||||
|
* @param userId userId
|
||||||
|
*/
|
||||||
|
private void updateIconAsync(int id, String url, int userId) {
|
||||||
|
ThreadPoolUtil.execute(() -> {
|
||||||
|
String icon = getIconPath(url, null, null, false);
|
||||||
|
if (StrUtil.isEmpty(icon)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bookmarkDao.updateIcon(id, icon);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@ -353,7 +377,7 @@ public class BookmarkServiceImpl implements BookmarkService {
|
|||||||
while (!(deal = bookmarkDao.selectUserNoIcon(userId, start, size)).isEmpty()) {
|
while (!(deal = bookmarkDao.selectUserNoIcon(userId, start, size)).isEmpty()) {
|
||||||
start += size;
|
start += size;
|
||||||
deal.forEach(item -> {
|
deal.forEach(item -> {
|
||||||
String icon = getIconPath(item.getUrl(), null, null);
|
String icon = getIconPath(item.getUrl(), null, null, false);
|
||||||
if (StrUtil.isNotEmpty(icon)) {
|
if (StrUtil.isNotEmpty(icon)) {
|
||||||
bookmarkDao.updateIcon(item.getBookmarkId(), icon);
|
bookmarkDao.updateIcon(item.getBookmarkId(), icon);
|
||||||
}
|
}
|
||||||
@ -387,13 +411,14 @@ public class BookmarkServiceImpl implements BookmarkService {
|
|||||||
/**
|
/**
|
||||||
* 获取icon,通过网络获取,或者从base64还原
|
* 获取icon,通过网络获取,或者从base64还原
|
||||||
*
|
*
|
||||||
* @param url url
|
* @param url 书签url路径
|
||||||
* @param icon icon
|
* @param icon base64编码的icon
|
||||||
* @param iconUrl iconUrl
|
* @param iconUrl base64编码的文件,文件名,用于获取文件名后缀
|
||||||
|
* @param quick 是否快速获取
|
||||||
* @return {@link String}
|
* @return {@link String}
|
||||||
* @author fanxb
|
* @author fanxb
|
||||||
*/
|
*/
|
||||||
private String getIconPath(String url, String icon, String iconUrl) {
|
private String getIconPath(String url, String icon, String iconUrl, boolean quick) {
|
||||||
String host;
|
String host;
|
||||||
try {
|
try {
|
||||||
URL urlObj = new URL(url);
|
URL urlObj = new URL(url);
|
||||||
@ -420,7 +445,7 @@ public class BookmarkServiceImpl implements BookmarkService {
|
|||||||
return iconPath;
|
return iconPath;
|
||||||
}
|
}
|
||||||
//再根据url解析
|
//再根据url解析
|
||||||
iconPath = saveFile(host, urlIconAddress + "/icon?url=" + host + "&size=16..128..256");
|
iconPath = saveFile(host, urlIconAddress + "/icon?url=" + host + "&size=16..128..256", quick);
|
||||||
if (StrUtil.isNotEmpty(iconPath)) {
|
if (StrUtil.isNotEmpty(iconPath)) {
|
||||||
hostIconDao.insert(host, iconPath);
|
hostIconDao.insert(host, iconPath);
|
||||||
}
|
}
|
||||||
@ -430,13 +455,14 @@ public class BookmarkServiceImpl implements BookmarkService {
|
|||||||
/**
|
/**
|
||||||
* 保存文件到icon路径
|
* 保存文件到icon路径
|
||||||
*
|
*
|
||||||
* @param host host
|
* @param host host
|
||||||
* @param url url
|
* @param url url
|
||||||
|
* @param quick 是否快速获取,快速获取超时时间1s
|
||||||
* @return {@link String}
|
* @return {@link String}
|
||||||
* @author FleyX
|
* @author FleyX
|
||||||
*/
|
*/
|
||||||
private String saveFile(String host, String url) {
|
private String saveFile(String host, String url, boolean quick) {
|
||||||
try (Response res = HttpUtil.getClient(false).newCall(new Request.Builder().url(url)
|
try (Response res = (quick ? HttpUtil.getSHORT_CLIENT() : HttpUtil.getClient(false)).newCall(new Request.Builder().url(url)
|
||||||
.header("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36 Edg/100.0.1185.36")
|
.header("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36 Edg/100.0.1185.36")
|
||||||
.get().build()).execute()) {
|
.get().build()).execute()) {
|
||||||
assert res.body() != null;
|
assert res.body() != null;
|
||||||
@ -450,6 +476,8 @@ public class BookmarkServiceImpl implements BookmarkService {
|
|||||||
} else {
|
} else {
|
||||||
log.info("未获取到icon:{}", url);
|
log.info("未获取到icon:{}", url);
|
||||||
}
|
}
|
||||||
|
} catch (SocketTimeoutException timeoutException) {
|
||||||
|
log.info("获取icon超时:{}", host);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("url获取icon故障:{}", url, e);
|
log.error("url获取icon故障:{}", url, e);
|
||||||
}
|
}
|
||||||
|
@ -23,12 +23,6 @@
|
|||||||
<artifactId>bookmark-common</artifactId>
|
<artifactId>bookmark-common</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,44 +74,44 @@
|
|||||||
<version>8.0.33</version>
|
<version>8.0.33</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--邮件依赖-->
|
<!-- <!–邮件依赖–>-->
|
||||||
<dependency>
|
<!-- <dependency>-->
|
||||||
<groupId>org.springframework.boot</groupId>
|
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||||
<artifactId>spring-boot-starter-mail</artifactId>
|
<!-- <artifactId>spring-boot-starter-mail</artifactId>-->
|
||||||
</dependency>
|
<!-- </dependency>-->
|
||||||
|
|
||||||
<!--减负依赖-->
|
<!-- <!–减负依赖–>-->
|
||||||
<dependency>
|
<!-- <dependency>-->
|
||||||
<groupId>org.projectlombok</groupId>
|
<!-- <groupId>org.projectlombok</groupId>-->
|
||||||
<artifactId>lombok</artifactId>
|
<!-- <artifactId>lombok</artifactId>-->
|
||||||
</dependency>
|
<!-- </dependency>-->
|
||||||
<!--json工具依赖-->
|
<!-- <!–json工具依赖–>-->
|
||||||
<dependency>
|
<!-- <dependency>-->
|
||||||
<groupId>com.alibaba</groupId>
|
<!-- <groupId>com.alibaba</groupId>-->
|
||||||
<artifactId>fastjson</artifactId>
|
<!-- <artifactId>fastjson</artifactId>-->
|
||||||
<version>1.2.83</version>
|
<!-- <version>1.2.83</version>-->
|
||||||
</dependency>
|
<!-- </dependency>-->
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<!-- <dependency>-->
|
||||||
<groupId>org.elasticsearch.client</groupId>
|
<!-- <groupId>org.elasticsearch.client</groupId>-->
|
||||||
<artifactId>elasticsearch-rest-high-level-client</artifactId>
|
<!-- <artifactId>elasticsearch-rest-high-level-client</artifactId>-->
|
||||||
</dependency>
|
<!-- </dependency>-->
|
||||||
|
|
||||||
<dependency>
|
<!-- <dependency>-->
|
||||||
<groupId>cn.hutool</groupId>
|
<!-- <groupId>cn.hutool</groupId>-->
|
||||||
<artifactId>hutool-all</artifactId>
|
<!-- <artifactId>hutool-all</artifactId>-->
|
||||||
<version>5.8.21</version>
|
<!-- <version>5.8.21</version>-->
|
||||||
</dependency>
|
<!-- </dependency>-->
|
||||||
|
|
||||||
<!--单元测试-->
|
<!--单元测试-->
|
||||||
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-test -->
|
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-test -->
|
||||||
<!--mysql jdbc依赖-->
|
<!--mysql jdbc依赖-->
|
||||||
<dependency>
|
<!-- <dependency>-->
|
||||||
<groupId>mysql</groupId>
|
<!-- <groupId>mysql</groupId>-->
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
<!-- <artifactId>mysql-connector-java</artifactId>-->
|
||||||
<version>8.0.33</version>
|
<!-- <version>8.0.33</version>-->
|
||||||
</dependency>
|
<!-- </dependency>-->
|
||||||
|
|
||||||
<!--邮件依赖-->
|
<!--邮件依赖-->
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -140,7 +140,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-all</artifactId>
|
<artifactId>hutool-all</artifactId>
|
||||||
<version>5.8.21</version>
|
<version>5.8.25</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--单元测试-->
|
<!--单元测试-->
|
||||||
|
@ -53,7 +53,7 @@ public class Bookmark {
|
|||||||
this.setUserId(userId);
|
this.setUserId(userId);
|
||||||
this.setPath(path);
|
this.setPath(path);
|
||||||
this.setType(FOLDER_TYPE);
|
this.setType(FOLDER_TYPE);
|
||||||
this.setName(name);
|
this.setName(name.length() > 2000 ? name.substring(0, 1999) : name);
|
||||||
this.setAddTime(addTime);
|
this.setAddTime(addTime);
|
||||||
this.setSort(sort);
|
this.setSort(sort);
|
||||||
this.setCreateTime(System.currentTimeMillis());
|
this.setCreateTime(System.currentTimeMillis());
|
||||||
@ -64,7 +64,7 @@ public class Bookmark {
|
|||||||
this.setUserId(userId);
|
this.setUserId(userId);
|
||||||
this.setPath(path);
|
this.setPath(path);
|
||||||
this.setType(BOOKMARK_TYPE);
|
this.setType(BOOKMARK_TYPE);
|
||||||
this.setName(name);
|
this.setName(name.length() > 2000 ? name.substring(0, 1999) : name);
|
||||||
this.setUrl(url);
|
this.setUrl(url);
|
||||||
this.setIcon(icon);
|
this.setIcon(icon);
|
||||||
this.setSort(sort);
|
this.setSort(sort);
|
||||||
|
@ -74,14 +74,18 @@ public class ConfigServiceImpl implements ConfigService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getBingImg() {
|
private String getBingImg() {
|
||||||
JSONObject bingObj = HttpUtil.getObj(bingHost + bingUrl, null, false);
|
try {
|
||||||
String path = bingObj.getJSONArray("images").getJSONObject(0).getString("url");
|
JSONObject bingObj = HttpUtil.getObj(bingHost + bingUrl, null, false);
|
||||||
String picUrl = bingHost + path;
|
String path = bingObj.getJSONArray("images").getJSONObject(0).getString("url");
|
||||||
Request request = new Request.Builder().url(picUrl).build();
|
String picUrl = bingHost + path;
|
||||||
try (Response res = HttpUtil.getClient(false).newCall(request).execute()) {
|
Request request = new Request.Builder().url(picUrl).build();
|
||||||
byte[] bytes = res.body().bytes();
|
try (Response res = HttpUtil.getClient(false).newCall(request).execute()) {
|
||||||
String filePath = CommonConstant.fileSavePath + "/files/public/bing.jpg";
|
byte[] bytes = res.body().bytes();
|
||||||
FileUtil.writeBytes(bytes, filePath);
|
String filePath = CommonConstant.fileSavePath + "/files/public/bing.jpg";
|
||||||
|
FileUtil.writeBytes(bytes, filePath);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取bing每日一图错误:{}", e.getLocalizedMessage(), e);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("获取bing每日一图错误:{}", e.getLocalizedMessage(), e);
|
log.error("获取bing每日一图错误:{}", e.getLocalizedMessage(), e);
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,14 @@ public class HttpUtil {
|
|||||||
.readTimeout(60, TimeUnit.SECONDS)
|
.readTimeout(60, TimeUnit.SECONDS)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 超时时间1s
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private static final OkHttpClient SHORT_CLIENT = new OkHttpClient.Builder().connectTimeout(1, TimeUnit.SECONDS)
|
||||||
|
.readTimeout(1, TimeUnit.SECONDS)
|
||||||
|
.build();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取客户端
|
* 获取客户端
|
||||||
*
|
*
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>2.7.14</version>
|
<version>2.7.17</version>
|
||||||
<relativePath/>
|
<relativePath/>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
alter table bookmark
|
||||||
|
modify name varchar(2000) not null;
|
1
bookmark_front/.gitignore
vendored
1
bookmark_front/.gitignore
vendored
@ -24,3 +24,4 @@ pnpm-debug.log*
|
|||||||
*.njsproj
|
*.njsproj
|
||||||
*.sln
|
*.sln
|
||||||
*.sw?
|
*.sw?
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user