修改图片显示

文章默认发布时间为现在
发布时间为必填
This commit is contained in:
jacky 2024-04-24 22:06:24 +08:00
parent 21d24f5d2f
commit ca16ebcf49
10 changed files with 33 additions and 21 deletions

View File

@ -21,7 +21,7 @@
<div class="media"> <div class="media">
<div v-for="(item, key) in picList" :key="key" class="media-box"> <div v-for="(item, key) in picList" :key="key" class="media-box">
<div class="img-box-list"> <div class="img-box-list">
<el-image :key="key" fit="cover" :src="getUrl(item.url)" style="width: 138px; height: 138px;" <el-image :key="key" fit="contain" :src="getUrl(item.url)" style="width: 138px; height: 138px;"
@click="chooseImg(item)"> @click="chooseImg(item)">
<template #error> <template #error>
<div class="img-box-list"> <div class="img-box-list">

View File

@ -705,3 +705,11 @@ li {
line-height: 1.2; line-height: 1.2;
margin-bottom: 15px; margin-bottom: 15px;
} }
.gva-image {
width: 120px;
height: 80px;
background: #F5F7FA;
padding: 6px;
border-radius: 5px;
}

View File

@ -11,9 +11,9 @@
<el-table-column align="left" label="ID" min-width="60" prop="ID" /> <el-table-column align="left" label="ID" min-width="60" prop="ID" />
<el-table-column align="left" label="媒体文件" min-width="160" prop="mediaUrl"> <el-table-column align="left" label="媒体文件" min-width="160" prop="mediaUrl">
<template #default="scope"> <template #default="scope">
<el-image v-if="scope.row.adType === 1 || scope.row.adType === 3" :src="scope.row.mediaUrl" class="file" <el-image v-if="scope.row.adType === 1 || scope.row.adType === 3" :src="scope.row.mediaUrl"
fit="cover" :preview-src-list="[scope.row.mediaUrl]" preview-teleported hide-on-click-modal class="gva-image" fit="contain" :preview-src-list="[scope.row.mediaUrl]" preview-teleported
close-on-press-escape style="width: 120px; height: 80px" /> hide-on-click-modal close-on-press-escape />
<div v-else-if="scope.row.adType === 2"> <div v-else-if="scope.row.adType === 2">
<video :src="scope.row.mediaUrl" controls="controls" style="width: 120px; height: 80px" /> <video :src="scope.row.mediaUrl" controls="controls" style="width: 120px; height: 80px" />
</div> </div>
@ -459,7 +459,7 @@ const uploadFailure = () => {
} }
</style> </style>
<style> <style scope>
.avatar-uploader .el-upload { .avatar-uploader .el-upload {
border: 1px solid var(--el-border-color); border: 1px solid var(--el-border-color);
border-radius: 6px; border-radius: 6px;

View File

@ -8,7 +8,7 @@
<el-table-column align="left" label="ID" min-width="50" prop="ID" /> <el-table-column align="left" label="ID" min-width="50" prop="ID" />
<el-table-column align="left" label="示例图片" min-width="100" prop="position"> <el-table-column align="left" label="示例图片" min-width="100" prop="position">
<template #default="scope"> <template #default="scope">
<el-image :src="scope.row.imgUrl" class="file" fit="cover" :preview-src-list="[scope.row.imgUrl]" <el-image :src="scope.row.imgUrl" class="gva-image" fit="contain" :preview-src-list="[scope.row.imgUrl]"
preview-teleported hide-on-click-modal close-on-press-escape style="width: 100px; height: 100px" /> preview-teleported hide-on-click-modal close-on-press-escape style="width: 100px; height: 100px" />
</template> </template>
</el-table-column> </el-table-column>

View File

@ -32,9 +32,9 @@
</el-table-column> </el-table-column>
<el-table-column align="left" label="头像" min-width="120" prop="avatar"> <el-table-column align="left" label="头像" min-width="120" prop="avatar">
<template #default="scope"> <template #default="scope">
<el-image v-if="scope.row.avatar" :src="scope.row.avatar" class="file" fit="cover" <el-image v-if="scope.row.avatar" :src="scope.row.avatar" class="gva-image" fit="contain"
:preview-src-list="[scope.row.avatar]" preview-teleported hide-on-click-modal close-on-press-escape :preview-src-list="[scope.row.avatar]" preview-teleported hide-on-click-modal close-on-press-escape
style="max-width: 70px; max-height: 90px" /> style="max-width: 80px; max-height: 100px" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="left" label="姓名/职称" min-width="120" prop="name"> <el-table-column align="left" label="姓名/职称" min-width="120" prop="name">

View File

@ -44,7 +44,6 @@
<el-button v-auth="btnAuth.delete" icon="delete" style="margin-left: 10px;" <el-button v-auth="btnAuth.delete" icon="delete" style="margin-left: 10px;"
:disabled="!multipleSelection.length" @click="handleMultiDelete">删除</el-button> :disabled="!multipleSelection.length" @click="handleMultiDelete">删除</el-button>
</div> </div>
<!-- 由于此处菜单跟左侧列表一一对应所以不需要分页 pageSize默认999 --> <!-- 由于此处菜单跟左侧列表一一对应所以不需要分页 pageSize默认999 -->
<el-table ref="multipleTable" :data="tableData" row-key="ID" @selection-change="handleSelectionChange"> <el-table ref="multipleTable" :data="tableData" row-key="ID" @selection-change="handleSelectionChange">
<el-table-column fixed type="selection" width="40" align="center" /> <el-table-column fixed type="selection" width="40" align="center" />
@ -103,7 +102,7 @@
<el-table-column align="left" label="状态" width="80"> <el-table-column align="left" label="状态" width="80">
<template #default="scope">{{ formatStatus(scope.row.status) }}</template> <template #default="scope">{{ formatStatus(scope.row.status) }}</template>
</el-table-column> </el-table-column>
<el-table-column align="left" fixed="right" label="操作" width="140" class="dispose-cell"> <el-table-column align="left" fixed="right" label="操作" width="80" class="dispose-cell">
<template #default="scope"> <template #default="scope">
<div class="flex md-2"> <div class="flex md-2">
<el-button v-if="scope.row.status === 1" v-auth="btnAuth.submit" type="success" link icon="check" <el-button v-if="scope.row.status === 1" v-auth="btnAuth.submit" type="success" link icon="check"

View File

@ -65,6 +65,9 @@
<el-divider direction="vertical" style="height: 100%" /> <el-divider direction="vertical" style="height: 100%" />
</el-col> </el-col>
<el-col :span="6"> <el-col :span="6">
<el-form-item label="发布时间" prop="publishDate">
<el-date-picker v-model="editForm.publishDate" type="datetime" placeholder="请选择" style="width:100%" />
</el-form-item>
<el-form-item label="摘要" prop="desc"> <el-form-item label="摘要" prop="desc">
<el-input v-model="editForm.desc" type="textarea" rows="7" :show-word-limit="true" maxlength="100" <el-input v-model="editForm.desc" type="textarea" rows="7" :show-word-limit="true" maxlength="100"
autocomplete="off" resize="none" /> autocomplete="off" resize="none" />
@ -80,9 +83,6 @@
<el-form-item label="跳转链接" prop="url"> <el-form-item label="跳转链接" prop="url">
<el-input v-model="editForm.url" autocomplete="off" placeholder="https://" clearable /> <el-input v-model="editForm.url" autocomplete="off" placeholder="https://" clearable />
</el-form-item> </el-form-item>
<el-form-item label="发布时间">
<el-date-picker v-model="editForm.publishDate" type="datetime" placeholder="请选择" style="width:100%" />
</el-form-item>
<el-form-item label="文章标签" prop="tags"> <el-form-item label="文章标签" prop="tags">
<div class="flex flex-wrap gap-2"> <div class="flex flex-wrap gap-2">
<el-tag v-for="(item, index) in tagList" :key="index" type="info" closable size="large" <el-tag v-for="(item, index) in tagList" :key="index" type="info" closable size="large"
@ -157,6 +157,7 @@ import {
import { importFetcherArticleById } from '@/api/fetcher' import { importFetcherArticleById } from '@/api/fetcher'
import { isUrl } from '@/utils/validator' import { isUrl } from '@/utils/validator'
import { articleTypeOptions } from '@/utils/options' import { articleTypeOptions } from '@/utils/options'
import { formatDate } from '@/utils/format'
// //
defineOptions({ defineOptions({
@ -203,6 +204,9 @@ const formRules = reactive({
content: [ content: [
{ required: true, message: '请输入文章内容', trigger: 'blur' } { required: true, message: '请输入文章内容', trigger: 'blur' }
], ],
publishDate: [
{ required: true, message: '请选择发布时间', trigger: 'blur' }
],
url: [ url: [
{ validator: isUrl, message: '请输入正确的跳转地址', trigger: 'blur' } { validator: isUrl, message: '请输入正确的跳转地址', trigger: 'blur' }
] ]
@ -292,11 +296,12 @@ const emptyForm = () => {
desc: '', desc: '',
source: '', source: '',
url: '', url: '',
publishDate: '', publishDate: formatDate(new Date()),
articleTime: '', articleTime: '',
tags: '', tags: '',
imgs: '', imgs: '',
} }
console.log(editForm.value)
} }
// //
@ -360,7 +365,6 @@ const initFormByFetcher = async (id) => {
editForm.value.author = author editForm.value.author = author
editForm.value.source = source editForm.value.source = source
editForm.value.content = content editForm.value.content = content
editForm.value.publishDate = publicTime
editForm.value.articleTime = publicTime editForm.value.articleTime = publicTime
editForm.value.articleType = 1 editForm.value.articleType = 1
} else { } else {

View File

@ -32,7 +32,7 @@
</el-table-column> </el-table-column>
<el-table-column align="left" label="头像" min-width="120" prop="avatar"> <el-table-column align="left" label="头像" min-width="120" prop="avatar">
<template #default="scope"> <template #default="scope">
<el-image v-if="scope.row.avatar" :src="scope.row.avatar" class="file" fit="cover" <el-image v-if="scope.row.avatar" :src="scope.row.avatar" class="gva-image" fit="contain"
:preview-src-list="[scope.row.avatar]" preview-teleported hide-on-click-modal close-on-press-escape :preview-src-list="[scope.row.avatar]" preview-teleported hide-on-click-modal close-on-press-escape
style="max-width: 70px; max-height: 90px" /> style="max-width: 70px; max-height: 90px" />
</template> </template>

View File

@ -54,10 +54,10 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="left" label="ID" min-width="50" prop="ID" /> <el-table-column align="left" label="ID" min-width="50" prop="ID" />
<el-table-column align="left" label="封面" min-width="120" prop="cover"> <el-table-column align="left" label="封面" min-width="140" prop="cover">
<template #default="scope"> <template #default="scope">
<el-image :src="scope.row.cover" class="file" fit="cover" :preview-src-list="[scope.row.cover]" <el-image :src="scope.row.cover" class="gva-image" fit="contain" :preview-src-list="[scope.row.cover]"
preview-teleported hide-on-click-modal close-on-press-escape style="width: 100px; height: 100px" /> preview-teleported hide-on-click-modal close-on-press-escape />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="left" label="标题" min-width="220" prop="title" /> <el-table-column align="left" label="标题" min-width="220" prop="title" />

View File

@ -14,8 +14,9 @@
<el-table :data="tableData"> <el-table :data="tableData">
<el-table-column align="left" label="预览" width="110"> <el-table-column align="left" label="预览" width="110">
<template #default="scope"> <template #default="scope">
<el-image :src="getUrl(scope.row.url)" class="file" fit="cover" :preview-src-list="[getUrl(scope.row.url)]" <el-image :src="getUrl(scope.row.url)" class="gva-image" fit="contain"
:preview-teleported="true" style="width: 80px; height: 80px" /> :preview-src-list="[getUrl(scope.row.url)]" :preview-teleported="true"
style="width: 100px; height: 100px;" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="left" label="日期" prop="UpdatedAt" width="180"> <el-table-column align="left" label="日期" prop="UpdatedAt" width="180">