cc-tools-utils 0.0.2 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -2
- package/dist/img/Transform.d.ts +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/js/bus.d.ts +8 -0
- package/dist/js/cesiumHooks.d.ts +68 -0
- package/dist/js/tools.d.ts +2 -0
- package/dist/lib/js/cesiumHooks.d.ts +1 -0
- package/dist/lib/js/tools.d.ts +3 -28
- package/package.json +16 -25
- package/vue-config-helper.js +54 -0
- package/lib/img/Transform.ts +0 -44
- package/lib/js/Anima.js +0 -10949
- package/lib/js/bus.ts +0 -24
- package/lib/js/cesiumHooks.js +0 -1054
- package/lib/js/tools.ts +0 -238
package/dist/js/bus.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export function isArrayEqual(arr1: any, arr2: any): any;
|
|
2
|
+
export const DEFAULT_HEIGHT: 25000000;
|
|
3
|
+
export const DEFAULT_POSITION: number[];
|
|
4
|
+
export const MODEL_DISPLAY_DISTANCE: 5000000;
|
|
5
|
+
export const allEntitiesIds: import("vue").Ref<any[], any[]>;
|
|
6
|
+
export function setCesiumAccessToken(token: string): void;
|
|
7
|
+
export function getHeading(pointA: any, pointB: any): number;
|
|
8
|
+
export function getRhumbBearing(pos1: any[], pos2: any[]): number;
|
|
9
|
+
export function getPitch(pointA: any, pointB: any): number;
|
|
10
|
+
export function updataModelPosition(viewer: any, { model, targetPosition, totalDuration }: {
|
|
11
|
+
model: any;
|
|
12
|
+
targetPosition: any;
|
|
13
|
+
totalDuration?: number;
|
|
14
|
+
}): void;
|
|
15
|
+
export function transformCartesian3ToWGS84(cartesian3: any): number[];
|
|
16
|
+
export function toCesiumColor(color: any): Color;
|
|
17
|
+
export function toCesiumPosition(position: any): Cartesian3;
|
|
18
|
+
export function backToChina(viewer: any, callback: any, time: any): void;
|
|
19
|
+
export function initCesium(boxID: any, doSomething: any): {
|
|
20
|
+
viewer: Cesium.Viewer;
|
|
21
|
+
};
|
|
22
|
+
export function divergingWaves(viewer: any, { defaultPosition, r, r2, step, max, speed, defaultColor, id, }?: {
|
|
23
|
+
defaultPosition?: number[];
|
|
24
|
+
r?: number;
|
|
25
|
+
r2?: number;
|
|
26
|
+
step?: number;
|
|
27
|
+
max?: number;
|
|
28
|
+
speed?: number;
|
|
29
|
+
defaultColor?: string;
|
|
30
|
+
id?: string;
|
|
31
|
+
}): any;
|
|
32
|
+
export function addEquatorialLine(viewer: any, color?: string): void;
|
|
33
|
+
export function airRouteFn(viewer: any): void;
|
|
34
|
+
export function cameraAnimation(viewer: any, position: any, orientation: any): void;
|
|
35
|
+
export function addPointer(viewer: any, { position, pointColor, pointerSize, id, label, billboard, nearScale, farScale, nearDistance, farDistance, hoverImage, }?: {
|
|
36
|
+
position: any;
|
|
37
|
+
pointColor: any;
|
|
38
|
+
pointerSize: any;
|
|
39
|
+
id: any;
|
|
40
|
+
label?: {};
|
|
41
|
+
billboard: any;
|
|
42
|
+
nearScale?: number;
|
|
43
|
+
farScale?: number;
|
|
44
|
+
nearDistance?: number;
|
|
45
|
+
farDistance?: number;
|
|
46
|
+
hoverImage: any;
|
|
47
|
+
}): any;
|
|
48
|
+
export function addLine(viewer: any): void;
|
|
49
|
+
export function add3DModel(viewer: any, airShipPosition: any, cameraPosition: any): void;
|
|
50
|
+
export function initEvents({ viewer, scene, camera, entities, clock }: {
|
|
51
|
+
viewer: any;
|
|
52
|
+
scene: any;
|
|
53
|
+
camera: any;
|
|
54
|
+
entities: any;
|
|
55
|
+
clock: any;
|
|
56
|
+
}): void;
|
|
57
|
+
export function followModel(viewer: any, options: any): void;
|
|
58
|
+
export function initCluster(viewer: any, { source, image: mainImage, imgs }: {
|
|
59
|
+
source: any;
|
|
60
|
+
image: any;
|
|
61
|
+
imgs: any;
|
|
62
|
+
}): any;
|
|
63
|
+
export function combineIconAndLabel(url: any, label: any, size: any): any;
|
|
64
|
+
export function addHover(viewer: Viewer, onHover: Function): () => void;
|
|
65
|
+
export function cc(): void;
|
|
66
|
+
import { Color } from "cesium";
|
|
67
|
+
import { Cartesian3 } from "cesium";
|
|
68
|
+
import * as Cesium from "cesium";
|
|
@@ -61,6 +61,7 @@ export function initCluster(viewer: any, { source, image: mainImage, imgs }: {
|
|
|
61
61
|
}): any;
|
|
62
62
|
export function combineIconAndLabel(url: any, label: any, size: any): any;
|
|
63
63
|
export function addHover(viewer: Viewer, onHover: Function): () => void;
|
|
64
|
+
export function cc(): void;
|
|
64
65
|
import { Color } from "cesium";
|
|
65
66
|
import { Cartesian3 } from "cesium";
|
|
66
67
|
import * as Cesium from "cesium";
|
package/dist/lib/js/tools.d.ts
CHANGED
|
@@ -1,31 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* @param end - 结束状态对象
|
|
5
|
-
* @param time - 动画持续时间(秒)
|
|
6
|
-
* @param onUpdate - 更新回调函数
|
|
7
|
-
* @param onComplete - 完成回调函数
|
|
8
|
-
* @returns Tween动画实例
|
|
9
|
-
*/
|
|
10
|
-
export declare const anima: (begin: Record<string, any>, end: Record<string, any>, time: number, onUpdate?: (data: any) => void, onComplete?: () => void) => any;
|
|
11
|
-
/**
|
|
12
|
-
* 防抖函数
|
|
13
|
-
* @param time - 延迟时间(毫秒)
|
|
14
|
-
* @param fn - 要执行的函数
|
|
15
|
-
* @returns 防抖后的函数
|
|
16
|
-
*/
|
|
17
|
-
export declare const debounce: <T extends (...args: any[]) => any>(time: number, fn: T) => (...args: Parameters<T>) => void;
|
|
18
|
-
/**
|
|
19
|
-
* 节流函数
|
|
20
|
-
* @param time - 节流时间间隔(毫秒)
|
|
21
|
-
* @param fn - 要执行的函数
|
|
22
|
-
* @returns 节流后的函数
|
|
23
|
-
*/
|
|
24
|
-
export declare const throttle: <T extends (...args: any[]) => any>(time: number, fn: T) => (...args: Parameters<T>) => void;
|
|
25
|
-
/**
|
|
26
|
-
* 蒙版渐隐动画
|
|
27
|
-
* @param parentDom - 父级DOM元素
|
|
28
|
-
*/
|
|
1
|
+
export declare const anima: (begin: any, end: any, time: any, onUpdate: any, onComplete: any) => any;
|
|
2
|
+
export declare const debounce: (time: number, fn: Function) => () => void;
|
|
3
|
+
export declare const throttle: (time: number, fn: Function) => () => void;
|
|
29
4
|
export declare const maskAnima: (parentDom: Element) => void;
|
|
30
5
|
export declare const callPromises: (arr: any) => any;
|
|
31
6
|
export declare const callFunctions: (arr: any) => void;
|
package/package.json
CHANGED
|
@@ -1,58 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cc-tools-utils",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.0.5",
|
|
4
|
+
"description": "Cesium工具库,包含常用的Cesium hooks和工具函数",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"type-check": "
|
|
8
|
+
"type-check": "false",
|
|
9
9
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
10
|
-
"build": "webpack --config webpack.dev.js"
|
|
11
|
-
"dev": "webpack --config webpack.dev.js --mode development"
|
|
10
|
+
"build": "webpack --config webpack.dev.js "
|
|
12
11
|
},
|
|
13
12
|
"keywords": [
|
|
14
|
-
"
|
|
13
|
+
"cesium",
|
|
15
14
|
"tools",
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"event-bus",
|
|
19
|
-
"javascript",
|
|
20
|
-
"typescript"
|
|
15
|
+
"utils",
|
|
16
|
+
"hooks"
|
|
21
17
|
],
|
|
22
|
-
"author": "
|
|
23
|
-
"license": "
|
|
18
|
+
"author": "",
|
|
19
|
+
"license": "ISC",
|
|
24
20
|
"repository": {
|
|
25
21
|
"type": "git",
|
|
26
22
|
"url": "https://gitee.com/chen-cheng-1998/learn_own.git"
|
|
27
23
|
},
|
|
28
24
|
"files": [
|
|
29
25
|
"dist",
|
|
30
|
-
"lib",
|
|
31
26
|
"README.md",
|
|
32
|
-
"LICENSE"
|
|
27
|
+
"LICENSE",
|
|
28
|
+
"vue-config-helper.js",
|
|
29
|
+
"CONSUMER_PROJECT_CONFIG.md"
|
|
33
30
|
],
|
|
34
|
-
"
|
|
31
|
+
"devDependencies": {
|
|
35
32
|
"@vue/compiler-sfc": "^3.5.11",
|
|
36
|
-
"cesium": "^1.137.0",
|
|
37
33
|
"css-loader": "^7.1.2",
|
|
38
34
|
"style-loader": "^4.0.0",
|
|
39
|
-
"vue": "
|
|
40
|
-
"vue-loader": "^17.4.2"
|
|
41
|
-
},
|
|
42
|
-
"devDependencies": {
|
|
35
|
+
"vue-loader": "^17.4.2",
|
|
43
36
|
"@babel/core": "^7.18.0",
|
|
37
|
+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
|
|
44
38
|
"@babel/plugin-proposal-optional-chaining": "^7.17.12",
|
|
45
39
|
"@babel/preset-env": "^7.18.2",
|
|
46
|
-
"@babel/preset-react": "^7.17.12",
|
|
47
40
|
"@types/node": "^22.7.5",
|
|
48
41
|
"babel-loader": "^8.2.5",
|
|
49
42
|
"clean-webpack-plugin": "^4.0.0",
|
|
50
|
-
"copy-webpack-plugin": "^11.0.0",
|
|
51
43
|
"ts-loader": "^9.2.6",
|
|
52
44
|
"typescript": "^4.5.4",
|
|
53
45
|
"webpack": "^5.65.0",
|
|
54
|
-
"webpack-bundle-analyzer": "^4.5.0",
|
|
55
46
|
"webpack-cli": "^4.9.1",
|
|
56
47
|
"webpack-parallel-uglify-plugin": "^2.0.0"
|
|
57
48
|
}
|
|
58
|
-
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* cc-tools-utils 的 Vue CLI 配置辅助工具
|
|
3
|
+
*
|
|
4
|
+
* 使用方法:
|
|
5
|
+
* 在消费项目的 vue.config.js 中:
|
|
6
|
+
*
|
|
7
|
+
* const ccToolsConfig = require('cc-tools-utils/vue-config-helper');
|
|
8
|
+
* module.exports = ccToolsConfig;
|
|
9
|
+
*
|
|
10
|
+
* 或者合并配置:
|
|
11
|
+
* const { defineConfig } = require('@vue/cli-service');
|
|
12
|
+
* const ccToolsConfig = require('cc-tools-utils/vue-config-helper');
|
|
13
|
+
*
|
|
14
|
+
* module.exports = defineConfig({
|
|
15
|
+
* ...ccToolsConfig,
|
|
16
|
+
* // 你的其他配置
|
|
17
|
+
* });
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const { defineConfig } = require("@vue/cli-service");
|
|
21
|
+
|
|
22
|
+
module.exports = defineConfig({
|
|
23
|
+
transpileDependencies: ["cesium", /@cesium/],
|
|
24
|
+
|
|
25
|
+
configureWebpack: {
|
|
26
|
+
module: {
|
|
27
|
+
rules: [
|
|
28
|
+
{
|
|
29
|
+
test: /\.m?js$/,
|
|
30
|
+
include: /node_modules[\\/](cesium|@cesium)/,
|
|
31
|
+
use: {
|
|
32
|
+
loader: "babel-loader",
|
|
33
|
+
options: {
|
|
34
|
+
presets: [
|
|
35
|
+
[
|
|
36
|
+
"@babel/preset-env",
|
|
37
|
+
{
|
|
38
|
+
targets: {
|
|
39
|
+
browsers: ["> 1%", "last 2 versions", "not ie <= 8"],
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
],
|
|
44
|
+
plugins: [
|
|
45
|
+
"@babel/plugin-proposal-nullish-coalescing-operator",
|
|
46
|
+
"@babel/plugin-proposal-optional-chaining",
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
});
|
package/lib/img/Transform.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// 图片url转 base64
|
|
2
|
-
const imgUrlToBase64 = async (url, callback) => {
|
|
3
|
-
let Img = new Image(),
|
|
4
|
-
dataURL = "";
|
|
5
|
-
Img.src = url + "?v=" + Math.random();
|
|
6
|
-
Img.setAttribute("crossOrigin", "Anonymous");
|
|
7
|
-
Img.onload = function () {
|
|
8
|
-
let canvas = document.createElement("canvas"),
|
|
9
|
-
width = Img.width,
|
|
10
|
-
height = Img.height;
|
|
11
|
-
canvas.width = width;
|
|
12
|
-
canvas.height = height;
|
|
13
|
-
(canvas.getContext("2d") as any).drawImage(Img, 0, 0, width, height);
|
|
14
|
-
dataURL = canvas.toDataURL("image/webp");
|
|
15
|
-
return callback ? callback(dataURL) : null;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
// 下载文件
|
|
20
|
-
const downloadFile = (content: any, fileName: string) => {
|
|
21
|
-
//下载base64图片 传入base64
|
|
22
|
-
let base64ToBlob = function (code: any) {
|
|
23
|
-
let parts = code.split(";base64,");
|
|
24
|
-
let contentType = parts[0].split(":")[1];
|
|
25
|
-
let raw = window.atob(parts[1]);
|
|
26
|
-
let rawLength = raw.length;
|
|
27
|
-
let uInt8Array = new Uint8Array(rawLength);
|
|
28
|
-
for (let i = 0; i < rawLength; ++i) {
|
|
29
|
-
uInt8Array[i] = raw.charCodeAt(i);
|
|
30
|
-
}
|
|
31
|
-
return new Blob([uInt8Array], {
|
|
32
|
-
type: contentType,
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
let aLink = document.createElement("a");
|
|
36
|
-
let blob = base64ToBlob(content); //new Blob([content]);
|
|
37
|
-
let evt = document.createEvent("HTMLEvents");
|
|
38
|
-
evt.initEvent("click", true, true); //initEvent 不加后两个参数在FF下会报错 事件类型,是否冒泡,是否阻止浏览器的默认行为
|
|
39
|
-
aLink.download = fileName;
|
|
40
|
-
aLink.href = URL.createObjectURL(blob);
|
|
41
|
-
aLink.click();
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export { imgUrlToBase64, downloadFile };
|