diff --git a/src/api/modules/notice/index.ts b/src/api/modules/notice/index.ts index 4eb4565..2e4c040 100644 --- a/src/api/modules/notice/index.ts +++ b/src/api/modules/notice/index.ts @@ -6,5 +6,13 @@ export const getNoticeListApi = (params: any) => { } //创建公告 export const createNoticeApi = (params: any) => { - return request.get('/notice/createNotice', {...params}) -} \ No newline at end of file + return request.post('/notice/createNotice', {...params}) +} +//编辑草稿 +export const editNoticeApi = (params: any) => { + return request.post('/notice/editNotice', {...params}) +} +//删除草稿 +export const deleteNoticeApi = (params: any) => { + return request.post('/notice/delNotice', {...params}) +} diff --git a/src/api/modules/upload.ts b/src/api/modules/upload.ts new file mode 100644 index 0000000..f7342ce --- /dev/null +++ b/src/api/modules/upload.ts @@ -0,0 +1,27 @@ +import { request } from '@/api'; // 引入你已封装的request + +/** + * 图片上传接口(适配富文本编辑器) + * @param file 要上传的文件对象 + * @returns Promise<{ url: string }> 图片上传后的URL + */ +export const uploadImageApi = (file: File): Promise<{ url: string }> => { + // 构建FormData(图片上传必须用FormData格式) + const formData = new FormData(); + formData.append('image', file); // 对应后端接收字段名image + + // 使用你已封装的post请求,禁用loading(富文本自身有状态提示) + return request.post<{ url: string }>( + '/upload/image', + formData, + { + // 覆盖默认配置:图片上传需要特殊的请求头 + headers: { + 'Content-Type': 'multipart/form-data', // 表单上传必须的头 + showLoading: false // 禁用全局loading,避免和编辑器loading冲突 + }, + timeout: 30 * 1000, // 图片上传超时时间30秒 + noRetry: false // 允许重试(网络波动时自动重试) + } + ); +}; \ No newline at end of file diff --git a/src/views/notice/index.vue b/src/views/notice/index.vue index 057ebee..2225408 100644 --- a/src/views/notice/index.vue +++ b/src/views/notice/index.vue @@ -7,24 +7,34 @@ 新建 +
+ 已发布 + 草稿 +
- -