|
|
@ -21,9 +21,15 @@ const simple_encrypt = text => {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 获取图片列表
|
|
|
|
// 获取图片列表
|
|
|
|
const getImageList = async (key,type='111') => {
|
|
|
|
const getImageList = async (key, overlist = false) => {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const { errcode, result } = await fetchJSON(`${HT3_HOST}/oss/list_unique_key?key=${key}&type=${type}`);
|
|
|
|
let url;
|
|
|
|
|
|
|
|
if (overlist) {
|
|
|
|
|
|
|
|
url = `${HT3_HOST}/oss/list_over_unique_key?key=${key}`;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
url = `${HT3_HOST}/oss/list_unique_key?key=${key}`;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const { errcode, result } = await fetchJSON(url);
|
|
|
|
if (errcode === 0) {
|
|
|
|
if (errcode === 0) {
|
|
|
|
return result
|
|
|
|
return result
|
|
|
|
.map(file => ({
|
|
|
|
.map(file => ({
|
|
|
@ -221,13 +227,12 @@ export const ImageUploader = props => {
|
|
|
|
export const ImageViewer = props => {
|
|
|
|
export const ImageViewer = props => {
|
|
|
|
const [fileList, setFileList] = useState([]);
|
|
|
|
const [fileList, setFileList] = useState([]);
|
|
|
|
const key = props.osskey;
|
|
|
|
const key = props.osskey;
|
|
|
|
const type = props.type || '111';
|
|
|
|
const overlist = props.overlist || false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 组件挂载时获取图片列表
|
|
|
|
// 组件挂载时获取图片列表
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
const loadImages = async () => {
|
|
|
|
const loadImages = async () => {
|
|
|
|
const images = await getImageList(key,type);
|
|
|
|
const images = await getImageList(key, overlist);
|
|
|
|
|
|
|
|
|
|
|
|
setFileList(images);
|
|
|
|
setFileList(images);
|
|
|
|
if (props.onChange) {
|
|
|
|
if (props.onChange) {
|
|
|
@ -253,7 +258,7 @@ export const ImageViewer = props => {
|
|
|
|
<Image width={200} src={item.url} />
|
|
|
|
<Image width={200} src={item.url} />
|
|
|
|
) : (
|
|
|
|
) : (
|
|
|
|
<a href={item.url} download>
|
|
|
|
<a href={item.url} download>
|
|
|
|
<Button type="primary" icon={<FileTextOutlined />} size="large" title={item.key.replace(/^.*[\\\/]/, '')}>
|
|
|
|
<Button type="primary" icon={<FileTextOutlined />} size="large" title={item.key.replace(/^.*[\\\/]/, "")}>
|
|
|
|
...{item.key.slice(-10)}
|
|
|
|
...{item.key.slice(-10)}
|
|
|
|
</Button>
|
|
|
|
</Button>
|
|
|
|
</a>
|
|
|
|
</a>
|
|
|
|