Commit d5ba6a73 by 高浩杰

登录注册修改密码加 enter 发布博客修改不能加网址 修改博客

parent 0a38bd70
<template>
<div>
<div class="select-container" v-if="selectType === '1'" style="min-height: 100px;width: 354px;">
<div class="select-container" v-if="selectType === '1'" @mouseleave="isShow2=false" style="min-height: 100px;width: 354px;">
<div class="select-container__input-box">
<div>
<input
......@@ -186,6 +186,7 @@ export default {
};
this.result.push(obj);
this.$popupbox.close();
this.$emit('handleTag', this.result);
this.$message({
type: 'success',
message: '标签创建成功'
......
......@@ -35,7 +35,7 @@ module.exports = {
*/
plugins: [
'~/plugins/axios',
{src:'~/plugins/mavonEditor.js',ssr:true},
{src:'~/plugins/mavonEditor.js',ssr:false},
{src:'~/plugins/cropper.js',ssr:false},
{src:'~/plugins/messageBox.js',ssr:true},
{src:'~/plugins/popupBox.js',ssr:true},
......
......@@ -8,7 +8,7 @@
>
<div class="blog-release_List" v-for="val in blogList" :key="val.blogId" :info="val">
<div style="width: 60%"><p @click="toDetail">{{val.blogTitle}}</p></div>
<div class="blog-release_List_r" @click="toDetail" >{{val.category}}</div>
<div class="blog-release_List_r" @click="toDetail">{{val.category}}</div>
</div>
</card-container>
<card-container
......@@ -33,9 +33,15 @@
<div class="header-content">
<div class="select__wrap">
<span>*</span>
<select-card selectType="2" :class-list="classList" @handleClass="handleBlogClass" ref="blogClass" placeholder="请选择文章分类" ></select-card>
<select-card
selectType="2"
:class-list="classList"
@handleClass="handleBlogClass"
ref="blogClass"
placeholder="请选择文章分类"
></select-card>
</div>
<input type="text" placeholder="相关链接" style="width: 461px;" v-model="originLink" ref="originLink">
<input type="text" placeholder="相关链接" style="width: 461px;" v-model="originLink" ref="originLink">
</div>
<div class="header-content">
<span>*</span>
......@@ -104,8 +110,8 @@
</div>
<div class="blog-release__footer">
<p class="footer__left">上传封面
<img :src="this.cover" alt="">
<input type="file" @change="(e)=>changeToUploadCover(e)" placeholder="上传项目封面图" >
<img :src="cover" alt="">
<input type="file" @change="(e)=>changeToUploadCover(e)" placeholder="上传项目封面图">
</p>
<div class="footer__right">
<p>已自动存为草稿</p>
......@@ -121,342 +127,411 @@
</template>
<script>
import CardContainer from "../../../components/pc/cardContainer";
import SelectCard from "../../../components/pc/select/selectCard";
import config from "../../../action/config";
export default {
async asyncData ({ $axios }) {
const blogListRes = await $axios.$get(config.api.get.Blog.myList,{
params:{
page:1,
size:12,
}
});
console.log(this);
import CardContainer from "../../../components/pc/cardContainer";
import SelectCard from "../../../components/pc/select/selectCard";
import config from "../../../action/config";
export default {
async asyncData({$axios, query}) {
const blogListRes = await $axios.$get(config.api.get.Blog.myList, {
params: {
page: 1,
size: 12,
}
});
if (query.hasOwnProperty('id')) {
const blogDetailRes = await $axios.$get(config.api.get.Blog.detail + query.id);
return {
blogList:blogListRes.data.dataList
detailContent: blogDetailRes.data,
blogList: blogListRes.data.dataList
}
} else {
return {
blogList: blogListRes.data.dataList
};
}
},
mounted() {
if (this.$route.query.id) {
this.blogTitle = this.detailContent.blogTitle;
this.originLink = this.detailContent.originLink;
this.blogAbstract = this.detailContent.blogAbstract;
this.content = this.detailContent.content;
this.cover = this.detailContent.cover;
this.allowComment = this.detailContent.allowComment;
this.allowForward = this.detailContent.allowForward;
this.way = this.detailContent.viewPrivileges;
this.$refs.blogClass.$refs.select.value = this.detailContent.category;
this.blogClass = this.detailContent.categoryId;
console.log(this.$refs.tagIds);
let tags = [];
this.tagList = new Set();
this.detailContent.tags.forEach(item => {
let obj = {
tag: item.tagName,
tagId: item.tagId
};
tags.push(obj);
this.tagList.add(item.tagId);
});
this.$refs.tagIds.result = tags;
}
},
components: {SelectCard, CardContainer},
data() {
return {
markdownOption: {
bold: true, // 粗体
italic: true, // 斜体
header: true, // 标题
underline: true, // 下划线
strikethrough: true, // 中划线
mark: true, // 标记
superscript: true, // 上角标
subscript: true, // 下角标
quote: true, // 引用
ol: true, // 有序列表
ul: true, // 无序列表
link: true, // 链接
imagelink: true, // 图片链接
code: true, // code
table: true, // 表格
fullscreen: true, // 全屏编辑
readmodel: true, // 沉浸式阅读
htmlcode: true, // 展示html源码
help: false, // 帮助
undo: true, // 上一步
redo: true, // 下一步
trash: true, // 清空
save: true, // 保存(触发events中的save事件)
navigation: true, // 导航目录
alignleft: true, // 左对齐
subfield: true, // 单双栏模式
preview: true // 预览
},
zIndex: 100, // 控制全屏时
content: '',
comment: '',
reprint: '',
lastSaveTime: new Date(),
blogClass: '',
addFile: {},
userCover: '',
cover: '无',
originLink: '',
way: 1,
allowComment: true,
allowForward: true,
blogAbstract: '',
blogTitle: '',
blogDetail: '',
tagIds: '',
i: 0,
tagList: new Set(),
img: "",
classList: [{tagId: 1, tag: "web"}, {tagId: 2, tag: "java"}, {tagId: 3, tag: "javascript"}]
// classList:["web","java","javascript"]
}
},
methods: {
toDetail() {
this.$router.push('/detail')
},
components: {SelectCard, CardContainer},
data() {
return {
markdownOption: {
bold: true, // 粗体
italic: true, // 斜体
header: true, // 标题
underline: true, // 下划线
strikethrough: true, // 中划线
mark: true, // 标记
superscript: true, // 上角标
subscript: true, // 下角标
quote: true, // 引用
ol: true, // 有序列表
ul: true, // 无序列表
link: true, // 链接
imagelink: true, // 图片链接
code: true, // code
table: true, // 表格
fullscreen: true, // 全屏编辑
readmodel: true, // 沉浸式阅读
htmlcode: true, // 展示html源码
help: false, // 帮助
undo: true, // 上一步
redo: true, // 下一步
trash: true, // 清空
save: true, // 保存(触发events中的save事件)
navigation: true, // 导航目录
alignleft: true, // 左对齐
subfield: true, // 单双栏模式
preview: true // 预览
},
zIndex: 100, // 控制全屏时
content: '',
comment: '',
reprint: '',
lastSaveTime: new Date(),
blogClass: '',
addFile:{},
userCover:'',
cover:'无',
originLink:'',
way:1,
allowComment:true,
allowForward:true,
blogAbstract:'',
blogTitle:'',
blogDetail:'',
tagIds:'',
i:0,
tagList:[],
img:"",
classList: [{tagId:1,tag:"web"}, {tagId:2,tag:"java"},{tagId:3,tag:"javascript"}]
// classList:["web","java","javascript"]
// 获得下拉框得内容
handleBlogClass(value) {
this.blogClass = value.tag;
if (value.tag === "web") {
this.blogClass = 1;
} else if (value.tag === "java") {
this.blogClass = 2
} else if (value.tag === "javascript") {
this.blogClass = 3
}
console.log(this.blogClass)
},
methods: {
toDetail(){
this.$router.push('/detail')
},
// 获得下拉框得内容
handleBlogClass(value) {
this.blogClass = value.tag;
if(value.tag==="web"){
this.blogClass=1;
}else if(value.tag==="java"){
this.blogClass=2
}else if(value.tag==="javascript"){
this.blogClass=3
}
console.log(this.blogClass)
},
handleQuestionClass(value) {
this.class = value;
console.log(value);
},
// 获得得标签数组
handleTagList(tagList) {
this.tagIds=tagList;
console.log(this.tagIds);
console.log(this.tagIds.length);
for(this.i;this.i<this.tagIds.length;this.i++){
this.tagList+=this.tagIds[this.i].tag+" "
}
},
//上传图片
async changeToUploadCover(e) {
let formData = new window.FormData();
formData.append('file', e.target.files[0]);
formData.append('type', 1);
//console.log(formData);
const isLt5M = (e).target.files[0].size / 1024 / 1024 < 5
if (!isLt5M) {
this.$message.error('图片大小超过5M,请重新选择图片!');
return false
}
let imgResponse = await this.$axios.$post(config.api.post.Resource.file, formData);
console.log(imgResponse);
if (imgResponse.code === 0) {
this.cover = imgResponse.data;//图片地址
this.$message({
type: 'success',
message: '图片上传成功'
})
} else {
this.$message({
type: 'warning',
message: imgResponse.msg
})
}
handleQuestionClass(value) {
this.class = value;
console.log(value);
},
// 获得得标签数组
handleTagList(tagList) {
console.log(this.tagList);
tagList.forEach(item => {
this.tagList.add(item.tagId)
});
},
//上传图片
async changeToUploadCover(e) {
},
let formData = new window.FormData();
formData.append('file', e.target.files[0]);
formData.append('type', 1);
//console.log(formData);
const isLt5M = (e).target.files[0].size / 1024 / 1024 < 5
if (!isLt5M) {
this.$message.error('图片大小超过5M,请重新选择图片!');
return false
}
let imgResponse = await this.$axios.$post(config.api.post.Resource.file, formData);
console.log(imgResponse);
if (imgResponse.code === 0) {
this.cover = imgResponse.data;//图片地址
this.$message({
type: 'success',
message: '图片上传成功'
})
} else {
this.$message({
type: 'warning',
message: imgResponse.msg
})
}
//参数判断
dataPost() {
if(this.blogTitle===''){
this.$refs.blogTitle.focus();
this.$message({
message: "请输入文章标题",
type: 'warning'
});
return false;
}
if(this.blogClass===''){
this.$refs.blogClass.handleShow();
this.$refs.blogClass.$refs.select.focus();
this.$message({
message: "请选择文章分类",
type: 'warning'
});
return false;
}
if(this.blogAbstract===''){
this.$refs.blogAbstract.focus();
this.$message({
message: "请输入文章摘要(用一句话介绍该文章)",
type: 'warning'
});
return false;
}
if(this.content===''){
this.$refs.content.textAreaFocus();
},
this.$message({
message: "请输入博客正文",
type: 'warning'
});
//参数判断
dataPost() {
if (this.blogTitle === '') {
this.$refs.blogTitle.focus();
this.$message({
message: "请输入文章标题",
type: 'warning'
});
return false;
}
if (this.blogClass === '') {
this.$refs.blogClass.handleShow();
this.$refs.blogClass.$refs.select.focus();
this.$message({
message: "请选择文章分类",
type: 'warning'
});
return false;
}
if (this.blogAbstract === '') {
this.$refs.blogAbstract.focus();
this.$message({
message: "请输入文章摘要(用一句话介绍该文章)",
type: 'warning'
});
return false;
}
if (this.content === '') {
this.$refs.content.textAreaFocus();
this.$message({
message: "请输入博客正文",
type: 'warning'
});
return false;
}
if (this.tagList.size === '') {
//this.$refs.tagIds.focus();
this.$refs.tagIds.handleShow();
this.$refs.tagIds.$refs.tag.focus();
this.$message({
message: "请添加或创建您的博客标签",
type: 'warning'
});
return false;
}
if (this.originLink !== '') {
let reg = /^(?=^.{3,255}$)((http|https|ftp)?:\/\/)?(www\.)?[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+(:\d+)*(\/)?(?:\/(.+)\/?$)?(\/\w+\.\w+)*([\?&]\w+=\w*|[\u4e00-\u9fa5]+)*$/;
if (this.originLink === "无" || reg.test(this.originLink)) {
this.dataPostSaveUserInfo();
return false;
}
if(this.tagIds===''){
//this.$refs.tagIds.focus();
this.$refs.tagIds.handleShow();
this.$refs.tagIds.$refs.tag.focus();
} else if (!reg.test(this.originLink)) {
this.$refs.originLink.focus();
this.$message({
message: "请添加或创建您的博客标签",
type: 'warning'
type: 'warning',
message: '请输入正确的网站地址'
});
return false;
}
if(this.originLink!==''){
let reg =/^(?=^.{3,255}$)((http|https|ftp)?:\/\/)?(www\.)?[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+(:\d+)*(\/)?(?:\/(.+)\/?$)?(\/\w+\.\w+)*([\?&]\w+=\w*|[\u4e00-\u9fa5]+)*$/;
if (this.originLink==="无" ) {
this.dataPostSaveUserInfo();
return false;
} else if (!reg.test(this.originLink)) {
this.$refs.originLink.focus();
this.dataPostSaveUserInfo();
this.$message({
type: 'warning',
message: '请输入正确的网站地址'
});
return false
}
}else{
this.originLink='无';
this.dataPostSaveUserInfo()
return false
}
},
} else {
this.originLink = '无';
this.dataPostSaveUserInfo()
}
},
dataPostSaveUserInfo(){
this.$axios.$post(config.api.post.Blog.release,{
allowComment: this.allowComment,//评论权限
allowForward: this.allowForward,//转载权限
blogAbstract: this.blogAbstract,//摘要
content: this.content,//内容
contentHtml: this.blogDetail,// 内容的html
blogTitle: this.blogTitle,//标题
categoryId: this.blogClass,//文章类型
cover: this.cover,//封面图
originLink: this.originLink,
tagIds: [
this.tagList//标签id
],
topicIds: [
"null"//话题id
],
viewPrivileges: this.way //1公开,0私有
}).then((response)=>{
if(response.code===0){
this.$message({
message:"提交成功",
type:'success'
});
/* setTimeout(() => {
this.$router.push('/personal-center/home/blog')
}, 500);*/
this.$router.push('/personal-center/home/blog')
}else{
this.$message({
message:response.msg,
type:'warning'
})
}
})
},
dataPostSaveUserInfo() {
if (this.$route.query.id) {
this.$axios.$put(config.api.put.Blog.revise + this.$route.query.id, {
allowComment: this.allowComment,//评论权限
allowForward: this.allowForward,//转载权限
blogAbstract: this.blogAbstract,//摘要
content: this.content,//内容
contentHtml: this.blogDetail,// 内容的html
blogTitle: this.blogTitle,//标题
categoryId: this.blogClass,//文章类型
cover: this.cover,//封面图
originLink: this.originLink,
tagIds: Array.from(this.tagList),
topicIds: [
"null"//话题id
],
viewPrivileges: this.way //1公开,0私有
})
.then((response) => {
if (response.code === 0) {
this.$message({
message: "修改博客成功",
type: 'success'
});
this.$router.push('/personal-center/home/blog')
} else {
this.$message({
message: response.msg,
type: 'warning'
})
}
})
} else {
this.$axios.$post(config.api.post.Blog.release, {
allowComment: this.allowComment,//评论权限
allowForward: this.allowForward,//转载权限
blogAbstract: this.blogAbstract,//摘要
content: this.content,//内容
contentHtml: this.blogDetail,// 内容的html
blogTitle: this.blogTitle,//标题
categoryId: this.blogClass,//文章类型
cover: this.cover,//封面图
originLink: this.originLink,
tagIds: Array.from(this.tagList),
topicIds: [
"null"//话题id
],
viewPrivileges: this.way //1公开,0私有
})
.then((response) => {
if (response.code === 0) {
this.$message({
message: "发布博客成功",
type: 'success'
});
/* setTimeout(() => {
this.$router.push('/personal-center/home/blog')
}, 500);*/
this.$router.push('/personal-center/home/blog')
} else {
this.$message({
message: response.msg,
type: 'warning'
})
}
})
}
},
imgAdd(pos, file) {
// filename: 写在md中的文件名, File: File Object
// 第一步.将图片上传到服务器.
let formdata = new window.FormData();
formdata.append('file', file);
formdata.append('type', 4);
this.$axios.$post(config.api.post.Resource.file, formdata)
.then((res) => {
console.log(res);
let url = res.data;
this.$refs.content.$img2Url(pos, url);
this.$message({
type: 'success',
message: '上传图片成功'
})
imgAdd(pos, file) {
// filename: 写在md中的文件名, File: File Object
// 第一步.将图片上传到服务器.
let formdata = new window.FormData();
formdata.append('file', file);
formdata.append('type', 4);
this.$axios.$post(config.api.post.Resource.file, formdata)
.then((res) => {
console.log(res);
let url = res.data;
this.$refs.content.$img2Url(pos, url);
this.$message({
type: 'success',
message: '上传图片成功'
})
.catch(err => {
this.$message({
type: 'warning',
message: '图片上传失败'
})
})
.catch(err => {
this.$message({
type: 'warning',
message: '图片上传失败'
})
},
imgDel(pos) {
//删除图片,并不是修改就会触发,仅支持工具栏操作
// filename: 写在md中的文件名
console.log(pos);
},
save(value, render) { //保存文章内容
this.blogDetail = render;
},
intervalSave(value, render) {
// 自动保存
// render: value 经过markdown解析后的结果
// this.lastSaveTime = now;
this.blogDetail = render;
// let now = new Date();
// if (now - this.lastSaveTime >= 2 * 1000) {}
},
readScreen(boolean, str) { // 预览
this.zIndex = 8000
}
})
},
}
imgDel(pos) {
//删除图片,并不是修改就会触发,仅支持工具栏操作
// filename: 写在md中的文件名
console.log(pos);
},
save(value, render) { //保存文章内容
this.blogDetail = render;
},
intervalSave(value, render) {
// 自动保存
// render: value 经过markdown解析后的结果
// this.lastSaveTime = now;
this.blogDetail = render;
// let now = new Date();
// if (now - this.lastSaveTime >= 2 * 1000) {}
},
readScreen(boolean, str) { // 预览
this.zIndex = 8000
}
},
}
</script>
<style lang="scss" scoped>
input{
border:1*$length solid transparent;
input {
border: 1*$length solid transparent;
@extend %animate-transition;
&:focus{
border:1*$length solid #00AAE6;
&:focus {
border: 1*$length solid #00AAE6;
}
}
.blog-release-container {
width: $pageWidth;
margin: 24*$length auto 32*$length auto;
@extend %flex-row-spb;
align-items: start;
.blog-release-container__l {
.blog-release_List{
.blog-release_List {
width: 266*$length;
@extend %flex-row-spb;
margin-top: 5px;
padding-left: 18*$length;
padding-right: 18*$length;
font-size: 13*$length;
p{
p {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.blog-release_List_r{
.blog-release_List_r {
color: #999999
}
:hover{
:hover {
color: #00AAE6;
cursor:pointer
cursor: pointer
}
}
}
.blog-release-container__r {
.blog-release {
width: 748*$length;
margin: 0 auto;
.blog-release__header {
margin-top: 40*$length;
.header-content{
.header-content {
@extend %flex-row-spb;
margin-bottom: 32*$length;
> span {
color: #FF7474;
font-size: 6*$length;
}
> input {
width: 726*$length;
padding: 14*$length 16*$length;
......@@ -465,9 +540,11 @@
@include border-radius(4*$length);
@include fontStyle(14, 46, 500, #666, left);
}
.select__wrap{
.select__wrap {
@extend %flex-row-spb;
align-items: start;
> span {
color: #FF7474;
font-size: 6*$length;
......@@ -477,32 +554,39 @@
}
}
}
.blog-release__content {
@extend %flex-row-spb;
align-items: start;
> span {
display: inline-block;
margin-top: 18*$length;
color: #FF7474;
font-size: 6*$length;
}
.editor-container {
width: 723*$length;
height: 230*$length;
overflow: auto;
.editor {
min-height: 230*$length;
min-width: 723*$length;
}
}
}
.blog-release__select__wrap {
@extend %flex-row-spb;
align-items: start;
margin-top: 32*$length;
.select-content{
.select-content {
@extend %flex-row-spb;
align-items: start;
> span {
color: #FF7474;
font-size: 6*$length;
......@@ -511,25 +595,32 @@
}
}
}
.choose-container{
.choose-container {
@extend %flex-row-spb;
.input-box__wrap{
.input-box__wrap {
@extend %flex-row-spb;
> span {
margin-right: 16*$length;
color: #FF7474;
font-size: 6*$length;
}
.input-box {
margin-right: 40*$length;
line-height: 16*$length;
input[type="radio"] {
display: none;
}
label {
@include fontStyle(12, 16, 500, #999, left);
vertical-align: middle;
}
input[type="radio"] + label::before {
content: "\a0"; /*不换行空格*/
display: inline-block;
......@@ -544,6 +635,7 @@
background-color: #fff;
@include border-radius(2*$length);
}
input[type="radio"]:checked + label::before {
display: inline-block;
width: 12*$length;
......@@ -567,38 +659,44 @@
@extend %flex-row-spb;
align-items: flex-end;
margin-top: 35*$length;
.footer__left{
.footer__left {
overflow: hidden;
width:196*$length;
width: 196*$length;
background-color: #F4F8FA;
@extend %cursorPointer;
@include border-radius(4*$length);
@include fontStyle(12,130,500,#666,center);
& input{
@include fontStyle(12, 130, 500, #666, center);
& input {
float: left;
height:100%;
width:100%;
height: 100%;
width: 100%;
opacity: 0;
transform: translateY(-200%);
@extend %cursorPointer;
}
& img{
& img {
float: left;
height:100%;
width:100%;
height: 100%;
width: 100%;
transform: translateY(-100%);
object-fit: contain;
}
}
.footer__right{
.footer__right {
@extend %flex-row-spb;
justify-content: flex-end;
> p {
margin-right: 32*$length;
@include fontStyle(12,16,500,#999,left);
@include fontStyle(12, 16, 500, #999, left);
}
> button {
@include fontStyle(14,19,500,#fff,center);
@include fontStyle(14, 19, 500, #fff, center);
width: 100*$length;
height: 40*$length;
background-color: #00AAE6;
......@@ -606,12 +704,14 @@
@extend %cursorPointer;
@include border-radius(4*$length);
}
.preview{
.preview {
color: #666;
background-color: #fff;
margin-right: 16*$length;
@extend %animate-transition;
&:hover{
&:hover {
color: #fff;
background-color: #00AAE6;
}
......
......@@ -40,7 +40,7 @@
></login-input>
</template>
<template #mainFooter>
<login-button @handle="handleRegister" button="注册"></login-button>
<login-button @handle="handleRegister" button="注册" ref="registerButton"></login-button>
</template>
</login-wrap>
</div>
......@@ -164,12 +164,7 @@ export default {
}
},
handleRegisterEnter() {
console.log(123);
console.log(this);
this.$on('handle', (isAgree) => {
console.log(isAgree);
this.handleRegister(isAgree)
})
this.$refs.registerButton.handel();
},
async handleRegister(isAgree) {
this.checkAccount();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment