|
|
@@ -130,6 +130,7 @@ export default {
|
|
|
blogId: this.$route.params.id,
|
|
|
blogEdit: {},
|
|
|
blogFile: null,
|
|
|
+ blogImageList: [],
|
|
|
categoryOption: ['Fashion', 'Food', 'Gaming', 'Quote', 'Video'],
|
|
|
statusOption: ['Published', 'Pending', 'Draft'],
|
|
|
snowOption: {
|
|
|
@@ -157,7 +158,6 @@ export default {
|
|
|
|
|
|
const { inputImageRenderer } = useInputImageRenderer(refInputEl, base64 => {
|
|
|
refPreviewEl.value.src = base64
|
|
|
-
|
|
|
})
|
|
|
|
|
|
return {
|
|
|
@@ -171,7 +171,7 @@ export default {
|
|
|
return format(new Date(date), 'yyyy-MM-dd hh:mm', { locale: zhTW })
|
|
|
},
|
|
|
getUserAvatar(userId) {
|
|
|
- return require('@/assets/images/avatars/' + userId + '-small.png')
|
|
|
+ return ('/images/_/_/_/_/MessagePractise/resources/js/src/assets/images/avatars/' + userId + '-small.png');
|
|
|
},
|
|
|
getUserFullName(userId) {
|
|
|
for (var i = 0; i < this.userList.length; i++) {
|
|
|
@@ -182,13 +182,11 @@ export default {
|
|
|
return 'none';
|
|
|
},
|
|
|
getBannerImg(blogId) {
|
|
|
- var imagePath;
|
|
|
for (var i = 0; i < this.blogImageList.length; i++) {
|
|
|
if (this.blogImageList[i].blogId == blogId) {
|
|
|
- imagePath = this.blogImageList[i].saveName;
|
|
|
+ return this.blogImageList[i].savePath;
|
|
|
}
|
|
|
}
|
|
|
- return require('@/assets/images/banner/' + imagePath);
|
|
|
},
|
|
|
getBase64(file) {
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
@@ -199,28 +197,32 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
saveChanges() {
|
|
|
- var imageSaveName = Date.now();
|
|
|
+ useJwt.getPost('/api/blog/edit', {
|
|
|
+ blogId: this.blogId,
|
|
|
+ title: this.blogEdit.title,
|
|
|
+ content: this.blogEdit.content,
|
|
|
+ tags: JSON.stringify(this.blogEdit.tags),
|
|
|
+ })
|
|
|
+ .then(res => {
|
|
|
+ if(res.data == 'success') {
|
|
|
+ console.log(res.data);
|
|
|
+ } else {
|
|
|
+ console.log(res.data);
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- console.log(this.$refs.refPreviewEl.src)
|
|
|
-
|
|
|
- console.log(this.blogId)
|
|
|
- console.log(this.blogEdit.blogTitle)
|
|
|
- console.log(this.blogEdit.excerpt)
|
|
|
-
|
|
|
- // useJwt.getPost('/api/blog/after_edit', {
|
|
|
- // blogId: this.blogId,
|
|
|
- // blogTitle: this.blogEdit.blogTitle,
|
|
|
- // blogContent: this.blogEdit.excerpt,
|
|
|
- // blogTags: this.blogEdit.blogCategories,
|
|
|
- // blogImage: this.blogFile.name,
|
|
|
- // saveName: imageSaveName,
|
|
|
- // });
|
|
|
-
|
|
|
- // // save image to /app/blog/banner
|
|
|
- // var promise = this.getBase64(this.blogFile);
|
|
|
- // promise.then(function (result) {
|
|
|
- // useJwt.getPost('/api/blog/save_banner', { blogImageFile: result, saveName: imageSaveName});
|
|
|
- // });
|
|
|
+ // save image to /app/blog/banner
|
|
|
+ var img = this.$refs.refPreviewEl.src;
|
|
|
+ var formdata = new FormData;
|
|
|
+ formdata.append('blogId', this.blogId);
|
|
|
+ formdata.append('fileName', this.blogFile.name);
|
|
|
+ formdata.append('bannerImage', this.blogFile);
|
|
|
+ if (this.blogFile) {
|
|
|
+ useJwt.getPost('/api/blog-image/store', formdata)
|
|
|
+ .then(res => {
|
|
|
+ console.log(res.data);
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
}
|