From e59aeff82e2d6b8ae7d13af1975a5f84f06c383c Mon Sep 17 00:00:00 2001
From: panda <7934952@qq.com>
Date: Fri, 28 Jun 2024 17:07:31 +0800
Subject: [PATCH] add new
---
src/components/blogs/HomePage.vue | 8 +-
src/services/admin/classtic.ts | 48 ++++---
src/stores/index.ts | 25 +---
.../admin/classticmanage/ClassticFormView.vue | 18 +--
.../classticmanage/ClassticManageView.vue | 121 +++++++++++++++---
5 files changed, 142 insertions(+), 78 deletions(-)
diff --git a/src/components/blogs/HomePage.vue b/src/components/blogs/HomePage.vue
index 14f757a..f02bcee 100644
--- a/src/components/blogs/HomePage.vue
+++ b/src/components/blogs/HomePage.vue
@@ -44,7 +44,7 @@
-
{{ classtic.text }}
@@ -117,11 +117,11 @@ import APlayer from 'APlayer';
import { createEcharts } from "@/hooks/intex"
import { useRouter, useRoute } from 'vue-router';
import iconComponents from "@/assets/index";
-import { classticContentStore,comLinkContentStore } from '@/stores';
+import { comLinkContentStore } from '@/stores';
+import {classticlist,classticList} from "@/services/admin/classtic"
const router = useRouter()
const route = useRoute()
-const classticContent=classticContentStore()
const comLinkContent=comLinkContentStore()
/**
@@ -400,7 +400,7 @@ const random = ref();
onMounted(() => {
scrollbar.value = document.querySelector('.simplebar-content-wrapper');
- classticContent.classticList()
+ classticList()
comLinkContent.comLinkList()
nextTick(() => {
const authorElement = document.querySelector('.author');
diff --git a/src/services/admin/classtic.ts b/src/services/admin/classtic.ts
index b74ca9c..cbdc31b 100644
--- a/src/services/admin/classtic.ts
+++ b/src/services/admin/classtic.ts
@@ -5,6 +5,11 @@ import { classticStore } from "@/stores";
const { searchValue, classticForm } = classticStore()
const classticlist = ref([])
+const classticOneData = ref({
+ header: "",
+ text: "",
+ descr: ""
+})
const classticList = async () => {
try {
const response = await get("/classtics/list");
@@ -23,25 +28,6 @@ const classticList = async () => {
console.error("Failed to fetch data", error);
}
}
-const onSubmit = async (id?: any) => {
- if (id) {
- await put(`/classtics/update/${id}`, classticForm)
- // 更新 classticlist
- const updatedIndex = classticlist.value.findIndex(item => item.id === id);
- console.log(classticlist.value[0])
- if (updatedIndex !== -1) {
- classticlist.value[updatedIndex] = {
- ...classticlist.value[updatedIndex], // 保留原始项的其他属性
- header: classticForm.header,
- text: classticForm.text,
- descr: classticForm.descr,
- };
- }
- } else {
- await post("/classtics/add", classticForm)
- await classticList()
- }
-}
const classticSearch = async () => {
try {
const response = await get(
@@ -63,7 +49,15 @@ const classticSearch = async () => {
console.log("classtic request is error")
}
}
-
+const onSubmit = async (id?: any) => {
+ if (id) {
+ await put(`/classtics/update/${id}`, classticForm)
+ await classticList()
+ } else {
+ await post("/classtics/add", classticForm)
+ await classticList()
+ }
+}
const classticDel = async (id: any) => {
try {
if (id) {
@@ -77,6 +71,18 @@ const classticDel = async (id: any) => {
}
}
+const classticOne = async (id: any) => {
+ try {
+ const response=await get(`classtics/list/search/${id}`)
+ if (response) {
+ classticOneData.value=response.data.data;
+ } else {
+ console.log("classtic one data is null")
+ }
+ } catch (error) {
+ console.log("classtic one data is error")
+ }
+}
-export { classticlist, classticForm, classticList, classticSearch, classticDel, onSubmit }
\ No newline at end of file
+export { classticlist, classticForm, classticOneData, classticList, classticSearch, classticDel, onSubmit, classticOne }
\ No newline at end of file
diff --git a/src/stores/index.ts b/src/stores/index.ts
index 66a32f8..eb60ff0 100644
--- a/src/stores/index.ts
+++ b/src/stores/index.ts
@@ -5,35 +5,27 @@ import dayjs from 'dayjs';
import type { blogInterface, classticFormInterface } from '@/api/admin';
import type { classticSearchInterface } from '@/api/admin/classtic';
-export const indexStore = defineStore("index", () => {
-
- return {}
-})
-
export const classticStore = defineStore("classtic", () => {
- const searchValue = reactive({
+ const searchList = reactive({
title: ""
})
- const classticForm = reactive({
+
+ const formList = reactive({
header: "",
text: "",
descr: ""
})
- const modalForm = reactive({
- // 控制对话框开关
+ const formControl = reactive({
open: false,
- // 控制对话框title
title: "",
- // 控制对话框点击事件标识
mode: "",
- // 通过ids控制哪个功能事件
ids: ""
})
- const modalDel=reactive({
- open:false
+ const delControl = reactive({
+ open: false
})
- return { searchValue, classticForm,modalForm,modalDel }
+ return { formControl, delControl }
})
@@ -49,8 +41,6 @@ export const classticStore = defineStore("classtic", () => {
// 博客列表
const bloglist = ref([])
-// 语录列表
-
export const useAuthStore = defineStore("auth", () => {
const tokenValue = ref("")
@@ -63,7 +53,6 @@ export const useAuthStore = defineStore("auth", () => {
return { setToken, removeToken }
})
-
// 链接接口
export const comLinkContentStore = defineStore("comlink", () => {
interface comlinkInterface {
diff --git a/src/views/admin/classticmanage/ClassticFormView.vue b/src/views/admin/classticmanage/ClassticFormView.vue
index 83bd628..fdf0f23 100644
--- a/src/views/admin/classticmanage/ClassticFormView.vue
+++ b/src/views/admin/classticmanage/ClassticFormView.vue
@@ -1,18 +1,5 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/src/views/admin/classticmanage/ClassticManageView.vue b/src/views/admin/classticmanage/ClassticManageView.vue
index c31755a..cdb682a 100644
--- a/src/views/admin/classticmanage/ClassticManageView.vue
+++ b/src/views/admin/classticmanage/ClassticManageView.vue
@@ -2,12 +2,29 @@
-
+
- 查询
+ 查询
新增
-
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -16,9 +33,9 @@
@@ -33,32 +50,96 @@