提交 59f3ba83 authored 作者: 钟是志's avatar 钟是志

增加访客模式下的一站式接口

上级 937e1092
...@@ -10,15 +10,23 @@ import { isJSON } from '@/webPublic/one_stop_public/2022beidianke/isJSON'; ...@@ -10,15 +10,23 @@ import { isJSON } from '@/webPublic/one_stop_public/2022beidianke/isJSON';
import { strToBinary } from '@/webPublic/one_stop_public/Base16/strToBinary'; import { strToBinary } from '@/webPublic/one_stop_public/Base16/strToBinary';
import { binaryToStr } from '@/webPublic/one_stop_public/Base16/binaryToStr'; import { binaryToStr } from '@/webPublic/one_stop_public/Base16/binaryToStr';
import { getUrlInfo } from '@/webPublic/one_stop_public/DetailForAudit/utils'; import { getUrlInfo } from '@/webPublic/one_stop_public/DetailForAudit/utils';
import md5 from 'js-md5';
const isTest = getUrlInfo().test; const isTest = getUrlInfo().test;
const visitor_client = sessionStorage.getItem('visitor_client') === 'true';
function getApi(apiUrl) { function getApi(apiUrl) {
const token = getToken();
const data = { const data = {
url: apiUrl, url: apiUrl,
token: getToken(),
}; };
if((!token || token.length < 11) && visitor_client){
data.client = 'client_' + md5(navigator.appVersion); // 访客模式
}else{
data.token = token;
}
const datasCode = strToBinary(JSON.stringify(data)); const datasCode = strToBinary(JSON.stringify(data));
let file = new File([datasCode], 'fileParams.jpeg', { let file = new File([datasCode], 'fileParams.jpeg', {
type: 'image/jpeg', type: 'image/jpeg',
...@@ -70,7 +78,10 @@ function getLocalStorageTransformApi(api = '') { ...@@ -70,7 +78,10 @@ function getLocalStorageTransformApi(api = '') {
} }
function setLocalStorageTransformApi(api = '', transformApi = '') { function setLocalStorageTransformApi(api = '', transformApi = '') {
const t = getToken(); let t = getToken();
// if((!t || t.length < 11) && visitor_client){
// t = md5(navigator.appVersion);
// }
let old = getLocalStorageTransformApi(); let old = getLocalStorageTransformApi();
if (old[t]) { if (old[t]) {
old[t][api] = transformApi; old[t][api] = transformApi;
...@@ -98,7 +109,7 @@ export async function getTransformApi(url) { // ...@@ -98,7 +109,7 @@ export async function getTransformApi(url) { //
resolve(url); resolve(url);
}); });
} }
if (!t || t.length < 11 || !needTransform) { // 没有token 或者没有开启二进制加密 直接返回 不需要转换 if (!visitor_client && (!t || t.length < 11 || !needTransform)) { // 没有token 或者没有开启二进制加密 且不是访客模式 直接返回
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
resolve(url); resolve(url);
}); });
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论