temp:零时提交

This commit is contained in:
fanxb 2020-03-22 20:43:39 +08:00
parent a214f4074b
commit 060178d4fc
10 changed files with 125 additions and 46 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.idea

View File

@ -42,43 +42,10 @@ web端已经完成。
1. 手动编辑导入
![](https://raw.githubusercontent.com/FleyX/files/master/blogImg/20190801191601.png)
2. 谷歌、火狐浏览器书签备份文件直接导入.如果同一级别下名称相同导致冲突,将跳过,保留原有的。
2. 谷歌、火狐浏览器书签备份文件直接导入,相同名称的将都保留
![](https://raw.githubusercontent.com/FleyX/files/master/blogImg/20190801191721.png)
## 改
1. 修改节点内容,右键->编辑。(移动端长按相当于右键)
2. 修改书签顺序,所属文件夹,直接拖拽书签到目标位置
# 开发进度
## 2019-06-27
**tag: 第一篇:环境搭建**
前端 react 框架搭建完成。
## 2019-07-10
**tag: 第二篇:注册登录重置密码完成**
后台框架搭建,并完成以下功能:
- 登录,注册,重置密码,发送验证码接口完成
- 书签 html 上传解析并存到数据库,仅测试了 chrome 导出的书签文件
- 查询某个用户的书签树
前台完成以下功能:
- 注册,登录,重置密码界面完成
## 2019-07-22
增删改查功能完成。支持节点拖拽
## 2019-07-30
- docker 部署重新整理,部署更方便了。
- 加入 elasticsearch 全文检索,可以方便的搜索书签啦。
- 树节点增加右键菜单,更加便捷的增删改

View File

@ -0,0 +1,40 @@
package com.fanxb.bookmark.business.bookmark.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import java.util.List;
/**
* Created with IntelliJ IDEA
* Created By Fxb
* Date: 2020/3/19
* Time: 0:05
*/
@Data
@Builder
public class PinYinBody {
/**
* 待转换拼音的文本列表
*/
private List<String> strs;
private Config config;
@Data
@AllArgsConstructor
public static class Config {
/**
* 是否启用分词模式
*/
private boolean segment;
/**
* 是否启用多音字
*/
private boolean heteronym;
/**
* 风格
*/
private int style;
}
}

View File

@ -0,0 +1,14 @@
package com.fanxb.bookmark.business.bookmark.service;
import java.util.List;
/**
* Created with IntelliJ IDEA
* Created By Fxb
* Date: 2020/3/18
* Time: 23:47
*/
public interface PinYinService {
List<String> changeStrings(List<String> stringList);
}

View File

@ -0,0 +1,32 @@
package com.fanxb.bookmark.business.bookmark.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.fanxb.bookmark.business.bookmark.entity.PinYinBody;
import com.fanxb.bookmark.business.bookmark.service.PinYinService;
import com.fanxb.bookmark.common.constant.Constant;
import com.fanxb.bookmark.common.util.HttpUtil;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/**
* Created with IntelliJ IDEA
* Created By Fxb
* Date: 2020/3/18
* Time: 23:48
*/
@Service
public class PinYinServiceImpl implements PinYinService {
private static final String PATH = "/pinyinChange";
@Override
public List<String> changeStrings(List<String> stringList) {
Map<String, String> header = Collections.singletonMap("token", Constant.pinyinToken);
PinYinBody body = PinYinBody.builder().strs(stringList).config(new PinYinBody.Config(false, false, 1)).build();
JSONArray result = HttpUtil.post(Constant.pinyinBaseUrl + PATH, JSON.toJSONString(body), header);
return null;
}
}

View File

@ -39,9 +39,9 @@ public class Constant {
public static boolean isDev = false;
@Value("${isDev}")
public void setIsDev(boolean isDev) {
Constant.isDev = isDev;
@Value("${spring.profiles.active}")
public void setIsDev(String active) {
Constant.isDev = active.contains("dev");
}
public static String jwtSecret = "";
@ -72,4 +72,21 @@ public class Constant {
serviceAddress = address;
}
/**
* 拼音服务调用地址
*/
public static String pinyinBaseUrl;
@Value("${pinyin.base-url}")
public void setPinyinBaseUrl(String baseUrl){
pinyinBaseUrl=baseUrl;
}
/**
* 调用拼音服务token
*/
public static String pinyinToken;
@Value("${pinyin.token}")
public void setPinyinToken(String pinyinToken) {
Constant.pinyinToken = pinyinToken;
}
}

View File

@ -66,6 +66,9 @@ es:
host: localhost
port: 9200
scheme: http
pinyin:
base-url: http://localhost:8012
token: 123456
# 默认文件上传基路径
fileSavePath: ./

View File

@ -7,8 +7,10 @@
"axios": "^0.19.0",
"babel-plugin-import": "^1.12.0",
"clipboard": "^2.0.4",
"css-loader": "^2.1.1",
"customize-cra": "^0.2.14",
"less": "^3.9.0",
"less-loader": "^5.0.0",
"query-string": "^6.8.1",
"react": "^16.8.6",
"react-app-rewired": "^2.1.3",
@ -16,8 +18,7 @@
"react-redux": "^7.1.0",
"react-router-dom": "^5.0.1",
"react-scripts": "3.0.1",
"redux": "^4.0.1",
"less-loader": "^5.0.0"
"redux": "^4.0.1"
},
"scripts": {
"start": "react-app-rewired start",

View File

@ -1,5 +1,6 @@
const Koa = require("koa");
const pinyin = require("pinyin");
const koaBody = require("koa-body");
const config = require("./config.js");
@ -13,7 +14,7 @@ app.use(async (ctx, next) => {
await next();
ctx.res.statusCode = 200;
} catch (error) {
log.error(error);
console.error(error);
if (error.message.startsWith("token")) {
ctx.res.statusCode = 401;
} else {
@ -28,17 +29,19 @@ app.use(async (ctx, next) => {
if (!ctx.req.headers["token"] === config.token) {
throw new Error("token校验失败");
}
if (ctx.req.url !== "/pinyinChange" && ctx.req.method !== "POST") {
throw new Error("路径错误");
}
await next();
});
app.use(koaBody());
//业务处理
app.use(async ctx => {
if (ctx.req.url !== "/pinyinChange" && ctx.req.method !== "post") {
throw new Error("路径错误");
}
let body = ctx.request.body;
let style;
switch (body.style) {
switch (body.config.style) {
case 1:
style = pinyin.STYLE_NORMAL;
break;
@ -60,9 +63,9 @@ app.use(async ctx => {
default:
style = pinyin.STYLE_NORMAL;
}
body.config.style = style;
body.config.style = pinyin.STYLE_NORMAL;
let res = [];
body.strs.forEach(item => res.push(pinyin(item, body.config.style)));
body.strs.forEach(item => res.push(pinyin(item, body.config)));
ctx.body = res;
});

View File

@ -10,6 +10,7 @@
"license": "MIT",
"dependencies": {
"koa": "^2.11.0",
"koa-body": "^4.1.1",
"pinyin": "^2.9.0"
}
}