bug修改

This commit is contained in:
simple321vip
2022-04-30 01:34:51 +08:00
parent 868ebfee3a
commit 91ee8a9577
7 changed files with 174 additions and 110 deletions
+33 -48
View File
@@ -1,9 +1,13 @@
import request from '../utils/request' import request from '../utils/request'
import Qs from 'qs' import Qs from 'qs'
const headers = {
'Content-Type': 'application/json;charsetset=UTF-8'
}
const get_blogs = (params: Object) => { const get_blogs = (params: Object) => {
return request({ return request({
url: '/blog', url: '/blog',
method: 'get', method: 'GET',
params: params, params: params,
paramsSerializer: (params) => { paramsSerializer: (params) => {
return Qs.stringify(params, { arrayFormat: 'repeat' }) return Qs.stringify(params, { arrayFormat: 'repeat' })
@@ -11,83 +15,64 @@ const get_blogs = (params: Object) => {
}) })
} }
const get_blog = (params: any) => {
return request({
url: '/blog/' + params.blog_id,
method: 'get'
})
}
const listAll = () => { const listAll = () => {
return request({ return request({
url: '/author/blog/list', url: '/author/blog/list',
method: 'get' method: 'GET'
}) })
} }
const updateBtName = (params: Object) => { const updateBtName = (data: Object) => {
return request({ return request({
url: '/author/blog/update_blog_type', url: '/author/blog_type',
method: 'post', method: 'POST',
headers: { headers: headers,
'Content-Type': 'application/json;charsetset=UTF-8' data: data
},
data: params
}) })
} }
const insert_blog_type = (params: Object) => { const putBlogType = (data: Object) => {
return request({ return request({
url: '/blog/insert_blog_type', url: '/author/blog_type',
method: 'put', method: 'PUT',
headers: { headers: headers,
'Content-Type': 'application/json;charsetset=UTF-8' data: data
},
data: params
}) })
} }
const getContent = (id: string) => { const getContent = (id: string) => {
return request({ return request({
url: '/author/blog/' + id + '/content', url: '/author/blog/content/' + id,
method: 'get', method: 'GET',
headers: { headers: headers,
'Content-Type': 'application/json;charsetset=UTF-8'
}
}) })
} }
const newBlog = (postData: Object) => { const putBlog = (postData: Object) => {
return request({ return request({
url: '/author/blog/createContent', url: '/author/blog/content',
method: 'post', method: 'PUT',
headers: { headers: headers,
'Content-Type': 'application/json;charsetset=UTF-8'
},
data: postData data: postData
}) })
} }
const updateContent = (params: Object) => { const updateContent = (postData: Object) => {
return request({ return request({
url: '/author/blog/updateContent', url: '/author/blog/content',
method: 'post', method: 'POST',
headers: { headers: headers,
'Content-Type': 'application/json;charsetset=UTF-8' data: postData
},
data: params
}) })
} }
const deleteContent = (params: string) => { const deleteContent = (bid: string) => {
return request({ return request({
url: '/author/blog/delete/' + params, url: '/author/blog/content/' + bid,
method: 'get', method: 'DELETE',
headers: { headers: headers,
'Content-Type': 'application/json;charsetset=UTF-8'
}
}) })
} }
export { get_blogs, get_blog, listAll, updateBtName, insert_blog_type, getContent, newBlog, updateContent, deleteContent } export { get_blogs, listAll, updateBtName, putBlogType, getContent, putBlog, updateContent, deleteContent }
+1 -1
View File
@@ -1,7 +1,7 @@
import request from '../utils/request' import request from '../utils/request'
const authorize = (params: any) => { const authorize = (params: any) => {
return request({ return request({
url: '/api/vi/authorize', url: '/authorize',
method: 'post', method: 'post',
data: params data: params
}) })
+4 -2
View File
@@ -14,8 +14,10 @@
</el-main> </el-main>
<el-footer> <el-footer>
<span> <span>
小管设计8 本网站不涉及色情赌博毒品和政治宗教等内容暂时为个人学习用途
<br />一个执着于小提琴学习的垃圾程序员1 考虑到法律风险针对有敏感词汇还设有过滤功能所以暂时不对外提供一切功能
<br />
再次重申本网站只作为学习网站
</span> </span>
</el-footer> </el-footer>
</el-container> </el-container>
+127 -46
View File
@@ -1,15 +1,16 @@
<template> <template>
<div class="blog_editer" v-if="isReady"> <div class="blog_editer" v-if="isReady">
<div class="bt_section" :style="btWholeStyle"> <div class="bt_section" :style="btWholeStyle">
<el-button @click="insertBlogType">增加</el-button> <el-button class="bt-input" @click="contentDialogVisible = true">增加</el-button>
<el-button class="bts" v-for="(value, key) of blogTypes" :key="key" @click="onclickTypeTab(value[0])"> <el-button class="bt-input" v-for="(value, key) of blogTypes" :key="key" @click="onclickTypeTab(value[0])">
<el-dropdown trigger="click"> <el-dropdown trigger="click">
<el-icon> <el-icon v-show="checkedBlogIndex == value[0]">
<edit /> <edit />
</el-icon> </el-icon>
<template #dropdown> <template #dropdown>
<el-dropdown-menu> <el-dropdown-menu>
<el-dropdown-item @click="handleEditBtName(value[1])">修改</el-dropdown-item> <el-dropdown-item @click="dialogVisible = true">修改</el-dropdown-item>
<el-dropdown-item @click="btdeleteDialogVisible = true">删除</el-dropdown-item>
<el-dropdown-item @click="true">退出</el-dropdown-item> <el-dropdown-item @click="true">退出</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</template> </template>
@@ -18,32 +19,51 @@
</el-button> </el-button>
</div> </div>
<div class="b_section" :style="bWholeStyle"> <div class="b_section" :style="bWholeStyle">
<el-button @click="insertBlog">增加</el-button> <el-button class="bt-input" @click="insertBlog">增加</el-button>
<el-button v-for="(blog, index) of blogTypes.get(checkedBlogIndex)?.blogs" @click="onclickBlogTab(blog[0])"> <el-button class="bt-input" v-for="(blog, index) of blogTypes.get(checkedBlogIndex)?.blogs"
@click="onclickBlogTab(blog[0])">
{{ blog[1].title }} {{ blog[1].title }}
</el-button> </el-button>
</div> </div>
<div class="c_section">
<div class="title_style">
<el-input v-model="((blogTypes.get(checkedBlogIndex) as BlogType).blogs.get(checkedIndex) as Blog).title"
@keyup.enter.native="saveTitle" @blur="saveTitle">
</el-input>
</div>
<div :style="cWholeStyle"> <div :style="cWholeStyle">
<md-editor theme="light" <md-editor theme="light"
v-model="((blogTypes.get(checkedBlogIndex) as BlogType).blogs.get(checkedIndex) as Blog).content" v-model="((blogTypes.get(checkedBlogIndex) as BlogType).blogs.get(checkedIndex) as Blog).content"
@save="saveContent" /> @save="saveContent" :style="{ height: innerHeight }" />
</div> </div>
<el-dialog v-model="dialogVisible" title="Tips" width="30%"> </div>
<el-dialog v-model="dialogVisible" title="修改博客分类名称" width="30%">
<el-input v-model="(blogTypes.get(checkedBlogIndex) as BlogType).btName"></el-input> <el-input v-model="(blogTypes.get(checkedBlogIndex) as BlogType).btName"></el-input>
<template #footer> <template #footer>
<span class="dialog-footer"> <span class="dialog-footer">
<el-button @click="dialogVisible = false">Cancel</el-button> <el-button @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click="saveType">Confirm</el-button> <el-button type="primary" @click="saveType">确认</el-button>
</span> </span>
</template> </template>
</el-dialog> </el-dialog>
<el-dialog v-model="contentDialogVisible" title="Tips" width="30%"> <el-dialog v-model="contentDialogVisible" title="新的博客分类" width="30%">
<el-input v-model="((blogTypes.get(checkedBlogIndex) as BlogType).blogs.get(checkedIndex) as Blog).title"> <el-input v-model="btName">
</el-input> </el-input>
<template #footer> <template #footer>
<span class="dialog-footer"> <span class="dialog-footer">
<el-button @click="contentDialogVisible = false">Cancel</el-button> <el-button @click="contentDialogVisible = false">取消</el-button>
<el-button type="primary" @click="saveTitle">Confirm</el-button> <el-button type="primary" @click="insertBlogType">确认</el-button>
</span>
</template>
</el-dialog>
<el-dialog v-model="btdeleteDialogVisible" title="删除博客分类" width="30%">
你正在对 {{ (blogTypes.get(checkedBlogIndex) as BlogType).btName }}
<el-input v-model="btName" :placeholder="'请输入<' + (blogTypes.get(checkedBlogIndex) as BlogType).btName + '>'">
</el-input>
<template #footer>
<span class="dialog-footer">
<el-button @click="btdeleteDialogVisible = false">取消</el-button>
<el-button type="primary" @click="insertBlogType">确认</el-button>
</span> </span>
</template> </template>
</el-dialog> </el-dialog>
@@ -51,18 +71,13 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { onBeforeMount, onMounted, reactive, ref, watch } from 'vue' import { onMounted, reactive, ref } from 'vue'
import MdEditor from 'md-editor-v3' import MdEditor from 'md-editor-v3'
import { Edit } from "@element-plus/icons-vue"; import { Edit } from "@element-plus/icons-vue";
import 'md-editor-v3/lib/style.css' import 'md-editor-v3/lib/style.css'
import { updateBtName, updateContent, listAll, insert_blog_type, getContent, newBlog } from '../../api/blog' import { updateBtName, updateContent, listAll, putBlogType, getContent, putBlog } from '../../api/blog'
import $moment from "moment"; import $moment from "moment";
// const MD_SETTING = () => {
// return {
// tools: [{ title: 'bold' }]
// }
// }
type Blog = { type Blog = {
bid: string, bid: string,
btId: string, btId: string,
@@ -80,10 +95,17 @@ type BlogType = {
const blogTypes = reactive<Map<string, BlogType>>(new Map()) const blogTypes = reactive<Map<string, BlogType>>(new Map())
const dialogVisible = ref(false) const dialogVisible = ref(false)
const contentDialogVisible = ref(false) const contentDialogVisible = ref(false)
const btdeleteDialogVisible = ref(false)
let checkedIndex = ref<string>("") let checkedIndex = ref<string>("")
let checkedBlogIndex = ref<string>("") let checkedBlogIndex = ref<string>("")
let isReady = ref(false) let isReady = ref(false)
// 関数定義
/**
* Blog一覧取得
*/
const getTestData = async () => { const getTestData = async () => {
await listAll().then(response => { await listAll().then(response => {
response.data.forEach((element: any) => { response.data.forEach((element: any) => {
@@ -109,12 +131,12 @@ const getTestData = async () => {
isReady.value = true isReady.value = true
checkedBlogIndex.value = blogTypes.keys().next().value checkedBlogIndex.value = blogTypes.keys().next().value
checkedIndex.value = blogTypes.values().next().value.blogs.keys().next().value checkedIndex.value = blogTypes.values().next().value.blogs.keys().next().value
console.log(checkedIndex.value)
} }
getTestData()
// watch(blogTypes, (newValue, oldValue) => { /**
// console.log(newValue, '新值', oldValue, '旧值') * BlogTypeを選べる
// }, { deep: true }) * @param key
*/
const onclickTypeTab = (key: string) => { const onclickTypeTab = (key: string) => {
const bid = <string>blogTypes.get(key)?.blogs.values().next().value.bid const bid = <string>blogTypes.get(key)?.blogs.values().next().value.bid
getContent(bid).then(response => { getContent(bid).then(response => {
@@ -131,6 +153,9 @@ const handleEditBtName = (bt: BlogType) => {
dialogVisible.value = true dialogVisible.value = true
} }
/**
* Blogタイプ名称修正
*/
const saveType = () => { const saveType = () => {
const query = { const query = {
btId: checkedBlogIndex.value, btId: checkedBlogIndex.value,
@@ -141,15 +166,20 @@ const saveType = () => {
}) })
} }
/**
* Blogタイトル修正
*/
const saveTitle = () => { const saveTitle = () => {
const query = { const query = {
bid: checkedIndex.value, bid: checkedIndex.value,
title: ((blogTypes.get(checkedBlogIndex.value) as BlogType).blogs.get(checkedIndex.value) as Blog).title title: ((blogTypes.get(checkedBlogIndex.value) as BlogType).blogs.get(checkedIndex.value) as Blog).title
} }
updateContent(query).then(response => { updateContent(query).then(response => {
contentDialogVisible.value = false
}) })
} }
/**
* Blog内容修正
*/
const saveContent = () => { const saveContent = () => {
const query = { const query = {
bid: checkedIndex.value, bid: checkedIndex.value,
@@ -159,15 +189,15 @@ const saveContent = () => {
}) })
} }
const insertBlogType = () => { /**
dialogVisible.value = true * ブログ新規作成
} */
const insertBlog = () => { const insertBlog = () => {
const data = { const data = {
btId: checkedBlogIndex.value, btId: checkedBlogIndex.value,
title: $moment().format("YYYY-MM-DD") title: $moment().format("YYYY-MM-DD")
} }
newBlog(data).then(response => { putBlog(data).then(response => {
const { bid, title, content } = response.data const { bid, title, content } = response.data
const blog = { const blog = {
bid: bid, bid: bid,
@@ -181,49 +211,100 @@ const insertBlog = () => {
checkedIndex.value = bid checkedIndex.value = bid
}) })
} }
console.log(window.innerWidth) // Blogタイプ新規作成用、作成後、リセットする
let btName = ref("")
const insertBlogType = () => {
const data = {
btName: btName.value
}
putBlogType(data).then(response => {
const blog_type: BlogType = {
btId: response.data.btId,
btName: response.data.btName,
blogs: new Map<string, Blog>()
}
blogTypes.set(response.data.btId, blog_type)
response.data.blog_list.forEach((item: any) => {
const blog: Blog = {
bid: item.bid,
btId: item.btId,
btName: item.btName,
title: item.title,
blog_prex: item.blog_prex,
content: item.content
}
blog_type.blogs.set(item.bid, blog)
})
contentDialogVisible.value = false
btName.value = ""
})
}
const deleteBlogType = () => {
}
// Created 段階の関数呼び出す処理
getTestData()
// サイズ調整部分
type WholeStyle = { type WholeStyle = {
width: string width: string
height: string
} }
let innerHeight = ref("")
const btWholeStyle = reactive<WholeStyle>({} as WholeStyle) const btWholeStyle = reactive<WholeStyle>({} as WholeStyle)
let btWidth = 0.10 * window.innerWidth let btWidth = 0.10 * window.innerWidth
btWholeStyle.width = btWidth + 'px' btWholeStyle.width = btWidth + 'px'
btWholeStyle.height = window.innerHeight + 'px'
const bWholeStyle = reactive<WholeStyle>({} as WholeStyle) const bWholeStyle = reactive<WholeStyle>({} as WholeStyle)
let bWidth = 0.23 * window.innerWidth let bWidth = 0.23 * window.innerWidth
bWholeStyle.width = bWidth + 'px' bWholeStyle.width = bWidth + 'px'
const cWholeStyle = reactive<WholeStyle>({} as WholeStyle) const cWholeStyle = reactive<WholeStyle>({} as WholeStyle)
let contentWidth = 0.67 * window.innerWidth let contentWidth = 0.67 * window.innerWidth
cWholeStyle.width = contentWidth + 'px' cWholeStyle.width = contentWidth + 'px'
innerHeight.value = (window.innerHeight - 50) + 'px'
onMounted(() => {
})
</script> </script>
<style scoped> <style scoped>
.b_section { .b_section,
.bt_section,
.c_section {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
width: 100px; align-items: stretch;
border-right: 1px solid royalblue;
} }
.bts {
.bt-input {
display: flex;
flex-direction: row;
justify-content: flex-start;
margin-left: 0px; margin-left: 0px;
padding-left: 0px; padding-left: 10px;
font-size: 15px;
overflow: hidden;
height: 50px;
border-radius: 0px;
border-right: 0px;
} }
.el-button { .title_style :deep() .el-input__inner {
font-size: 15px; height: 50px;
font-size: 20px;
} }
.el-dropdown { .el-dropdown {
margin-right: 5px; margin-right: 5px;
} }
.bt_section {
display: flex;
flex-direction: column;
align-items: flex-start;
width: 100px;
}
.blog_editer { .blog_editer {
display: flex; display: flex;
} }
+2 -2
View File
@@ -15,7 +15,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { reactive, ref } from 'vue'; import { reactive, ref } from 'vue';
import { get_blogs, getContent, newBlog, updateContent, deleteContent } from '../../api/blog' import { get_blogs, getContent, putBlog, updateContent, deleteContent } from '../../api/blog'
import router from '../../router/index' import router from '../../router/index'
type Blog = { type Blog = {
bid: string, bid: string,
@@ -62,7 +62,7 @@ const test1 = () => {
blog_type_id: "2808000", blog_type_id: "2808000",
title: "dddddddd" title: "dddddddd"
} }
newBlog(params).then(response => { putBlog(params).then(response => {
console.log(response) console.log(response)
}) })
} }
+4 -4
View File
@@ -7,12 +7,12 @@ import MdEditor from 'md-editor-v3';
import 'md-editor-v3/lib/style.css'; import 'md-editor-v3/lib/style.css';
import { ref } from 'vue'; import { ref } from 'vue';
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import { get_blog } from '../../api/blog' // import { get_blog } from '../../api/blog'
let text = ref<string>('') let text = ref<string>('')
const route = useRoute() const route = useRoute()
get_blog(route.query).then(response => { // get_blog(route.query).then(response => {
text.value = response.data.blog_text // text.value = response.data.blog_text
}) // })
</script> </script>
-4
View File
@@ -3,7 +3,6 @@
width: '600px', width: '600px',
height: '300px' height: '300px'
}"></div> }"></div>
<div class="dashboard">这里我想分享的一些东西无论是生活还是工作还是学科</div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@@ -61,7 +60,4 @@ onMounted(() => {
</script> </script>
<style> <style>
.dashboard {
background-color: beige;
}
</style> </style>