panda 9 months ago
parent
commit
0488baa780
  1. 12
      src/api/admin/index.ts
  2. 31
      src/components/admin/MainWrapper.vue
  3. 97
      src/components/blogs/HomePage.vue
  4. 7
      src/router/admin.ts
  5. 71
      src/services/admin/classtic.ts
  6. 56
      src/stores/index.ts
  7. 14
      src/views/admin/ClassticManageView.vue
  8. 236
      src/views/admin/CommonLinkManageView.vue
  9. 24
      src/views/admin/classticmanage/ClassticFormView.vue

12
src/api/admin/classtic.ts → src/api/admin/index.ts

@ -7,12 +7,10 @@ export interface classticInterface {
descr: string
}
export interface classticSearchInterface {
title: string
}
export interface classticFormInterface {
header: string,
text: string,
export interface comLinkInterface {
key: string,
id?: number,
linktext: string,
linkurl: string,
descr: string
}

31
src/components/admin/MainWrapper.vue

@ -6,7 +6,7 @@
<component :is=iconComponents.TitleOutLined :class="collapsed ? 'small' : 'large'" />
<span v-if="!collapsed">{{ state.name }}</span>
</a-flex>
<a-menu v-model:openKeys="state.openKeys" v-model:selectedKeys="state.selectedKeys" mode="inline" theme="light"
<a-menu v-model:selectedKeys="state.selectedKeys" mode="inline" theme="light"
:inline-collapsed="state.collapsed" :items="items" style="border-inline-end: none;" @click="menuItemclick">
</a-menu>
</div>
@ -41,17 +41,16 @@
</template>
<script setup lang='ts'>
import { computed, ref, onMounted, h, reactive } from 'vue';
import { computed, ref, onMounted, h, reactive, watch } from 'vue';
import iconComponents from "@/assets/index"
import { RouterView, useRouter } from 'vue-router'
import { RouterView, useRouter, useRoute } from 'vue-router'
import { MenuFoldOutlined, MenuUnfoldOutlined, LogoutOutlined, DashboardOutlined } from '@ant-design/icons-vue';
import { get } from "@/tools/request"
import { message } from 'ant-design-vue';
import { useAuthStore } from '@/stores/index'
const router = useRouter()
const state = reactive({
collapsed: false,
openKeys: [1],
selectedKeys: ['1'],
name: '博客后台系统',
menuWidth: '10%'
@ -87,42 +86,48 @@ const items = reactive([
},
{
key: '5',
icon: () => h(iconComponents.DiaryOutLined),
label: '链接管理',
title: '链接管理',
url: '/admin/commonlinkmanage'
},
{
key: '6',
icon: () => h(iconComponents.TypeOutLined),
label: '分类管理',
title: '分类管理',
url: '/admin/typemanage'
},
{
key: '6',
key: '7',
icon: () => h(iconComponents.CommentOutLined),
label: '评论管理',
title: '评论管理',
url: '/admin/commentmanage'
},
{
key: '7',
key: '8',
icon: () => h(iconComponents.PhotoOutLined),
label: '相册管理',
title: '相册管理',
url: '/admin/imagemanage'
},
{
key: '8',
key: '9',
icon: () => h(iconComponents.FileOutLined),
label: '文件管理',
title: '文件管理',
url: '/admin/filemanage'
},
{
key: '9',
key: '10',
icon: () => h(iconComponents.SystemOutLined),
label: '系统设置',
title: '系统设置',
url: '/admin/systemmanage'
},
]);
const router = useRouter()
const menuItemclick = function ({ item }: { item: any }) {
const menuItemclick = ({ item }: { item: any }) => {
router.push(item.url)
}
const collapsed = computed(() => state.collapsed);
@ -136,11 +141,11 @@ const jumpdashboard = function () {
state.selectedKeys = ['1']
router.push('/admin/dashboard')
}
onMounted(async () => {
const userinfo = await get(
'/users/me',
undefined,
undefined,
{
'Accept': 'application/json',
'Content-Type': 'application/x-www-form-urlencoded'

97
src/components/blogs/HomePage.vue

@ -5,7 +5,7 @@
<a-menu v-model:selectedKeys="current" mode="horizontal" :items="items" style="border-bottom: none;" />
<a-input-search v-model:value="value" placeholder="search" style="width: 200px" @search="onSearch" />
</div>
<div class="author" v-if="show_author"></div>
<div class="author" v-if="show_author">{{ author }}</div>
<!-- 轮播 -->
<div class="carousel" v-if="show_carousel">
@ -19,7 +19,7 @@
<div class="anchorDown" v-if="show_anchornDown">
<a-button type="link" shape="circle" size="large" @click="downScroll">
<template #icon>
<DownCircleOutlined style="font-size: 35px;color: aliceblue;" spin />
<DownCircleOutlined spin />
</template>
</a-button>
</div>
@ -53,8 +53,8 @@
</a-card>
<a-card hoverable title="常用链接">
<div class="button-group">
<a-button type="dashed" v-for="comlink in comLinkContent.comlinklist" :key="comlink.id"
@click="comLinkContent.comLinkClick(comlink.linkurl)">{{
<a-button type="dashed" v-for="comlink in comlinklist" :key="comlink.id"
@click="comLinkClick(comlink.linkurl)">{{
comlink.linktext
}}</a-button>
</div>
@ -106,7 +106,7 @@
</Simplebar>
</template>
<script lang="ts" setup>
import { h, reactive, ref, nextTick,toRefs } from 'vue';
import { h, reactive, ref, nextTick, toRefs } from 'vue';
import type { MenuProps } from 'ant-design-vue';
import { HomeOutlined, HighlightOutlined, ProfileOutlined, CameraOutlined, UsergroupDeleteOutlined, DownCircleOutlined } from '@ant-design/icons-vue';
import Typed from 'typed.js';
@ -114,33 +114,26 @@ import { onMounted, watch } from 'vue';
import { CaretRightOutlined } from '@ant-design/icons-vue';
import 'APlayer/dist/APlayer.min.css';
import APlayer from 'APlayer';
import {get} from "@/tools/request"
import { createEcharts } from "@/hooks/intex"
import { useRouter, useRoute } from 'vue-router';
import iconComponents from "@/assets/index";
import { comLinkContentStore } from '@/stores';
import {classticlist,classticList} from "@/services/admin/classtic"
import type { classticInterface } from '@/api/admin';
import type { comLinkInterface } from '@/api/admin/index';
const router = useRouter()
const route = useRoute()
const comLinkContent=comLinkContentStore()
/**
* 导航菜单
*/
// const show_menu = ref(false);
// const show_carousel = ref(true);
// const show_author = ref(true)
// const show_anchornDown = ref(true)
const author=ref("SunFree.")
/**
* 隐藏参数
*/
const isshow=reactive({
show_menu:false,
show_carousel:true,
show_author:true,
show_anchornDown:true
const idShow = reactive({
show_menu: false,
show_carousel: true,
show_author: true,
show_anchornDown: true
})
const {show_menu,show_carousel,show_author,show_anchornDown}=toRefs(isshow)
const { show_menu, show_carousel, show_author, show_anchornDown } = toRefs(idShow)
const mainCss = reactive({
marginTop: "0px"
@ -262,6 +255,52 @@ const downScroll = () => {
* 左侧栏
*/
//
const classticlist=ref<classticInterface[]>([])
const classticList=async ()=>{
try {
await get("/classtics/list").then(response => {
if (response) {
classticlist.value = response.data.data.map((item: any, index: any) => ({
key: (index + 1).toString(),
header: item.header,
text: item.text,
descr: item.descr
}));
} else {
console.log("the interface request data does not exist!")
}
})
} catch (error) {
console.error("Failed to fetch data", error);
}
}
const comLinkClick = (url: string) => {
if (url.startsWith('http://') || url.startsWith('https://')) {
window.open(url, "_blank"); // 使 window.location.href
} else {
router.push(url); // 使 Vue Router push
}
}
const comlinklist = ref<comLinkInterface[]>([])
const comLinkList = async () => {
try {
await get("/comlinks/list").then(response => {
if (response) {
comlinklist.value = response.data.data.map((item: any, index: any) => ({
key: (index + 1).toString(),
id: item.id,
linktext: item.linktext,
linkurl: item.linkurl,
descr: item.descr
}));
} else {
console.log("the interface request data does not exist!")
}
})
} catch (error) {
console.error("Failed to fetch data", error);
}
}
const activeKey = ref(['']);
const customStyle = 'background: #F5F5F5;border-radius: 4px;margin-bottom: 12px;border: 0;overflow: hidden';
@ -399,9 +438,8 @@ const random = ref();
onMounted(() => {
scrollbar.value = document.querySelector('.simplebar-content-wrapper');
classticList()
comLinkContent.comLinkList()
comLinkList()
nextTick(() => {
const authorElement = document.querySelector('.author');
if (authorElement) {
@ -462,6 +500,8 @@ onMounted(() => {
});
}
});
scrollbar.value = document.querySelector('.simplebar-content-wrapper');
createEcharts(heat, heatMapData);
@ -471,7 +511,7 @@ watch(
(newRouteName) => {
updateCarouselVisibility(newRouteName);
if (newRouteName) {
const menuItem = items.value.find((item:any) => item.key === newRouteName);
const menuItem = items.value.find((item: any) => item.key === newRouteName);
if (menuItem) {
current.value = [menuItem.key];
} else {
@ -508,7 +548,7 @@ watch(
display: inline-block;
font-size: 100px;
font-family: 'Courier New', Courier, monospace;
background: linear-gradient(270deg, #f5f4f2, #d6cdc7, #4b4949);
background: linear-gradient(270deg, #d9d8d6, #7d7771, rgb(85, 68, 68));
background-size: 400% 400%;
-webkit-background-clip: text;
color: transparent;
@ -546,7 +586,10 @@ watch(
border-style: hidden;
transform: translateX(-50%);
}
.anchorDown span{
font-size: 35px;
color: aliceblue;
}
.mainContainer {
display: flex;
justify-content: center;

7
src/router/admin.ts

@ -30,7 +30,12 @@ const adminRoute:Array<RouteRecordRaw>=[
{
path:"classticmanage",
name:"classticmanage",
component:()=>import("@/views/admin/classticmanage/ClassticManageView.vue")
component:()=>import("@/views/admin/ClassticManageView.vue")
},
{
path:"commonlinkmanage",
name:"commonlinkmanage",
component:()=>import("@/views/admin/CommonLinkManageView.vue")
}
]

71
src/services/admin/classtic.ts

@ -1,71 +0,0 @@
import { get, remove, put, post } from "@/tools/request"
import { reactive, ref } from "vue";
import type { classticInterface, classticFormInterface } from "@/api/admin/classtic"
import { classticStore } from "@/stores";
const { searchValue, classticForm } = classticStore()
const classticlist = ref<classticInterface[]>([])
const classticOneData = ref({
header: "",
text: "",
descr: ""
})
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")
}
}
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) {
await remove(`/classtics/delete/${id}`)
await classticList()
} else {
console.log("id is null")
}
} catch (error) {
console.log("request is error")
}
}
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, classticOneData, classticList, classticSearch, classticDel, onSubmit, classticOne }

56
src/stores/index.ts

@ -4,6 +4,9 @@ import { get } from "@/tools/request"
import dayjs from 'dayjs';
import type { blogInterface } from '@/api/admin';
export const mainWrapperStore=defineStore("mainWrapper",()=>{
})
export const classticStore = defineStore("classtic", () => {
const addControl = reactive({
open: false,
@ -24,8 +27,26 @@ export const classticStore = defineStore("classtic", () => {
})
return { addControl, delControl,editControl }
})
export const comLinkStore = defineStore("comLink", () => {
const addControl = reactive({
open: false,
title: "",
mode: "",
ids: ""
})
const delControl = reactive({
open: false,
ids: ""
})
const editControl = reactive({
open: false,
ids: "",
title:""
})
return { addControl, delControl,editControl }
})
@ -50,41 +71,6 @@ export const useAuthStore = defineStore("auth", () => {
return { setToken, removeToken }
})
// 链接接口
export const comLinkContentStore = defineStore("comlink", () => {
interface comlinkInterface {
id: number,
linktext: string,
linkurl: string
}
const comlinklist = ref<comlinkInterface[]>([])
const comLinkList = async () => {
try {
const response = await get("/comlink/list");
if (response) {
comlinklist.value = response.data.data.map((items: any) => ({
id: items.id,
linktext: items.linktext,
linkurl: items.linkurl
}))
} else {
console.log("response data is not exist")
}
} catch (error) {
console.error("Failed to fetch data", error);
}
}
const comLinkClick = (url: string) => {
if (url.startsWith('http://') || url.startsWith('https://')) {
window.open(url, "_blank"); // 使用 window.location.href 打开外部链接
} else {
router.push(url); // 否则使用 Vue Router 的 push 方法导航
}
}
return { comlinklist, comLinkList, comLinkClick }
})
// 博客列表接口
export const blogContentStore = defineStore("blog", () => {
const blogList = async () => {

14
src/views/admin/classticmanage/ClassticManageView.vue → src/views/admin/ClassticManageView.vue

@ -65,10 +65,10 @@
<script setup lang='ts'>
import { onMounted, reactive, ref } from 'vue';
import { classticStore } from "@/stores/index"
import { classticForm, classticList, classticlist } from "@/services/admin/classtic"
import type { classticInterface } from "@/api/admin/index"
import { get, post, remove, put } from '@/tools/request';
const { delControl, addControl, editControl } = classticStore()
const classticlist = ref<classticInterface[]>([])
const searchlist = reactive({
title: ""
})
@ -169,12 +169,12 @@ const del = async (id: any) => {
const editModal = (id: any) => {
editControl.ids = id
editControl.title="编辑"
editControl.title = "编辑"
editControl.open = true
get(
`/classtics/list/search/${id}`
).then(response=>{
editList.value=response.data.data
).then(response => {
editList.value = response.data.data
})
}
const edit = async (id: any) => {
@ -185,10 +185,10 @@ const edit = async (id: any) => {
`/classtics/update/${id}`,
editList.value
)
editControl.open=false
editControl.open = false
formRef.value.resetFields()
classticList()
}else{
} else {
console.log("id do not exist!")
}
} catch (error) {

236
src/views/admin/CommonLinkManageView.vue

@ -0,0 +1,236 @@
<template>
<div class="content">
<div class="search">
<a-space>
<a-input v-model:value="searchlist.linktext" placeholder="链接名称" />
</a-space>
<a-space style="margin-left: 16px;">
<a-button @click="search">查询</a-button>
<a-button type="primary" ghost @click="addModal">新增</a-button>
<a-modal v-model:open="addControl.open" :title="addControl.title" cancelText="取消" okText="确定" @ok="add">
<a-form ref="formRef" :model="addList" name="basic" :label-col="{ span: 4, offset: 2 }"
:wrapper-col="{ span: 16 }">
<a-form-item label="链接名称" name="linktext" :rules="[{ required: true, message: '请输入链接名称!' }]">
<a-input v-model:value="addList.linktext" />
</a-form-item>
<a-form-item label="链接地址" name="linkurl" :rules="[{ required: true, message: '请输入链接地址!' }]">
<a-input v-model:value="addList.linkurl" />
</a-form-item>
<a-form-item label="备注" name="descr" :rules="[{ required: true, message: '请输入备注!' }]">
<a-input v-model:value="addList.descr" />
</a-form-item>
</a-form>
</a-modal>
</a-space>
</div>
<div class="table">
<a-table bordered :data-source="comlinklist" :columns="columns">
<template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'operation'">
<a-space>
<div>
<a-button size="small" danger @click="delModal(record.id)">删除</a-button>
<a-modal v-model:open="delControl.open" title="提示" ok-text="确认" cancel-text="取消"
@ok="del">
<p>确认删除吗</p>
</a-modal>
</div>
<a-button size="small" type="primary" ghost @click="editModal(record.id)">编辑</a-button>
<a-modal v-model:open="editControl.open" :title="editControl.title" cancelText="取消"
okText="确定" @ok="edit">
<a-form ref="formRef" :model="editList" name="basic" :label-col="{ span: 4, offset: 2 }"
:wrapper-col="{ span: 16 }">
<a-form-item label="链接名称" name="linktext"
:rules="[{ required: true, message: '请修改链接名称!' }]">
<a-input v-model:value="editList.linktext" />
</a-form-item>
<a-form-item label="链接地址" name="linkurl"
:rules="[{ required: true, message: '请修改链接地址!' }]">
<a-input v-model:value="editList.linkurl" />
</a-form-item>
<a-form-item label="备注" name="descr"
:rules="[{ required: true, message: '请修改备注!' }]">
<a-input v-model:value="editList.descr" />
</a-form-item>
</a-form>
</a-modal>
</a-space>
</template>
</template>
</a-table>
</div>
</div>
</template>
<script setup lang='ts'>
import { onMounted, reactive, ref } from 'vue';
import { comLinkStore } from "@/stores/index"
import type { comLinkInterface } from "@/api/admin/classtic"
import { get, post, remove, put } from '@/tools/request';
const { delControl, addControl, editControl } = comLinkStore()
const comlinklist = ref<comLinkInterface[]>([])
const searchlist = reactive({
linktext: ""
})
const addList = ref({
linktext: "",
linkurl: "",
descr: ""
})
const editList = ref({
linktext: "",
linkurl: "",
descr: ""
})
const comLinkList = async () => {
try {
await get("/comlinks/list").then(response => {
if (response) {
comlinklist.value = response.data.data.map((item: any, index: any) => ({
key: (index + 1).toString(),
id: item.id,
linktext: item.linktext,
linkurl: item.linkurl,
descr: item.descr
}));
} else {
console.log("the interface request data does not exist!")
}
})
} catch (error) {
console.error("Failed to fetch data", error);
}
}
const search = async () => {
try {
await get(
"/comlinks/list/search",
{ linktext: searchlist.linktext }
).then(response => {
if (response) {
comlinklist.value = response.data.data.map((items: any, index: any) => ({
key: (index + 1).toString(),
id: items.id,
linktext: items.linktext,
linkurl: items.linkurl,
descr: items.descr
}))
} else {
console.log("the interface request data does not exist!")
}
})
} catch (error) {
console.log("interface request exception")
}
}
const addModal = () => {
addControl.title = "新增"
addControl.open = true;
};
const formRef = ref();
const add = async () => {
try {
await post(
"/comlinks/add",
addList.value
)
comLinkList()
addControl.open = false
formRef.value.resetFields();
} catch (error) {
console.log("interface request exception")
}
}
const delModal = (id: any) => {
delControl.ids = id
delControl.open = true
};
//
const del = async (id: any) => {
id = delControl.ids
try {
if (id) {
await remove(
`/comlinks/delete/${id}`
)
comLinkList()
} else {
console.log("id do not exist!")
}
} catch (error) {
console.log("interface request exception")
}
delControl.open = false
}
const editModal = (id: any) => {
editControl.ids = id
editControl.title = "编辑"
editControl.open = true
get(
`/comlinks/list/search/${id}`
).then(response => {
editList.value = response.data.data
})
}
const edit = async (id: any) => {
id = editControl.ids
try {
if (id) {
await put(
`/comlinks/update/${id}`,
editList.value
)
editControl.open = false
formRef.value.resetFields()
comLinkList()
} else {
console.log("id do not exist!")
}
} catch (error) {
console.log("interface request exception")
}
}
//
onMounted(async () => {
comLinkList()
});
const columns = [
{
title: '序号',
dataIndex: 'key',
width: '5%',
},
{
title: '链接名称',
dataIndex: 'linktext',
width: '20%',
},
{
title: '连接地址',
dataIndex: 'linkurl',
},
{
title: '备注',
dataIndex: 'descr',
},
{
title: '操作',
dataIndex: 'operation',
},
];
</script>
<style scoped>
.content {
padding: 24px 24px 0 24px;
}
.search {
margin: 0 0 24px 0;
}
</style>

24
src/views/admin/classticmanage/ClassticFormView.vue

@ -1,24 +0,0 @@
<template>
</template>
<script setup lang='ts'>
import { ref } from "vue";
import { classticStore } from "@/stores/index"
import { onSubmit } from "@/services/admin/classtic"
const { modalForm, classticForm } = classticStore()
const formRef = ref();
const submit = () => {
if (modalForm.ids) {
onSubmit(modalForm.ids)
} else {
onSubmit()
}
formRef.value.resetFields();
modalForm.open = false
};
</script>
<style></style>
Loading…
Cancel
Save