Browse Source

add news

master
panda 9 months ago
parent
commit
c0e497a051
  1. 4
      src/api/admin.ts
  2. 9
      src/api/blog.ts
  3. 45
      src/stores/index.ts
  4. 52
      src/views/admin/classticmanage/ClassticManageView.vue

4
src/api/admin.ts

@ -1,4 +0,0 @@
// 语录管理
export interface searchValue{
classtictitle: string,
}

9
src/api/blog.ts

@ -11,3 +11,12 @@ export interface blogInterface {
typename: string, typename: string,
labelnames: string labelnames: string
} }
// 语录管理
export interface classticInterface {
key:string,
id:number,
header: string,
text: string,
descr: string
}

45
src/stores/index.ts

@ -3,10 +3,13 @@ import { defineStore } from 'pinia'
import { get } from "@/tools/request" import { get } from "@/tools/request"
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { useRouter } from "vue-router" import { useRouter } from "vue-router"
import type { blogInterface } from '@/api/blog';
import type { blogInterface,classticInterface } from '@/api/blog';
const router = useRouter() const router = useRouter()
// 博客列表 // 博客列表
const bloglist = ref<blogInterface[]>([]) const bloglist = ref<blogInterface[]>([])
// 语录列表
const classticlist = ref<classticInterface[]>([])
export const useAuthStore = defineStore("auth", () => { export const useAuthStore = defineStore("auth", () => {
const tokenValue = ref("") const tokenValue = ref("")
@ -21,18 +24,14 @@ export const useAuthStore = defineStore("auth", () => {
// 语录列表接口 // 语录列表接口
export const classticContentStore = defineStore("classtic", () => { export const classticContentStore = defineStore("classtic", () => {
interface classticInterface {
id: number,
header: string,
text: string,
descr: string
}
const classticlist = ref<classticInterface[]>([])
const classticList = async () => { const classticList = async () => {
try { try {
const response = await get("/classtics/list"); const response = await get("/classtics/list");
if (response) { if (response) {
classticlist.value = response.data.data.map((item: any) => ({
classticlist.value = response.data.data.map((item: any,index:any) => ({
key:(index+1).toString(),
id:item.id, id:item.id,
header: item.header, header: item.header,
text: item.text, text: item.text,
@ -48,6 +47,34 @@ export const classticContentStore = defineStore("classtic", () => {
return { classticlist, classticList } 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", () => { export const comLinkContentStore = defineStore("comlink", () => {
interface comlinkInterface { interface comlinkInterface {

52
src/views/admin/classticmanage/ClassticManageView.vue

@ -2,15 +2,27 @@
<div class="content"> <div class="content">
<div class="search"> <div class="search">
<a-space> <a-space>
<a-input v-model:value="searchList.classtictitle" placeholder="语录标题" />
<a-input v-model:value="classticSearch.searchValue.title" placeholder="语录标题" />
</a-space> </a-space>
<a-space style="margin-left: 16px;"> <a-space style="margin-left: 16px;">
<a-button>查询</a-button>
<a-button @click="classticSearch.classticSearch">查询</a-button>
<a-button type="primary" ghost @click="modal('add')">新增</a-button> <a-button type="primary" ghost @click="modal('add')">新增</a-button>
<a-modal v-model:open="addModal.addOpen" ok-text="确认" cancel-text="取消" :title="addModal.addTitle" @ok="handleOk">
<p>Some contents...</p>
<p>Some contents...</p>
<p>Some contents...</p>
<a-modal v-model:open="addModal.addOpen" ok-text="确认" cancel-text="取消" :title="addModal.addTitle"
@ok="handleOk">
<a-form :model="formState" name="basic">
<a-form-item label="语录标题" name="classticname"
:rules="[{ required: true, message: '请输入语录标题' }]" v-bind="formItemLayout">
<a-input v-model:value="formState.name" />
</a-form-item>
<a-form-item label="语录内容" name="classticcontent"
:rules="[{ required: true, message: '请输入语录内容' }]" v-bind="formItemLayout">
<a-input v-model:value="formState.name" />
</a-form-item>
<a-form-item label="备注" name="classticdescr"
:rules="[{ message: '请输入备注' }]" v-bind="formItemLayout">
<a-textarea v-model:value="formState.name" />
</a-form-item>
</a-form>
</a-modal> </a-modal>
</a-space> </a-space>
</div> </div>
@ -38,11 +50,15 @@
<script setup lang='ts'> <script setup lang='ts'>
import { ref, reactive, onMounted } from 'vue'; import { ref, reactive, onMounted } from 'vue';
import type { searchValue } from "@/api/admin"
import { useRouter } from "vue-router" import { useRouter } from "vue-router"
const router = useRouter() const router = useRouter()
import { classticContentStore } from "@/stores"
import { classticContentStore,classticSearchStore } from "@/stores"
const classticContent = classticContentStore()
const classticSearch=classticSearchStore()
const formItemLayout = {
labelCol: { span: 4 ,offset:2},
wrapperCol: { span: 16 },
};
const addModal = reactive({ const addModal = reactive({
addOpen: false, addOpen: false,
addTitle: "", addTitle: "",
@ -59,7 +75,6 @@ const modal=(mode:string)=>{
} }
const addhandleOk = () => { const addhandleOk = () => {
addOpen.value = true; addOpen.value = true;
addOpen.value = false;
}; };
const edithandleOk = () => { const edithandleOk = () => {
// Logic for editing // Logic for editing
@ -77,10 +92,19 @@ const handleOk=()=> {
addModal.addOpen = false; addModal.addOpen = false;
} }
const searchList = reactive<searchValue>({
classtictitle: ""
})
const classticContent = classticContentStore()
interface FormState {
name: string,
content: string,
descr: string
}
const formState = reactive<FormState>({
name: '',
content: '',
descr: ''
});
const deleteOpen = ref<boolean>(false); const deleteOpen = ref<boolean>(false);
const toDelete = reactive<{ key: string, id: number }>({ const toDelete = reactive<{ key: string, id: number }>({
key: '', key: '',

Loading…
Cancel
Save