|
@ -2,9 +2,7 @@ import { reactive, ref } from 'vue' |
|
|
import { defineStore } from 'pinia' |
|
|
import { defineStore } from 'pinia' |
|
|
import { get, post, put, remove } from "@/tools/request" |
|
|
import { get, post, put, remove } from "@/tools/request" |
|
|
import dayjs from 'dayjs'; |
|
|
import dayjs from 'dayjs'; |
|
|
import { useRouter } from "vue-router" |
|
|
|
|
|
import type { blogInterface, classticInterface, classticFormInterface } from '@/api/admin'; |
|
|
import type { blogInterface, classticInterface, classticFormInterface } from '@/api/admin'; |
|
|
const router = useRouter() |
|
|
|
|
|
// 博客列表
|
|
|
// 博客列表
|
|
|
const bloglist = ref<blogInterface[]>([]) |
|
|
const bloglist = ref<blogInterface[]>([]) |
|
|
// 语录列表
|
|
|
// 语录列表
|
|
@ -83,9 +81,21 @@ export const classticFormStore = defineStore("classform", () => { |
|
|
}) |
|
|
}) |
|
|
const onSubmit = async (id?: any) => { |
|
|
const onSubmit = async (id?: any) => { |
|
|
if (id) { |
|
|
if (id) { |
|
|
await put(`/classtics/update/${id}`,classticform) |
|
|
|
|
|
|
|
|
const response = await put(`/classtics/update/${id}`, classticform) |
|
|
|
|
|
const updatedClasstic = response.data.data; |
|
|
|
|
|
const index = classticlist.value.findIndex(item => item.id === updatedClasstic.id) |
|
|
|
|
|
if (index !== -1) { |
|
|
|
|
|
updatedClasstic.key = classticlist.value[index].key; |
|
|
|
|
|
classticlist.value[index] = updatedClasstic; |
|
|
|
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
await post("/classtics/add",classticform) |
|
|
|
|
|
|
|
|
const response=post("/classtics/add", classticform) |
|
|
|
|
|
const newClasstic = { |
|
|
|
|
|
...(await response).data.data, |
|
|
|
|
|
key: (classticlist.value.length + 1).toString() |
|
|
|
|
|
} |
|
|
|
|
|
classticlist.value.push(newClasstic) |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return { classticform, onSubmit } |
|
|
return { classticform, onSubmit } |
|
|