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

代理修改

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