From c23efbe2832d1a9eecd4ef5d20d984661b24dd22 Mon Sep 17 00:00:00 2001 From: inleft <inleft@qq.com> Date: Tue, 22 Feb 2022 01:21:52 +0800 Subject: [PATCH] 文章添加补充 --- src/components/mini/mdDetail.vue | 10 ++-- src/components/mini/box10-add.vue | 35 ++++++++++++----- src/components/mini/Aplayer.vue | 2 src/components/mini/box-new-article.vue | 6 ++- src/components/mini/box2-class.vue | 2 src/components/group/MyModal.vue | 41 ++++++++++++++++---- src/components/group/articleListScorll.vue | 4 +- 7 files changed, 71 insertions(+), 29 deletions(-) diff --git a/src/components/group/MyModal.vue b/src/components/group/MyModal.vue index 6ccd798..55de7de 100644 --- a/src/components/group/MyModal.vue +++ b/src/components/group/MyModal.vue @@ -21,11 +21,11 @@ <script> import box10 from "../mini/box10-add.vue" - + import { blogAdd } from '../../api/blogArticle.js' - + import md5 from 'js-md5'; export default { components: { box10 @@ -45,25 +45,50 @@ }, handleOk(e) { console.log(this.$refs.modalBox.form); - var res = this.$refs.modalBox.$refs.myForm.validate(valid => { + var res; + this.$refs.modalBox.$refs.myForm.validate(valid => { if (valid) { this.$message.info("校验通过") + res = true; } else { this.$message.info("校验失败") - return false; + res = false; } }); - if (!res) return; - this.$message.info("提交表单") + let tempData = this.$refs.modalBox.form; + var param = { + secret: tempData.secret, + title: tempData.title, + articleTypeId: tempData.class, + isOnline: !tempData.online ? 1 : 0, + articleFileId: tempData.fileId, + content: tempData.content, + articleFileType: tempData.blogType, + introduce: "", + coverFileId: tempData.coverFile, + publishDate: tempData.publishDate, + isTop: tempData.top ? 1 : 0, + topValue: tempData.sliderValue, + isLock: tempData.lock ? 1 : 0, + authStatus: tempData.auth, + authPassword: tempData.password == "" ? null : md5(tempData.password), + editorStatus: !tempData.tempSave?1:0 + } + console.log(param) this.loading = true; - setTimeout(() => { + blogAdd(param).then((res) => { + this.$message.info("生成日志成功..") this.visible = false; this.loading = false; - }, 3000); + }); + // setTimeout(() => { + // this.visible = false; + // this.loading = false; + // }, 3000); }, reset(e) { var res = this.$refs.modalBox.$refs.myForm.resetFields() diff --git a/src/components/group/articleListScorll.vue b/src/components/group/articleListScorll.vue index c18502a..99f4a78 100644 --- a/src/components/group/articleListScorll.vue +++ b/src/components/group/articleListScorll.vue @@ -1,8 +1,8 @@ <template> <div> <div v-infinite-scroll="loadMore" infinite-scroll-disabled="busy" :infinite-scroll-distance="10"> - <div v-for="temp in data"> - <newArticle v-bind="temp"></newArticle> + <div v-for="(temp,index) in data"> + <newArticle v-bind="temp" :index="index"></newArticle> <!-- <box5 v-bind="temp"></box5> --> </div> <div v-if="loading && !busy" class="demo-loading-container"> diff --git a/src/components/mini/Aplayer.vue b/src/components/mini/Aplayer.vue index bc5933d..cb0f163 100644 --- a/src/components/mini/Aplayer.vue +++ b/src/components/mini/Aplayer.vue @@ -1,6 +1,6 @@ <template> <div class="fade"> - <aplayer :audio="audio" fixed style="z-index: 10;" :preload="preload" /> + <aplayer :audio="audio" fixed style="z-index: 10;" :volume="0.1" :preload="preload" /> <!-- <a-modal ref="musicModal" title="" :dialog-style="{ top: '10px' }" :mask="false" :maskClosable="false" :visible="modal1Visible" @ok="() => setModal1Visible(false)" @cancel="() => setModal1Visible(false)"> diff --git a/src/components/mini/box-new-article.vue b/src/components/mini/box-new-article.vue index 91ffc2d..ebf3225 100644 --- a/src/components/mini/box-new-article.vue +++ b/src/components/mini/box-new-article.vue @@ -3,7 +3,7 @@ <div class="recent-posts" id="recent-posts"> <div class="recent-post-item"> <div class="miniTag" v-if="isTop==1">置顶</div> - <div class="post_cover left_radius" v-if="id%2==0"> + <div class="post_cover left_radius" v-if="index%2==0"> <router-link :to="{path:'/mdDetail',query:{id:id}}" :title="title"> <div class="block left_radius"></div> <img class="post_bg" :src="coverFileURL" :onerror="img404" :alt="title"> @@ -53,7 +53,9 @@ <script> export default { props: { - "id": { + "index": { + default: 0, + },"id": { default: 0, }, "isTop": { diff --git a/src/components/mini/box10-add.vue b/src/components/mini/box10-add.vue index 70509ef..6a4b427 100644 --- a/src/components/mini/box10-add.vue +++ b/src/components/mini/box10-add.vue @@ -68,10 +68,10 @@ <a-form-model-item label=" 日志类型"> <a-radio-group v-model="form.blogType"> - <a-radio value="Markdown"> + <a-radio value="1"> markdown </a-radio> - <a-radio value="Html"> + <a-radio value="2"> html </a-radio> </a-radio-group> @@ -110,6 +110,7 @@ </a-upload> --> <a-upload :customRequest="customRequest" name="file" :showUploadList="true" list-type="picture" + @change="handleChangeCoverFile" :default-file-list="form.coverFileList"> <a-button> <a-icon type="upload" />jpg/png/jpeg.. @@ -155,10 +156,10 @@ <div v-show="form.lock "> <a-form-model-item label="阅读权限"> <a-radio-group v-model="form.auth"> - <a-radio value="private"> + <a-radio value="2"> 私人 </a-radio> - <a-radio value="password"> + <a-radio value="3"> 密码授权 </a-radio> </a-radio-group> @@ -209,7 +210,7 @@ } else { console.log("文件未传"); this.$refs.myForm.validateField('blogFileList') - if (this.form.blogFileList == null || this.form.blogFileList.length == 0) { + if (this.form.fileId == null) { callback(new Error('文件未传')); } } @@ -235,12 +236,15 @@ content: '', class: [], tempSave: false, - blogType: "Markdown", + blogType: "1", publishDate: "", lock: false, top: false, - auth: "private", + sliderValue:50, + auth: 1, password: "", + fileId: null, + coverFile: null, blogFileList: [], coverFileList: [], }, @@ -288,10 +292,8 @@ }, methods: { beforeUpload(file, fileList) { - console.log(333); - console.log(this.blogFileList); return new Promise((resolve, reject) => { - if (fileList.length >= 2) { + if (this.form.fileId != null) { this.$message.error('这里最多上传一个文件'); return reject(false); } @@ -316,6 +318,18 @@ console.log(info.file, info.fileList); } if (info.file.status === 'done') { + this.form.fileId = info.file.response.data; + this.$message.success(`${info.file.name} file uploaded successfully`); + } else if (info.file.status === 'error') { + this.$message.error(`${info.file.name} file upload failed.`); + } + }, + handleChangeCoverFile(info) { + if (info.file.status !== 'uploading') { + console.log(info.file, info.fileList); + } + if (info.file.status === 'done') { + this.form.coverFile = info.file.response.data; this.$message.success(`${info.file.name} file uploaded successfully`); } else if (info.file.status === 'error') { this.$message.error(`${info.file.name} file upload failed.`); @@ -330,6 +344,7 @@ sysFileInfoUpload(formData).then((res) => { if (res.success) { this.$message.success('上传成功') + option.onSuccess(res, option.file) } else { this.$message.error('上传失败:' + res.message) diff --git a/src/components/mini/box2-class.vue b/src/components/mini/box2-class.vue index 0d6a7c6..a26cd6d 100644 --- a/src/components/mini/box2-class.vue +++ b/src/components/mini/box2-class.vue @@ -38,7 +38,7 @@ this.$message.info('loading',0.3); queryBlogArticleType({}).then((res) => { this.list1 = res.data.slice(0, 3) - this.list2 = res.data.slice(4) + this.list2 = res.data.slice(3) }) }, data() { diff --git a/src/components/mini/mdDetail.vue b/src/components/mini/mdDetail.vue index 4c98a31..632ffe8 100644 --- a/src/components/mini/mdDetail.vue +++ b/src/components/mini/mdDetail.vue @@ -123,15 +123,15 @@ return } - - //获取日志资源文件 - this.showMsg = false; - this.errorMsg = ""; this.$axios .get(res.data.articleFileURL) .then((res) => { this.source = res.data; }) + + //获取日志资源文件 + this.showMsg = false; + this.errorMsg = ""; }) }, pressEnter() { @@ -152,7 +152,7 @@ this.$router.go(-1); } }, - + } </script> -- Gitblit v1.9.1