提交 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,52 +104,56 @@ export default class index extends Component { ...@@ -94,52 +104,56 @@ 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>
)} )}
{ {
visible && visible &&
<Modal <Modal
title={pathName} title={pathName}
visible={true} visible={true}
width={1200} width={1200}
destroyOnClose destroyOnClose
centered={true} centered={true}
onOk={this.handleOk} onOk={this.handleOk}
onCancel={this.handleCancel}> onCancel={this.handleCancel}>
{type === 'pdf' ? ( {type === 'pdf' ? (
<iframe <iframe
style={{ style={{
width: '100%', width: '100%',
height: 600, height: 600,
}} }}
src={path} src={path}
/> />
) : ( ) : (
<div <div
style={{ style={{
height: 650, height: 650,
maxWidth: 1200, maxWidth: 1200,
}}> }}>
<a onClick={this.download}> <a onClick={this.download}>
下载文件 下载文件
</a> </a>
{/* {FileViewer && ( {
!!checkIsImage(path) &&
<img src={path} style={{ maxWidth: '100%', }}/>
}
{/* {FileViewer && (
<FileViewer <FileViewer
fileType={type} fileType={type}
filePath={path} filePath={path}
/> />
)}*/} )}*/}
</div> </div>
)} )}
</Modal> </Modal>
} }
</> </>
......
...@@ -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;
} }
......
...@@ -6,95 +6,94 @@ import { getOneStopMyInfo } from '@/webPublic/one_stop_public/utils/utils'; ...@@ -6,95 +6,94 @@ import { getOneStopMyInfo } from '@/webPublic/one_stop_public/utils/utils';
import { delCookie, setCookie } from '@/webPublic/one_stop_public/utils/cookie'; import { delCookie, setCookie } from '@/webPublic/one_stop_public/utils/cookie';
export function setToken(value, time) { export function setToken(value, time) {
if (getToken() !== value) { if (getToken() !== value) {
setCookie('token', value, 1); setCookie('token', value, 1);
sessionStorage.removeItem('cacheMobile'); sessionStorage.removeItem('cacheMobile');
localStorage.setItem('antd-pro-token-onestop', value); localStorage.setItem('antd-pro-token-onestop', value);
localStorage.setItem('antd-pro-token', value); localStorage.setItem('antd-pro-token', value);
localStorage.setItem('wisdom-school-token', value); localStorage.setItem('wisdom-school-token', value);
return getOneStopMyInfo(); return getOneStopMyInfo();
} else { } else {
return new Promise((resolve, reject) => { if (value && value.length > 10) {
resolve(true); setCookie('token', value, 1);
}); }
} return new Promise((resolve, reject) => {
resolve(true);
});
}
} }
/** /**
* 获取token * 获取token
* */ * */
export function getToken() { export function getToken() {
const x = localStorage.getItem('antd-pro-token-onestop'); const x = localStorage.getItem('antd-pro-token-onestop');
if (x && x.length > 11) { if (x && x.length > 11) {
return x; return x;
} }
const y = localStorage.getItem('antd-pro-token'); const y = localStorage.getItem('antd-pro-token');
if (y && y.length > 11) { if (y && y.length > 11) {
return y; return y;
} }
return null; return null;
} }
/** /**
* 删除token * 删除token
* */ * */
export const delToken = () => { export const delToken = () => {
delCookie('token'); delCookie('token');
localStorage.removeItem('antd-pro-type'); localStorage.removeItem('antd-pro-type');
localStorage.removeItem('antd-pro-token-onestop'); localStorage.removeItem('antd-pro-token-onestop');
localStorage.removeItem('antd-pro-token'); localStorage.removeItem('antd-pro-token');
localStorage.removeItem('wisdom-school-token'); localStorage.removeItem('wisdom-school-token');
localStorage.removeItem('user'); localStorage.removeItem('user');
sessionStorage.removeItem('cacheMobile'); sessionStorage.removeItem('cacheMobile');
}; };
export const getUserInfo = () => { export const getUserInfo = () => {
let x = localStorage.getItem('user'); let x = localStorage.getItem('user');
if (isJSON(x)) { if (isJSON(x)) {
x = JSON.parse(x); x = JSON.parse(x);
if (!x.groupsId) { if (!x.groupsId) {
x.groupsId = 'pub'; x.groupsId = 'pub';
} }
return x; return x;
} else { } else {
return { return {
groupsId: 'pub', groupsId: 'pub',
}; };
} }
}; };
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);
} }
export function getCurrentUser() { export function getCurrentUser() {
const d = sessionStorage.getItem('currentUser'); const d = sessionStorage.getItem('currentUser');
if (d && isJSON(d)) { if (d && isJSON(d)) {
return JSON.parse(d); return JSON.parse(d);
} else { } else {
return {}; return {};
} }
} }
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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论