koishi-plugin-tmp-bot 1.3.2 → 1.3.4

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.
@@ -4,6 +4,7 @@ const guildBind = require('../database/guildBind')
4
4
  const truckyAppApi = require('../api/truckyAppApi')
5
5
  const truckersMpApi = require('../api/truckersMpApi')
6
6
  const baiduTranslate = require('../util/baiduTranslate')
7
+ const common = require('../util/common')
7
8
 
8
9
  /**
9
10
  * 定位
@@ -54,6 +55,7 @@ module.exports = async (ctx, cfg, session, tmpId) => {
54
55
  await page.setViewport({ width: 1000, height: 1000 })
55
56
  await page.goto(`file:///${resolve(__dirname, '../resource/position.html')}`)
56
57
  await page.evaluate(`setData(${JSON.stringify(data)})`)
58
+ await common.sleep(100)
57
59
  await page.waitForNetworkIdle()
58
60
  const element = await page.$("#container");
59
61
  return (
@@ -62,7 +64,6 @@ module.exports = async (ctx, cfg, session, tmpId) => {
62
64
  }), "image/jpg")
63
65
  )
64
66
  } catch (e) {
65
- console.info(e)
66
67
  return '渲染异常,请重试'
67
68
  } finally {
68
69
  if (page) {
@@ -10,9 +10,12 @@
10
10
  margin: 0;
11
11
  padding: 0;
12
12
  }
13
+ * {
14
+ font-family: "微软雅黑", serif;
15
+ }
13
16
  #container {
14
- width: 380px;
15
- height: 260px;
17
+ width: 500px;
18
+ height: 320px;
16
19
  position: relative;
17
20
  }
18
21
  .map {
@@ -22,7 +25,7 @@
22
25
  }
23
26
  .user-info-box {
24
27
  width: 100%;
25
- height: 58px;
28
+ height: 76px;
26
29
  position: absolute;
27
30
  bottom: 0;
28
31
  z-index: 999;
@@ -31,20 +34,23 @@
31
34
  display: flex;
32
35
  flex-direction: row;
33
36
  align-items: center;
34
- padding: 0 12px;
37
+ padding: 0 14px;
35
38
  box-sizing: border-box;
36
39
  }
37
40
  .avatar {
38
- width: 40px;
39
- height: 40px;
41
+ width: 56px;
42
+ height: 56px;
40
43
  border-radius: 4px;
41
44
  }
42
45
  .user {
43
- height: 40px;
44
- width: 180px;
46
+ height: 56px;
47
+ width: 220px;
48
+ display: flex;
49
+ flex-direction: column;
50
+ justify-content: center;
45
51
  }
46
52
  .user {
47
- font-size: 14px;
53
+ font-size: 16px;
48
54
  color: #eeeeee;
49
55
  margin-left: 10px;
50
56
  box-sizing: border-box;
@@ -52,6 +58,7 @@
52
58
  .user .server-name-box {
53
59
  display: flex;
54
60
  align-items: center;
61
+ margin-top: 4px;
55
62
  }
56
63
  .user .username {
57
64
  white-space: nowrap;
@@ -70,15 +77,18 @@
70
77
  .location-box {
71
78
  flex-grow: 1;
72
79
  color: #eeeeee;
73
- font-size: 14px;
74
- height: 40px;
80
+ font-size: 16px;
81
+ height: 56px;
75
82
  box-sizing: border-box;
76
83
  border-right: 4px solid #54d354;
77
84
  text-align: right;
78
85
  padding-right: 6px;
86
+ display: flex;
87
+ flex-direction: column;
88
+ justify-content: center;
79
89
  }
80
90
  .location-box>* {
81
- width: 116px;
91
+ width: 174px;
82
92
  white-space: nowrap;
83
93
  overflow: hidden;
84
94
  text-overflow: ellipsis;
@@ -92,25 +102,17 @@
92
102
  <img class="avatar" src="https://static.truckersmp.com/avatarsN/small/defaultavatar.png"/>
93
103
  <div class="user">
94
104
  <div class="username">...</div>
95
- <div class="server-name-box">
105
+ <div class="server-name-box" style="margin-top: 4px">
96
106
  <span class="server-name">...</span>游戏中
97
107
  </div>
98
108
  </div>
99
109
  <div class="location-box">
100
110
  <div class="country">...</div>
101
- <div class="real-name">...</div>
111
+ <div class="real-name" style="margin-top: 4px">...</div>
102
112
  </div>
103
113
  </div>
104
114
  </div>
105
115
  <script>
106
- // a: https://static.truckersmp.com/avatarsN/defaultavatar.png
107
- // sa: https://static.truckersmp.com/avatarsN/small/defaultavatar.png
108
- // name: Damien12345
109
- // x: -13426
110
- // y: -5998
111
- // serverName: Simulation 1
112
- // country: Germany
113
- // realName: Duisburg
114
116
  let multipliers = {
115
117
  x: 71292,
116
118
  y: 60412
@@ -132,7 +134,7 @@
132
134
 
133
135
  // 定义地图
134
136
  let map = L.map('map', {
135
- attributionControl: false, // 去除右下角的 leaflet 标识
137
+ attributionControl: false,
136
138
  crs: L.CRS.Simple,
137
139
  zoomControl: false
138
140
  });
@@ -166,16 +168,16 @@
166
168
  document.getElementsByClassName('country')[0].innerText = data.country
167
169
  document.getElementsByClassName('real-name')[0].innerText = data.realName
168
170
 
169
- let mapCoordinate = map.unproject(calculateMapCoordinate(data.x, data.y), 8)
170
- L.circleMarker(mapCoordinate, {
171
- color: '#3e9edc', // 标记点边框颜色
172
- fillColor: '#3e9edc', // 标记点填充颜色
173
- fillOpacity: 1, // 标记点填充不透明度(0到1之间的值)
174
- radius: 6 // 标记点半径(以像素为单位)
171
+ L.circleMarker(map.unproject(calculateMapCoordinate(data.x, data.y), 8), {
172
+ color: '#2f2f2f', // 标记点边框颜色
173
+ weight: 2, // 标记点边框大小
174
+ fillColor: '#158cfb', // 标记点填充颜色
175
+ fillOpacity: 1, // 标记点填充不透明度(0到1之间的值)
176
+ radius: 6 // 标记点半径(以像素为单位)
175
177
  }).addTo(map);
176
178
 
177
- // 移动地图到坐标
178
- map.setView(mapCoordinate, 7);
179
+ // 移动地图到坐标,视角稍微向上移动
180
+ map.setView(map.unproject(calculateMapCoordinate(data.x, data.y + 80), 8), 7);
179
181
  }
180
182
  </script>
181
183
  </body>
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ sleep (ms) {
3
+ return new Promise(resolve => setTimeout(resolve, ms));
4
+ }
5
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-tmp-bot",
3
3
  "description": "欧洲卡车模拟2 TMP查询机器人",
4
- "version": "1.3.2",
4
+ "version": "1.3.4",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [