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