Compare commits
557 Commits
d503e64098
...
master
Author | SHA1 | Date | |
---|---|---|---|
38dcbe7f7a | |||
71ba51772d | |||
11a3db5b61 | |||
b662da584a | |||
311623e208 | |||
fadbb6a911 | |||
0afefe44ca | |||
71ec027000 | |||
c913be2690 | |||
217cf85ea4 | |||
d5cf2a600e | |||
e6f235036e | |||
35a7825759 | |||
4bd192dc87 | |||
78de3276d3 | |||
cabf64088b | |||
a50fbc26d7 | |||
d92a540786 | |||
db6d39e02e | |||
d01a56d9dc | |||
16eb852d9d | |||
f006ca5a2b | |||
460472b29a | |||
3579ff100f | |||
731c423483 | |||
c3a2e68980 | |||
84246a3a61 | |||
23ceb718e9 | |||
9cb43687c4 | |||
fe9c299d64 | |||
16fda90d96 | |||
e3ff6020ac | |||
32dc012598 | |||
f6afa97b2d | |||
7be3859988 | |||
f1339ad082 | |||
ac812246ea | |||
177da7a28a | |||
4cd7efcfe4 | |||
e520f3b581 | |||
ee849ba62a | |||
0c3ea8fe73 | |||
cd9e00fc33 | |||
7738212dd7 | |||
942375b06b | |||
cf2b805770 | |||
7e7d21f9ce | |||
dc35cb8354 | |||
4a9a0c4214 | |||
e377368c41 | |||
f341f08248 | |||
8eac9bce6c | |||
2ec6dcd74f | |||
6e33ae2972 | |||
8631a697f4 | |||
22a1379ca8 | |||
38cf536f1b | |||
4f21a81706 | |||
178f44a5a3 | |||
4fa4c754f9 | |||
5101dc7657 | |||
b412e847d4 | |||
e39823db40 | |||
e71ec5b9c1 | |||
52342e6623 | |||
dd594676ac | |||
6380ee505f | |||
c5dac4fbcc | |||
d50dbe719d | |||
3fa3b5b508 | |||
dd12f54dc9 | |||
d37243af6b | |||
3e4b85fc48 | |||
b4dadc415d | |||
fff6fb5584 | |||
3d50132338 | |||
10538985ce | |||
2696d5cad5 | |||
f0af5e47fa | |||
a517e694aa | |||
03ec2223aa | |||
c9496f4400 | |||
db20b45f78 | |||
78dd437746 | |||
922af12760 | |||
b910c6fee2 | |||
eb895793dd | |||
19b48371ef | |||
26b2ff2370 | |||
b96217b9bb | |||
f68e5f96f6 | |||
c35a75d030 | |||
974b2e7038 | |||
f9a6ad7fda | |||
eaaf940960 | |||
6f7d7e56c2 | |||
0f439c9220 | |||
2b989e1d46 | |||
26bef3f724 | |||
e075ce1bfc | |||
a257068054 | |||
80bb267e7d | |||
57460d0af1 | |||
910b24019e | |||
4dd1f2d6d5 | |||
17ee714729 | |||
08556fbf7f | |||
23b6551829 | |||
9b06c042ef | |||
ab7d51d3a2 | |||
5f6547aeb1 | |||
d26db2d321 | |||
9d9224d6ad | |||
055811702b | |||
eb98e8c8c3 | |||
288ee14d5e | |||
26e4c899db | |||
a95d18906f | |||
2737e579c8 | |||
069841ea99 | |||
85e5572e53 | |||
46f9c0568c | |||
1a476b8ee8 | |||
d06d6a9504 | |||
0c81842fd6 | |||
2ba08c79ed | |||
ddccc64586 | |||
0c0e55a383 | |||
253e395ace | |||
9d1f96309f | |||
192ffb5091 | |||
9cecbeaa20 | |||
8a3f338e27 | |||
2415c96cf9 | |||
8b57f957b6 | |||
3b1ad5cd05 | |||
81d22d0b69 | |||
856ecd7c43 | |||
a74419c288 | |||
e0a4b1e8fa | |||
4f2eec9468 | |||
873aecf815 | |||
1eba94076d | |||
76488de0cd | |||
5c125bc37b | |||
80e22c8f92 | |||
c69a91651d | |||
5b118055c5 | |||
8887392758 | |||
a2ea5e5979 | |||
06d111b9e6 | |||
897e41c422 | |||
2b88c32489 | |||
ba2b8444af | |||
62ab2a4672 | |||
2815b7d6b0 | |||
203c808fa2 | |||
eba51942d7 | |||
8682b0d8b8 | |||
d9662b5e7d | |||
043d49cb20 | |||
8ff57e80d8 | |||
b1bc73cddb | |||
141aa7be4d | |||
fa46f632d9 | |||
15c4ad5484 | |||
c1b891b4b2 | |||
621084cd82 | |||
d3317b0e32 | |||
b0abb5f47b | |||
43419d52af | |||
99b7183e36 | |||
e99e27c8d1 | |||
47a8b17061 | |||
bbb105b622 | |||
5e3bd52949 | |||
31b00165cf | |||
6f2b503bd2 | |||
dc59ade2b8 | |||
bfafbc9591 | |||
70aa152b1a | |||
d09db36ed8 | |||
76d80b23b1 | |||
7c2e4d7e14 | |||
5465136879 | |||
b773a2d149 | |||
395f6f352a | |||
2290eb28d7 | |||
a21bf2f755 | |||
468dda51e1 | |||
ac579263b8 | |||
2b07329c87 | |||
6eed9d9244 | |||
09691bdbe6 | |||
384eb35d84 | |||
bf23c8c18f | |||
ade1177294 | |||
b0a05519f0 | |||
211b94d76b | |||
23313b9645 | |||
9ec6b9818c | |||
c0338033b4 | |||
2b25709c14 | |||
c9cceb53f7 | |||
53d5f677c4 | |||
72a8665906 | |||
6c96dc2abc | |||
fdab021ff2 | |||
e7cf93f7e4 | |||
cb817e47b4 | |||
b59bd89e43 | |||
6f73a308ba | |||
0c06379ff6 | |||
27f95371c5 | |||
46f46a7c75 | |||
8d453efb07 | |||
7d6c13e935 | |||
2c9c72d714 | |||
93c2f6e512 | |||
fa1f3215cf | |||
6e53520a33 | |||
e7dc466c88 | |||
e6c92a3b51 | |||
9fb3357c1f | |||
ead5b7bd70 | |||
ab68bbcd40 | |||
f637e65635 | |||
dc39b5861d | |||
18957eb7a7 | |||
cec48c13af | |||
0b6b578d25 | |||
c1d6a8d92c | |||
4e08f7387f | |||
48a72e22cf | |||
8d7736b3fc | |||
589d21d622 | |||
68b43b1246 | |||
5f42c21467 | |||
ee2f5ec71e | |||
a7f9339eb8 | |||
239c989a26 | |||
91b7f38f8c | |||
290fc16c32 | |||
70db0367e1 | |||
46bfa429d3 | |||
369ba1ad20 | |||
7ea0594610 | |||
874c04e497 | |||
fceb454b2a | |||
7c171e432f | |||
53e1f94c78 | |||
6832b91cfd | |||
bbbba22ebd | |||
ceabac7fb8 | |||
0d180e63f2 | |||
446d30ce35 | |||
0ea88f33b8 | |||
b256eb83f0 | |||
7f19586b93 | |||
2b339df606 | |||
160223bf5f | |||
4d0845ee53 | |||
5fdb8bdfe3 | |||
cfb6085bbf | |||
73772f036f | |||
dbb649d1ce | |||
f3f8ab0b87 | |||
31c21c7bb5 | |||
59d1f881dd | |||
b84985414a | |||
5ffe04d20e | |||
7e15764ba5 | |||
1c14669ddf | |||
6eb10c27a4 | |||
bb512fe0f3 | |||
6f79e07193 | |||
b4113bdf2a | |||
2bbeb83502 | |||
38dd85de64 | |||
ea56d292ec | |||
5258b37d07 | |||
ba037ac2cd | |||
31963f69c3 | |||
e4523299d4 | |||
340954167f | |||
169f5ae376 | |||
984ec9c4fb | |||
93df563660 | |||
1405857f55 | |||
b77d5fe171 | |||
9584ab4baa | |||
00122c93fc | |||
d45bce2ef8 | |||
92d8c52b18 | |||
72577614aa | |||
cff2ce34f1 | |||
8f9b042941 | |||
26e1493aa7 | |||
e3b4826dce | |||
fb105b7962 | |||
a712dce2cd | |||
e182b87f02 | |||
11bded87e4 | |||
291a5eca02 | |||
678f10c96b | |||
cb6ca3f709 | |||
ad04cff917 | |||
9dfa9ee146 | |||
f4cbde8ee2 | |||
e7558d770c | |||
c80984cb51 | |||
6c05e20e8d | |||
91423fdf5c | |||
d93b0d71a9 | |||
3588c5d386 | |||
58cbe1c902 | |||
dbc26a3d49 | |||
c1512c5a34 | |||
89bd2e6d92 | |||
a437d7a485 | |||
25786908b7 | |||
2e7a72a89a | |||
c6d971392b | |||
5556264b9e | |||
65f4191211 | |||
594de41607 | |||
40cb0589f8 | |||
479291d857 | |||
5870c66161 | |||
ce1665a2c6 | |||
f01487dc50 | |||
ddf3bcf651 | |||
5497871ce3 | |||
15a724a5fe | |||
1cdd24271c | |||
3469f1e186 | |||
37c914c662 | |||
288d7df341 | |||
d260f9983d | |||
6018fcc9ba | |||
e4f2548199 | |||
75f190907d | |||
3fe1767190 | |||
48a30fd508 | |||
aab67593eb | |||
589422ad0e | |||
67f58089ff | |||
9f45f2e3b5 | |||
f0577d7d27 | |||
5e162ef59d | |||
bc0c9e3a90 | |||
5c1aca212e | |||
30f53f75e9 | |||
2222649770 | |||
5454018914 | |||
396dcd5748 | |||
525733b9e5 | |||
8843763499 | |||
179d9ba6aa | |||
f7ec845a7b | |||
297048ab91 | |||
b4a023570f | |||
59325f7877 | |||
3b90f269ae | |||
7933ffbc0e | |||
37e01eda4b | |||
77150924b4 | |||
c092650aed | |||
4c01c0a4a3 | |||
6359daba49 | |||
7c1f07eb7d | |||
6dff42a6cb | |||
c414e541c1 | |||
c8cc1a329b | |||
4511145f52 | |||
10ed8585e3 | |||
4f6cb30832 | |||
4e18057981 | |||
aa6de50a78 | |||
1ac6a846ba | |||
25e3c62ad9 | |||
0098a9829d | |||
acdd8cf467 | |||
dae6c05005 | |||
34d0fee2f6 | |||
afd59bc373 | |||
d67de58a37 | |||
52056dde9d | |||
1dbde76257 | |||
388a31dd18 | |||
3c476fbba0 | |||
9f3e150509 | |||
314903104c | |||
c61582c631 | |||
1e822facc8 | |||
c98e3f72e1 | |||
16caf1b5e6 | |||
7e4a5e17cc | |||
c12fa631e4 | |||
4372472769 | |||
2c7b056405 | |||
18b5df1133 | |||
c68bbc7717 | |||
b8652c084b | |||
d80fcbf454 | |||
30ea9bc1dd | |||
786e7a516f | |||
6cab291522 | |||
f163893ccf | |||
d97838a919 | |||
52d4a07204 | |||
9049969546 | |||
0a790aebb5 | |||
616e9fc7b7 | |||
adb3ba7123 | |||
001adefac7 | |||
7ab2e0ae32 | |||
15742dd235 | |||
271f99fb16 | |||
da3a46189e | |||
53309746f5 | |||
3b61e84a7f | |||
ca09a1b326 | |||
9e2cf9c73a | |||
806ed029cf | |||
174ef50f6f | |||
12e80c57d3 | |||
896ea07fad | |||
12173054e9 | |||
53444ef514 | |||
23e3460853 | |||
8f9972343a | |||
4cf4efc094 | |||
65a86571d7 | |||
c92db7241e | |||
e1617585ab | |||
c7e0486528 | |||
faf25cf5a7 | |||
4e26581af6 | |||
0df7221c10 | |||
d5092e7a58 | |||
2e24c41b60 | |||
ab1b50e6a0 | |||
f2330cf965 | |||
6bfb3364db | |||
094a7ba0f0 | |||
3f588d0846 | |||
8cc384cdcb | |||
a43f56def7 | |||
000689d29d | |||
b555fd4482 | |||
1b4b1c0128 | |||
20b5d7d685 | |||
1e87b87bb9 | |||
192caba460 | |||
c20495785d | |||
359c7ec47f | |||
d325fb2505 | |||
a7b148bc96 | |||
ff2f36e88c | |||
c7b4af704d | |||
26386882f0 | |||
a4d4861ba8 | |||
34b4ccfc5f | |||
e6cebe233c | |||
d09275da0e | |||
384069ecbf | |||
e1295bdda0 | |||
70d829af6c | |||
5e8fc48bc7 | |||
b8c9dd5be5 | |||
ae979b47c0 | |||
802fd82d02 | |||
1d120cde0a | |||
15a3919ce9 | |||
f45389c1a7 | |||
8ececf8c12 | |||
3488536489 | |||
dfd7030de9 | |||
90e6ddc212 | |||
9184fe6974 | |||
8acfe27a8d | |||
a6c2df39e2 | |||
a305c5bc19 | |||
459396080b | |||
6a69798ec6 | |||
062fa5b080 | |||
a8922c5666 | |||
b45b57e0ab | |||
5e69d5c156 | |||
f6c21bf195 | |||
71c1bdcf1c | |||
8f26476c9b | |||
3158dc84f7 | |||
0872d4ff68 | |||
07b5d5238a | |||
6cc64cd59c | |||
759be564fc | |||
606722f19e | |||
f33dc4fa39 | |||
7ca3fbd439 | |||
d34324c565 | |||
b2d2df4fee | |||
9b522cb819 | |||
544cc07862 | |||
2879a0243e | |||
ffffcaee88 | |||
522652bed7 | |||
f06e1a0197 | |||
d16ef9d948 | |||
b90b0a457c | |||
6d102306df | |||
92be2998fa | |||
f150ce24d2 | |||
fbe1dae085 | |||
b515fdbe1a | |||
52db7e00ab | |||
8c024e6269 | |||
a7e78deb57 | |||
aecff98642 | |||
1ff2c759dd | |||
c7340572c9 | |||
6bbe8a83f7 | |||
b6e4f84570 | |||
bebd4e3a2e | |||
8ce6d2877c | |||
93a3ea764e | |||
6ef758653e | |||
a02ef2d6b4 | |||
4a250f30f2 | |||
f37ca487f6 | |||
0223d9d86e | |||
973bff351d | |||
fe872490d5 | |||
7154bbbbcc | |||
760b707116 | |||
e60c435fa6 | |||
fbf9424960 | |||
4a5856f614 | |||
bbc927edba | |||
86afe6a30d | |||
3ff2728466 | |||
3d5a77b732 | |||
496adee0b4 | |||
78c13c4131 | |||
c069b53636 | |||
7e7e51853d | |||
b01d143ea6 | |||
a97db36e7d | |||
52908e6627 | |||
daff686afc | |||
ed996ee7f4 | |||
ab8fb27e23 | |||
09c8cf2333 | |||
0ac3f9da8f | |||
dd9b5da394 | |||
b79936b47b |
@ -1,11 +1,15 @@
|
||||
# 页面标题
|
||||
VITE_APP_TITLE = 新能源项目管理平台
|
||||
VITE_APP_TITLE = 煤科建管平台
|
||||
|
||||
# 开发环境配置
|
||||
VITE_APP_ENV = 'development'
|
||||
|
||||
# 开发环境
|
||||
VITE_APP_BASE_API = 'http://192.168.110.119:8899'
|
||||
VITE_APP_BASE_API = 'http://192.168.110.209:8899'
|
||||
# VITE_APP_BASE_API = 'http://58.17.134.85:8899'
|
||||
# GO开发环境
|
||||
VITE_APP_BASE_API_GO = 'http://xny.yj-3d.com:7464'
|
||||
# VITE_APP_BASE_API_GO = 'http://192.168.110.188:8919'
|
||||
|
||||
# 无人机接口地址
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
# 页面标题
|
||||
VITE_APP_TITLE = 新能源项目管理平台
|
||||
VITE_APP_TITLE = 煤科建管平台
|
||||
|
||||
# 生产环境配置
|
||||
VITE_APP_ENV = 'production'
|
||||
@ -14,12 +14,14 @@ VITE_APP_MONITOR_ADMIN = '/admin/applications'
|
||||
VITE_APP_SNAILJOB_ADMIN = '/snail-job'
|
||||
|
||||
# 生产环境
|
||||
VITE_APP_BASE_API = 'http://58.17.134.85:8899'
|
||||
# GO生产环境
|
||||
VITE_APP_BASE_API_GO = 'http://58.17.134.85:7464'
|
||||
VITE_APP_BASE_API = 'http://xny.yj-3d.com:8899'
|
||||
|
||||
# 是否在打包时开启压缩,支持 gzip 和 brotli
|
||||
VITE_BUILD_COMPRESS = gzip
|
||||
|
||||
VITE_APP_PORT = 80
|
||||
VITE_APP_PORT = 8081
|
||||
|
||||
# 接口加密功能开关(如需关闭 后端也必须对应关闭)
|
||||
VITE_APP_ENCRYPT = true
|
||||
|
1
absolute/path/to/index.vue
Normal file
@ -0,0 +1 @@
|
||||
|
@ -6,7 +6,7 @@
|
||||
<meta name="renderer" content="webkit" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<title>新能源项目管理平台</title>
|
||||
<title>煤科建管平台</title>
|
||||
<!--[if lt IE 11
|
||||
]><script>
|
||||
window.location.href = '/html/ie.html';
|
||||
@ -216,8 +216,8 @@
|
||||
<script src="/webrtc/jquery-1.12.2.min.js"></script>
|
||||
<script src="/webrtc/srs.sdk.js"></script>
|
||||
|
||||
<script src="./src/assets/sdk/YJEarth.min.js"></script>
|
||||
<script src="./src/utils/reconnecting-websocket.js"></script>
|
||||
<script src="/sdk/YJEarth.min.js"></script>
|
||||
<script src="/js/reconnecting-websocket.js"></script>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -14,7 +14,7 @@
|
||||
"lint:eslint": "eslint",
|
||||
"lint:eslint:fix": "eslint --fix",
|
||||
"prettier": "prettier --write .",
|
||||
"copy-cesium": "cpy 'src/assets/sdk/Cesium/{Workers,Assets,Widgets}' ./public/Cesium --flat --parents"
|
||||
"copy-cesium": "cpy './public/sdk/Cesium/{Workers,Assets,Widgets}' ./public/Cesium --flat --parents"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -31,11 +31,14 @@
|
||||
"await-to-js": "3.0.0",
|
||||
"axios": "1.7.8",
|
||||
"crypto-js": "4.2.0",
|
||||
"date-fns": "^4.1.0",
|
||||
"diagram-js": "12.3.0",
|
||||
"didi": "9.0.2",
|
||||
"echarts": "5.5.0",
|
||||
"echarts-gl": "^2.0.9",
|
||||
"element-plus": "2.8.8",
|
||||
"esbuild": "^0.25.0",
|
||||
"exceljs": "^4.4.0",
|
||||
"ezuikit-js": "^8.1.10",
|
||||
"file-saver": "^2.0.5",
|
||||
"fuse.js": "7.0.0",
|
||||
@ -64,10 +67,12 @@
|
||||
"vue-json-pretty": "2.4.0",
|
||||
"vue-print-nb": "^1.7.5",
|
||||
"vue-router": "4.4.5",
|
||||
"vue-simple-uploader": "^1.0.3",
|
||||
"vue-types": "5.1.3",
|
||||
"vue3-print-nb": "^0.1.4",
|
||||
"vue3-scroll-seamless": "^1.0.6",
|
||||
"vxe-table": "4.5.22"
|
||||
"vxe-table": "4.5.22",
|
||||
"xlsx": "^0.18.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "9.15.0",
|
||||
|
BIN
public/assets/demo/Sunny.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
public/assets/demo/avatar.png
Normal file
After Width: | Height: | Size: 7.4 KiB |
BIN
public/assets/demo/back.png
Normal file
After Width: | Height: | Size: 46 KiB |
BIN
public/assets/demo/back2.png
Normal file
After Width: | Height: | Size: 419 KiB |
BIN
public/assets/demo/back3.png
Normal file
After Width: | Height: | Size: 344 KiB |
BIN
public/assets/demo/back4.png
Normal file
After Width: | Height: | Size: 428 KiB |
BIN
public/assets/demo/fengshu.png
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
public/assets/demo/qiangdu.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
public/assets/demo/rain.png
Normal file
After Width: | Height: | Size: 1014 B |
BIN
public/assets/demo/rain1.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
public/assets/demo/rain_show.png
Normal file
After Width: | Height: | Size: 993 B |
BIN
public/assets/demo/riluo.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
public/assets/demo/sb1.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
public/assets/demo/sb2.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
public/assets/demo/sb3.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
public/assets/demo/sb4.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
public/assets/demo/sbi1.png
Normal file
After Width: | Height: | Size: 9.5 KiB |
BIN
public/assets/demo/sbi2.png
Normal file
After Width: | Height: | Size: 107 KiB |
BIN
public/assets/demo/shidu.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
public/assets/demo/sunny_s.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
public/assets/demo/wcl.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
public/assets/demo/ycl.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
public/assets/demo/yin.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
public/assets/demo/zgjxx.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
public/assets/demo/zzcl.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
public/billOfQuantities.xlsx
Normal file
BIN
public/catalog.xlsx
Normal file
BIN
public/daolu.xlsx
Normal file
BIN
public/dikuai.xlsx
Normal file
BIN
public/enterRoad.xlsx
Normal file
Before Width: | Height: | Size: 7.9 KiB After Width: | Height: | Size: 34 KiB |
BIN
public/landBlock.xlsx
Normal file
BIN
public/materialsEquipment.xlsx
Normal file
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 131 B |
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
382
public/sdk/3rdparty/reconnecting-websocket.js
vendored
Normal file
@ -0,0 +1,382 @@
|
||||
// MIT License:
|
||||
//
|
||||
// Copyright (c) 2010-2012, Joe Walnes
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
/**
|
||||
* This behaves like a WebSocket in every way, except if it fails to connect,
|
||||
* or it gets disconnected, it will repeatedly poll until it successfully connects
|
||||
* again.
|
||||
*
|
||||
* It is API compatible, so when you have:
|
||||
* ws = new WebSocket('ws://....');
|
||||
* you can replace with:
|
||||
* ws = new ReconnectingWebSocket('ws://....');
|
||||
*
|
||||
* The event stream will typically look like:
|
||||
* onconnecting
|
||||
* onopen
|
||||
* onmessage
|
||||
* onmessage
|
||||
* onclose // lost connection
|
||||
* onconnecting
|
||||
* onopen // sometime later...
|
||||
* onmessage
|
||||
* onmessage
|
||||
* etc...
|
||||
*
|
||||
* It is API compatible with the standard WebSocket API, apart from the following members:
|
||||
*
|
||||
* - `bufferedAmount`
|
||||
* - `extensions`
|
||||
* - `binaryType`
|
||||
*
|
||||
* Latest version: https://github.com/joewalnes/reconnecting-websocket/
|
||||
* - Joe Walnes
|
||||
*
|
||||
* Syntax
|
||||
* ======
|
||||
* var socket = new ReconnectingWebSocket(url, protocols, options);
|
||||
*
|
||||
* Parameters
|
||||
* ==========
|
||||
* url - The url you are connecting to.
|
||||
* protocols - Optional string or array of protocols.
|
||||
* options - See below
|
||||
*
|
||||
* Options
|
||||
* =======
|
||||
* Options can either be passed upon instantiation or set after instantiation:
|
||||
*
|
||||
* var socket = new ReconnectingWebSocket(url, null, { debug: true, reconnectInterval: 4000 });
|
||||
*
|
||||
* or
|
||||
*
|
||||
* var socket = new ReconnectingWebSocket(url);
|
||||
* socket.debug = true;
|
||||
* socket.reconnectInterval = 4000;
|
||||
*
|
||||
* debug
|
||||
* - Whether this instance should log debug messages. Accepts true or false. Default: false.
|
||||
*
|
||||
* automaticOpen
|
||||
* - Whether or not the websocket should attempt to connect immediately upon instantiation. The socket can be manually opened or closed at any time using ws.open() and ws.close().
|
||||
*
|
||||
* reconnectInterval
|
||||
* - The number of milliseconds to delay before attempting to reconnect. Accepts integer. Default: 1000.
|
||||
*
|
||||
* maxReconnectInterval
|
||||
* - The maximum number of milliseconds to delay a reconnection attempt. Accepts integer. Default: 30000.
|
||||
*
|
||||
* reconnectDecay
|
||||
* - The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist. Accepts integer or float. Default: 1.5.
|
||||
*
|
||||
* timeoutInterval
|
||||
* - The maximum time in milliseconds to wait for a connection to succeed before closing and retrying. Accepts integer. Default: 2000.
|
||||
*
|
||||
*/
|
||||
// (function (global, factory) {
|
||||
// if (typeof define === 'function' && define.amd) {
|
||||
// define([], factory);
|
||||
// } else if (typeof module !== 'undefined' && module.exports){
|
||||
// module.exports = factory();
|
||||
// } else {
|
||||
// global.ReconnectingWebSocket = factory();
|
||||
// }
|
||||
// })(this, function () {
|
||||
//
|
||||
// if (!('WebSocket' in window)) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
function ReconnectingWebSocket(url, protocols, options) {
|
||||
|
||||
// Default settings
|
||||
var settings = {
|
||||
|
||||
/** Whether this instance should log debug messages. */
|
||||
debug: false,
|
||||
|
||||
/** Whether or not the websocket should attempt to connect immediately upon instantiation. */
|
||||
automaticOpen: true,
|
||||
|
||||
/** The number of milliseconds to delay before attempting to reconnect. */
|
||||
reconnectInterval: 1000,
|
||||
/** The maximum number of milliseconds to delay a reconnection attempt. */
|
||||
maxReconnectInterval: 30000,
|
||||
/** The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist. */
|
||||
reconnectDecay: 1.5,
|
||||
|
||||
/** The maximum time in milliseconds to wait for a connection to succeed before closing and retrying. */
|
||||
timeoutInterval: 2000,
|
||||
|
||||
/** The maximum number of reconnection attempts to make. Unlimited if null. */
|
||||
maxReconnectAttempts: null,
|
||||
|
||||
/** The binary type, possible values 'blob' or 'arraybuffer', default 'blob'. */
|
||||
binaryType: 'blob'
|
||||
}
|
||||
if (!options) {
|
||||
options = {};
|
||||
}
|
||||
|
||||
// Overwrite and define settings with options if they exist.
|
||||
for (var key in settings) {
|
||||
if (typeof options[key] !== 'undefined') {
|
||||
this[key] = options[key];
|
||||
} else {
|
||||
this[key] = settings[key];
|
||||
}
|
||||
}
|
||||
|
||||
// These should be treated as read-only properties
|
||||
|
||||
/** The URL as resolved by the constructor. This is always an absolute URL. Read only. */
|
||||
this.url = url;
|
||||
|
||||
/** The number of attempted reconnects since starting, or the last successful connection. Read only. */
|
||||
this.reconnectAttempts = 0;
|
||||
|
||||
/**
|
||||
* The current state of the connection.
|
||||
* Can be one of: WebSocket.CONNECTING, WebSocket.OPEN, WebSocket.CLOSING, WebSocket.CLOSED
|
||||
* Read only.
|
||||
*/
|
||||
this.readyState = WebSocket.CONNECTING;
|
||||
|
||||
/**
|
||||
* A string indicating the name of the sub-protocol the server selected; this will be one of
|
||||
* the strings specified in the protocols parameter when creating the WebSocket object.
|
||||
* Read only.
|
||||
*/
|
||||
this.protocol = null;
|
||||
|
||||
// Private state variables
|
||||
|
||||
var self = this;
|
||||
var ws;
|
||||
var forcedClose = false;
|
||||
var timedOut = false;
|
||||
var eventTarget = document.createElement('div');
|
||||
|
||||
// Wire up "on*" properties as event handlers
|
||||
|
||||
eventTarget.addEventListener('open', function (event) {
|
||||
self.onopen(event);
|
||||
});
|
||||
eventTarget.addEventListener('close', function (event) {
|
||||
self.onclose(event);
|
||||
});
|
||||
eventTarget.addEventListener('connecting', function (event) {
|
||||
self.onconnecting(event);
|
||||
});
|
||||
eventTarget.addEventListener('message', function (event) {
|
||||
self.onmessage(event);
|
||||
});
|
||||
eventTarget.addEventListener('error', function (event) {
|
||||
self.onerror(event);
|
||||
});
|
||||
|
||||
// Expose the API required by EventTarget
|
||||
|
||||
this.addEventListener = eventTarget.addEventListener.bind(eventTarget);
|
||||
this.removeEventListener = eventTarget.removeEventListener.bind(eventTarget);
|
||||
this.dispatchEvent = eventTarget.dispatchEvent.bind(eventTarget);
|
||||
|
||||
/**
|
||||
* This function generates an event that is compatible with standard
|
||||
* compliant browsers and IE9 - IE11
|
||||
*
|
||||
* This will prevent the error:
|
||||
* Object doesn't support this action
|
||||
*
|
||||
* http://stackoverflow.com/questions/19345392/why-arent-my-parameters-getting-passed-through-to-a-dispatched-event/19345563#19345563
|
||||
* @param s String The name that the event should use
|
||||
* @param args Object an optional object that the event will use
|
||||
*/
|
||||
function generateEvent(s, args) {
|
||||
var evt = document.createEvent("CustomEvent");
|
||||
evt.initCustomEvent(s, false, false, args);
|
||||
return evt;
|
||||
};
|
||||
|
||||
this.open = function (reconnectAttempt) {
|
||||
ws = new WebSocket(self.url, protocols || []);
|
||||
ws.binaryType = this.binaryType;
|
||||
|
||||
if (reconnectAttempt) {
|
||||
if (this.maxReconnectAttempts && this.reconnectAttempts > this.maxReconnectAttempts) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
eventTarget.dispatchEvent(generateEvent('connecting'));
|
||||
this.reconnectAttempts = 0;
|
||||
}
|
||||
|
||||
if (self.debug || ReconnectingWebSocket.debugAll) {
|
||||
console.debug('ReconnectingWebSocket', 'attempt-connect', self.url);
|
||||
}
|
||||
|
||||
var localWs = ws;
|
||||
var timeout = setTimeout(function () {
|
||||
if (self.debug || ReconnectingWebSocket.debugAll) {
|
||||
console.debug('ReconnectingWebSocket', 'connection-timeout', self.url);
|
||||
}
|
||||
timedOut = true;
|
||||
localWs.close();
|
||||
timedOut = false;
|
||||
}, self.timeoutInterval);
|
||||
|
||||
ws.onopen = function (event) {
|
||||
clearTimeout(timeout);
|
||||
if (self.debug || ReconnectingWebSocket.debugAll) {
|
||||
console.debug('ReconnectingWebSocket', 'onopen', self.url);
|
||||
}
|
||||
self.protocol = ws.protocol;
|
||||
self.readyState = WebSocket.OPEN;
|
||||
self.reconnectAttempts = 0;
|
||||
var e = generateEvent('open');
|
||||
e.isReconnect = reconnectAttempt;
|
||||
reconnectAttempt = false;
|
||||
eventTarget.dispatchEvent(e);
|
||||
};
|
||||
|
||||
ws.onclose = function (event) {
|
||||
clearTimeout(timeout);
|
||||
ws = null;
|
||||
if (forcedClose) {
|
||||
self.readyState = WebSocket.CLOSED;
|
||||
eventTarget.dispatchEvent(generateEvent('close'));
|
||||
} else {
|
||||
self.readyState = WebSocket.CONNECTING;
|
||||
var e = generateEvent('connecting');
|
||||
e.code = event.code;
|
||||
e.reason = event.reason;
|
||||
e.wasClean = event.wasClean;
|
||||
eventTarget.dispatchEvent(e);
|
||||
if (!reconnectAttempt && !timedOut) {
|
||||
if (self.debug || ReconnectingWebSocket.debugAll) {
|
||||
console.debug('ReconnectingWebSocket', 'onclose', self.url);
|
||||
}
|
||||
eventTarget.dispatchEvent(generateEvent('close'));
|
||||
}
|
||||
|
||||
var timeout = self.reconnectInterval * Math.pow(self.reconnectDecay, self.reconnectAttempts);
|
||||
setTimeout(function () {
|
||||
self.reconnectAttempts++;
|
||||
self.open(true);
|
||||
}, timeout > self.maxReconnectInterval ? self.maxReconnectInterval : timeout);
|
||||
}
|
||||
};
|
||||
ws.onmessage = function (event) {
|
||||
if (self.debug || ReconnectingWebSocket.debugAll) {
|
||||
console.debug('ReconnectingWebSocket', 'onmessage', self.url, event.data);
|
||||
}
|
||||
var e = generateEvent('message');
|
||||
e.data = event.data;
|
||||
eventTarget.dispatchEvent(e);
|
||||
};
|
||||
ws.onerror = function (event) {
|
||||
if (self.debug || ReconnectingWebSocket.debugAll) {
|
||||
console.debug('ReconnectingWebSocket', 'onerror', self.url, event);
|
||||
}
|
||||
eventTarget.dispatchEvent(generateEvent('error'));
|
||||
};
|
||||
}
|
||||
|
||||
// Whether or not to create a websocket upon instantiation
|
||||
if (this.automaticOpen == true) {
|
||||
this.open(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transmits data to the server over the WebSocket connection.
|
||||
*
|
||||
* @param data a text string, ArrayBuffer or Blob to send to the server.
|
||||
*/
|
||||
this.send = function (data) {
|
||||
if (ws) {
|
||||
if (self.debug || ReconnectingWebSocket.debugAll) {
|
||||
console.debug('ReconnectingWebSocket', 'send', self.url, data);
|
||||
}
|
||||
return ws.send(data);
|
||||
} else {
|
||||
throw 'INVALID_STATE_ERR : Pausing to reconnect websocket';
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Closes the WebSocket connection or connection attempt, if any.
|
||||
* If the connection is already CLOSED, this method does nothing.
|
||||
*/
|
||||
this.close = function (code, reason) {
|
||||
// Default CLOSE_NORMAL code
|
||||
if (typeof code == 'undefined') {
|
||||
code = 1000;
|
||||
}
|
||||
forcedClose = true;
|
||||
if (ws) {
|
||||
ws.close(code, reason);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Additional public API method to refresh the connection if still open (close, re-open).
|
||||
* For example, if the app suspects bad data / missed heart beats, it can try to refresh.
|
||||
*/
|
||||
this.refresh = function () {
|
||||
if (ws) {
|
||||
ws.close();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* An event listener to be called when the WebSocket connection's readyState changes to OPEN;
|
||||
* this indicates that the connection is ready to send and receive data.
|
||||
*/
|
||||
ReconnectingWebSocket.prototype.onopen = function (event) {
|
||||
};
|
||||
/** An event listener to be called when the WebSocket connection's readyState changes to CLOSED. */
|
||||
ReconnectingWebSocket.prototype.onclose = function (event) {
|
||||
};
|
||||
/** An event listener to be called when a connection begins being attempted. */
|
||||
ReconnectingWebSocket.prototype.onconnecting = function (event) {
|
||||
};
|
||||
/** An event listener to be called when a message is received from the server. */
|
||||
ReconnectingWebSocket.prototype.onmessage = function (event) {
|
||||
};
|
||||
/** An event listener to be called when an error occurs. */
|
||||
ReconnectingWebSocket.prototype.onerror = function (event) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Whether all instances of ReconnectingWebSocket should log debug messages.
|
||||
* Setting this to true is the equivalent of setting all instances of ReconnectingWebSocket.debug to true.
|
||||
*/
|
||||
ReconnectingWebSocket.debugAll = false;
|
||||
|
||||
ReconnectingWebSocket.CONNECTING = WebSocket.CONNECTING;
|
||||
ReconnectingWebSocket.OPEN = WebSocket.OPEN;
|
||||
ReconnectingWebSocket.CLOSING = WebSocket.CLOSING;
|
||||
ReconnectingWebSocket.CLOSED = WebSocket.CLOSED;
|
||||
|
||||
// return ReconnectingWebSocket;
|
||||
// });
|