提交 2a39de98 authored 作者: 钟是志's avatar 钟是志

泸职环境 门户修改 增加加密的接口

上级 5e6b4989
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
*/ */
import { extend } from 'umi-request'; import { extend } from 'umi-request';
import { notification, message } from 'antd'; import { notification, message } from 'antd';
import { getToken } from './token'; import { getToken, getVersion } from './token';
import { import {
queryApiActionPath, queryApiActionPath,
queryOauthActionPath, queryOauthActionPath,
...@@ -148,10 +148,7 @@ export async function requestOrigin(url, data, options = {}){ ...@@ -148,10 +148,7 @@ export async function requestOrigin(url, data, options = {}){
let version = let version = getVersion();
localStorage.getItem('version') && localStorage.getItem('version') !== 'undefined'
? JSON.parse(localStorage.getItem('version'))
: null;
if (options.method === 'GET') { if (options.method === 'GET') {
......
...@@ -5,88 +5,96 @@ import { isJSON } from '@/webPublic/one_stop_public/copy'; ...@@ -5,88 +5,96 @@ import { isJSON } from '@/webPublic/one_stop_public/copy';
import { getOneStopMyInfo } from '@/webPublic/one_stop_public/utils/utils'; 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';
import { getToken } from './getToken'; import { getToken } from './getToken';
export { getToken } from './getToken';
export { getToken } from './getToken';
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 {
if (value && value.length > 10) { if (value && value.length > 10) {
setCookie('token', value, 1); setCookie('token', value, 1);
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
resolve(true); resolve(true);
}); });
} }
} }
/** /**
* 删除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';
x.differenceBetweenServerAndClientTime = 0; x.differenceBetweenServerAndClientTime = 0;
} }
return x; return x;
} else { } else {
return { return {
groupsId: 'pub', groupsId: 'pub',
differenceBetweenServerAndClientTime: 0, differenceBetweenServerAndClientTime: 0,
}; };
} }
}; };
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') {
v.token = getToken(); v.token = getToken();
sessionStorage.setItem('currentUser', JSON.stringify(v)); sessionStorage.setItem('currentUser', JSON.stringify(v));
} }
}
export function getVersion() {
if(window.CONFIG.VERSION){
return window.CONFIG.VERSION;
}
const version =
localStorage.getItem('version') && localStorage.getItem('version') !== 'undefined'
? JSON.parse(localStorage.getItem('version'))
: '';
return version;
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论