import {isExternal} from "@/utils/validate"; import {baseUrl} from "@/config"; /** * 判断是否空字符串 */ export function isBlank(str) { return str == null || str === ''; } /** * 字符串转换为数组 */ export function strToList(str, split = ',') { if (isBlank(str)) { return []; } if (str instanceof Array) { return str; } return str.split(split); } export function getRealUrl(url) { return url.substring(0, url.lastIndexOf('?')) } export function isEmpty(obj) { return obj == null || obj.length === 0; } /** * 转换本地URL,若是本地URL则加前缀,否则直接返回 * @param url */ export function parseLocalUrl(url) { if (isEmpty(url) || isExternal(url)) { return url; } return baseUrl + url; }