isdata-customer-sdk 0.2.85 → 0.2.87

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/utils.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("axios"),t={},r=Object.prototype.hasOwnProperty;function n(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function o(e){try{return encodeURIComponent(e)}catch(e){return null}}t.stringify=function(e,t){t=t||"";var n,s,a=[];for(s in"string"!=typeof t&&(t="?"),e)if(r.call(e,s)){if((n=e[s])||null!=n&&!isNaN(n)||(n=""),s=o(s),n=o(n),null===s||null===n)continue;a.push(s+"="+n)}return a.length?t+a.join("&"):""},t.parse=function(e){for(var t,r=/([^=?#&]+)=?([^&]*)/g,o={};t=r.exec(e);){var s=n(t[1]),a=n(t[2]);null===s||null===a||s in o||(o[s]=a)}return o};const s="development"===process.env.NODE_ENV,a="true"===process.env.VUE_APP_ONLINE_DEVELOPMENT_MODE||"true"===process.env.REACT_APP_ONLINE_DEVELOPMENT_MODE;window.isDevopmentMode=s,window.isOnlineDevelopmentMode=a;var i=((r="")=>{r&&(r.startsWith("/")&&(r=r.slice(1,r.length)),r.endsWith("/")&&(r=r.slice(0,-1)));const n=e.create({baseURL:`/${r?r+"/":""}sdata/rest`,timeout:6e4,validateStatus:function(e){return e>=200&&e<300},headers:window.location.search&&t.parse(window.location.search).token||window.token?{token:t.parse(window.location.search).token||window.token}:{}});let o=n.post;return n.post=(e,t,r)=>{let s=window.VITE_SERVICE_BASE_URL||"";if(s){let a=s+e;return o.call(n,a,t,r)}return o.call(n,e,t,r)},n.interceptors.request.use(e=>{if(!a&&s){let t=window.mockData.PORTAL_SERVER_ADDRESS,r=window.mockData.VITE_SERVICE_BASE_URL;e.url=`${t}${r}${e.url}`}return e},e=>Promise.reject(e)),n.defaults.headers.post["Content-Type"]="application/json",n.interceptors.response.use(e=>{let{data:t}=e;return"string"==typeof t&&(t=JSON.parse(t)),!t||200===t.status||t instanceof Blob?t instanceof Blob?(e.data=t,e):(e.data=t&&t.result,e):Promise.reject(e)},e=>{if(!e.response||401!==e.response.status)return Promise.reject(e.response)}),n})(window.prefixPath||"");const l=e=>{try{return new URL(e).pathname.split("/").pop()||"downloaded_file"}catch(e){return"downloaded_file"}};exports.createFileFromUrl=async(e,t)=>{try{const r=await fetch(e);if(!r.ok)throw new Error(`网络请求失败: ${r.status} ${r.statusText}`);const n=await r.blob(),o=t||l(e);return new File([n],o,{type:n.type,lastModified:Date.now()})}catch(e){throw console.error("创建 File 失败:",e),e}},exports.doRestPost=async(e,t)=>await i.post(e,t),exports.extractFilenameFromUrl=l,exports.extractNewItems=(e,t)=>e.filter(e=>!t.includes(e)),exports.findClosestAncestorByClass=(e,t)=>{let r=e;for(;r;){if(r.classList&&r.classList.contains(t))return r;r=r.parentElement}return null},exports.getClientIp=async()=>{let e=await i.post("/ext/getClientIp"),t=e?.data?.clientIp;return t},exports.getFileSize=async e=>{try{const t=await fetch(e,{method:"GET",headers:{Range:"bytes=0-0"}});if(206!==t.status)throw new Error("不支持 Range 请求");const r=t.headers.get("Content-Range"),n=r?.match(/\/(\d+)$/)?.[1];return n?parseInt(n,10):-1}catch(e){return console.error("获取文件大小失败:",e),-1}},exports.getI18nKey=e=>{let t=/\$L\{([^}]+)\}/g.exec(e);return t?t[1]:e},exports.getUrlParamValue=(e,t)=>{try{const r=new URL(e).searchParams.get(t);return r&&-1!==r.indexOf("#")?r.split("#")[0]:r}catch(e){return console.error("URL 格式错误:",e),""}},exports.getWebURL=e=>{let t;t=e instanceof String?JSON.parse(e):e;let r=`/storage_area/public${(t[0]||{}).url}`,n="";if(!window.isOnlineDevelopmentMode&&window.isDevopmentMode){n=window.mockData.PORTAL_SERVER_ADDRESS}return`${n}${r}`},exports.hasUrlParams=e=>{try{return new URL(e,window.location.href).search.length>0}catch(e){return!1}},exports.queryAssetById=(e,t=200)=>i.post(`/asset/getAssetData?asset_id=${e}&count=${t}`,{filters:[]});
1
+ "use strict";var e=require("axios"),t={},r=Object.prototype.hasOwnProperty;function n(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function o(e){try{return encodeURIComponent(e)}catch(e){return null}}t.stringify=function(e,t){t=t||"";var n,s,a=[];for(s in"string"!=typeof t&&(t="?"),e)if(r.call(e,s)){if((n=e[s])||null!=n&&!isNaN(n)||(n=""),s=o(s),n=o(n),null===s||null===n)continue;a.push(s+"="+n)}return a.length?t+a.join("&"):""},t.parse=function(e){for(var t,r=/([^=?#&]+)=?([^&]*)/g,o={};t=r.exec(e);){var s=n(t[1]),a=n(t[2]);null===s||null===a||s in o||(o[s]=a)}return o};const s="development"===process.env.NODE_ENV,a="true"===process.env.VUE_APP_ONLINE_DEVELOPMENT_MODE||"true"===process.env.REACT_APP_ONLINE_DEVELOPMENT_MODE;window.isDevopmentMode=s,window.isOnlineDevelopmentMode=a;var i=((r="")=>{r&&(r.startsWith("/")&&(r=r.slice(1,r.length)),r.endsWith("/")&&(r=r.slice(0,-1)));const n=e.create({baseURL:`/${r?r+"/":""}sdata/rest`,timeout:6e4,validateStatus:function(e){return e>=200&&e<300},headers:window.location.search&&t.parse(window.location.search).token||window.token?{token:t.parse(window.location.search).token||window.token}:{}});let o=n.post;return n.post=(e,t,r)=>{let s=window.VITE_SERVICE_BASE_URL||"";if(s){let a=s+e;return o.call(n,a,t,r)}return o.call(n,e,t,r)},n.interceptors.request.use(e=>{if(!a&&s){let t=window.mockData.PORTAL_SERVER_ADDRESS,r=window.mockData.VITE_SERVICE_BASE_URL;e.url=`${t}${r}${e.url}`}return e},e=>Promise.reject(e)),n.defaults.headers.post["Content-Type"]="application/json",n.interceptors.response.use(e=>{let{data:t}=e;return"string"==typeof t&&(t=JSON.parse(t)),!t||200===t.status||t instanceof Blob?t instanceof Blob?(e.data=t,e):(e.data=t&&t.result,e):Promise.reject(e)},e=>{if(!e.response||401!==e.response.status)return Promise.reject(e.response)}),n})(window.prefixPath||"");const l=e=>{try{return new URL(e).pathname.split("/").pop()||"downloaded_file"}catch(e){return"downloaded_file"}};exports.createFileFromUrl=async(e,t)=>{try{const r=await fetch(e);if(!r.ok)throw new Error(`网络请求失败: ${r.status} ${r.statusText}`);const n=await r.blob(),o=t||l(e);return new File([n],o,{type:n.type,lastModified:Date.now()})}catch(e){throw console.error("创建 File 失败:",e),e}},exports.doRestPost=async(e,t)=>await i.post(e,t),exports.extractFilenameFromUrl=l,exports.extractNewItems=(e,t)=>e.filter(e=>!t.includes(e)),exports.findClosestAncestorByClass=(e,t)=>{let r=e;for(;r;){if(r.classList&&r.classList.contains(t))return r;r=r.parentElement}return null},exports.getClientIp=async()=>{let e=await i.post("/ext/getClientIp"),t=e?.data?.clientIp;return t},exports.getFileSize=async e=>{try{const t=await fetch(e,{method:"GET",headers:{Range:"bytes=0-0"}});if(206!==t.status)throw new Error("不支持 Range 请求");const r=t.headers.get("Content-Range"),n=r?.match(/\/(\d+)$/)?.[1];return n?parseInt(n,10):-1}catch(e){return console.error("获取文件大小失败:",e),-1}},exports.getI18nKey=e=>{let t=/\$L\{([^}]+)\}/g.exec(e);return t?t[1]:e},exports.getUrlParamValue=(e,t)=>{try{const r=new URL(e).searchParams.get(t);return r&&-1!==r.indexOf("#")?r.split("#")[0]:r}catch(e){return console.error("URL 格式错误:",e),""}},exports.getWebURL=e=>{if(!e)return;let t;t="[object String]"===Object.prototype.toString.call(e)?JSON.parse(e):e;let r=`/storage_area/public${(t[0]||{}).url}`,n="";if(!window.isOnlineDevelopmentMode&&window.isDevopmentMode){n=window.mockData.PORTAL_SERVER_ADDRESS}return`${n}${r}`},exports.hasUrlParams=e=>{try{return new URL(e,window.location.href).search.length>0}catch(e){return!1}},exports.queryAssetById=(e,t=200)=>i.post(`/asset/getAssetData?asset_id=${e}&count=${t}`,{filters:[]}),exports.removeTransformNone=()=>{document.querySelectorAll(".canvas-wrapper-display").forEach(e=>{const t=window.getComputedStyle(e);"none"!==t.transform&&"matrix(1, 0, 0, 1, 0, 0)"!==t.transform||(e.style.transform="")})};