banner增加

This commit is contained in:
2026-01-12 18:38:26 +08:00
parent 2d7f0526ba
commit 9c0efc38d0
2 changed files with 16 additions and 7 deletions

View File

@@ -97,7 +97,7 @@
横幅图片
</label>
<FileUpload :as-dialog="false" list-type="cover" v-model:cover-url="currentBanner.imageUrl"
accept="image/*" :max-size="10" tip="支持 jpg、png、gif 格式建议尺寸1920x600" module="banner" />
accept="image/*" :max-size="10" tip="支持 jpg、png、gif 格式建议尺寸1920x324" module="banner" />
</div>
<div class="form-group">
@@ -106,6 +106,10 @@
链接类型
</label>
<div class="radio-group">
<label class="radio-item">
<input v-model="currentBanner.linkType" type="radio" :value="0" />
<span class="radio-label"></span>
</label>
<label class="radio-item">
<input v-model="currentBanner.linkType" type="radio" :value="1" />
<span class="radio-label">资源</span>
@@ -264,7 +268,7 @@ const pageParam = ref<PageParam>({
const dialogVisible = ref(false);
const isEdit = ref(false);
const currentBanner = ref<Banner>({
linkType: 1,
linkType: 0,
status: 1,
orderNum: 0,
});
@@ -308,7 +312,7 @@ function handlePageSizeChange(size: number) {
function handleCreate() {
isEdit.value = false;
currentBanner.value = {
linkType: 1,
linkType: 0,
status: 1,
orderNum: 0,
};
@@ -369,7 +373,7 @@ async function loadSelectedItem(linkID: string, linkType: number) {
function handleCloseDialog() {
dialogVisible.value = false;
currentBanner.value = {
linkType: 1,
linkType: 0,
status: 1,
orderNum: 0,
};
@@ -463,11 +467,12 @@ async function handleDelete(banner: Banner) {
// 获取链接类型文本
function getLinkTypeText(linkType?: number): string {
const types: Record<number, string> = {
0: '无',
1: '资源',
2: '课程',
3: '外部链接',
};
return types[linkType || 1] || '未知';
return types[linkType ?? 0] || '未知';
}
// 格式化日期

View File

@@ -1,6 +1,6 @@
<template>
<div class="banner-card">
<div class="banner-content" @click="handleLearn">
<div class="banner-content" :class="{ 'clickable': props.banner.linkType !== 0 }" @click="handleLearn">
<img :src="FILE_DOWNLOAD_URL + props.banner.imageUrl" alt="banner" class="banner-image">
</div>
</div>
@@ -17,6 +17,10 @@ const props = defineProps<{
}>();
console.log(props.banner);
function handleLearn() {
// linkType 为 0 时不跳转,仅展示
if (props.banner.linkType === 0) {
return;
}
if (props.banner.linkType === 1) {
console.log(`/resource/${props.banner.linkID}`);
router.push(`/article/show?articleId=${props.banner.linkID}`);
@@ -41,7 +45,7 @@ function handleLearn() {
position: relative;
background-color: red;
:hover {
&.clickable:hover {
cursor: pointer;
}