From 7ac4108d799187947b48c0e2f428698fb3ce1673 Mon Sep 17 00:00:00 2001 From: yma16 <17685043634@163.com> Date: Mon, 25 Apr 2022 00:44:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=80=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/index.js | 2 +- src/comment/ArticleComment.vue | 43 +++++---- src/components/Article.vue | 96 +++---------------- src/components/Csslearn.vue | 9 +- src/components/Login.vue | 36 ++++--- src/components/Register.vue | 27 +----- src/router/index.js | 168 ++++++++++++++++----------------- src/service/user.service.js | 14 ++- src/store/modules/user.js | 66 ++++++------- 9 files changed, 183 insertions(+), 278 deletions(-) diff --git a/config/index.js b/config/index.js index 969aa82..0a216ba 100644 --- a/config/index.js +++ b/config/index.js @@ -11,7 +11,7 @@ module.exports = { assetsPublicPath: "/", proxyTable: { "/api/": { - target: "http://114.116.52.53/", //后端接口地址 + target: "http://yongma16.xyz/", //后端接口地址 ws: true, //接受websocket请求 changeOrigin: true, //是否允许跨越 chunkOrigins: true, diff --git a/src/comment/ArticleComment.vue b/src/comment/ArticleComment.vue index 4a40a95..9f5e5d1 100644 --- a/src/comment/ArticleComment.vue +++ b/src/comment/ArticleComment.vue @@ -55,7 +55,7 @@ export default { }; }, mounted() { - this.getComments(); + articleId && this.getComments(); }, methods: { dateToString(dateValue) { @@ -95,7 +95,6 @@ export default { let params = { articleId: articleId ? articleId : that.articleId, }; - console.log("获取评论id", params.articleId); axios .post(that.baseurl + "comment/get/", params) .then((res) => { @@ -106,35 +105,34 @@ export default { item.date = that.dateToString(item.date); }); } catch (e) { - console.log(e); + throw Error(e) } - console.log("评论获取成功", res); }) .catch((r) => { - console.log("评论获取失败", r); + throw Error(r) }); }, increment(userId, articleId, content) { - if (content === "" || !content) { - this.$notify({ - title: "评论失败!", - message: "评论内容不能为空", - position: "top-left", - }); - return false; - } let that = this; - if (!localStorage.getItem("yma16siteUserInfoName")) { + if (!localStorage.getItem("yma16siteUserInfo")) { that.$router .push({ path: "/login", }) .catch((error) => { - console.log(error); + throw Error(error); }); } else { - that.userId = localStorage.getItem("yma16siteUserInfoName"); - console.log("提交评论", articleId, that.userId, content); + if (content === "" || !content) { + that.$notify({ + title: "评论失败!", + message: "评论内容不能为空", + position: "top-left", + }); + return false; + } + const userInfo = JSON.parse(localStorage.getItem("yma16siteUserInfo")); + that.userId = userInfo.username; let params = { username: that.userId, articleId: articleId, @@ -151,11 +149,18 @@ export default { item.date = that.dateToString(item.date); }); } catch (e) { - console.log(e); + throw Error(e) } }) .catch((r) => { - console.log("评论提交失败", r); + that.$router + .push({ + path: "/login", + }) + .catch((error) => { + throw Error(error) + }); + throw Error(r); }); } }, diff --git a/src/components/Article.vue b/src/components/Article.vue index 8f39f60..a441c2d 100644 --- a/src/components/Article.vue +++ b/src/components/Article.vue @@ -262,7 +262,7 @@ export default { pageSize: 4, pageArray: [6, 8, 10], postcomment: { - articleId: 1, + articleId: undefined, articleCommit: null, }, articleId: [], //文章的id @@ -270,8 +270,6 @@ export default { }, watch: { topshow: function (newvalue, oldvalue) { - console.log("侦听"); - console.log("new", newvalue, "old", oldvalue); if (newvalue === true) { document.getElementById("topiconid").style.display = "none"; } else { @@ -293,16 +291,13 @@ export default { handleSizeChange(val) { // 转到第一页md_title let that = this; - console.log(`每页 ${val} 条`); that.pageAnalysFun(that.pageAnalys.allTitle, val); //触发修改 }, handleCurrentChange(val) { let that = this; - console.log(that.currentPage, "currentPage", that.pageAnalys.allTitle); //触发md_title的修改 that.currentPage = val; that.pageAnalysFun(that.pageAnalys.allTitle); //触发修改 - console.log(`当前页: ${val}`); }, pageAnalysFun(allTitleArray, selectListLength) { let that = this; @@ -315,7 +310,6 @@ export default { that.splitLength = selectListLength; //划分长度 } splitLength = that.splitLength; - console.log("一页几条", splitLength); let splitNum = Math.ceil(that.total / splitLength); //向上取整 that.pageAnalys.childNum = splitNum; //子数组个数 that.pageAnalys.allTitle = allTitleArray; //所有标题 @@ -348,20 +342,15 @@ export default { try { that.md_title = that.pageAnalys.titleArray[this.currentPage - 1]; } catch (e) { - console.log(e); + throw Error(e) } - console.log("总数", that.pageAnalys.titleArray); - console.log("分页数据", that.pageAnalys.titleArray[this.currentPage - 1]); - console.log("当前页", that.md_title); }, increment: function () { this.$store.commit("increment"); - console.log(this.$store.state.count); }, topvisible: function () { let dom = document.getElementById("hometitle"); this.topshow = this.elementIsVisibleInViewport(dom); - // console.log('this.topshow', this.topshow) setTimeout(this.topvisible); }, elementIsVisibleInViewport: function (el, partiallyVisible = false) { @@ -375,7 +364,7 @@ export default { : top >= 0 && left >= 0 && bottom <= innerHeight && right <= innerWidth; }, li_errorClass: function () { - console.log("选择文章"); + }, cssPage: function (index) { this.challenge_loc = index; @@ -387,7 +376,7 @@ export default { path: "/css", }) .catch((error) => { - console.log(error); + throw Error(error) }); break; case "echarts地图配置": @@ -396,7 +385,7 @@ export default { path: "/home", }) .catch((error) => { - console.log(error); + throw Error(error) }); break; case "websocket聊天": @@ -405,14 +394,13 @@ export default { path: "/onlinewebsocket", }) .catch((error) => { - console.log(error); + throw Error(error) }); break; case "vue3测试平台": - window.open(this.baseurl + "emoji/index/"); + window.open(this.baseurl + "/emoji_api/index/"); break; default: - console.log("case name没找到"); break; } }, @@ -445,72 +433,37 @@ export default { // 传入索引 }) .then((res) => { - // alter('提交中'); - // console.log(res.data) if (res.data.code === 1) { - console.log("success return home!"); - // that.$router.push({path:'/home'}) - // 无需跳转 - // document.cookie= `user=${that.ruleForm.name}` - // 添加cookie - console.log("获取Article"); let respdata = res.data; let content = respdata.article; that.md_data = []; // 清空 - // console.log(that.md_data) content.map((o) => { that.md_data.push(o); // 传入一个文章 }); that.the_title = respdata.the_title; } else if (res.data.code === 0) { // alter("失败!") - console.log("post 失败"); + that.$message.error('失败') } }) - .catch((res) => { - console.log(res); + .catch((error) => { + throw Error(error) }); - console.log("that.postcomment.articleId", that.postcomment.articleId); that.getCommentsFromArticle(that.postcomment.articleId); }, }, - // mounted() { - // console.log('document滚动',document.documentElement.scrollTop); - - // window.addEventListener("scroll", this.handleScroll); - // window.addEventListener("echarts", this.datasetfunc); - // }, - // watch(){ - // console.log('watch事件!'); - // console.log('document滚动',document.documentElement.scrollTop); - // }, - // destroyed() { - // console.log('document滚动',document.documentElement.scrollTop); - // // window.removeEventListener("echarts", this.datasetfunc); - // }, created: function () { // 初始化 - console.log("初始化"); let that = this; - // window.οnscrοll = function () { - // //鼠标滚轮滚动距离超过10像素时,回到顶部按钮才显示 - // if (document.documentElement.scrollTop > 10) { - // that.toTopIsShow = true; - // } else { - // that.toTopIsShow = false; - // } - // }; - console.log("测试created!"); axios .get(that.baseurl + "article/index/") .then((res) => { - console.log("获取Article", res); let resdata = res.data; let content = resdata.article; // 传递过来的文章 进行处理 let title = resdata.title; that.articleId = resdata.articleObjectId; - console.log("获取ArticleId", that.articleId); - // console.log('content', content, 'title', title) + that.postcomment.articleId = resdata.articleId; + this.$refs.commentRef.getComments(that.postcomment.articleId); //触发子组件的方法 content.map((o) => { that.md_data.push(o); }); @@ -518,31 +471,10 @@ export default { return o; }); that.the_title = resdata.the_title; - console.log("分页实现"); this.pageAnalysFun(titleAllArray); //分页 - // that.md_data.push(res.data.article); //markdown值传递 - // let weather = resdata.weather - // let high = weather.high - // let low = weather.low - // console.log('weather', weather) - // weather.title.map((o) => { - // that.weather_title.push(o) - // }) - // high.map((o) => { - // that.weather_high.push(o) - // }) - // low.map((o) => { - // that.weather_low.push(o) - // }) - // try { - // this.datasetfunc() // 等待dom和文件加载完之后执行dataserfunc,加载天气 - // } catch (e) { - // console.log(e) - // window.onload = this.datasetfunc // 等待dom - // } }) - .catch((res) => { - console.log(res); + .catch((r) => { + throw Error(r); }); // get log }, }; diff --git a/src/components/Csslearn.vue b/src/components/Csslearn.vue index cdb332a..c4597ac 100644 --- a/src/components/Csslearn.vue +++ b/src/components/Csslearn.vue @@ -67,7 +67,6 @@ export default { window.parent.location.href = this.ifreame_content; }, li_errorClass: function () { - console.log(0); }, get_ifreame: function (index) { let that = this; // that @@ -77,15 +76,10 @@ export default { }, getCss: function () { try { - console.log( - "domMain", - document.getElementById("mainappid"), - document.getElementById("mainappid").style - ); document.getElementById("mainappid").style.padding = "0"; document.getElementById("mainappid").style.margin = "0"; } catch (e) { - console.log("e", e); + throw Error(e) } let that = this; @@ -101,7 +95,6 @@ export default { // 标题传递 // eslint-disable-next-line camelcase that.css_title = csstitle; - console.log(that.css_path, that.css_title); // 传递第一个路html路径 that.ifreame_content = that.css_path[0]; // 传递长度 diff --git a/src/components/Login.vue b/src/components/Login.vue index e2595ee..84e74a0 100644 --- a/src/components/Login.vue +++ b/src/components/Login.vue @@ -21,6 +21,7 @@ type="password" v-model="ruleForm.pass" autocomplete="off" + show-password > @@ -31,7 +32,7 @@ 没有账号?没有账号? 去注册