Merge branch 'dev' of fanxb/bookmark into master

This commit is contained in:
fanxb 2022-04-17 18:02:54 +08:00 committed by Gogs
commit 9e3308d6ca
9 changed files with 90 additions and 7 deletions

View File

@ -6,6 +6,8 @@
部署教程:[docker-compose 部署](https://github.com/FleyX/bookmark/blob/master/DEPLOY.md)
**为获得更好的体验,建议将主页设置为 fleyx.com,并安装浏览器拓展**
# 缘由
1. 主要用的是 chrome但是有时候需要用其他的浏览器Firefoxie 等。然后这些浏览器上没有书签,想进个网站还得打开 chrome 复制 url太麻烦。

View File

@ -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<GlobalConfigPo> {
}

View File

@ -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;
}

View File

@ -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<String, String> map;
}

View File

@ -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<GlobalConfigPo> pos = globalConfigDao.selectByMap(Collections.emptyMap());
Map<String, String> 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;
}

View File

@ -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", "浏览器插件版本");

View File

@ -11,7 +11,7 @@
</div>
<div>
浏览器插件
<a href="/static/bookmarkBrowserPlugin.zip" download="浏览器插件.zip" target="_blank">点击下载</a>
<a href="/static/bookmarkBrowserPlugin.zip" download="浏览器插件.zip" target="_blank">最新版本{{ serverConfig.map.pluginVersion }}(注意更新)</a>
,使用详情请参考使用教程
</div>
<div>交流反馈qq群150056494,邮箱fleyx20@outlook.com</div>
@ -34,8 +34,14 @@
</template>
<script>
import { mapState } from "vuex";
import { GLOBAL_CONFIG, SERVER_CONFIG } from "@/store/modules/globalConfig";
export default {
name: "about",
data() {
return { version: "" };
},
computed: { ...mapState(GLOBAL_CONFIG, [SERVER_CONFIG]) },
mounted() {
window.qieziStatisticKey = "b74c4b571b644782a837433209827874";
let script = document.createElement("script");
@ -43,6 +49,12 @@ export default {
script.defer = true;
script.src = "https://qiezi.fleyx.com/qiezijs/1.0/qiezi_statistic.min.js";
document.getElementsByTagName("head")[0].appendChild(script);
let serverConfig = this.$store.state[GLOBAL_CONFIG + "/" + SERVER_CONFIG];
console.log(serverConfig);
if (serverConfig.map.pluginVersion) {
this.version = serverConfig.map.pluginVersion;
}
},
};
</script>

View File

@ -8,7 +8,7 @@
html,
body {
padding: 0.2em;
width: 8em;
min-width: 8em;
}
#content {
color: red;
@ -23,7 +23,11 @@
<!-- <button title="同步浏览器书签到云端(覆盖云端)">同步浏览器</button> -->
</div>
<p id="content"></p>
<div class="bottom">插件版本:<span id="version"></span></div>
<div class="bottom">
<div>插件版本:<span id="version"></span></div>
<div>最新版本:<a href="" id="newestVersion">最新版本</a></div>
<div><a id="about" target="_blank">关于</a></span></div>
</div>
<script type="text/javascript" src="/static/js/axios.min.js"></script>
<script type="text/javascript" src="/static/js/config.js"></script>
<script type="text/javascript" src="/popup/index.js"></script>

View File

@ -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;
})();
/**