create a blog insert api

This commit is contained in:
simple321vip
2022-04-20 23:19:42 +08:00
parent e3be0674d8
commit e966d15e5e
2 changed files with 29 additions and 2 deletions
+13 -1
View File
@@ -40,4 +40,16 @@ const update_blog_type = (params: Object) => {
}) })
} }
export { get_blogs, get_blog, get_user_blogs, update_blog_type } const insert_blog_type = (params: Object) => {
return request({
url: '/blog/insert_blog_type',
method: 'put',
headers: {
'Content-Type': 'application/json;charsetset=UTF-8'
},
data: params
})
}
export { get_blogs, get_blog, get_user_blogs, update_blog_type, insert_blog_type }
+16 -1
View File
@@ -25,7 +25,7 @@ import MdEditor from 'md-editor-v3';
import 'md-editor-v3/lib/style.css'; import 'md-editor-v3/lib/style.css';
import { get_user_blogs } from '../../api/blog' import { get_user_blogs } from '../../api/blog'
import { Blog, BlogType } from '../../entity/index' import { Blog, BlogType } from '../../entity/index'
import { update_blog_type } from '../../api/blog' import { update_blog_type, insert_blog_type } from '../../api/blog'
import Tab from '../../components/common/Tab.vue' import Tab from '../../components/common/Tab.vue'
let text = ref<string>("") let text = ref<string>("")
@@ -64,6 +64,21 @@ get_user_blogs({}).then(response => {
}); });
blog_type_list.push(blog_type) blog_type_list.push(blog_type)
}); });
}).then(() => {
if (blog_type_list.length == 0) {
const data = {
blog_type_name: '未分类'
}
insert_blog_type(data).then(response => {
if (response.data) {
blog_type_list.push({
blog_type_id: response.data.blog_type_id,
blog_type_name: response.data.blog_type_id,
blog_list: []
})
}
})
}
}) })
const handleCheck = (id: string) => { const handleCheck = (id: string) => {
return type_tab.id == id return type_tab.id == id