hot-form
Version:
A project developed based on ant-design-vue and vant whitch do some things on create/render/modify and etc. for forms. Also can custom some component on the form items if you want. 一个基于antdv/vant开发的创建表单组件,包含表单渲染、表单编辑页面、以及植入自定义附加内容的组件
32 lines (28 loc) • 1.26 kB
JavaScript
// 全局公共业务方法
/**
* 分离链接(处理图片) 远程地址与本地,分离banStr类与proxy类图片
* @param {String} path - 需要处理的文件名
* @param {String} proxy - 远程文件代理名称
* @param {String} banStr - 区分远程与本地图片类型的字符串(默认使用http://中的://处理)
* @return {String} 返回值 为替换proxy之后的字符串
*/
function pathDeal(path, proxy, banStr = '://') {
if (!path || !path.trim()) return path;
let arr = path.split(banStr);
if (arr.length > 1) return path;
const str = proxy ? proxy : '';
return path.replace(str.replace(/\/*\//, ''), '').replace(/\/+/g, '/');
}
// 分离链接(处理图片)(远程地址与本地,分离 `http://` 与 `proxy`代理)
export function $getLink(path, proxy) {
if (path && path.split('://').length > 1) return path;
let pathStr = `/${pathDeal(path, proxy)}`;
// 去掉多余的/
return `${proxy}${pathStr.replace(/\/+/g, '/')}`;
}
// 分离链接(处理远程地址,将加上 `proxy` 代理的文件处理,重新传回给后端)
export function $partLink(path, proxy) {
let str = pathDeal(path, proxy);
// 去掉最前面的/
return str.replace(/^\//, '');
}