From c0e497a051587539fa00f3881dabb51454e3f477 Mon Sep 17 00:00:00 2001 From: panda <7934952@qq.com> Date: Tue, 25 Jun 2024 17:02:24 +0800 Subject: [PATCH] add news --- src/api/admin.ts | 4 - src/api/blog.ts | 9 ++ src/stores/index.ts | 47 +++++++--- .../classticmanage/ClassticManageView.vue | 90 ++++++++++++------- 4 files changed, 103 insertions(+), 47 deletions(-) diff --git a/src/api/admin.ts b/src/api/admin.ts index 8900789..e69de29 100644 --- a/src/api/admin.ts +++ b/src/api/admin.ts @@ -1,4 +0,0 @@ -// 语录管理 -export interface searchValue{ - classtictitle: string, -} \ No newline at end of file diff --git a/src/api/blog.ts b/src/api/blog.ts index e3688a2..a23135f 100644 --- a/src/api/blog.ts +++ b/src/api/blog.ts @@ -10,4 +10,13 @@ export interface blogInterface { 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/stores/index.ts b/src/stores/index.ts index 3b0983f..4aec395 100644 --- a/src/stores/index.ts +++ b/src/stores/index.ts @@ -3,10 +3,13 @@ import { defineStore } from 'pinia' import { get } from "@/tools/request" import dayjs from 'dayjs'; import { useRouter } from "vue-router" -import type { blogInterface } from '@/api/blog'; +import type { blogInterface,classticInterface } from '@/api/blog'; const router = useRouter() // 博客列表 const bloglist = ref([]) +// 语录列表 +const classticlist = ref([]) + export const useAuthStore = defineStore("auth", () => { const tokenValue = ref("") @@ -21,19 +24,15 @@ export const useAuthStore = defineStore("auth", () => { // 语录列表接口 export const classticContentStore = defineStore("classtic", () => { - interface classticInterface { - id: number, - header: string, - text: string, - descr: string - } - const classticlist = ref([]) + + const classticList = async () => { try { const response = await get("/classtics/list"); if (response) { - classticlist.value = response.data.data.map((item: any) => ({ - 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 @@ -48,6 +47,34 @@ export const classticContentStore = defineStore("classtic", () => { return { classticlist, classticList } }) +export const classticSearchStore=defineStore("chassticsearch",()=>{ + const searchValue=reactive({ + title:"" + }) + const classticSearch=async ()=>{ + try { + const response=await get( + "/classtics/list/search", + {header:searchValue.title} + ) + if (response) { + 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{ + console.log("classtic request is nulll") + } + } catch (error) { + console.log("classtic request is error") + } + } + return {classticSearch,searchValue} +}) + // 链接接口 export const comLinkContentStore = defineStore("comlink", () => { interface comlinkInterface { diff --git a/src/views/admin/classticmanage/ClassticManageView.vue b/src/views/admin/classticmanage/ClassticManageView.vue index adef83b..dce612c 100644 --- a/src/views/admin/classticmanage/ClassticManageView.vue +++ b/src/views/admin/classticmanage/ClassticManageView.vue @@ -2,15 +2,27 @@
@@ -38,49 +50,61 @@