wgt-node-utils 0.0.29 → 0.0.32

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 CHANGED
@@ -1,92 +1,251 @@
1
1
  # wgt-node-utils
2
2
 
3
-
4
-
5
- ## Getting started
6
-
7
- To make it easy for you to get started with GitLab, here's a list of recommended next steps.
8
-
9
- Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
10
-
11
- ## Add your files
12
-
13
- - [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
14
- - [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
15
-
3
+ # 发布流程
4
+ **1、设置npm发布仓库地址为Nexus的地址**
5
+ ```sh
6
+ npm set http://172.30.10.160:8081/nexus/repository/wgt/
7
+ ```
8
+ **2、 发布包整体**
9
+ ```sh
10
+ npm publish --registry http://172.30.10.160:8081/nexus/repository/wgt/
11
+ ```
12
+ # wgt node端 公共函数库 使用方法
13
+ > 项目安装脚本
14
+ ```sh
15
+ npm install wgt-node-utils --registry http://172.30.10.160:8081/nexus/repository/npm-group
16
+ ```
17
+ ## 工具库使用
18
+ ```javascript
19
+ const wgtNodeUtils = require('wgt-node-utils');
20
+ wgtNodeUtils.getSiteByHostname(siteIdPath, req.hostname, DEFAULT_SITE_ID)
16
21
  ```
17
- cd existing_repo
18
- git remote add origin https://gitlab.yeahmobi.com/wgt/wgt-node-utils.git
19
- git branch -M main
20
- git push -uf origin main
21
- ```
22
-
23
- ## Integrate with your tools
24
-
25
- - [ ] [Set up project integrations](https://gitlab.yeahmobi.com/wgt/wgt-node-utils/-/settings/integrations)
26
-
27
- ## Collaborate with your team
28
-
29
- - [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
30
- - [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
31
- - [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
32
- - [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
33
- - [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
34
-
35
- ## Test and Deploy
36
-
37
- Use the built-in continuous integration in GitLab.
38
-
39
- - [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
40
- - [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
41
- - [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
42
- - [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
43
- - [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
44
-
45
- ***
46
-
47
- # Editing this README
48
-
49
- When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
50
-
51
- ## Suggestions for a good README
52
- Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
53
-
54
- ## Name
55
- Choose a self-explaining name for your project.
56
-
57
- ## Description
58
- Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
59
-
60
- ## Badges
61
- On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
62
-
63
- ## Visuals
64
- Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
65
-
66
- ## Installation
67
- Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
68
-
69
- ## Usage
70
- Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
71
-
72
- ## Support
73
- Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
74
-
75
- ## Roadmap
76
- If you have ideas for releases in the future, it is a good idea to list them in the README.
77
-
78
- ## Contributing
79
- State if you are open to contributions and what your requirements are for accepting them.
80
-
81
- For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
82
-
83
- You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
84
-
85
- ## Authors and acknowledgment
86
- Show your appreciation to those who have contributed to the project.
87
-
88
- ## License
89
- For open source projects, say how it is licensed.
90
-
91
- ## Project status
92
- If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
22
+ ### 工具函数说明
23
+ #### getSystem 获取系统信息
24
+ #### 使用
25
+ ```javascript
26
+ wgtNodeUtils.getSystem(userAgent)
27
+ ```
28
+ ##### 参数说明:
29
+ |参数 | 类型 | 说明 | 是否必传 | 默认值 |
30
+ |---------|--------------|-----------------------------------------------------------------------------|------|-----|
31
+ | userAgent | string | 设备的Ua信息 | 是 | -- |
32
+
33
+ #### getCloudFrontDevice 获取系统信息
34
+ #### 使用
35
+ ```javascript
36
+ wgtNodeUtils.getCloudFrontDevice(headers)
37
+ ```
38
+ ##### 参数说明:
39
+ |参数 | 类型 | 说明 | 是否必传 | 默认值 |
40
+ |---------|--------------|-----------------------------------------------------------------------------|------|-----|
41
+ | headers | object | CDN 返回的req.headers 对象 | 是 | -- |
42
+
43
+ #### getCloudFrontSystem // 获取cloud front传回的设备信息
44
+ #### 使用
45
+ ```javascript
46
+ wgtNodeUtils.getCloudFrontSystem(device)
47
+ ```
48
+ ##### 参数说明:
49
+ |参数 | 类型 | 说明 | 是否必传 | 默认值 |
50
+ |---------|--------------|-----------------------------------------------------------------------------|------|-----|
51
+ | device | string | 回传设备信息 | 是 | -- |
52
+
53
+ #### addCommonHeadersInfo // 通用头信息添加
54
+ #### 使用
55
+ ```javascript
56
+ wgtNodeUtils.addCommonHeadersInfo(res)
57
+ ```
58
+ ##### 参数说明:
59
+ |参数 | 类型 | 说明 | 是否必传 | 默认值 |
60
+ |---------|--------------|-----------------------------------------------------------------------------|------|-----|
61
+ | res | object | node端 响应 header 对象 | 是 | -- |
62
+
63
+
64
+ #### getSiteByHostname // 获取siteId 通过hostname
65
+ #### 使用方法
66
+ ```javascript
67
+ await wgtNodeUtils.getSiteByHostname(url, hostname, defaultSiteId)
68
+ ```
69
+ ##### 参数说明:
70
+ |参数 | 类型 | 说明 | 是否必传 | 默认值 |
71
+ |---------|--------------|-----------------------------------------------------------------------------|------|-----|
72
+ | url | string | 获取siteID接口地址 | 是 | -- |
73
+ | hostname | string | 网站解析域名 | 是 | -- |
74
+ | defaultSiteId | string | 网站默认siteID | 是 | -- |
75
+
76
+ #### readF2eFiles // node启动时将静态资源读取到内存中
77
+ #### 使用方法
78
+ ```javascript
79
+ await wgtNodeUtils.readF2eFiles(buildName, version, dirname, useReactRouterDom)
80
+ ```
81
+ ##### 参数说明:
82
+ |参数 | 类型 | 说明 | 是否必传 | 默认值 |
83
+ |---------|--------------|-----------------------------------------------------------------------------|------|-----|
84
+ | buildName | string | 项目打包名称 | 是 | -- |
85
+ | version | string | 项目版本号 | 是 | -- |
86
+ | dirname | string | 项目绝对地址 | 是 | -- |
87
+ | useReactRouterDom | boolean | 是否需要今天文件ReactRouterDom | 是 | false |
88
+
89
+
90
+ #### getMainDomainByHostname // 获取主域名
91
+ #### 使用
92
+ ```javascript
93
+ wgtNodeUtils.getMainDomainByHostname(hostname)
94
+ ```
95
+ ##### 参数说明:
96
+ |参数 | 类型 | 说明 | 是否必传 | 默认值 |
97
+ |---------|--------------|-----------------------------------------------------------------------------|------|-----|
98
+ | hostname | string | 网站地址 | 是 | -- |
99
+
100
+ #### appendLog // node启动时将静态资源读取到内存中
101
+ #### 使用方法
102
+ ```javascript
103
+ await wgtNodeUtils.appendLog(message, ENV, components, err)
104
+ ```
105
+ ##### 参数说明:
106
+ |参数 | 类型 | 说明 | 是否必传 | 默认值 |
107
+ |---------|--------------|-----------------------------------------------------------------------------|------|-----|
108
+ | message | string | 错误信息 | 是 | -- |
109
+ | err | string || object | 错误类型 | 否 | -- |
110
+ | ENV | string | 环境变量 | 是 | -- |
111
+ | components | string | 项目名称 | 是 | -- |
112
+
113
+ #### isEmptyObj // 验证是否空对象
114
+ #### 使用
115
+ ```javascript
116
+ wgtNodeUtils.isEmptyObj(object)
117
+ ```
118
+ ##### 参数说明:
119
+ |参数 | 类型 | 说明 | 是否必传 | 默认值 |
120
+ |---------|--------------|-----------------------------------------------------------------------------|------|-----|
121
+ | object | object | 验证对象 | 是 | -- |
122
+
123
+
124
+ #### clearGameCardListData // 用于渲染游戏卡列表,清理无用字段
125
+ #### 使用
126
+ ```javascript
127
+ wgtNodeUtils.clearGameCardListData(list)
128
+ ```
129
+ ##### 参数说明:
130
+ |参数 | 类型 | 说明 | 是否必传 | 默认值 |
131
+ |---------|--------------|-----------------------------------------------------------------------------|------|-----|
132
+ | list | array | 所需要清理的list item返回格式 | 是 | -- |
133
+ ##### 返回格式
134
+ ```javascript
135
+ return {
136
+ id: item.game_id,
137
+ icon: item.base_icon,
138
+ path: item.game_path,
139
+ name: item.game_name,
140
+ icon_video: item.icon_video,
141
+ new: item.new ? true : undefined // 将false转换为undefined, 用于节省ssr生成的文本长度
142
+ }
143
+ ```
144
+
145
+ #### clearGameData // 用于渲染游戏详情的数据,清理无用字段
146
+ #### 使用
147
+ ```javascript
148
+ wgtNodeUtils.clearGameData(list)
149
+ ```
150
+ ##### 参数说明:
151
+ |参数 | 类型 | 说明 | 是否必传 | 默认值 |
152
+ |---------|--------------|-----------------------------------------------------------------------------|------|-----|
153
+ | list | array | 所需要清理的list | 是 | -- |
154
+ ##### 返回格式
155
+ ```javascript
156
+ return {
157
+ id: item.id,
158
+ path: item.path,
159
+ icon: item.base_icon,
160
+ name: item.name
161
+ };
162
+ ```
163
+
164
+ #### clearCategoryListData // 用于渲染类型卡片列表,清理无用字段
165
+ #### 使用
166
+ ```javascript
167
+ wgtNodeUtils.clearCategoryListData(list)
168
+ ```
169
+ ##### 参数说明:
170
+ |参数 | 类型 | 说明 | 是否必传 | 默认值 |
171
+ |---------|--------------|-----------------------------------------------------------------------------|------|-----|
172
+ | list | array | 所需要清理的list | 是 | -- |
173
+ ##### 返回格式
174
+ ```javascript
175
+ return {
176
+ id: item.id,
177
+ path: item.path,
178
+ icon: item.base_icon,
179
+ name: item.name
180
+ };
181
+ ```
182
+
183
+ #### clearWalkThroughVideoListData // 用于渲染演练视频卡片的数据,清理无用字段
184
+ #### 使用
185
+ ```javascript
186
+ wgtNodeUtils.clearWalkThroughVideoListData(list)
187
+ ```
188
+ ##### 参数说明:
189
+ |参数 | 类型 | 说明 | 是否必传 | 默认值 |
190
+ |---------|--------------|-----------------------------------------------------------------------------|------|-----|
191
+ | list | array | 所需要清理的list | 是 | -- |
192
+ ##### 返回格式
193
+ ```javascript
194
+ return {
195
+ game_name: item.game_name,
196
+ game_path: item.game_path,
197
+ thumbnail: item.thumbnail,
198
+ video_id: item.video_id,
199
+ duration: item.duration
200
+ };
201
+ ```
202
+ #### getLanguageList // 获取网站语言列表
203
+ #### 使用
204
+ ```javascript
205
+ wgtNodeUtils.getLanguageList(url)
206
+ ```
207
+ ##### 参数说明:
208
+ |参数 | 类型 | 说明 | 是否必传 | 默认值 |
209
+ |---------|--------------|-----------------------------------------------------------------------------|------|-----|
210
+ | hostname | string | 网站语言请求地址 | 是 | -- |
211
+
212
+
213
+ #### checkDomainAvailability // 监测域名是否可用 以状态返回200为准 返回 boolean
214
+ #### 使用
215
+ ```javascript
216
+ wgtNodeUtils.checkDomainAvailability(url)
217
+ ```
218
+ ##### 参数说明:
219
+ |参数 | 类型 | 说明 | 是否必传 | 默认值 |
220
+ |---------|--------------|-----------------------------------------------------------------------------|------|-----|
221
+ | url | string | 需要检查域名地址 | 是 | -- |
222
+
223
+
224
+ #### ReplaceGameResources // 游戏详情页面, 游戏资源链接替换 返回字符串
225
+ #### 使用
226
+ ```javascript
227
+ await wgtNodeUtils.ReplaceGameResources(link, hostName, ENV)
228
+ ```
229
+ ##### 参数说明:
230
+ |参数 | 类型 | 说明 | 是否必传 | 默认值 |
231
+ |---------|--------------|-----------------------------------------------------------------------------|------|-----|
232
+ | link | string | 需要检查域名地址 | 是 | -- |
233
+ | hostName | string | 需要检查域名地址 | 是 | -- |
234
+ | ENV | string | 需要检查域名地址 | 是 | -- |
235
+
236
+
237
+ #### getModelF2eFiles // 获取前端静态资源列表
238
+ #### 使用
239
+ ```javascript
240
+ await wgtNodeUtils.(pageName, isMobile, useReactRouterDom = false)
241
+ ```
242
+ ##### 参数说明:
243
+ |参数 | 类型 | 说明 | 是否必传 | 默认值 |
244
+ |---------|--------------|-----------------------------------------------------------------------------|------|-----|
245
+ | pageName | string | 静态页面文件名称 | 是 | -- |
246
+ | isMobile | boolean | 是否为手机设备 | 是 | -- |
247
+ | useReactRouterDom | boolean | 是否需要ReactRouterDom | 是 | -- |
248
+
249
+
250
+
251
+