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