diff --git a/src/api/blog.ts b/src/api/blog.ts index d19cfdd..167f5fa 100644 --- a/src/api/blog.ts +++ b/src/api/blog.ts @@ -40,4 +40,16 @@ const update_blog_type = (params: Object) => { }) } -export { get_blogs, get_blog, get_user_blogs, update_blog_type } \ No newline at end of file +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 } \ No newline at end of file diff --git a/src/view/blog/createBlog.vue b/src/view/blog/createBlog.vue index eb2cd9b..bea05c8 100644 --- a/src/view/blog/createBlog.vue +++ b/src/view/blog/createBlog.vue @@ -25,7 +25,7 @@ import MdEditor from 'md-editor-v3'; import 'md-editor-v3/lib/style.css'; import { get_user_blogs } from '../../api/blog' 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' let text = ref("") @@ -64,6 +64,21 @@ get_user_blogs({}).then(response => { }); 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) => { return type_tab.id == id