diff --git a/src/api/admin.ts b/src/api/admin.ts index e69de29..6dad6f3 100644 --- a/src/api/admin.ts +++ b/src/api/admin.ts @@ -0,0 +1,22 @@ +// 博客管理 +export interface blogInterface { + key: string, + blogtitle: string, + create_at: Date, + readnum: number, + readminite: number, + wordcount: number, + img: string, + blogcontent: string, + typename: string, + labelnames: string + } + +// 语录管理 +export interface classticInterface { + key:string, + id?:number, + header: string, + text: string, + descr: string + } \ No newline at end of file diff --git a/src/api/blog.ts b/src/api/blog.ts index a23135f..e69de29 100644 --- a/src/api/blog.ts +++ b/src/api/blog.ts @@ -1,22 +0,0 @@ -// 博客管理 -export interface blogInterface { - key: string, - blogtitle: string, - create_at: Date, - readnum: number, - readminite: number, - wordcount: number, - img: string, - blogcontent: string, - typename: string, - labelnames: string - } - -// 语录管理 -export interface classticInterface { - key:string, - id:number, - header: string, - text: string, - descr: string - } \ No newline at end of file diff --git a/src/components/blogs/ceshi.vue b/src/components/blogs/ceshi.vue index 61c7c71..d5c37b0 100644 --- a/src/components/blogs/ceshi.vue +++ b/src/components/blogs/ceshi.vue @@ -1,13 +1,58 @@ + \ No newline at end of file + +const onFinishFailed = (errorInfo: any) => { + console.log('Failed:', errorInfo); +}; + + diff --git a/src/stores/index.ts b/src/stores/index.ts index 4aec395..ddc0226 100644 --- a/src/stores/index.ts +++ b/src/stores/index.ts @@ -1,15 +1,20 @@ import { reactive, ref } from 'vue' import { defineStore } from 'pinia' -import { get } from "@/tools/request" +import { get, post, put } from "@/tools/request" import dayjs from 'dayjs'; import { useRouter } from "vue-router" -import type { blogInterface,classticInterface } from '@/api/blog'; +import type { blogInterface, classticInterface } from '@/api/admin'; const router = useRouter() // 博客列表 const bloglist = ref([]) // 语录列表 const classticlist = ref([]) - +// 语录新增 +const classticadd=reactive({ + header:"", + text:"", + descr:"" +}) export const useAuthStore = defineStore("auth", () => { const tokenValue = ref("") @@ -24,15 +29,15 @@ export const useAuthStore = defineStore("auth", () => { // 语录列表接口 export const classticContentStore = defineStore("classtic", () => { - + const classticList = async () => { try { const response = await get("/classtics/list"); if (response) { - classticlist.value = response.data.data.map((item: any,index:any) => ({ - key:(index+1).toString(), - id:item.id, + classticlist.value = response.data.data.map((item: any, index: any) => ({ + key: (index + 1).toString(), + id: item.id, header: item.header, text: item.text, descr: item.descr @@ -46,35 +51,49 @@ export const classticContentStore = defineStore("classtic", () => { } return { classticlist, classticList } }) - -export const classticSearchStore=defineStore("chassticsearch",()=>{ - const searchValue=reactive({ - title:"" +// 语录查询接口 +export const classticSearchStore = defineStore("chassticsearch", () => { + const searchValue = reactive({ + title: "" }) - const classticSearch=async ()=>{ + const classticSearch = async () => { try { - const response=await get( + const response = await get( "/classtics/list/search", - {header:searchValue.title} + { header: searchValue.title } ) if (response) { - classticlist.value=response.data.data.map((items:any,index:any)=>({ - key:(index+1).toString(), - id:items.id, + classticlist.value = response.data.data.map((items: any, index: any) => ({ + key: (index + 1).toString(), + id: items.id, header: items.header, text: items.text, descr: items.descr })) - }else{ + } else { console.log("classtic request is nulll") } } catch (error) { console.log("classtic request is error") } } - return {classticSearch,searchValue} + return { classticSearch, searchValue } +}) +// 语录新增/编辑接口 +export const classticAddStore=defineStore("classticadd",()=>{ + const onSubmit=async ()=>{ + await post("/classtics/add", + { + header:classticadd.header, + text:classticadd.text, + descr:classticadd.descr + } + ) + } + return {onSubmit,classticadd} }) + // 链接接口 export const comLinkContentStore = defineStore("comlink", () => { interface comlinkInterface { diff --git a/src/views/admin/blogmange/BlogFormView.vue b/src/views/admin/blogmange/BlogFormView.vue index 1f79395..807fab0 100644 --- a/src/views/admin/blogmange/BlogFormView.vue +++ b/src/views/admin/blogmange/BlogFormView.vue @@ -33,9 +33,8 @@ import { ref, onMounted, reactive } from 'vue'; import type { UnwrapRef } from 'vue'; import type { Rule } from 'ant-design-vue/es/form'; import { post, get, put } from '@/tools/request'; -import { useRouter, useRoute } from 'vue-router' +import { useRouter } from 'vue-router' const router = useRouter() -const route = useRoute() interface FormState { id?: number; blogtitle: string; @@ -75,23 +74,6 @@ onMounted(async () => { ...items })) }) - const { id } = route.params - if (id) { - get(`/blogs/list/search/${id}`).then(response => { - const blog = response.data.data; - // 设置表单的初始值为编辑博客的信息 - formState.id = blog.id; - formState.blogtitle = blog.blogtitle; - formState.typeid = blog.typeid; - formState.blogcontent = blog.blogcontent; - formState.descr = blog.descr; - // 初始化 Vditor 并设置内容 - console.log(blog.id) - if (blog.id) { - content.value=blog.blogcontent; - } - }) - } }); const onSubmit = () => { formRef.value diff --git a/src/views/admin/classticmanage/ClassticManageView.vue b/src/views/admin/classticmanage/ClassticManageView.vue index dce612c..4760834 100644 --- a/src/views/admin/classticmanage/ClassticManageView.vue +++ b/src/views/admin/classticmanage/ClassticManageView.vue @@ -8,19 +8,19 @@ 查询 新增 - - - + @ok="classticAdd.onSubmit"> + + + - - + - - + + @@ -52,12 +52,14 @@ import { ref, reactive, onMounted } from 'vue'; import { useRouter } from "vue-router" const router = useRouter() -import { classticContentStore,classticSearchStore } from "@/stores" +import { classticAddStore, classticContentStore, classticSearchStore } from "@/stores" +import { put, post } from "@/tools/request" const classticContent = classticContentStore() -const classticSearch=classticSearchStore() +const classticSearch = classticSearchStore() +const classticAdd=classticAddStore() const formItemLayout = { - labelCol: { span: 4 ,offset:2}, - wrapperCol: { span: 16 }, + labelCol: { span: 4, offset: 2 }, + wrapperCol: { span: 16 }, }; const addModal = reactive({ addOpen: false, @@ -73,36 +75,8 @@ const modal = (mode: string) => { } addModal.addOpen = true; } -const addhandleOk = () => { - addOpen.value = true; -}; -const edithandleOk = () => { - // Logic for editing - console.log('Edit logic here'); -} - -const handleOk = () => { - if (addModal.modalMode === 'add') { - // Handle add action - addhandleOk(); - } else if (addModal.modalMode === 'edit') { - // Handle edit action - edithandleOk(); - } - addModal.addOpen = false; -} -interface FormState { - name: string, - content: string, - descr: string -} -const formState = reactive({ - name: '', - content: '', - descr: '' -}); const deleteOpen = ref(false); @@ -128,7 +102,6 @@ const blogAdd = function () { // 获取列表 onMounted(async () => { classticContent.classticList() - }); const columns = [ {