Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
xxx committed Dec 10, 2024
2 parents ba51195 + 3ccb66e commit 523006f
Show file tree
Hide file tree
Showing 79 changed files with 1,437 additions and 1,967 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 版本 4.9.13

## 优化

- 优化:[API]重构图片、课件存储

# 版本 4.9.12

## 新增
Expand Down
4 changes: 4 additions & 0 deletions xyz.meedu.admin/src/api/course.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ export function attachList(params: any) {
return client.get(`/backend/api/v1/course_attach`, params);
}

export function attachUploadSign(params: any) {
return client.get(`/backend/api/v1/course_attach/create`, params);
}

export function attachStore(params: any) {
return client.post(`/backend/api/v1/course_attach`, params);
}
Expand Down
1 change: 1 addition & 0 deletions xyz.meedu.admin/src/components/quill-editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export const QuillEditor: React.FC<PropInterface> = (props) => {
<SelectImage
open={showUploadImage}
from={1}
scene="editor"
onCancel={() => setShowUploadImage(false)}
onSelected={(url) => {
let quill = refs?.current.getEditor();
Expand Down
47 changes: 28 additions & 19 deletions xyz.meedu.admin/src/components/select-image/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,49 +27,58 @@ interface ImageItem {
interface PropsInterface {
open: boolean;
from: number;
scene: string;
onCancel: () => void;
onSelected: (url: string) => void;
}

export const SelectImage = (props: PropsInterface) => {
const [from, setFrom] = useState(0);
const [scene, setScene] = useState("");
const [imageList, setImageList] = useState<ImageItem[]>([]);
const [refresh, setRefresh] = useState(false);
const [page, setPage] = useState(1);
const [size, setSize] = useState(15);
const [total, setTotal] = useState(0);
const [selected, setSelected] = useState<string>("");
const fromRows = [
{ key: 0, name: "全部图片" },
{ key: "", name: "全部图片" },
{
key: 1,
name: "幻灯片",
key: "cover",
name: "课程封面",
},
{
key: 2,
name: "课程封面",
key: "avatar",
name: "学员头像",
},
{
key: "config",
name: "系统配置",
},
{
key: "editor",
name: "文本编辑器",
},
{
key: 3,
name: "课程详情页",
key: "decoration",
name: "装修",
},
{
key: 4,
name: "文章配图",
key: "other",
name: "其它",
},
];

useEffect(() => {
setFrom(props.from);
}, [props.from]);
setScene(props.scene);
}, [props.scene]);

// 获取图片列表
const getImageList = () => {
media
.imageList({ page: page, size: size, from: from })
.imageList({ page: page, size: size, scene: scene })
.then((res: any) => {
setTotal(res.data.data.total);
setImageList(res.data.data.data);
setTotal(res.data.total);
setImageList(res.data.data);
})
.catch((err) => {
console.log("错误,", err);
Expand All @@ -87,7 +96,7 @@ export const SelectImage = (props: PropsInterface) => {
if (props.open) {
getImageList();
}
}, [props.open, from, refresh, page, size]);
}, [props.open, scene, refresh, page, size]);

return (
<>
Expand Down Expand Up @@ -115,7 +124,7 @@ export const SelectImage = (props: PropsInterface) => {
style={{ position: "absolute", right: 30, top: 15, zIndex: 15 }}
>
<UploadImageSub
from={from}
scene={props.scene}
onUpdate={() => {
resetImageList();
}}
Expand All @@ -127,11 +136,11 @@ export const SelectImage = (props: PropsInterface) => {
<div
key={item.key}
className={
item.key === from
item.key === scene
? styles["category-act-item"]
: styles["category-item"]
}
onClick={() => setFrom(item.key)}
onClick={() => setScene(item.key)}
>
{item.name}
</div>
Expand Down
47 changes: 30 additions & 17 deletions xyz.meedu.admin/src/components/upload-image-button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,46 +35,59 @@ interface ImageItem {

interface PropsInterface {
text: any;
scene: string;
onSelected: (url: string) => void;
}

export const UploadImageButton = (props: PropsInterface) => {
const [showModal, setShowModal] = useState(false);

const [from, setFrom] = useState(0);
const [scene, setScene] = useState("");
const [imageList, setImageList] = useState<ImageItem[]>([]);
const [refresh, setRefresh] = useState(false);
const [page, setPage] = useState(1);
const [size, setSize] = useState(15);
const [total, setTotal] = useState(0);
const [selected, setSelected] = useState<string>("");
const fromRows = [
{ key: 0, name: "全部图片" },
{ key: "", name: "全部图片" },
{
key: 1,
name: "幻灯片",
key: "cover",
name: "课程封面",
},
{
key: 2,
name: "课程封面",
key: "avatar",
name: "学员头像",
},
{
key: "config",
name: "系统配置",
},
{
key: 3,
name: "课程详情页",
key: "editor",
name: "文本编辑器",
},
{
key: 4,
name: "文章配图",
key: "decoration",
name: "装修",
},
{
key: "other",
name: "其它",
},
];

useEffect(() => {
setScene(props.scene);
}, [props.scene]);

// 获取图片列表
const getImageList = () => {
media
.imageList({ page: page, size: size, from: from })
.imageList({ page: page, size: size, scene: scene })
.then((res: any) => {
setTotal(res.data.data.total);
setImageList(res.data.data.data);
setTotal(res.data.total);
setImageList(res.data.data);
})
.catch((err) => {
console.log("错误,", err);
Expand All @@ -92,7 +105,7 @@ export const UploadImageButton = (props: PropsInterface) => {
if (showModal) {
getImageList();
}
}, [from, refresh, page, size, showModal]);
}, [scene, refresh, page, size, showModal]);

return (
<>
Expand Down Expand Up @@ -129,7 +142,7 @@ export const UploadImageButton = (props: PropsInterface) => {
style={{ position: "absolute", right: 30, top: 15, zIndex: 15 }}
>
<UploadImageSub
from={from}
scene={props.scene}
onUpdate={() => {
resetImageList();
}}
Expand All @@ -141,11 +154,11 @@ export const UploadImageButton = (props: PropsInterface) => {
<div
key={item.key}
className={
item.key === from
item.key === scene
? styles["category-act-item"]
: styles["category-item"]
}
onClick={() => setFrom(item.key)}
onClick={() => setScene(item.key)}
>
{item.name}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getToken } from "../../../utils";
import { InboxOutlined } from "@ant-design/icons";

interface PropsInterface {
from: number;
scene: string;
onUpdate: () => void;
}

Expand All @@ -16,7 +16,7 @@ export const UploadImageSub = (props: PropsInterface) => {
const uploadProps = {
name: "file",
multiple: true,
action: config.url + "/backend/api/v1/media/image?from=" + props.from,
action: config.url + "/backend/api/v1/media/image?scene=" + props.scene,
headers: {
authorization: "Bearer " + getToken(),
},
Expand All @@ -33,7 +33,6 @@ export const UploadImageSub = (props: PropsInterface) => {
} else if (status === "error") {
message.error(`${info.file.name} 上传失败`);
}
console.log(info);
},
showUploadList: {
showRemoveIcon: false,
Expand Down
Loading

0 comments on commit 523006f

Please sign in to comment.