diff --git a/bookMarkService/business/bookmark/src/main/java/com/fanxb/bookmark/business/bookmark/dao/HostIconDao.java b/bookMarkService/business/bookmark/src/main/java/com/fanxb/bookmark/business/bookmark/dao/HostIconDao.java index 915100b..cf8f3bf 100644 --- a/bookMarkService/business/bookmark/src/main/java/com/fanxb/bookmark/business/bookmark/dao/HostIconDao.java +++ b/bookMarkService/business/bookmark/src/main/java/com/fanxb/bookmark/business/bookmark/dao/HostIconDao.java @@ -1,9 +1,6 @@ package com.fanxb.bookmark.business.bookmark.dao; -import org.apache.ibatis.annotations.Insert; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.*; /** * @author fanxb @@ -28,6 +25,15 @@ public interface HostIconDao { * @return {@link String} * @author fanxb */ - @Select("select iconPath from host_icon where host=#{host}") + @Select("select iconPath from host_icon where host=#{host} limit 1") String selectByHost(String host); + + /** + * 删除一条 + * + * @param host host + * @author FleyX + */ + @Delete("delete from host_icon where host=#{host}") + void deleteByHost(String host); } diff --git a/bookMarkService/business/bookmark/src/main/java/com/fanxb/bookmark/business/bookmark/service/impl/BookmarkServiceImpl.java b/bookMarkService/business/bookmark/src/main/java/com/fanxb/bookmark/business/bookmark/service/impl/BookmarkServiceImpl.java index 192a62f..e212e03 100644 --- a/bookMarkService/business/bookmark/src/main/java/com/fanxb/bookmark/business/bookmark/service/impl/BookmarkServiceImpl.java +++ b/bookMarkService/business/bookmark/src/main/java/com/fanxb/bookmark/business/bookmark/service/impl/BookmarkServiceImpl.java @@ -345,6 +345,7 @@ public class BookmarkServiceImpl implements BookmarkService { try { byte[] b = Base64Decoder.decode(icon.substring(icon.indexOf(",") + 1)); String iconPath = saveToFile(iconUrl, host, b); + hostIconDao.deleteByHost(host); hostIconDao.insert(host, iconPath); return iconPath; } catch (Exception e) { @@ -404,7 +405,7 @@ public class BookmarkServiceImpl implements BookmarkService { * @author FleyX */ private String saveToFile(String iconUrl, String host, byte[] b) { - String fileName = URLEncoder.encode(host, StandardCharsets.UTF_8) + iconUrl.substring(iconUrl.lastIndexOf(".")); + String fileName = host.replace(":", ".") + iconUrl.substring(iconUrl.lastIndexOf(".")); String filePath = Paths.get(FileConstant.FAVICON_PATH, host.replace("www", "").replaceAll("\\.", "").substring(0, 2), fileName).toString(); FileUtil.writeBytes(b, Paths.get(CommonConstant.fileSavePath, filePath).toString()); return File.separator + filePath; diff --git a/bookMarkService/common/src/main/java/com/fanxb/bookmark/common/dao/GlobalConfigDao.java b/bookMarkService/common/src/main/java/com/fanxb/bookmark/common/dao/GlobalConfigDao.java new file mode 100644 index 0000000..983012d --- /dev/null +++ b/bookMarkService/common/src/main/java/com/fanxb/bookmark/common/dao/GlobalConfigDao.java @@ -0,0 +1,14 @@ +package com.fanxb.bookmark.common.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.fanxb.bookmark.common.entity.po.GlobalConfigPo; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * @author fanxb + */ +@Mapper +public interface GlobalConfigDao extends BaseMapper { +} diff --git a/bookMarkService/common/src/main/java/com/fanxb/bookmark/common/entity/po/GlobalConfigPo.java b/bookMarkService/common/src/main/java/com/fanxb/bookmark/common/entity/po/GlobalConfigPo.java new file mode 100644 index 0000000..28f3e4d --- /dev/null +++ b/bookMarkService/common/src/main/java/com/fanxb/bookmark/common/entity/po/GlobalConfigPo.java @@ -0,0 +1,20 @@ +package com.fanxb.bookmark.common.entity.po; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +/** + * 全局配置表 + * + * @author FleyX + */ +@Data +@TableName("global_config") +public class GlobalConfigPo { + @TableId(value = "code") + private String code; + private String value; + private String description; +} diff --git a/bookMarkService/common/src/main/java/com/fanxb/bookmark/common/entity/vo/GlobalConfigVo.java b/bookMarkService/common/src/main/java/com/fanxb/bookmark/common/entity/vo/GlobalConfigVo.java index 30a52bd..821510e 100644 --- a/bookMarkService/common/src/main/java/com/fanxb/bookmark/common/entity/vo/GlobalConfigVo.java +++ b/bookMarkService/common/src/main/java/com/fanxb/bookmark/common/entity/vo/GlobalConfigVo.java @@ -2,6 +2,8 @@ package com.fanxb.bookmark.common.entity.vo; import lombok.Data; +import java.util.Map; + /** * 全局公共配置 * @@ -17,4 +19,8 @@ public class GlobalConfigVo { * bing每日一图地址 */ private String bingImgSrc; + /** + * 浏览器插件版本plugin + */ + private Map map; } diff --git a/bookMarkService/common/src/main/java/com/fanxb/bookmark/common/service/impl/ConfigServiceImpl.java b/bookMarkService/common/src/main/java/com/fanxb/bookmark/common/service/impl/ConfigServiceImpl.java index 26c0866..7384f46 100644 --- a/bookMarkService/common/src/main/java/com/fanxb/bookmark/common/service/impl/ConfigServiceImpl.java +++ b/bookMarkService/common/src/main/java/com/fanxb/bookmark/common/service/impl/ConfigServiceImpl.java @@ -6,6 +6,8 @@ import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONObject; import com.fanxb.bookmark.common.constant.NumberConstant; import com.fanxb.bookmark.common.constant.RedisConstant; +import com.fanxb.bookmark.common.dao.GlobalConfigDao; +import com.fanxb.bookmark.common.entity.po.GlobalConfigPo; import com.fanxb.bookmark.common.entity.vo.GlobalConfigVo; import com.fanxb.bookmark.common.service.ConfigService; import com.fanxb.bookmark.common.util.HttpUtil; @@ -15,10 +17,9 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; +import java.util.*; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; /** * @author fanxb @@ -30,10 +31,12 @@ public class ConfigServiceImpl implements ConfigService { private final StringRedisTemplate stringRedisTemplate; + private final GlobalConfigDao globalConfigDao; @Autowired - public ConfigServiceImpl(StringRedisTemplate stringRedisTemplate) { + public ConfigServiceImpl(StringRedisTemplate stringRedisTemplate, GlobalConfigDao globalConfigDao) { this.stringRedisTemplate = stringRedisTemplate; + this.globalConfigDao = globalConfigDao; } @Value("${bing.host}") @@ -43,9 +46,12 @@ public class ConfigServiceImpl implements ConfigService { @Override public GlobalConfigVo getGlobalConfig() { + List pos = globalConfigDao.selectByMap(Collections.emptyMap()); + Map map = pos.stream().collect(Collectors.toMap(GlobalConfigPo::getCode, GlobalConfigPo::getValue)); GlobalConfigVo vo = new GlobalConfigVo(); vo.setProxyExist(HttpUtil.getProxyExist()); vo.setBingImgSrc(getCacheBingImg()); + vo.setMap(map); return vo; } diff --git a/bookMarkService/web/src/main/resources/db/migration/V22__新增全局配置表.sql b/bookMarkService/web/src/main/resources/db/migration/V22__新增全局配置表.sql new file mode 100644 index 0000000..6abeec2 --- /dev/null +++ b/bookMarkService/web/src/main/resources/db/migration/V22__新增全局配置表.sql @@ -0,0 +1,13 @@ +CREATE TABLE bookmark.global_config +( + code varchar(20) NOT NULL, + value varchar(100) NOT NULL COMMENT '值', + description varchar(100) NOT NULL COMMENT '描述', + CONSTRAINT global_config_pk PRIMARY KEY (code) +) ENGINE=InnoDB +DEFAULT CHARSET=utf8mb4 +COLLATE=utf8mb4_0900_ai_ci +COMMENT='全局配置表'; + +insert into global_config +values ("pluginVersion", "0.1.1", "浏览器插件版本"); diff --git a/bookMarkService/web/src/main/resources/db/migration/V23__插件版本更新.sql b/bookMarkService/web/src/main/resources/db/migration/V23__插件版本更新.sql new file mode 100644 index 0000000..54f5158 --- /dev/null +++ b/bookMarkService/web/src/main/resources/db/migration/V23__插件版本更新.sql @@ -0,0 +1,3 @@ +update global_config +set value='0.1.2' +where code = "pluginVersion"; diff --git a/bookmark_front/src/components/main/things/AddBookmark.vue b/bookmark_front/src/components/main/things/AddBookmark.vue index 58fcfe3..4336703 100644 --- a/bookmark_front/src/components/main/things/AddBookmark.vue +++ b/bookmark_front/src/components/main/things/AddBookmark.vue @@ -62,7 +62,7 @@ export default { file: null, }, rules: { - name: [{ required: true, min: 1, max: 1000, message: "名称长度为1-1000", trigger: "change" }], + name: [{ required: true, min: 1, max: 1000, message: "名称长度为1-200", trigger: "change" }], url: [{ required: true, min: 1, message: "不能为空", trigger: "change" }], }, }; diff --git a/bookmark_front/src/main.js b/bookmark_front/src/main.js index d0b0f35..c0c9eb3 100644 --- a/bookmark_front/src/main.js +++ b/bookmark_front/src/main.js @@ -19,7 +19,8 @@ import { Popconfirm, AutoComplete, Select, - Popover + Popover, + Breadcrumb } from "ant-design-vue"; import App from "./App.vue"; import router from "./router"; @@ -46,6 +47,7 @@ Vue.use(Popconfirm); Vue.use(AutoComplete); Vue.use(Select); Vue.use(Popover); +Vue.use(Breadcrumb); Vue.component("my-icon", IconFont); Vue.prototype.$message = message; diff --git a/bookmark_front/src/store/index.js b/bookmark_front/src/store/index.js index 7e865a3..13cc15e 100644 --- a/bookmark_front/src/store/index.js +++ b/bookmark_front/src/store/index.js @@ -22,7 +22,8 @@ let noLoginFinish = false; //执行各自的非登陆初始化 (async () => { await store.dispatch(globalConfig.GLOBAL_CONFIG + "/" + globalConfig.noLoginInit); - await store.dispatch(treeData.TREE_DATA + "/" + treeData.noLoginInit); + //无需等待执行 + store.dispatch(treeData.TREE_DATA + "/" + treeData.noLoginInit); noLoginFinish = true; })(); @@ -35,8 +36,9 @@ export async function loginInit () { } console.log(store.state[globalConfig.GLOBAL_CONFIG][globalConfig.TOKEN]); if (checkJwtValid(store.state[globalConfig.GLOBAL_CONFIG][globalConfig.TOKEN])) { - await store.dispatch(globalConfig.GLOBAL_CONFIG + "/" + globalConfig.loginInit); - await store.dispatch(treeData.TREE_DATA + "/" + treeData.loginInit); + //无需等待执行完毕 + store.dispatch(globalConfig.GLOBAL_CONFIG + "/" + globalConfig.loginInit); + store.dispatch(treeData.TREE_DATA + "/" + treeData.loginInit); } } diff --git a/bookmark_front/src/store/modules/treeData.js b/bookmark_front/src/store/modules/treeData.js index cfa4ebd..0baa87b 100644 --- a/bookmark_front/src/store/modules/treeData.js +++ b/bookmark_front/src/store/modules/treeData.js @@ -249,12 +249,16 @@ const actions = { } context.state[TOTAL_TREE_DATA][""].push(targetNode); } else { + let path = sourceNode.path + "." + sourceNode.bookmarkId; + if (!context.state[TOTAL_TREE_DATA][path]) { + context.state[TOTAL_TREE_DATA][path] = []; + } if (sourceNode.children === undefined) { - sourceNode.children = []; + sourceNode.children = context.state[TOTAL_TREE_DATA][path]; } sourceNode.children.push(targetNode); } - if (targetNode.type === 0) { + if (targetNode.type === 1) { context.state[TOTAL_TREE_DATA][targetNode.path + "." + targetNode.bookmarkId] = []; } targetNode.isLeaf = targetNode.type === 0; diff --git a/bookmark_front/src/views/home/PinBookmarkItem.vue b/bookmark_front/src/views/home/PinBookmarkItem.vue index f21a36d..9ac862e 100644 --- a/bookmark_front/src/views/home/PinBookmarkItem.vue +++ b/bookmark_front/src/views/home/PinBookmarkItem.vue @@ -1,6 +1,6 @@ diff --git a/浏览器插件/bookmarkBrowserPlugin/popup/index.html b/浏览器插件/bookmarkBrowserPlugin/popup/index.html index d82fbaa..43bed80 100644 --- a/浏览器插件/bookmarkBrowserPlugin/popup/index.html +++ b/浏览器插件/bookmarkBrowserPlugin/popup/index.html @@ -8,7 +8,7 @@ html, body { padding: 0.2em; - width: 8em; + min-width: 8em; } #content { color: red; @@ -23,7 +23,11 @@

-
插件版本:
+
+
插件版本:
+
最新版本:最新版本
+ +
diff --git a/浏览器插件/bookmarkBrowserPlugin/popup/index.js b/浏览器插件/bookmarkBrowserPlugin/popup/index.js index 04e6582..3aeeb0d 100644 --- a/浏览器插件/bookmarkBrowserPlugin/popup/index.js +++ b/浏览器插件/bookmarkBrowserPlugin/popup/index.js @@ -9,7 +9,13 @@ var action = document.getElementById("action"); //初始化 login.href = bookmarkHost + "/manage/sso/auth"; document.getElementById("version").innerText = version; + document.getElementById("about").href = bookmarkHost + "/public/about"; sendToBg("getToken", null); + let newestBlock = document.getElementById("newestVersion"); + newestBlock.href = bookmarkHost + "/static/bookmarkBrowserPlugin.zip"; + let res = await axios.get("/common/config/global"); + console.log(res); + newestBlock.innerText = res.data.data.map.pluginVersion; })(); /** diff --git a/浏览器插件/bookmarkBrowserPlugin/static/js/config.js b/浏览器插件/bookmarkBrowserPlugin/static/js/config.js index f6fbefd..1b5b4bd 100644 --- a/浏览器插件/bookmarkBrowserPlugin/static/js/config.js +++ b/浏览器插件/bookmarkBrowserPlugin/static/js/config.js @@ -1,7 +1,7 @@ var bookmarkHost = "https://fleyx.com"; // var bookmarkHost = "http://localhost:8080"; -var version = "0.1.1"; +var version = "0.1.2"; window.token = localStorage.getItem('token'); axios.defaults.baseURL = bookmarkHost + '/bookmark/api'; diff --git a/浏览器插件/bookmarkBrowserPlugin/static/js/content.js b/浏览器插件/bookmarkBrowserPlugin/static/js/content.js index b639bb8..667d0a5 100644 --- a/浏览器插件/bookmarkBrowserPlugin/static/js/content.js +++ b/浏览器插件/bookmarkBrowserPlugin/static/js/content.js @@ -62,7 +62,7 @@ async function addBookmark (data) { document.getElementsByTagName("body")[0].appendChild(addBlockDiv); iframe = document.createElement("iframe"); iframe.src = bookmarkHost + "/noHead/addBookmark?token=" + data.token; - iframe.setAttribute("style", "width:70%;min-height:60vh;margin-left:15%;margin-top:10vh;padding:0;border:0;border-radius:10px"); + iframe.setAttribute("style", "width:640px;display:block;height:80vh;margin:0 auto;margin-top:10vh;padding:0;border:0;border-radius:10px"); addBlockDiv.appendChild(iframe); }