nce-utils v0.2.16
nce-utils
nce 项目公用的工具类
地址
https://www.npmjs.com/package/nce-utils
安装
可以在浏览器中直接使用JavaScript文件 nce-utils.umd.js或通过npm方式安装。
浏览器直接加载
会在全局环境添加NceUtils对象:
<script src='path/to/nce-utils.umd.js'></script>
npm方式
npm install nce-utils -S
使用
示例
通过script标签方式引入:
<script>
let date = NceUtils.dateTool.getFormatDate();
console.info(date);
</script>
按需引入:
import { dateTool } from "nce-utils";
let date = dateTool.getForamtDate();
console.info(date);
模块说明
AES generatekey随机生成指定数量的16进制key encrypt加密 * decrypt解密
AES128 uuid decrypt encrypt getMixedText * getUnMixedText
dateTool 日期格式化 formatDate getCurrentDayZeroTime getDateStr getCurrentTime * getFormatDate
featureMeta 地理要素 coordEach coordReduce propEach propReduce featureEach featureReduce coordAll geomEach geomReduce feature flattenEach flattenReduce
loadTools loadScript loadScriptCode loadScripts removeScript removeScripts loadStyle loadStyleCode loadStyles removeStyle removeStyles
MapApiLoader 加载地图Api的类 tools removeAllApi load2dBaseApi loadPluginApi load3dBaseApi loadCDNApi
```javascript import { MapApiLoader } from "nce-utils"; // 创建实例时需要传入url参数 const mapApiLoader = new MapApiLoader({ APP_JS_2D_API_URL: "", APP_JS_3D_API_URL: "", APP_JS_API_PLUGINS_URL: "", APP_JS_API_CDN_URL: "", }); console.info(mapApiLoader.tools.loadPluginApi); ```
message * 封装element-ui的message
```js // main.js import { message } from "nce-utils"; Vue.prototype.$message = message; // 使用 this.$message({ message: res.msg, type: "success", }); ```
storageUtil setSession getSession removeSession setLocal getLocal removeLocal
transformUnit changeSizeUnit 字节单位向上转换 changeTimeUnit 秒数转为时长字符串
user 处理登录、退出登录、平台间跳转。
logout 退出登录,并跳转到登录页
参数名称 说明 类型 默认值 userkey 在localstorage中储存用户信息的key string "user" loginRoute 登录页的路由 string "/nce-user/portalLogin" user的所有方法中参数需要按顺序传入,有默认值的可不传,不再重复说明。
checkLogin 检查用户是否登录,未登录会自动跳转到登录页
参数名称 说明 类型 默认值 userkey 在localstorage中储存用户信息的key string "user" loginRoute 登录页的路由 string "/nce-user/portalLogin"
* toLogin 跳转到登录页,建议使用checkLogin方法代替
| 参数名称 | 说明 | 类型 | 默认值 |
| - | - | - | - |
| data |跳转到登录页时需要放在url中携带的数据|object| null |
|loginRoute|登录页的路由|string | "/nce-user/portalLogin"|
* getFromUrl 从url解析fromUrl,返回值:包含fromUrl的对象
| 返回值说明 |
| - |
| 带有fromUrl的对象,如{ fromUrl: "www.xxx.com/data" }|
* switchPlatform 切换平台
| 参数名称 | 说明 | 类型 | 默认值 |
| - | - | - | - |
| route |切换的平台,不需要完整路径,域名后面的部分即可,如/nce-data |string||
|url|目标平台地址的协议+域名,如:http://cloud.app.ncloud.navinfo.com|string | window.location.protocol + "//" + window.location.host|
| type | 打开浏览器窗口的方式 | "_self" 或 "_blank" | "_self" |
* openUrl 打开页面
| 参数名称 | 说明 | 类型 | 默认值 |
| - | - | - | - |
| url | 目标页面地址 |string||
| type | 打开浏览器窗口的方式 | "_self" 或 "_blank" | "_blank" |
uuidUtil getUuid getUuid_Eight loadjscssfile removejscssfile createjscssfile replacejscssfile
validator 校验 validateUsername validateMail validatePass validateCheckPass validatePhone validateServicename
common
- getMenuByRouter
- joinParamToUrl
- debounce 函数防抖
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago