Skip to content

Commit d201ca3

Browse files
author
潘卓然Y7000P
committed
【SDK】【修正】【补充代码规范以及代码检查】
1 parent 557d9ca commit d201ca3

7 files changed

Lines changed: 245 additions & 8 deletions

File tree

.eslintignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
./src/service/
2+
./src/config/
3+
./src/leaflet/extend/
4+
./src/openlayers/extend/
5+
./src/cesiumjs/ui/
6+
./website

.eslintrc.json

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// Use this file as a starting point for your project's .eslintrc.
2+
// Copy this file, and add rule overrides as needed.
3+
//
4+
// Window 安装方法 eslit-aribnb安装地址https://www.npmjs.com/package/eslint-config-airbnb
5+
//
6+
// Mac 安装方法 转载地址 https://blog.csdn.net/m0_37068028/article/details/78548148
7+
// (
8+
// export PKG=eslint-config-airbnb;
9+
// npm info "$PKG@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG@latest"
10+
// )
11+
// eslint + airbnb + prettier 维护代码风格
12+
// npm i eslint eslint-config-airbnb eslint-config-prettier eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-prettier babel-eslint babel-plugin-import --save-dev
13+
// 'extends': ['airbnb', 'plugin:prettier/recommended'],
14+
15+
{
16+
"extends": ["airbnb", "plugin:prettier/recommended"],
17+
// 默认情况下,ESLint 会在所有父级目录里寻找配置文件,一直到根目录。如果你想要你所有项目都遵循一个特定的约定时,这将会很有用,
18+
// 但有时候会导致意想不到的结果。为了将 ESLint 限制到一个特定的项目,在你项目根目录下的 package.json 文件或者 .eslintrc.* 文件里的
19+
// eslintConfig 字段下设置 "root": true。ESLint 一旦发现配置文件中有 "root": true,它就会停止在父级目录中寻找。
20+
"root": true,
21+
// 脚本在执行期间访问的额外的全局变量
22+
// 当访问未定义的变量时,no-undef 规则将发出警告。如果你想在一个文件里使用全局变量,推荐你定义这些全局变量,这样 ESLint 就不会发出警告了。你可以使用注释或在配置文件中定义全局变量。
23+
"globals": {
24+
"window": true,
25+
"document": true,
26+
"$": true,
27+
28+
// 可从外部导入
29+
"Cesium": "readonly"
30+
},
31+
// 设置插件
32+
// "plugins": [
33+
// 'html'
34+
// ],
35+
36+
// 设置解析器选项(必须设置这个属性)
37+
"parserOptions": {
38+
"ecmaVersion": 7,
39+
"sourceType": "module",
40+
"parser": "babel-eslint", //配置解析es6
41+
"ecmaFeatures": {
42+
"jsx": true
43+
// "arrowFunctions": true,
44+
// "experimentalObjectRestSpread": true,
45+
// "classes": true,
46+
// "modules": true,
47+
// "defaultParams": true
48+
}
49+
},
50+
// 启用的规则及各自的错误级别
51+
"rules": {
52+
// 禁止用console
53+
"no-console": 1,
54+
// 禁止用分号
55+
// "semi": [2, "never"],
56+
// "prettier/prettier": ["error", {}, { "usePrettierrc": true , "singleQuote": true, "parser": "flow" } ],
57+
// 在同一个作用域中禁止多次重复定义
58+
"no-redeclare": 1,
59+
60+
// 暂时去掉私有变量下划线的问题
61+
"no-underscore-dangle": 0,
62+
63+
// 针对 MapGIS 67 的要素修改规则 将参数的修改放开 先不搞 工作量实在太大了
64+
// 百度echarts 关键字 mapModel seriesModel
65+
"no-param-reassign": ["error", {
66+
"props": true,
67+
"ignorePropertyModificationsForRegex": ["^mapModel", "^seriesModel"]
68+
}],
69+
// 针对百度echarts原型链的处理
70+
"no-unused-vars": ["error", {
71+
"varsIgnorePattern": "[iI]gnored",
72+
"argsIgnorePattern": "^_"
73+
}]
74+
// 百度mapv源代码需要设置原型链条件,看情况放开
75+
// "no-proto" : true
76+
},
77+
// 指定你想启用的环境
78+
"env": {
79+
"browser": true,
80+
"es6": true,
81+
"node": true
82+
}
83+
}

.prettierrc.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// 执行下列两个命令,安装 eslint 和 prettier 工具
2+
// npm add --dev prettier
3+
// npm i -D eslint-plugin-prettier
4+
5+
module.exports = {
6+
// 超过最大值换行
7+
printWidth: 150,
8+
9+
// 缩进为4个空格
10+
tabWidth: 4,
11+
12+
// 不使用缩进符,而使用空格
13+
useTabs: false,
14+
15+
// 是否在语句末尾加分号
16+
semi: true,
17+
18+
// 单引号
19+
singleQuote: true,
20+
21+
// 数组 对象尾随不需要逗号
22+
trailingComma: 'none',
23+
24+
// 对象空格 { foo: bar }, false=> {foo:bar}
25+
bracketSpacing: true,
26+
27+
// jsx闭标签是否另起一行 <Test></Test>
28+
jsxBracketSameLine: true,
29+
30+
// 箭头函数,只有一个参数的时候,也需要括号
31+
arrowParens: 'always',
32+
33+
// 不需要写文件开头的 @prettier
34+
requirePragma: false,
35+
36+
// 不需要自动在文件开头插入 @prettier
37+
insertPragma: false,
38+
39+
// 使用默认的折行标准
40+
proseWrap: 'preserve',
41+
42+
// 根据显示样式决定 html 要不要折行
43+
htmlWhitespaceSensitivity: 'css',
44+
45+
// 换行符使用 lf
46+
endOfLine: 'lf'
47+
};

README.md

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[npm-img]: https://img.shields.io/badge/npm-10.5.0-brightgreen
77
[npm-url]: https://www.npmjs.com/package/@mapgis/webclient
88

9-
MapGIS Client for JavaScript:是增强的MapGIS Web开发平台,集成Openlayers、Leaflet、MapBox等框架ECharts、MapV、D3等可视化库,在传统WebGIS开发基础之上,增强大数据、实时流数据的高效可视化表达和分析,为用户带来全新开发体验。
9+
MapGIS Client for JavaScript:是增强的MapGIS Web开发平台,集成Openlayers、Leaflet、MapBox、Cesium,等框架ECharts、MapV、D3等可视化库,在传统WebGIS开发基础之上,增强大数据、实时流数据的高效可视化表达和分析,为用户带来全新开发体验。
1010

1111
<img alt="MapGIS" src="website/public/static/assets/logo/framework.png">
1212

@@ -18,6 +18,7 @@ MapGIS Client for JavaScript:是增强的MapGIS Web开发平台,集成Openla
1818
- [特性](#特性)
1919
- [示例](#示例)
2020
- [深入了解](#深入了解)
21+
- [代码结构](#代码结构)
2122
- [编译](#编译)
2223
- [问题](#问题)
2324
- [依赖](#依赖)
@@ -30,6 +31,8 @@ MapGIS Client for JavaScript:是增强的MapGIS Web开发平台,集成Openla
3031
### 司马云
3132
[MapGIS Client for Javascript](http://develop.smaryun.com:8899/)
3233

34+
> 本脚本所有的示例都在对应的演示站点有详细的说明教程
35+
3336
### github
3437
1. github是初始模板,物理上整合了leaflet,mapboxgl,cesium,openlayers, zondyclient等多个脚本,仅做技术验证&选型
3538
1. 司马云在逻辑上重构设计webclient-javascript,整合统一igserver,datastore,d3,mapv,echarts主流开源技术,基础平台长期维护
@@ -86,6 +89,27 @@ MapGIS Client for JavaScript:是增强的MapGIS Web开发平台,集成Openla
8689
</p>
8790

8891
## 深入了解
92+
### 代码结构
93+
``` text
94+
|-- WebClient-JavaSript
95+
|-- docs -- JsDoc文档生成模块
96+
|-- cdn -- 模块依赖离线cdn
97+
|-- jsdoc-config -- JsDoc的四大地图脚本的配置格式
98+
|-- templates -- JsDoc的内置模板
99+
|-- src -- sdk
100+
|-- cesiumjs -- cesium的代码结构
101+
|-- common -- 封装通用的基本类以及抽象类
102+
|-- config -- webpack 打包脚本
103+
|-- leaflet -- leaflet 代码结构
104+
|-- mapboxgl -- mapboxgl 代码结构
105+
|-- openlayers -- openlayers 代码结构
106+
|-- service -- 封装igserver服务
107+
|-- website -- 示例网站
108+
|-- express -- node服务,在一些wind2003等老机器上替代IIS
109+
|-- public -- 网页的公共路径
110+
|-- src -- 示例网页的vue代码
111+
```
112+
89113
### 编译
90114
0. 安装依赖
91115
``` sh
@@ -105,6 +129,22 @@ MapGIS Client for JavaScript:是增强的MapGIS Web开发平台,集成Openla
105129
npm run service-debug #单独编译服务调试版本
106130
npm run service-release #单独编译服务生产版本
107131
```
132+
133+
### 运行示例网页
134+
1. 进入对应的目录
135+
``` sh
136+
cd website
137+
```
138+
139+
1. 安装依赖
140+
``` sh
141+
npm install
142+
```
143+
1. 运行网页
144+
``` sh
145+
npm start
146+
```
147+
108148
### 问题
109149

110150
* [判断多边形自相交?](https://github.com/MapGIS/WebClient-JavaScript/issues/18)
@@ -118,6 +158,8 @@ MapGIS Client for JavaScript:是增强的MapGIS Web开发平台,集成Openla
118158
* [OpenLayers](https://openlayers.org/) version 5.0+
119159
* mapboxgl [1.9+]() ([CDN链接](https://www.npmjs.com/package/@mapgis/mapbox-gl))
120160
* [MapboxGL](https://www.npmjs.com/package/@mapgis/mapbox-gl) version 1.9+
161+
* cesium
162+
* [mapgis司马云pro版本-cesium]()
121163

122164

123165
## 资源
@@ -130,9 +172,13 @@ MapGIS Client for JavaScript:是增强的MapGIS Web开发平台,集成Openla
130172

131173
### 团队
132174

133-
* `service` [IGServer]()
134-
* `DataStore` [DataStore]()
135-
* `M3D` [M3D]()
175+
* 协议格式
176+
* `M3D` [M3D三维部门]()
177+
* 服务
178+
* `service` [IGServer]()
179+
* `DataStore` [DataStore]()
180+
* 前端
181+
* `技术支持` [技术支持部]()
136182

137183
### 证书
138184

package.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
"license": "Apache2",
3030
"devDependencies": {
3131
"babel-core": "^6.26.0",
32-
"babel-eslint": "^8.0.0",
32+
"babel-eslint": "^10.1.0",
3333
"babel-loader": "^7.1.2",
34+
"babel-plugin-import": "^1.13.0",
3435
"babel-plugin-transform-class-properties": "^6.11.5",
3536
"babel-plugin-transform-decorators-legacy": "^1.3.4",
3637
"babel-plugin-transform-flow-strip-types": "^6.21.0",
@@ -41,11 +42,17 @@
4142
"babel-runtime": "^6.11.6",
4243
"clean-webpack-plugin": "^0.1.18",
4344
"copy-webpack-plugin": "^4.5.1",
44-
"eslint": "^4.6.1",
45+
"eslint": "^7.4.0",
46+
"eslint-config-airbnb": "^18.2.0",
47+
"eslint-config-prettier": "^6.11.0",
4548
"eslint-loader": "^1.9.0",
46-
"eslint-plugin-import": "^2.8.0",
49+
"eslint-plugin-import": "^2.22.0",
50+
"eslint-plugin-jsx-a11y": "^6.3.1",
51+
"eslint-plugin-prettier": "^3.1.4",
52+
"eslint-plugin-react": "^7.20.3",
4753
"happypack": "^5.0.0",
4854
"json-loader": "^0.5.4",
55+
"prettier": "^2.0.5",
4956
"react-hot-loader": "^3.0.0-beta.6",
5057
"source-map-loader": "^0.2.3",
5158
"url-loader": "^0.5.9",

website/README.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,70 @@
1-
# webclient-javascript-vue
1+
# MapGIS Webclient Javascript Website
2+
23

34
## Project setup
45
```
6+
npm install
7+
# or
58
yarn install
69
```
710

811
### Compiles and hot-reloads for development
912
```
13+
npm run serve
14+
# or
1015
yarn serve
1116
```
1217

1318
### Compiles and minifies for production
1419
```
20+
npm run build
21+
# or
1522
yarn build
1623
```
1724

1825
### Lints and fixes files
1926
```
27+
npm run lint
28+
# or
2029
yarn lint
2130
```
2231

2332
### Customize configuration
2433
See [Configuration Reference](https://cli.vuejs.org/config/).
34+
35+
# express 后台运行f发布
36+
37+
1. 安装全局的express环境
38+
``` sh
39+
npm install -g express-generator@4
40+
```
41+
2. 进入对应的webclient-javascript-vue的express目录下
42+
``` sh
43+
cd path/to/website/express
44+
```
45+
3. 在express目录下新建server文件夹,并按需修改app.js中的端口
46+
``` sh
47+
express server && cd server
48+
```
49+
``` js
50+
app.listen(8899)
51+
```
52+
4. 在server目录下安装依赖
53+
``` sh
54+
npm install
55+
npm install --save node-windows
56+
npm start
57+
```
58+
5. 复制上一级中的windowserver.js到当前目录,并修改里面的路径
59+
``` js
60+
let svc = new Service({
61+
name: "WebClientTest", //服务名称
62+
description: "WebClient项目NodeJs服务器", //描述
63+
script: "path/to/webclient-javascript-vue/express/server/bin/www", //nodejs项目要启动的文件路径
64+
});
65+
```
66+
6. 启动对应的windowserver脚本,注册为windows的服务
67+
``` sh
68+
node windowserver.js
69+
```
70+
7. 在windows的服务中,启动服务,默认情况是随开机自启的

website/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "10.5.0",
44
"private": true,
55
"scripts": {
6+
"start": "npm run serve",
67
"serve": "vue-cli-service serve",
78
"build": "vue-cli-service build",
89
"lint": "vue-cli-service lint"
@@ -20,6 +21,7 @@
2021
"splitpanes": "^2.0.0",
2122
"vue": "^2.6.10",
2223
"vue-codemirror": "^4.0.6",
24+
"vue-echarts": "^5.0.0-beta.0",
2325
"vue-lazyload": "^1.3.3",
2426
"vue-markdown": "^2.2.4",
2527
"vue-router": "^3.1.3",

0 commit comments

Comments
 (0)