diff --git a/bookMarkService/common/src/main/java/com/fanxb/bookmark/common/filter/LoginFilter.java b/bookMarkService/common/src/main/java/com/fanxb/bookmark/common/filter/LoginFilter.java index ebdb723..27252f9 100644 --- a/bookMarkService/common/src/main/java/com/fanxb/bookmark/common/filter/LoginFilter.java +++ b/bookMarkService/common/src/main/java/com/fanxb/bookmark/common/filter/LoginFilter.java @@ -51,12 +51,12 @@ public class LoginFilter implements Filter { @Autowired private UrlDao urlDao; - private static AntPathMatcher matcher = new AntPathMatcher(); + private static final AntPathMatcher matcher = new AntPathMatcher(); volatile private static List publicUrl; @Override - public void init(FilterConfig filterConfig) throws ServletException { + public void init(FilterConfig filterConfig) { } @Override diff --git a/bookmark_front/src/layout/main/Content.vue b/bookmark_front/src/layout/main/Content.vue index 64c627f..6f42191 100644 --- a/bookmark_front/src/layout/main/Content.vue +++ b/bookmark_front/src/layout/main/Content.vue @@ -28,6 +28,6 @@ export default {}; font-size: 0.14rem; - background-color: rgba(249, 231, 62, 0.2); + background-color: white; } diff --git a/bookmark_front/src/layout/main/Top.vue b/bookmark_front/src/layout/main/Top.vue index ceee6d2..4ae924b 100644 --- a/bookmark_front/src/layout/main/Top.vue +++ b/bookmark_front/src/layout/main/Top.vue @@ -45,6 +45,7 @@ export default { justify-content: space-between; align-items: center; background-color: rgba(197, 190, 198, 0.4); + z-index: 100; .ico { height: 100%; } diff --git a/bookmark_front/src/main.js b/bookmark_front/src/main.js index 385e3c3..071c921 100644 --- a/bookmark_front/src/main.js +++ b/bookmark_front/src/main.js @@ -1,5 +1,5 @@ import Vue from "vue"; -import { Button, FormModel, Input, Icon, message, Checkbox, Dropdown, Menu } from "ant-design-vue"; +import { Button, FormModel, Input, Icon, message, Checkbox, Dropdown, Menu, Tree } from "ant-design-vue"; import App from "./App.vue"; import router from "./router"; import store from "./store"; @@ -11,6 +11,7 @@ Vue.component(Icon.name, Icon); Vue.use(Checkbox); Vue.use(Dropdown); Vue.use(Menu); +Vue.use(Tree); Vue.prototype.$message = message; Vue.config.productionTip = false; diff --git a/bookmark_front/src/router/index.js b/bookmark_front/src/router/index.js index 7c97398..bf7f5e8 100644 --- a/bookmark_front/src/router/index.js +++ b/bookmark_front/src/router/index.js @@ -2,7 +2,7 @@ import Vue from "vue"; import VueRouter from "vue-router"; import Main from "../views/main/Main.vue"; import UserInfo from "../views/main/pages/personSpace/UserInfo.vue"; -import BookmarkTree from "../views/main/pages/things/BookmarkTree.vue"; +import BookmarkManage from "../views/main/pages/things/BookmarkManage.vue"; import Public from "../views/public/Public.vue"; import Login from "../views/public/pages/Login.vue"; @@ -18,8 +18,8 @@ const routes = [ children: [ { path: "", - name: "BookmarkTree", - component: BookmarkTree + name: "BookmarkManage", + component: BookmarkManage }, { path: "personSpakce/userInfo", diff --git a/bookmark_front/src/store/index.js b/bookmark_front/src/store/index.js index 0132f59..c8a51b2 100644 --- a/bookmark_front/src/store/index.js +++ b/bookmark_front/src/store/index.js @@ -1,6 +1,7 @@ import Vue from "vue"; import Vuex from "vuex"; import globalConfig from "./modules/globalConfig"; +import treeData from "./modules/treeData"; Vue.use(Vuex); @@ -9,6 +10,7 @@ export default new Vuex.Store({ mutations: {}, actions: {}, modules: { - globalConfig + globalConfig, + treeData } }); diff --git a/bookmark_front/src/store/modules/globalConfig.js b/bookmark_front/src/store/modules/globalConfig.js index 0b6a411..29435b7 100644 --- a/bookmark_front/src/store/modules/globalConfig.js +++ b/bookmark_front/src/store/modules/globalConfig.js @@ -1,4 +1,4 @@ -import localforage, { clear } from "localforage"; +import localforage from "localforage"; /** * 存储全局配置 */ diff --git a/bookmark_front/src/store/modules/treeData.js b/bookmark_front/src/store/modules/treeData.js new file mode 100644 index 0000000..e665740 --- /dev/null +++ b/bookmark_front/src/store/modules/treeData.js @@ -0,0 +1,61 @@ +import localforage from "localforage"; +import httpUtil from "../../util/HttpUtil"; + +/** + * 书签树相关配置 + */ +const state = { + //全部书签数据 + totalTreeData: {}, + isInit: false +}; + +const getters = {}; + +const actions = { + //从缓存初始化数据 + async init(context) { + if (context.state.isInit) { + return; + } + let data = await localforage.getItem("totalTreeData"); + if (data == null) { + await context.dispatch("refresh"); + } else { + context.commit("totalTreeData", data); + } + }, + //刷新缓存数据 + async refresh(context) { + let treeData = await httpUtil.get("/bookmark/currentUser"); + context.commit("totalTreeData", treeData); + localforage.setItem("totalTreeData", treeData); + }, + //清除缓存数据 + async clear(context) { + context.commit("totalTreeData", {}); + await localforage.removeItem("totalTreeData"); + } +}; + +const mutations = { + treeData(state, treeData) { + localforage.setItem("treeData", treeData); + state.treeData = treeData; + }, + totalTreeData(state, totalTreeData) { + localforage.setItem("totalTreeData", totalTreeData); + state.totalTreeData = totalTreeData; + }, + isInit(state, isInit) { + state.isInit = isInit; + } +}; + +export default { + namespaced: true, + state, + getters, + actions, + mutations +}; diff --git a/bookmark_front/src/util/HttpUtil.js b/bookmark_front/src/util/HttpUtil.js index 5df374e..0dbe469 100644 --- a/bookmark_front/src/util/HttpUtil.js +++ b/bookmark_front/src/util/HttpUtil.js @@ -28,21 +28,27 @@ async function request(url, method, params, body, isForm, redirect) { if (body) { options.data = body; } + let res; try { - const res = await http.default.request(options); - const { code, data, message } = res.data; - if (code === 1) { - return data; - } - if (code === -1 && redirect) { - // 跳转到登陆页 - router.replace(`/public/login?redirect=${encodeURIComponent(router.currentRoute.fullPath)}`); - return null; - } + res = await http.default.request(options); + } catch (err) { + window.vueInstance.$message.error("发生了某些异常问题"); + console.error(err); + return; + } + const { code, data, message } = res.data; + if (code === 1) { + return data; + } else if (code === -1 && redirect) { + // 跳转到登陆页 + window.vueInstance.$message.error("您尚未登陆,请先登陆"); + router.replace(`/public/login?redirect=${encodeURIComponent(router.currentRoute.fullPath)}`); + throw new Error(message); + } else if (code === 0) { window.vueInstance.$message.error(message); throw new Error(message); - } catch (err) { - throw new Error(err); + } else { + console.error(res.data); } } diff --git a/bookmark_front/src/views/main/Main.vue b/bookmark_front/src/views/main/Main.vue index 548a90d..afe0d5a 100644 --- a/bookmark_front/src/views/main/Main.vue +++ b/bookmark_front/src/views/main/Main.vue @@ -13,11 +13,15 @@ import Content from "@/layout/main/Content.vue"; import Bottom from "@/layout/main/Bottom.vue"; import Top from "@//layout/main/Top.vue"; +import httpUtil from "../../util/HttpUtil"; export default { name: "Home", components: { Top, Content, Bottom }, async beforeCreate() { - this.$store.dispatch("globalConfig/init"); + //数据初始化 + await this.$store.dispatch("globalConfig/init"); + //更新用户基本信息 + this.$store.commit("globalConfig/setUserInfo", await httpUtil.get("/user/currentUserInfo")); } }; diff --git a/bookmark_front/src/views/main/pages/things/BookmarkManage.vue b/bookmark_front/src/views/main/pages/things/BookmarkManage.vue new file mode 100644 index 0000000..d829a12 --- /dev/null +++ b/bookmark_front/src/views/main/pages/things/BookmarkManage.vue @@ -0,0 +1,91 @@ + + + + + diff --git a/bookmark_front/src/views/main/pages/things/BookmarkTree.vue b/bookmark_front/src/views/main/pages/things/BookmarkTree.vue deleted file mode 100644 index ea1c1b8..0000000 --- a/bookmark_front/src/views/main/pages/things/BookmarkTree.vue +++ /dev/null @@ -1,11 +0,0 @@ - - - - - diff --git a/bookmark_front/src/views/public/pages/ResetPassword.vue b/bookmark_front/src/views/public/pages/ResetPassword.vue index 7f9037f..a943b89 100644 --- a/bookmark_front/src/views/public/pages/ResetPassword.vue +++ b/bookmark_front/src/views/public/pages/ResetPassword.vue @@ -21,7 +21,7 @@
- {{ countDown == 0 ? "获取验证码" : countDown + "秒后重试" }} + {{ countDown == 0 ? "获取验证码" : countDown + "秒后重试" }}
@@ -84,26 +84,30 @@ export default { async getAuthCode() { this.$refs.resetPassword.validateField("email", async message => { if (message === "") { - await httpUtil.get("/user/authCode", { email: this.form.email }); - this.$message.success("发送成功,请查收(注意垃圾箱)"); - this.countDown = 60; - if (this.timer != null) { - clearInterval(this.timer); - } - this.timer = setInterval(() => { - if (this.countDown > 0) { - this.countDown = this.countDown - 1; - } else { + try { + this.countDown = 60; + if (this.timer != null) { clearInterval(this.timer); } - }, 1000); + this.timer = setInterval(() => { + if (this.countDown > 0) { + this.countDown = this.countDown - 1; + } else { + clearInterval(this.timer); + } + }, 1000); + await httpUtil.get("/user/authCode", { email: this.form.email }); + this.$message.success("发送成功,请查收(注意垃圾箱)"); + } catch (error) { + this.countDown = 0; + } } }); }, submit() { this.$refs.resetPassword.validate(async status => { if (status) { - let res = await httpUtil.put("/resetPassword", null, this.form); + let res = await httpUtil.post("/user/resetPassword", null, this.form); this.$message.success("重置成功"); this.$router.replace("login"); }