This commit is contained in:
2025-04-23 19:48:47 +08:00
parent 86aa66800c
commit fbfd175258
12 changed files with 469 additions and 112 deletions

View File

@@ -253,6 +253,137 @@ const admin = {
data: data data: data
}); });
}, },
getBarragelist: async (data) => {
return request({
url: '/admin/barrage/getlist',
method: Method.POST,
data: data
});
},
addBarrage: async (data) => {
return request({
url: '/admin/barrage/add',
method: Method.POST,
data: data
});
},
editBarrage: async (data) => {
return request({
url: '/admin/barrage/edit',
method: Method.POST,
data: data
});
},
barrageWeigh: async (data) => {
return request({
url: '/admin/barrage/weigh',
method: Method.POST,
data: data
});
},
barrageDel: async (data) => {
return request({
url: '/admin/barrage/del',
method: Method.POST,
data: data
});
},
getNoticeList: async (data) => {
return request({
url: '/admin/notice/getList',
method: Method.POST,
data: data
});
},
addNotice: async (data) => {
return request({
url: '/admin/notice/add',
method: Method.POST,
data: data
});
},
editNotice: async (data) => {
return request({
url: '/admin/notice/edit',
method: Method.POST,
data: data
});
},
delNotice: async (id) => {
return request({
url: '/admin/notice/del',
method: Method.POST,
data: {id}
});
},
getNoticeType: async () => {
return request({
url: '/admin/notice/getType',
method: Method.POST,
});
},
setNoticeStatus: async (id) => {
return request({
url: '/admin/notice/status',
method: Method.POST,
data: {id}
});
},
setNoticeTop: async (id) => {
return request({
url: '/admin/notice/top',
method: Method.POST,
data: {id}
});
},
setNotcieWeigh: async (data) => {
return request({
url: '/admin/notice/weigh',
method: Method.POST,
data: data
});
},
getADVType: async () => {
return request({
url: '/admin/adv/getType',
method: Method.POST,
});
},
addADV: async (data) => {
return request({
url: '/admin/adv/add',
method: Method.POST,
data: data
});
},
setADVStatus: async (id) => {
return request({
url: '/admin/adv/status',
method: Method.POST,
data: {id}
});
},
setADVWeigh: async (data) => {
return request({
url: '/admin/adv/weigh',
method: Method.POST,
data: data
});
},
delADV: async (id) => {
return request({
url: '/admin/adv/del',
method: Method.POST,
data: {id}
});
},
getADVList: async (data) => {
return request({
url: '/admin/adv/getList',
method: Method.POST,
data: data
});
},
} }
export default admin; export default admin;

View File

@@ -30,6 +30,19 @@ const system = {
] ]
}); });
}) })
},
uploadFile: async (file) => {
const formData = new FormData();
formData.append('file', file);
return request({
UN_AES: true,
url: '/admin/upload/upload',
method: Method.POST,
data: formData,
headers: {
'Content-Type': 'multipart/form-data; boundary=--------------------------611824495457697861278283'
}
});
} }
} }

View File

@@ -1,42 +1,38 @@
<script setup> <script setup>
import {ref} from 'vue'; import {onMounted, reactive} from 'vue';
const group = [ import Api from "../../api/index.js";
{
label: '站内URL', const group = reactive([]);
value: 0,
}, const {api} = defineProps({
{ api: {
label: '站内富文本页面', type: Function,
value: 1, default: Api.admin.getNoticeType
}, }
{ });
label: '微信链接', const form = defineModel('form');
value: 2, onMounted(() => {
}, api().then(({data}) => {
{ group.length = 0;
label: '外部链接', group.push(...data);
value: 3, })
}, })
{
label: '弹窗',
value: 4,
},
{
label: '空',
value: 5,
},
];
const type = ref(0);
</script> </script>
<template> <template>
<a-radio-group v-model:model-value="type"> <a-form-item label="跳转方式">
<a-radio-group class="w-full" v-model:model-value="form.type">
<div class="grid grid-cols-3"> <div class="grid grid-cols-3">
<a-radio v-for="item in group" :key="item.value" :value="item.value"> <a-radio v-for="item in group" :key="item.id" :value="item.id">
{{item.label}} {{ item.name }}
</a-radio> </a-radio>
</div> </div>
</a-radio-group> </a-radio-group>
</a-form-item>
<a-form-item label="url路径" v-if="[1,3,4].includes(form.type)">
<a-input v-model:model-value="form.url" placeholder="请输入url路径"></a-input>
</a-form-item>
</template> </template>
<style scoped lang="scss"> <style scoped lang="scss">

View File

@@ -1,14 +1,36 @@
<script setup> <script setup>
import {Message} from "@arco-design/web-vue";
const emits = defineEmits(['success']);
const {api, id} = defineProps({
api: {
type: Function,
default: async () => {
},
},
id: {
type: Number,
default: null,
},
});
const move = async (status) => {
const {code, msg} = await api({
type: status,
id: id,
});
if (code === 1) Message.success(msg);
emits('success');
}
</script> </script>
<template> <template>
<div class="flex gap-[10px]"> <div class="flex gap-[10px]">
<a-link :hoverable="false"> <a-link :hoverable="false" @click="move(1)">
<icon-arrow-rise/> <icon-arrow-rise/>
上移 上移
</a-link> </a-link>
<a-link :hoverable="false"> <a-link :hoverable="false" @click="move(0)">
<icon-arrow-fall/> <icon-arrow-fall/>
下移 下移
</a-link> </a-link>

View File

@@ -0,0 +1,39 @@
<script setup>
import {computed} from "vue";
import {Message} from "@arco-design/web-vue";
const {api, id} = defineProps({
api: {
type: Function,
default: async () => {
}
},
id: {
type: Number,
default: null,
}
});
const emits = defineEmits(['change']);
const modelValue = defineModel('model-value');
const status = computed({
get: () => Boolean(Number(modelValue.value)),
set: (value) => {
modelValue.value = value ? 1 : 0;
},
})
const change = async () => {
const {msg} = await api(id);
Message.success(msg);
emits('change');
}
</script>
<template>
<a-switch v-bind="$attrs" v-model:model-value="status" @change="change"></a-switch>
</template>
<style scoped lang="scss">
</style>

View File

@@ -0,0 +1,26 @@
<script setup>
import Api from "../../api/index.js";
const emits = defineEmits(['success']);
const files = defineModel('file');
const beforeUpload = (file) => {
Api.system.uploadFile(file).then(({data}) => {
files.value = data;
emits('success', file);
});
return false;
}
</script>
<template>
<a-upload draggable @before-upload="beforeUpload">
<template #upload-button v-if="files">
<a-image :src="files"></a-image>
</template>
</a-upload>
</template>
<style scoped lang="scss">
</style>

View File

@@ -1,8 +1,28 @@
<script setup> <script setup>
import {ref} from "vue"; import {reactive, ref} from "vue";
import JumpMethod from '../../../../../components/JumpMethod/index.vue'; import JumpMethod from '../../../../../components/JumpMethod/index.vue';
import UploadOne from "../../../../../components/upload/UploadOne.vue";
import Api from "../../../../../api/index.js";
import {Message} from "@arco-design/web-vue";
const {detail} = defineProps({
detail: {
type: Object,
default: {},
}
});
const emits = defineEmits(['success']);
const visible = ref(false); const visible = ref(false);
const form = reactive({
file: null,
type: 0,
});
const success = async () => {
const {msg} = await Api.admin.addADV(form);
Message.success(msg);
emits('success');
}
</script> </script>
<template> <template>
@@ -19,14 +39,13 @@ const visible = ref(false);
<a-modal <a-modal
title="编辑平台消息" title="编辑平台消息"
title-align="start" title-align="start"
@ok="success"
v-model:visible="visible"> v-model:visible="visible">
<a-form layout="vertical"> <a-form layout="vertical">
<a-form-item label="封面"> <a-form-item label="封面">
<a-upload></a-upload> <upload-one v-model:file="form.file"></upload-one>
</a-form-item>
<a-form-item label="跳转方式">
<JumpMethod></JumpMethod>
</a-form-item> </a-form-item>
<JumpMethod v-model:form="form" :api="Api.admin.getADVType"></JumpMethod>
</a-form> </a-form>
</a-modal> </a-modal>
</template> </template>

View File

@@ -1,38 +1,63 @@
<script setup> <script setup>
import {ref} from "vue"; import {reactive, ref, watch} from "vue";
import Api from "../../../../../api/index.js";
import {Message} from "@arco-design/web-vue";
import JumpMethod from "../../../../../components/JumpMethod/index.vue";
const visible = ref(false); const visible = ref(false);
const emits = defineEmits(['success']);
const {detail} = defineProps({
detail: {
type: Object,
default: null,
}
});
const form = reactive({
title: null,
content: null,
type: null,
url: null,
id: null,
});
const success = async () => {
if (detail?.id) {
const {code, msg} = await Api.admin.editNotice(form);
if (code === 1) Message.success(msg);
} else {
const {code, msg} = await Api.admin.addNotice(form);
if (code === 1) Message.success(msg);
}
emits('success');
}
watch(
() => visible.value,
(val) => {
if (val) Object.assign(form, detail)
},
)
</script> </script>
<template> <template>
<a-link :hoverable="false" @click="visible=true">编辑</a-link> <a-link v-if="!$slots.default" :hoverable="false" @click="visible=true">编辑</a-link>
<view @click="visible=true" v-else>
<slot></slot>
</view>
<a-modal <a-modal
title="编辑平台消息" :on-before-ok="success"
:title="`${detail ? '编辑' : '新增'}平台消息`"
title-align="start" title-align="start"
v-model:visible="visible"> v-model:visible="visible">
<a-form layout="vertical"> <a-form layout="vertical">
<a-form-item label="标题"> <a-form-item label="标题">
<a-input placeholder="请输入标题"></a-input> <a-input v-model:model-value="form.title" placeholder="请输入标题"></a-input>
</a-form-item> </a-form-item>
<a-form-item label="简介"> <a-form-item label="简介">
<a-textarea placeholder="请输入简介"></a-textarea> <a-textarea v-model:model-value="form.content" placeholder="请输入简介"></a-textarea>
</a-form-item>
<a-form-item label="跳转方式">
<a-radio-group>
<div class="grid grid-cols-3">
<a-radio :value="0">站内URL</a-radio>
<a-radio :value="1">站内富文本页面</a-radio>
<a-radio :value="2">微信链接</a-radio>
<a-radio :value="3">外部链接</a-radio>
<a-radio :value="4">弹窗</a-radio>
<a-radio :value="5"></a-radio>
</div>
</a-radio-group>
</a-form-item>
<a-form-item label="链接">
<a-input placeholder="请输入链接"></a-input>
</a-form-item> </a-form-item>
<JumpMethod v-model:form="form"></JumpMethod>
</a-form> </a-form>
</a-modal> </a-modal>
</template> </template>

View File

@@ -4,6 +4,8 @@ import {reactive} from "vue";
import useTableQuery from "../../../../../hooks/useTableQuery.js"; import useTableQuery from "../../../../../hooks/useTableQuery.js";
import Api from "../../../../../api/index.js"; import Api from "../../../../../api/index.js";
import EditBanner from "./EditBanner.vue"; import EditBanner from "./EditBanner.vue";
import XSwitch from "../../../../../components/XSwitch/index.vue";
import {Message} from "@arco-design/web-vue";
const columns = [ const columns = [
{ {
@@ -14,15 +16,16 @@ const columns = [
{ {
title: '封面', title: '封面',
dataIndex: 'key', dataIndex: 'key',
slotName: 'file',
}, },
{ {
title: '跳转方式', title: '跳转方式',
dataIndex: 'key', dataIndex: 'type_text',
}, },
{ {
title: '是否启用', title: '是否启用',
dataIndex: 'isA', dataIndex: 'isStatus',
slotName: 'isA', slotName: 'isStatus',
width: 100, width: 100,
align: 'center', align: 'center',
}, },
@@ -47,17 +50,23 @@ const vo = reactive({
total: 0, total: 0,
}); });
const {loading, pagination, initFetchData} = useTableQuery({ const {loading, pagination, fetchData} = useTableQuery({
parameter: po, parameter: po,
api: Api.system.getData, api: Api.admin.getADVList,
callback: (data) => { callback: (data) => {
Object.assign(vo, data); Object.assign(vo, data);
} }
}); });
const delADV = async (id) => {
const {msg} = await Api.admin.delADV(id);
Message.success(msg);
await fetchData();
}
</script> </script>
<template> <template>
<EditBanner></EditBanner> <EditBanner @success="fetchData"></EditBanner>
<a-table <a-table
:loading="loading" :loading="loading"
@@ -66,18 +75,32 @@ const {loading, pagination, initFetchData} = useTableQuery({
:data="vo.rows" :data="vo.rows"
:columns="columns" :columns="columns"
class="flex-grow mt-[20px] w-full"> class="flex-grow mt-[20px] w-full">
<template v-slot:isA> <template v-slot:file="{record}">
<a-switch></a-switch> <a-image height="60" :src="record.file"></a-image>
</template> </template>
<template v-slot:sort> <template v-slot:isStatus="{record}">
<SequenceAdjustment></SequenceAdjustment> <x-switch
v-model:model-value="record.status"
:id="record.id"
:api="Api.admin.setADVStatus"
@change="fetchData">
</x-switch>
</template> </template>
<template v-slot:action> <template v-slot:sort="{record}">
<SequenceAdjustment
:id="record.id"
@success="fetchData"
:api="Api.admin.setADVWeigh">
</SequenceAdjustment>
</template>
<template v-slot:action="{record}">
<div class="flex gap-[10px]"> <div class="flex gap-[10px]">
<EditBanner> <EditBanner>
<a-link :hoverable="false">编辑</a-link> <a-link :hoverable="false">编辑</a-link>
</EditBanner> </EditBanner>
<a-popconfirm content="确认删除吗?" @ok="delADV(record.id)">
<a-link :hoverable="false" status="danger">删除</a-link> <a-link :hoverable="false" status="danger">删除</a-link>
</a-popconfirm>
</div> </div>
</template> </template>
</a-table> </a-table>

View File

@@ -3,16 +3,17 @@ import {reactive} from "vue";
import useTableQuery from "../../../../../hooks/useTableQuery.js"; import useTableQuery from "../../../../../hooks/useTableQuery.js";
import Api from "../../../../../api/index.js"; import Api from "../../../../../api/index.js";
import SequenceAdjustment from "../../../../../components/SequenceAdjustment/index.vue"; import SequenceAdjustment from "../../../../../components/SequenceAdjustment/index.vue";
import {Message} from "@arco-design/web-vue";
const columns = [ const columns = [
{ {
title: 'ID', title: 'ID',
dataIndex: 'key', dataIndex: 'id',
width: 120, width: 120,
}, },
{ {
title: '内容', title: '内容',
dataIndex: 'content', dataIndex: 'title',
slotName: 'content', slotName: 'content',
}, },
{ {
@@ -36,21 +37,48 @@ const vo = reactive({
total: 0, total: 0,
}); });
const {loading, pagination, initFetchData} = useTableQuery({ const {loading, pagination, initFetchData, fetchData} = useTableQuery({
parameter: po, parameter: po,
api: Api.system.getData, api: Api.admin.getBarragelist,
callback: (data) => { callback: (data) => {
Object.assign(vo, data); Object.assign(vo, data);
} }
}); });
const success = async (item) => { const success = async (item) => {
if (item.id !== null) {
const {msg, code} = await Api.admin.editBarrage({
id: item.id,
title: item.title
});
if (code === 1) Message.success(msg);
} else {
const {msg, code} = await Api.admin.addBarrage({
title: item.title
});
if (code === 1) Message.success(msg);
}
await initFetchData();
}
const addContext = () => {
vo.rows.push({
id: null,
title: null,
})
}
const barrageDel = async (id) => {
const {code, msg} = await Api.admin.barrageDel({
id: id
});
if (code === 1) Message.success(msg);
await fetchData();
} }
</script> </script>
<template> <template>
<a-button type="primary"> <a-button type="primary" @click="addContext">
<template #icon> <template #icon>
<icon-plus/> <icon-plus/>
</template> </template>
@@ -67,15 +95,21 @@ const success = async (item) => {
<template v-slot:content="{record}"> <template v-slot:content="{record}">
<a-textarea <a-textarea
@blur="success(record)" @blur="success(record)"
v-model:model-value="record.key" v-model:model-value="record.title"
auto-size> auto-size>
</a-textarea> </a-textarea>
</template> </template>
<template v-slot:sort> <template v-slot:sort="{record}">
<SequenceAdjustment></SequenceAdjustment> <SequenceAdjustment
@success="fetchData"
:api="Api.admin.barrageWeigh"
:id="record.id">
</SequenceAdjustment>
</template> </template>
<template v-slot:action> <template v-slot:action="{record}">
<a-popconfirm content="您确认删除吗?" @ok="barrageDel(record.id)">
<a-link :hoverable="false" status="danger">删除</a-link> <a-link :hoverable="false" status="danger">删除</a-link>
</a-popconfirm>
</template> </template>
</a-table> </a-table>
</template> </template>

View File

@@ -2,8 +2,10 @@
import {reactive} from "vue"; import {reactive} from "vue";
import useTableQuery from "../../../../../hooks/useTableQuery.js"; import useTableQuery from "../../../../../hooks/useTableQuery.js";
import Api from "../../../../../api/index.js"; import Api from "../../../../../api/index.js";
import XSwitch from "../../../../../components/XSwitch/index.vue";
import SequenceAdjustment from "../../../../../components/SequenceAdjustment/index.vue"; import SequenceAdjustment from "../../../../../components/SequenceAdjustment/index.vue";
import EditPlatformNews from "./EditPlatformNews.vue"; import EditPlatformNews from "./EditPlatformNews.vue";
import {Message} from "@arco-design/web-vue";
const columns = [ const columns = [
{ {
@@ -13,30 +15,30 @@ const columns = [
}, },
{ {
title: '标题', title: '标题',
dataIndex: 'key', dataIndex: 'title',
}, },
{ {
title: '简介', title: '简介',
dataIndex: 'key', dataIndex: 'content',
}, },
{ {
title: '跳转方式', title: '跳转方式',
dataIndex: 'key', dataIndex: 'type_text',
}, },
{ {
title: '发布时间', title: '发布时间',
dataIndex: 'key', dataIndex: 'createtime',
}, },
{ {
title: '是否启用', title: '是否启用',
dataIndex: 'isA', dataIndex: 'status',
slotName: 'isA', slotName: 'isStatus',
width: 100, width: 100,
align: 'center', align: 'center',
}, },
{ {
title: '是否置顶', title: '是否置顶',
dataIndex: 'isTop', dataIndex: 'is_top',
slotName: 'isTop', slotName: 'isTop',
width: 100, width: 100,
align: 'center', align: 'center',
@@ -62,22 +64,30 @@ const vo = reactive({
total: 0, total: 0,
}); });
const {loading, pagination, initFetchData} = useTableQuery({ const {loading, pagination, initFetchData, fetchData} = useTableQuery({
parameter: po, parameter: po,
api: Api.system.getData, api: Api.admin.getNoticeList,
callback: (data) => { callback: (data) => {
Object.assign(vo, data); Object.assign(vo, data);
} }
}); });
const delNotice = async (id) => {
const {code, msg} = await Api.admin.delNotice(id);
if (code === 1) Message.success(msg);
await fetchData();
}
</script> </script>
<template> <template>
<EditPlatformNews @success="fetchData">
<a-button type="primary"> <a-button type="primary">
<template #icon> <template #icon>
<icon-plus/> <icon-plus/>
</template> </template>
新建 新建
</a-button> </a-button>
</EditPlatformNews>
<a-table <a-table
:loading="loading" :loading="loading"
@@ -86,19 +96,35 @@ const {loading, pagination, initFetchData} = useTableQuery({
:data="vo.rows" :data="vo.rows"
:columns="columns" :columns="columns"
class="flex-grow mt-[20px] w-full"> class="flex-grow mt-[20px] w-full">
<template v-slot:isA> <template v-slot:isStatus="{record}">
<a-switch></a-switch> <x-switch
v-model:model-value="record.status"
:id="record.id"
:api="Api.admin.setNoticeStatus"
@change="fetchData">
</x-switch>
</template> </template>
<template v-slot:isTop> <template v-slot:isTop="{record}">
<a-switch></a-switch> <x-switch
v-model:model-value="record.is_top"
:id="record.id"
:api="Api.admin.setNoticeTop"
@change="fetchData">
</x-switch>
</template> </template>
<template v-slot:sort> <template v-slot:sort="{record}">
<SequenceAdjustment></SequenceAdjustment> <SequenceAdjustment
:id="record.id"
@success="fetchData"
:api="Api.admin.setNotcieWeigh">
</SequenceAdjustment>
</template> </template>
<template v-slot:action> <template v-slot:action="{record}">
<div class="flex gap-[20px]"> <div class="flex gap-[20px]">
<EditPlatformNews></EditPlatformNews> <EditPlatformNews @success="fetchData" :detail="record"></EditPlatformNews>
<a-popconfirm content="确认删除吗?" @ok="delNotice(record.id)">
<a-link :hoverable="false" status="danger">删除</a-link> <a-link :hoverable="false" status="danger">删除</a-link>
</a-popconfirm>
</div> </div>
</template> </template>
</a-table> </a-table>

View File

@@ -20,11 +20,13 @@ request.interceptors.request.use((config) => {
console.log('请求拦截器', config.data); console.log('请求拦截器', config.data);
if (!config.UN_AES) {
const {context, iv} = AESCrypto.encrypt(JSON.stringify(config.data)); const {context, iv} = AESCrypto.encrypt(JSON.stringify(config.data));
config.data = { config.data = {
requestData: context, iv: iv, requestData: context, iv: iv,
}; };
}
return config; return config;
}, (error) => { }, (error) => {
@@ -41,6 +43,7 @@ request.interceptors.response.use((response) => {
} }
if (code !== 1) { if (code !== 1) {
Message.error(msg); Message.error(msg);
return Promise.reject(msg);
} }
if (!data.data) { if (!data.data) {
return {msg, code, data} return {msg, code, data}