提交 17415f8a authored 作者: 钟是志's avatar 钟是志

代理修改

上级 3979db01
/**
* web端文件预览功能
*/
import React, {Component} from 'react';
import {checkIsImage} from '@/webPublic/one_stop_public/libs/UploadCom';
import React, { Component } from 'react';
import { checkIsImage } from '@/webPublic/one_stop_public/libs/UploadCom';
import { getModal, getPopconfirm, isFromIframe } from '@/webPublic/one_stop_public/utils/utils';
// const FileViewer = CLIENT_TYPE === 'mobile' ? null : require('react-file-viewer');
......@@ -21,7 +21,7 @@ export default class index extends Component {
}
showModal = () => {
if(isFromIframe()){
if (isFromIframe()) {
return false;
}
this.setState({
......@@ -41,18 +41,26 @@ export default class index extends Component {
});
};
download = () => {
let {path, pathName} = this.props;
if(window?.parent?.open && typeof window.parent.open === 'function'){
let {
path,
pathName
} = this.props;
if (window?.parent?.open && typeof window.parent.open === 'function') {
window.parent.open(path, '_blank');
}else{
} else {
window.open(path, '_blank');
}
};
render() {
let {path, pathName, width, height} = this.props;
let {
path,
pathName,
width,
height
} = this.props;
const {visible} = this.state;
const { visible } = this.state;
let isShow = false;
let type;
let isImg = checkIsImage(pathName);
......@@ -77,15 +85,17 @@ export default class index extends Component {
<>
{isShow ? (
<Popconfirm
title='查看附件'
title="查看附件"
onConfirm={this.download}
okText='下载'
okText="下载"
onCancel={this.showModal}
cancelText={ isFromIframe() ? '取消' : '预览'}>
cancelText={isFromIframe() ? '取消' : '预览'}>
{isImg ? (
<img
ref={(node)=>{ this.imageDom = node;}}
ref={(node) => {
this.imageDom = node;
}}
style={{
width: width ? width : '100px',
height: height ? height : 'auto',
......@@ -94,13 +104,13 @@ export default class index extends Component {
alt={pathName}
/>
) : (
<a target='_blank' href={path}>
<a target="_blank" href={path}>
{pathName}
</a>
)}
</Popconfirm>
) : (
<a target='_blank' href={path}>
<a target="_blank" href={path}>
{pathName}
</a>
)}
......@@ -131,6 +141,10 @@ export default class index extends Component {
<a onClick={this.download}>
下载文件
</a>
{
!!checkIsImage(path) &&
<img src={path} style={{ maxWidth: '100%', }}/>
}
{/* {FileViewer && (
<FileViewer
fileType={type}
......
......@@ -21,7 +21,7 @@ export function checkIsImage(path) {
}
let p = path.toLowerCase();
let find = ['.jpg', '.png', '.jpeg', '.bmp', '.gif', '.bmp', '.svg'].find((x) => {
return path.indexOf(x) > -1;
return p.indexOf(x) > -1;
});
return !!find;
}
......
......@@ -44,7 +44,7 @@ const queryConfig = (key) => {
if (typeof key === 'undefined') return dynamicConfig;
if(dynamicConfig[key] && typeof dynamicConfig[key] === 'string' && process.env.NODE_ENV === 'development'){
let url = dynamicConfig[key];
url = url.replace('https://yx.bpi.edu.cn/produce', 'http://localhost:8000/produce');
url = url.replace('https://yx.bpi.edu.cn/produce', 'http://localhost:8010/produce');
url = url.replace('http://scjoyedu.eicp.net:51352/produce', 'http://localhost:8000/produce');
return url;
}
......
......@@ -14,6 +14,9 @@ export function setToken(value, time) {
localStorage.setItem('wisdom-school-token', value);
return getOneStopMyInfo();
} else {
if (value && value.length > 10) {
setCookie('token', value, 1);
}
return new Promise((resolve, reject) => {
resolve(true);
});
......@@ -65,22 +68,18 @@ export const getUserInfo = () => {
};
export function setFetchUrl(data) {
return localStorage.setItem('fetch-url-data', data);
}
export function getFetchUrl() {
return localStorage.getItem('fetch-url-data');
}
export function getType() {
return localStorage.getItem('antd-pro-type') || '';
}
export function setType(type) {
return localStorage.setItem('antd-pro-type', type);
}
......@@ -93,8 +92,8 @@ export function getCurrentUser() {
}
}
export function setCurrentUser(v){
if(v && typeof v === 'object'){
export function setCurrentUser(v) {
if (v && typeof v === 'object') {
sessionStorage.setItem('currentUser', JSON.stringify(v));
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论