web-资源修改
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { api } from '@/apis';
|
import { api } from '@/apis';
|
||||||
import type { ResultDomain, Resource, ResourceSearchParams } from '@/types';
|
import type { ResultDomain, Resource, ResourceSearchParams, PageParam, ResourceVO } from '@/types';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 资源API服务
|
* 资源API服务
|
||||||
@@ -25,13 +25,27 @@ export const resourceApi = {
|
|||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取资源分页列表
|
||||||
|
* @param filter 筛选条件
|
||||||
|
* @param pageParam 分页参数
|
||||||
|
* @returns Promise<ResultDomain<Resource>>
|
||||||
|
*/
|
||||||
|
async getResourcePage(pageParam: PageParam, filter?: ResourceSearchParams): Promise<ResultDomain<Resource>> {
|
||||||
|
const response = await api.post<Resource>('/news/resources/page', {
|
||||||
|
pageParam,
|
||||||
|
filter,
|
||||||
|
});
|
||||||
|
return response.data;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据ID获取资源详情
|
* 根据ID获取资源详情
|
||||||
* @param resourceID 资源ID
|
* @param resourceID 资源ID
|
||||||
* @returns Promise<ResultDomain<Resource>>
|
* @returns Promise<ResultDomain<Resource>>
|
||||||
*/
|
*/
|
||||||
async getResourceById(resourceID: string): Promise<ResultDomain<Resource>> {
|
async getResourceById(resourceID: string): Promise<ResultDomain<ResourceVO>> {
|
||||||
const response = await api.get<Resource>(`/news/resources/resource/${resourceID}`);
|
const response = await api.get<ResourceVO>(`/news/resources/resource/${resourceID}`);
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -40,18 +54,18 @@ export const resourceApi = {
|
|||||||
* @param resource 资源信息
|
* @param resource 资源信息
|
||||||
* @returns Promise<ResultDomain<Resource>>
|
* @returns Promise<ResultDomain<Resource>>
|
||||||
*/
|
*/
|
||||||
async createResource(resource: Resource): Promise<ResultDomain<Resource>> {
|
async createResource(resource: ResourceVO): Promise<ResultDomain<ResourceVO>> {
|
||||||
const response = await api.post<Resource>('/news/resources/resource', resource);
|
const response = await api.post<ResourceVO>('/news/resources/resource', resource);
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新资源
|
* 更新资源
|
||||||
* @param resource 资源信息
|
* @param resource 资源信息
|
||||||
* @returns Promise<ResultDomain<Resource>>
|
* @returns Promise<ResultDomain<ResourceVO>>
|
||||||
*/
|
*/
|
||||||
async updateResource(resource: Resource): Promise<ResultDomain<Resource>> {
|
async updateResource(resource: ResourceVO): Promise<ResultDomain<ResourceVO>> {
|
||||||
const response = await api.put<Resource>('/news/resources/resource', resource);
|
const response = await api.put<ResourceVO>('/news/resources/resource', resource);
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ export interface BaseDTO {
|
|||||||
*/
|
*/
|
||||||
export interface PageParam {
|
export interface PageParam {
|
||||||
/** 当前页码 */
|
/** 当前页码 */
|
||||||
page?: number;
|
page: number;
|
||||||
/** 每页条数 */
|
/** 每页条数 */
|
||||||
size?: number;
|
size: number;
|
||||||
/** 排序字段 */
|
/** 排序字段 */
|
||||||
orderBy?: string;
|
orderBy?: string;
|
||||||
/** 排序方向 asc/desc */
|
/** 排序方向 asc/desc */
|
||||||
@@ -47,7 +47,7 @@ export interface PageDomain<T> {
|
|||||||
/** 总页数 */
|
/** 总页数 */
|
||||||
pages: number;
|
pages: number;
|
||||||
/** 数据列表 */
|
/** 数据列表 */
|
||||||
records: T[];
|
dataList?: T[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -127,6 +127,23 @@ export interface Tag extends BaseDTO {
|
|||||||
status?: number;
|
status?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ResourceVO extends BaseDTO{
|
||||||
|
resource: Resource;
|
||||||
|
category: ResourceCategory;
|
||||||
|
tags: Tag[];
|
||||||
|
}
|
||||||
|
export interface tagVO extends BaseDTO{
|
||||||
|
/** 标签ID */
|
||||||
|
tagID?: string;
|
||||||
|
/** 标签名称 */
|
||||||
|
tagName?: string;
|
||||||
|
/** 标签描述 */
|
||||||
|
description?: string;
|
||||||
|
/** 标签颜色 */
|
||||||
|
tagColor?: string;
|
||||||
|
resourceID?: string;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 资源推荐实体
|
* 资源推荐实体
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<el-table-column prop="title" label="文章标题" min-width="200" />
|
<el-table-column prop="title" label="文章标题" min-width="200" />
|
||||||
<el-table-column prop="category" label="分类" width="120" />
|
<el-table-column prop="category" label="分类" width="120" />
|
||||||
<el-table-column prop="author" label="作者" width="120" />
|
<el-table-column prop="author" label="作者" width="120" />
|
||||||
<el-table-column prop="publishDate" label="发布日期" width="120" />
|
<el-table-column prop="publishTime" label="发布日期" width="120" />
|
||||||
<el-table-column prop="views" label="阅读量" width="100" />
|
<el-table-column prop="views" label="阅读量" width="100" />
|
||||||
<el-table-column prop="status" label="状态" width="100">
|
<el-table-column prop="status" label="状态" width="100">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
@@ -26,20 +26,34 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" width="200" fixed="right">
|
<el-table-column label="操作" width="200" fixed="right">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
|
<el-button size="small" @click="viewArticle(row)">查看</el-button>
|
||||||
<el-button size="small" @click="editArticle(row)">编辑</el-button>
|
<el-button size="small" @click="editArticle(row)">编辑</el-button>
|
||||||
<el-button size="small" type="danger" @click="deleteArticle(row)">删除</el-button>
|
<el-button size="small" type="danger" @click="deleteArticle()">删除</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
||||||
<el-pagination
|
<el-pagination
|
||||||
v-model:current-page="currentPage"
|
v-model:current-page="pageParam.page"
|
||||||
v-model:page-size="pageSize"
|
v-model:page-size="pageParam.size"
|
||||||
:total="total"
|
:total="total"
|
||||||
layout="total, sizes, prev, pager, next, jumper"
|
layout="total, sizes, prev, pager, next, jumper"
|
||||||
@size-change="handleSizeChange"
|
@size-change="handleSizeChange"
|
||||||
@current-change="handleCurrentChange"
|
@current-change="handleCurrentChange"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<!-- 文章查看弹窗 -->
|
||||||
|
<ArticleShowView
|
||||||
|
v-model="showViewDialog"
|
||||||
|
:as-dialog="true"
|
||||||
|
title="文章详情"
|
||||||
|
width="900px"
|
||||||
|
:article-data="currentArticle"
|
||||||
|
:category-list="categoryList"
|
||||||
|
:show-edit-button="true"
|
||||||
|
@edit="handleEditFromView"
|
||||||
|
@close="showViewDialog = false"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -47,20 +61,47 @@
|
|||||||
import { ref, onMounted } from 'vue';
|
import { ref, onMounted } from 'vue';
|
||||||
import { ElButton, ElInput, ElTable, ElTableColumn, ElTag, ElPagination, ElMessage } from 'element-plus';
|
import { ElButton, ElInput, ElTable, ElTableColumn, ElTag, ElPagination, ElMessage } from 'element-plus';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
|
import { resourceApi, resourceCategoryApi } from '@/apis/resource'
|
||||||
|
import type { PageParam, ResourceSearchParams, Resource, ResourceCategory } from '@/types';
|
||||||
|
import { ArticleShowView } from '@/views/article';
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const searchKeyword = ref('');
|
const searchKeyword = ref('');
|
||||||
const currentPage = ref(1);
|
const pageParam = ref<PageParam>({
|
||||||
const pageSize = ref(10);
|
page: 1,
|
||||||
const total = ref(0);
|
size: 10
|
||||||
const articles = ref<any[]>([]);
|
});
|
||||||
|
const filter = ref<ResourceSearchParams>({
|
||||||
|
keyword: searchKeyword.value
|
||||||
|
});
|
||||||
|
const total = ref<number>(0);
|
||||||
|
const articles = ref<Resource[]>([]);
|
||||||
|
const showViewDialog = ref(false);
|
||||||
|
const currentArticle = ref<any>(null);
|
||||||
|
const categoryList = ref<ResourceCategory[]>([]);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
loadArticles();
|
loadArticles();
|
||||||
|
loadCategories();
|
||||||
});
|
});
|
||||||
|
|
||||||
function loadArticles() {
|
async function loadCategories() {
|
||||||
// TODO: 加载文章数据
|
try {
|
||||||
|
const res = await resourceCategoryApi.getCategoryList();
|
||||||
|
if (res.success && res.dataList) {
|
||||||
|
categoryList.value = res.dataList;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('加载分类列表失败:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadArticles() {
|
||||||
|
const res = await resourceApi.getResourcePage(pageParam.value, filter.value);
|
||||||
|
if (res.success) {
|
||||||
|
articles.value = res.pageDomain?.dataList || [];
|
||||||
|
total.value = res.pageDomain?.total || 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showCreateDialog() {
|
function showCreateDialog() {
|
||||||
@@ -80,12 +121,40 @@ function handleDataCollection() {
|
|||||||
ElMessage.info('数据采集功能开发中');
|
ElMessage.info('数据采集功能开发中');
|
||||||
}
|
}
|
||||||
|
|
||||||
function editArticle(row: any) {
|
async function viewArticle(row: any) {
|
||||||
// TODO: 编辑文章
|
try {
|
||||||
|
const res = await resourceApi.getResourceById(row.resourceID);
|
||||||
|
if (res.success && res.data) {
|
||||||
|
// 将 ResourceVO 转换为 ArticleShowView 期望的格式
|
||||||
|
const resourceVO = res.data;
|
||||||
|
currentArticle.value = {
|
||||||
|
...resourceVO.resource,
|
||||||
|
tags: resourceVO.tags || []
|
||||||
|
};
|
||||||
|
showViewDialog.value = true;
|
||||||
|
} else {
|
||||||
|
ElMessage.error('获取文章详情失败');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
ElMessage.error('获取文章详情失败');
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteArticle(row: any) {
|
function editArticle(row: any) {
|
||||||
|
router.push('/article/add?id=' + row.resourceID);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleEditFromView() {
|
||||||
|
if (currentArticle.value?.resourceID) {
|
||||||
|
showViewDialog.value = false;
|
||||||
|
router.push('/article/add?id=' + currentArticle.value.resourceID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteArticle() {
|
||||||
// TODO: 删除文章
|
// TODO: 删除文章
|
||||||
|
ElMessage.info('删除功能开发中');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStatusType(status: string) {
|
function getStatusType(status: string) {
|
||||||
@@ -107,12 +176,12 @@ function getStatusText(status: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleSizeChange(val: number) {
|
function handleSizeChange(val: number) {
|
||||||
pageSize.value = val;
|
pageParam.value.size = val;
|
||||||
loadArticles();
|
loadArticles();
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleCurrentChange(val: number) {
|
function handleCurrentChange(val: number) {
|
||||||
currentPage.value = val;
|
pageParam.value.page = val;
|
||||||
loadArticles();
|
loadArticles();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -8,21 +8,21 @@
|
|||||||
<div class="article-form">
|
<div class="article-form">
|
||||||
<el-form ref="formRef" :model="articleForm" :rules="rules" label-width="100px" label-position="top">
|
<el-form ref="formRef" :model="articleForm" :rules="rules" label-width="100px" label-position="top">
|
||||||
<!-- 标题 -->
|
<!-- 标题 -->
|
||||||
<el-form-item label="文章标题" prop="title">
|
<el-form-item label="文章标题" prop="resource.title">
|
||||||
<el-input v-model="articleForm.title" placeholder="请输入文章标题" maxlength="100" show-word-limit />
|
<el-input v-model="articleForm.resource.title" placeholder="请输入文章标题" maxlength="100" show-word-limit />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<!-- 分类和标签 -->
|
<!-- 分类和标签 -->
|
||||||
<el-row :gutter="20">
|
<el-row :gutter="20">
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="文章分类" prop="categoryID">
|
<el-form-item label="文章分类" prop="resource.categoryID">
|
||||||
<el-select v-model="articleForm.categoryID" placeholder="请选择分类" style="width: 100%" :loading="categoryLoading">
|
<el-select v-model="articleForm.resource.categoryID" placeholder="请选择分类" style="width: 100%" :loading="categoryLoading">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="category in categoryList"
|
v-for="category in categoryList"
|
||||||
:key="category.categoryID || category.id"
|
:key="category.categoryID || category.id"
|
||||||
:label="category.name"
|
:label="category.name"
|
||||||
:value="category.categoryID || category.id || ''"
|
:value="category.categoryID || category.id || ''"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
<el-form-item label="封面图片">
|
<el-form-item label="封面图片">
|
||||||
<!-- 上传区域 - 只在没有封面图片时显示 -->
|
<!-- 上传区域 - 只在没有封面图片时显示 -->
|
||||||
<FileUpload
|
<FileUpload
|
||||||
v-if="!articleForm.coverImage"
|
v-if="!articleForm.resource.coverImage"
|
||||||
:as-dialog="false"
|
:as-dialog="false"
|
||||||
accept="image/*"
|
accept="image/*"
|
||||||
:max-size="2"
|
:max-size="2"
|
||||||
@@ -53,15 +53,15 @@
|
|||||||
@success="handleCoverUploadSuccess"
|
@success="handleCoverUploadSuccess"
|
||||||
/>
|
/>
|
||||||
<!-- 封面预览 - 只在有封面图片时显示 -->
|
<!-- 封面预览 - 只在有封面图片时显示 -->
|
||||||
<div v-if="articleForm.coverImage" class="cover-preview">
|
<div v-if="articleForm.resource.coverImage" class="cover-preview">
|
||||||
<img :src="articleForm.coverImage" class="cover" />
|
<img :src="FILE_DOWNLOAD_URL + articleForm.resource.coverImage" class="cover" />
|
||||||
<el-button type="danger" size="small" @click="removeCover">删除封面</el-button>
|
<el-button type="danger" size="small" @click="removeCover">删除封面</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<!-- 文章内容 -->
|
<!-- 文章内容 -->
|
||||||
<el-form-item label="文章内容" prop="content">
|
<el-form-item label="文章内容" prop="resource.content">
|
||||||
<RichTextComponent ref="editorRef" v-model="articleForm.content" height="500px"
|
<RichTextComponent ref="editorRef" v-model="articleForm.resource.content" height="500px"
|
||||||
placeholder="请输入文章内容..." />
|
placeholder="请输入文章内容..." />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
@@ -69,13 +69,13 @@
|
|||||||
<el-form-item label="发布设置">
|
<el-form-item label="发布设置">
|
||||||
<el-row :gutter="20">
|
<el-row :gutter="20">
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<el-checkbox v-model="articleForm.allowComment">允许评论</el-checkbox>
|
<el-checkbox v-model="articleForm.resource.allowComment">允许评论</el-checkbox>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<el-checkbox v-model="articleForm.isTop">置顶文章</el-checkbox>
|
<el-checkbox v-model="articleForm.resource.isTop">置顶文章</el-checkbox>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<el-checkbox v-model="articleForm.isRecommend">推荐文章</el-checkbox>
|
<el-checkbox v-model="articleForm.resource.isRecommend">推荐文章</el-checkbox>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -104,7 +104,7 @@
|
|||||||
:as-dialog="true"
|
:as-dialog="true"
|
||||||
title="文章预览"
|
title="文章预览"
|
||||||
width="900px"
|
width="900px"
|
||||||
:article-data="articleForm"
|
:article-data="articleForm.resource"
|
||||||
:category-list="categoryList"
|
:category-list="categoryList"
|
||||||
:show-edit-button="false"
|
:show-edit-button="false"
|
||||||
@close="previewVisible = false"
|
@close="previewVisible = false"
|
||||||
@@ -132,7 +132,8 @@ import { RichTextComponent } from '@/components/text';
|
|||||||
import { FileUpload } from '@/components/file';
|
import { FileUpload } from '@/components/file';
|
||||||
import { ArticleShowView } from './index';
|
import { ArticleShowView } from './index';
|
||||||
import { resourceCategoryApi, resourceTagApi, resourceApi } from '@/apis/resource';
|
import { resourceCategoryApi, resourceTagApi, resourceApi } from '@/apis/resource';
|
||||||
import { Resource, ResourceCategory, Tag } from '@/types/resource';
|
import { ResourceVO, ResourceCategory, Tag } from '@/types/resource';
|
||||||
|
import { FILE_DOWNLOAD_URL } from '@/config';
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
@@ -153,30 +154,23 @@ const categoryLoading = ref(false);
|
|||||||
const tagLoading = ref(false);
|
const tagLoading = ref(false);
|
||||||
|
|
||||||
// 表单数据
|
// 表单数据
|
||||||
const articleForm = ref<Resource>({
|
const articleForm = ref<ResourceVO>({
|
||||||
title: '',
|
resource: {
|
||||||
content: '',
|
},
|
||||||
categoryID: '',
|
category: {},
|
||||||
author: '',
|
tags: [],
|
||||||
source: '',
|
|
||||||
sourceUrl: '',
|
|
||||||
viewCount: 0,
|
|
||||||
coverImage: '',
|
|
||||||
tags: [] as Tag[],
|
|
||||||
allowComment: true,
|
|
||||||
isTop: false,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 表单验证规则
|
// 表单验证规则
|
||||||
const rules = {
|
const rules = {
|
||||||
title: [
|
'resource.title': [
|
||||||
{ required: true, message: '请输入文章标题', trigger: 'blur' },
|
{ required: true, message: '请输入文章标题', trigger: 'blur' },
|
||||||
{ min: 5, max: 100, message: '标题长度在 5 到 100 个字符', trigger: 'blur' }
|
{ min: 5, max: 100, message: '标题长度在 5 到 100 个字符', trigger: 'blur' }
|
||||||
],
|
],
|
||||||
categoryID: [
|
'resource.categoryID': [
|
||||||
{ required: true, message: '请选择文章分类', trigger: 'change' }
|
{ required: true, message: '请选择文章分类', trigger: 'change' }
|
||||||
],
|
],
|
||||||
content: [
|
'resource.content': [
|
||||||
{ required: true, message: '请输入文章内容', trigger: 'blur' }
|
{ required: true, message: '请输入文章内容', trigger: 'blur' }
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
@@ -234,11 +228,13 @@ async function handlePublish() {
|
|||||||
|
|
||||||
// TODO: 调用API发布文章
|
// TODO: 调用API发布文章
|
||||||
console.log('发布文章:', articleForm);
|
console.log('发布文章:', articleForm);
|
||||||
|
resourceApi.createResource(articleForm.value).then(res => {
|
||||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
if (res.success) {
|
||||||
|
ElMessage.success('发布成功');
|
||||||
ElMessage.success(isEdit.value ? '修改成功' : '发布成功');
|
} else {
|
||||||
router.push('/admin/manage/resource/articles');
|
ElMessage.error(res.message || '发布失败');
|
||||||
|
}
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('发布失败:', error);
|
console.error('发布失败:', error);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -267,8 +263,8 @@ async function handleSaveDraft() {
|
|||||||
|
|
||||||
// 预览
|
// 预览
|
||||||
function handlePreview() {
|
function handlePreview() {
|
||||||
console.log(articleForm.value.content);
|
console.log(articleForm.value.resource.content);
|
||||||
if (!articleForm.value.title) {
|
if (!articleForm.value.resource.title) {
|
||||||
ElMessage.warning('请先输入文章标题');
|
ElMessage.warning('请先输入文章标题');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -281,14 +277,14 @@ function handleCoverUploadSuccess(files: any[]) {
|
|||||||
const file = files[0];
|
const file = files[0];
|
||||||
// 使用文件下载URL构建完整路径
|
// 使用文件下载URL构建完整路径
|
||||||
import('@/config').then(config => {
|
import('@/config').then(config => {
|
||||||
articleForm.value.coverImage = config.FILE_DOWNLOAD_URL + file.id;
|
articleForm.value.resource.coverImage = config.FILE_DOWNLOAD_URL + file.id;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除封面
|
// 删除封面
|
||||||
function removeCover() {
|
function removeCover() {
|
||||||
articleForm.value.coverImage = '';
|
articleForm.value.resource.coverImage = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
<!-- 封面图片 -->
|
<!-- 封面图片 -->
|
||||||
<div v-if="articleData.coverImage" class="article-cover">
|
<div v-if="articleData.coverImage" class="article-cover">
|
||||||
<img :src="articleData.coverImage" class="cover-image" />
|
<img :src="FILE_DOWNLOAD_URL + articleData.coverImage" class="cover-image" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 文章内容 -->
|
<!-- 文章内容 -->
|
||||||
@@ -66,7 +66,7 @@
|
|||||||
|
|
||||||
<!-- 封面图片 -->
|
<!-- 封面图片 -->
|
||||||
<div v-if="articleData.coverImage" class="article-cover">
|
<div v-if="articleData.coverImage" class="article-cover">
|
||||||
<img :src="articleData.coverImage" class="cover-image" />
|
<img :src="FILE_DOWNLOAD_URL + articleData.coverImage" class="cover-image" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 文章内容 -->
|
<!-- 文章内容 -->
|
||||||
@@ -77,6 +77,8 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
import { ElDialog, ElButton } from 'element-plus';
|
import { ElDialog, ElButton } from 'element-plus';
|
||||||
|
import { FILE_DOWNLOAD_URL } from '@/config';
|
||||||
|
import { ResourceCategory } from '@/types/resource';
|
||||||
|
|
||||||
interface ArticleData {
|
interface ArticleData {
|
||||||
title?: string;
|
title?: string;
|
||||||
@@ -94,7 +96,7 @@ interface Props {
|
|||||||
title?: string; // Dialog 标题
|
title?: string; // Dialog 标题
|
||||||
width?: string; // Dialog 宽度
|
width?: string; // Dialog 宽度
|
||||||
articleData?: ArticleData; // 文章数据
|
articleData?: ArticleData; // 文章数据
|
||||||
categoryList?: Array<{ id?: string; categoryID?: string; name?: string }>; // 分类列表
|
categoryList?: Array<ResourceCategory>; // 分类列表
|
||||||
showEditButton?: boolean; // 是否显示编辑按钮
|
showEditButton?: boolean; // 是否显示编辑按钮
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user