const previewURL = '' const baseURL = '' // const baseURL = 'http://192.168.0.222:58888' /** * 公共GET请求 * @param {Object} params * @return {Promise>} */ let fetch_GET = (url, params) => { // 发送请求 return new Promise((resolve, reject) => { axios({ method: 'get', url: `${baseURL}${url}`, headers: { "X-Data-Sign": encrypt(JSON.stringify(params)), }, params, }).then(function (response) { resolve(response) }) .catch(function (error) { resolve(error.data) }); }) }; // 公共POST请求 let fetch_POST = (url, data) => { return new Promise((resolve, reject) => { axios({ method: "POST", url: `${baseURL}${url}`, data: { data, sign: encrypt(JSON.stringify(data)) }, headers: { "Content-Type": "application/json;charset=UTF-8", } }).then(function (res) { resolve(res); }).catch(err => { console.log(err, '异常') }); }); }; // function format(string) { if (!string) return '' const intl = new Intl.DateTimeFormat("zh", { hour12: false, year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit" }); const date = string instanceof Date ? string : new Date(string); return intl.format(date).replace(/\//g, "-"); } function formatDate(string) { if (!string) return '' const intl = new Intl.DateTimeFormat("zh", { hour12: false, year: "numeric", month: "2-digit", day: "2-digit" }); const date = string instanceof Date ? string : new Date(string); return intl.format(date).replace(/\//g, "-"); } function formatTime(string) { if (!string) return '' const intl = new Intl.DateTimeFormat("zh", { hour12: false, hour: "2-digit", minute: "2-digit", second: "2-digit" }); const date = string instanceof Date ? string : new Date(string); return intl.format(date); } // 修改网页图标 const changeFavicon = link => { let $favicon = document.querySelector('link[rel="icon"]'); if ($favicon !== null) { $favicon.href = link; } else { $favicon = document.createElement("link"); $favicon.rel = "icon"; $favicon.href = link; document.head.appendChild($favicon); } };