Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: 更新 load 方法,并修改 vite 打包暴露的全局变量名称为 niUtils #33

Merged
merged 3 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ getBrowserInfo();
</script>

<script>
commonUtils.getBrowserInfo();
niUtils.getBrowserInfo();
</script>
```

Expand Down
6 changes: 3 additions & 3 deletions debug/animation.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
function render() {
progress += 1; // 修改图像的位置
if (progress < 100) { // 在动画没有结束前,递归渲染
cnUtils.requestAnimationFrame(render);
niUtils.requestAnimationFrame(render);
}
}
const handlerId = cnUtils.requestAnimationFrame(render);
const handlerId = niUtils.requestAnimationFrame(render);
console.log('动画id', handlerId);

cnUtils.cancelAnimationFrame(handlerId);
niUtils.cancelAnimationFrame(handlerId);
</script>
</body>

Expand Down
2 changes: 1 addition & 1 deletion debug/browser.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<body>
<script>
const result = cnUtils.getBrowserInfo(); //调用刚刚定义的函数
const result = niUtils.getBrowserInfo(); //调用刚刚定义的函数
document.write("你使用的浏览器是:" + navigator.userAgent);
document.write("<br>");
document.write(
Expand Down
6 changes: 3 additions & 3 deletions debug/common.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
<body>
<script>
const str = '';
const isNull = cnUtils.isNotEmpty(str);
const isNull = niUtils.isNotEmpty(str);
console.log('是否不为空', isNull);

const world = 'helloWorld';
const newWorld = cnUtils.humpToLine(world);
const newWorld = niUtils.humpToLine(world);
console.log('驼峰转横线', newWorld);

const nowWorld = cnUtils.lineToHump(newWorld);
const nowWorld = niUtils.lineToHump(newWorld);
console.log('横线转驼峰', nowWorld);
</script>
</body>
Expand Down
2 changes: 1 addition & 1 deletion debug/computedTextWidth.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</head>
<body>
<script>
const textWidth = cnUtils.computedTextWidth("测试", "宋体");
const textWidth = niUtils.computedTextWidth("测试", "宋体");
console.log('文本宽度', textWidth);
</script>
</body>
Expand Down
10 changes: 5 additions & 5 deletions debug/cookie.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@

<body>
<script>
const cookie = cnUtils.setCookie('userName', 'admin');
const cookie = niUtils.setCookie('userName', 'admin');
console.log('设置的cookie信息', cookie);

const user = cnUtils.getCookie('userName');
const user = niUtils.getCookie('userName');
console.log('cookie信息-userName的值', user)

const allCookies = cnUtils.getAllCookies();
const allCookies = niUtils.getAllCookies();
console.log('cookie所有信息', allCookies)

cnUtils.removeCookie('userName');
const newCookies = cnUtils.getAllCookies();
niUtils.removeCookie('userName');
const newCookies = niUtils.getAllCookies();
console.log('cookie所有信息', newCookies)
</script>
</body>
Expand Down
10 changes: 5 additions & 5 deletions debug/coordinate.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@
</head>
<body>
<script>
const wgs84 = new cnUtils.Coordinate(
const wgs84 = new niUtils.Coordinate(
110.7781634600000643,
22.966523235000077
);

console.log("wgs85", wgs84);

const gcj02 = cnUtils.CoordinateUtils.transformWGS84ToGCJ02(wgs84);
const gcj02 = niUtils.CoordinateUtils.transformWGS84ToGCJ02(wgs84);
console.log("84转火星", gcj02);

const wgs84_02 = cnUtils.CoordinateUtils.transformGCJ02ToWGS84(gcj02);
const wgs84_02 = niUtils.CoordinateUtils.transformGCJ02ToWGS84(gcj02);
console.log("火星转84", wgs84_02);

const bd09 = cnUtils.CoordinateUtils.transformWGS84ToBD09(wgs84);
const bd09 = niUtils.CoordinateUtils.transformWGS84ToBD09(wgs84);
console.log("84转百度", bd09);

const wgs84_bd09 = cnUtils.CoordinateUtils.transformBD09ToWGS84(bd09);
const wgs84_bd09 = niUtils.CoordinateUtils.transformBD09ToWGS84(bd09);
console.log("百度转84", wgs84_bd09);
</script>
</body>
Expand Down
4 changes: 2 additions & 2 deletions debug/date.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
<body>
<script>
const date = new Date();
const strDate = cnUtils.formatDatetime(date);
const strDate = niUtils.formatDatetime(date);
console.log('日期字符串', strDate);

const numberDate = cnUtils.formatTimestamp(date);
const numberDate = niUtils.formatTimestamp(date);
console.log('日期数值', numberDate);
</script>
</body>
Expand Down
16 changes: 8 additions & 8 deletions debug/dom.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,28 @@
<body>
<div class="content"></div>
<script>
const dom = cnUtils.getDocument();
const dom = niUtils.getDocument();
console.log('当前dom', dom);

const el = cnUtils.createDom('div', 'test', 'width:100px; height: 100px;')
const el = niUtils.createDom('div', 'test', 'width:100px; height: 100px;')
console.log('dom元素', el);

cnUtils.removeDom(el);
niUtils.removeDom(el);

cnUtils.addClassName(el, 'add');
niUtils.addClassName(el, 'add');
console.log('dom元素', el);

cnUtils.removeClassName(el, 'add');
niUtils.removeClassName(el, 'add');
console.log('dom元素', el);

const newEl = cnUtils.removeClassNameByClassName('content');
const newEl = niUtils.removeClassNameByClassName('content');
console.log('dom元素', newEl);

const styleEl = cnUtils.injectStyle('font-size: 14px');
const styleEl = niUtils.injectStyle('font-size: 14px');
console.log('dom元素', styleEl);

const str = '<div></div>';
const newStr = cnUtils.filterXSS(str);
const newStr = niUtils.filterXSS(str);
console.log('转义后', str);
</script>
</body>
Expand Down
2 changes: 1 addition & 1 deletion debug/flex.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<body>
<script>
const screenScaleSize = cnUtils.getScreenScaleSize(1920, 2);
const screenScaleSize = niUtils.getScreenScaleSize(1920, 2);
console.log('屏幕缩放比例', screenScaleSize);
</script>
</body>
Expand Down
2 changes: 1 addition & 1 deletion debug/getJson.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<body>
<script>
cnUtils.getJson("./data/test.json", (res) => {
niUtils.getJson("./data/test.json", (res) => {
document.write(JSON.stringify(res));
});
</script>
Expand Down
6 changes: 3 additions & 3 deletions debug/url.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
<body>
<script>
const url = 'http://localhost:8080/getList?id=12';
const id = cnUtils.getUrlParam('id', url);
const id = niUtils.getUrlParam('id', url);
console.log('参数值', id);

const host = cnUtils.getHost(url);
const host = niUtils.getHost(url);
console.log('主机名', host);

const isSome = cnUtils.isSameDomain(url, globalThis.location.host);
const isSome = niUtils.isSameDomain(url, globalThis.location.host);
console.log('域名', globalThis.location.host);
console.log('域名是否相等', isSome);
</script>
Expand Down
8 changes: 4 additions & 4 deletions debug/uuid.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@

<body>
<script>
const uuid8 = cnUtils.getUuid8();
const uuid8 = niUtils.getUuid8();
console.log("8位随机id", uuid8);

const uuid16 = cnUtils.getUuid16();
const uuid16 = niUtils.getUuid16();
console.log("16位随机id", uuid16);

const uuid = cnUtils.getUuid(32);
const uuid = niUtils.getUuid(32);
console.log("自定义位数的随机id", uuid);

const uuidDigit = cnUtils.getUuidDigit(8);
const uuidDigit = niUtils.getUuidDigit(8);
console.log("自定义位数的随机数字id", uuidDigit);
</script>
</body>
Expand Down
14 changes: 7 additions & 7 deletions src/lib/CoordinateUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class CoordinateUtils {
* @returns {Coordinate} 坐标:[经度,纬度]
*
* @example
* cnUtils.CoordinateUtils.transformBD09ToGCJ02(coordinate);
* niUtils.CoordinateUtils.transformBD09ToGCJ02(coordinate);
*/
static transformBD09ToGCJ02(coordinate: Coordinate) {
const x = coordinate.lng - 0.0065;
Expand All @@ -82,7 +82,7 @@ export class CoordinateUtils {
* @return {Coordinate} 百度坐标:[经度,纬度]
*
* @example
* cnUtils.CoordinateUtils.transformGCJ02ToBD09(coordinate);
* niUtils.CoordinateUtils.transformGCJ02ToBD09(coordinate);
*/
static transformGCJ02ToBD09(coordinate: Coordinate) {
const z =
Expand All @@ -102,7 +102,7 @@ export class CoordinateUtils {
* @return {Coordinate} WGS84坐标:[经度,纬度]
*
* @example
* cnUtils.CoordinateUtils.simpleTransformGCJ02ToWGS84(coordinate);
* niUtils.CoordinateUtils.simpleTransformGCJ02ToWGS84(coordinate);
*/
static simpleTransformGCJ02ToWGS84(coordinate: Coordinate) {
if (outOfChina(coordinate)) {
Expand All @@ -129,7 +129,7 @@ export class CoordinateUtils {
* @param {Coordinate} gcj GCJ02经纬度
* @return {Coordinate} WGS84坐标:[经度,纬度]
* @example
* cnUtils.CoordinateUtils.transformGCJ02ToWGS84(coordinate);
* niUtils.CoordinateUtils.transformGCJ02ToWGS84(coordinate);
*/
static transformGCJ02ToWGS84(gcj: Coordinate) {
// 计算输入 gcj 坐标与将其计算为84坐标的偏差
Expand All @@ -156,7 +156,7 @@ export class CoordinateUtils {
* @return {Coordinate} GCJ02 坐标:[经度,纬度]
*
* @example
* cnUtils.CoordinateUtils.transformWGS84ToGCJ02(coordinate);
* niUtils.CoordinateUtils.transformWGS84ToGCJ02(coordinate);
*/
static transformWGS84ToGCJ02(coordinate: Coordinate) {
if (outOfChina(coordinate)) {
Expand Down Expand Up @@ -184,7 +184,7 @@ export class CoordinateUtils {
* @return {Coordinate} WGS84 坐标:[经度,纬度]
*
* @example
* cnUtils.CoordinateUtils.transformBD09ToWGS84(coordinate);
* niUtils.CoordinateUtils.transformBD09ToWGS84(coordinate);
*/
static transformBD09ToWGS84(coordinate: Coordinate) {
const gcj02 = CoordinateUtils.transformBD09ToGCJ02(coordinate);
Expand All @@ -200,7 +200,7 @@ export class CoordinateUtils {
* @return {Coordinate} BD09 坐标:[经度,纬度]
*
* @example
* cnUtils.CoordinateUtils.transformWGS84ToBD09(coordinate);
* niUtils.CoordinateUtils.transformWGS84ToBD09(coordinate);
*/
static transformWGS84ToBD09(coordinate: Coordinate) {
const gcj02 = CoordinateUtils.transformWGS84ToGCJ02(coordinate);
Expand Down
Loading