Skip to content

Commit 90f4f44

Browse files
committed
ADD: init
1 parent 3d0299b commit 90f4f44

File tree

260 files changed

+39050
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

260 files changed

+39050
-0
lines changed

.browserslistrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
> 1%
2+
last 2 versions
3+
not ie <= 8

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[*]
2+
charset = utf-8
3+
indent_style = space
4+
5+
[*.{js,jsx,ts,tsx,vue}]
6+
indent_style = space
7+
indent_size = 2
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true

.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
VUE_APP_HOST=
2+
VUE_APP_MN_CONFIG_PREFIX=/api/rest_j/v1/
3+
VUE_APP_MN_CONFIG_SOCKET=/ws/api/entrance/connect

.eslintrc.js

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
node: true
5+
},
6+
'extends': [
7+
'plugin:vue/essential',
8+
'@vue/standard'
9+
],
10+
rules: {
11+
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
12+
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
13+
'key-spacing': ['error'],
14+
'keyword-spacing': ['error'],
15+
'standard/no-callback-literal': 0,
16+
'handle-callback-err': 0,
17+
'no-return-assign': 0,
18+
'eqeqeq': 0,
19+
'comma-dangle': 0,
20+
'semi': 0,
21+
'space-before-function-paren': 0,
22+
'keyword-spacing': 0,
23+
'no-useless-escape': 0,
24+
'no-invalid-this': 0,
25+
'operator-linebreak': 0,
26+
'indent': [
27+
'error',
28+
4,
29+
{
30+
'SwitchCase': 1
31+
}
32+
],
33+
'no-const-assign': 'warn',
34+
'no-this-before-super': 'warn',
35+
'no-undef': 2,
36+
'no-unreachable': 'warn',
37+
'no-unused-vars': 'warn',
38+
'constructor-super': 'warn',
39+
'valid-typeof': 'warn',
40+
'one-var': 'warn',
41+
'max-len': 'off',
42+
'no-trailing-spaces': 'off',
43+
'require-jsdoc': 'warn',
44+
'camelcase': 'warn',
45+
'no-invalid-this': 'warn',
46+
'linebreak-style': 0,
47+
'vue/no-parsing-error': [2, {
48+
'x-invalid-end-tag': false,
49+
'invalid-first-character-of-tag-name': false
50+
}],
51+
'no-tabs': 0,
52+
'vue/html-indent': [2, 2, {
53+
'attribute': 1,
54+
'closeBracket': 0,
55+
'alignAttributesVertically': false
56+
}],
57+
'vue/require-default-prop': 0,
58+
'vue/component-name-in-template-casing': 0,
59+
'vue/html-closing-bracket-spacing': 0,
60+
'vue/html-closing-bracket-newline': 0,
61+
'vue/singleline-html-element-content-newline': 0,
62+
'vue/multiline-html-element-content-newline': 0,
63+
'vue/attributes-order': 0,
64+
'vue/html-self-closing': 0
65+
},
66+
parserOptions: {
67+
parser: 'babel-eslint'
68+
}
69+
}

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* text=auto
2+
* text eol=lf
3+
*.png binary
4+
*.gif binary

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.DS_Store
2+
.vscode
3+
.cache
4+
.idea/
5+
6+
node_modules/
7+
dist/
8+
9+
.package-lock.json
10+
.env.development

READMe.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
## 目录结构
2+
app
3+
├── assets
4+
│   ├── iconfont // 字体文件,图标
5+
│   ├── images // views用到的图片
6+
│ └── styles // 样式
7+
│ ├── variables.scss // 定义样式变量,保证页面的统一风格
8+
│ ├── iconfont.scss // 图标样式
9+
│ ├── app.scss // 整理布局、公共样式
10+
│ └── xxx.scss // 路由(views目录下)页面的样式
11+
├── js
12+
│   ├── component // 组件:不能包含业务逻辑
13+
│ │ ├── index.js // 组件库入口,插件化写法,组件命令为we-xxx
14+
│ │ └── xxx // 组件xxx
15+
│ │ ├── index.js // 组件xxx的入口文件
16+
│ │ ├── index.vue // 组件xxx的vue文件
17+
│ │ └── index.scss // 组件xxx的样式,需@import(variables.scss)
18+
│   ├── helper // 类似工具函数,跟业务逻辑没啥关系,比工具函数大一点
19+
│   ├── module // 模块
20+
│ │ ├── index.js // 模块入口文件
21+
│ │ ├── moduleMixin.js // 模块配置文件处理、模块间通讯核心逻辑
22+
│ │ └── xxx // 模块xxx
23+
│ │ ├── index.js // 模块xxx的配置
24+
│ │ ├── index.vue // 模块xxx的vue文件
25+
│ │ └── index.scss // 模块xxx的样式,需@import(variables.scss)
26+
│   ├── service // 服务
27+
│ │ ├── db // 包含各种写IndexDB的逻辑
28+
│ │ ├── api.js // 访问接口的ajax封装
29+
│ │ ├── mixin.js // 全局的mixin
30+
│ │ ├── router.js // 路由配置
31+
│ │ └── router.js // socket封装
32+
│   ├── utils // 工具函数
33+
│   ├── view // 页面视图
34+
│ │ ├── app.vue // 根路由视图
35+
│ │ ├── layout.vue // 登录进去的页面的路由视图
36+
│ │ ├── xxx.vue // xxx页面
37+
│ │ ├── router.js // 路由配置
38+
│ │ └── router.js // socket封装
39+
│   └── app.js // webpack入口文件
40+
├── tpls
41+
│  └── index.html // 入口html模板
42+
├── mumble.json // CLI工具mn2的配置文件
43+
├── webpack.base.js // webpack的基础配置
44+
├── webpack.dev.js // 执行`mn2 dev`命令的webpack配置
45+
└── webpack.prod.js // 执行`mn2 gen`命令的webpack配置
46+
47+
## 模块
48+
模块应该是独立的,跟外界无耦合的。内部由业务组件和UI组件组成,组件之间共享统一状态容器。模块和模块之间通过事件机制来交互。
49+
50+
### 配置
51+
```js
52+
// import index from './index.vue';
53+
export default {
54+
// 模块名称
55+
name: 'Demo',
56+
// 规范模块监测什么事件,或者说模块对外提供什么接口
57+
events: ['Demo:add'],
58+
// 规范模块能够触发其他模块什么事件或者说调用其他模块什么接口
59+
dispatchs: ['OtherModule:add', 'OtherModule:delete'],
60+
// 规范模块的动作,由外部调用或者自己执行
61+
methods: {
62+
showTree(arg, cb) {
63+
console.log(arg);
64+
},
65+
},
66+
// 模块内部组件统一的状态容器
67+
data() {
68+
return {};
69+
},
70+
// 规范模块对外提供的组件
71+
components: {
72+
index: () => import('./index.vue'),
73+
},
74+
};
75+
```
76+
77+
### 规范
78+
1. 模块首字母大写
79+
2. event定义的事件名称必须是 模块名:事件名
80+
3. index.scss需@import(variables.scss),保证风格的统一
81+
4. 模块不能依赖其他模块,只能使用this.dispatch调用其他模块接口
82+
83+
### events 和 methods 的差别
84+
events里面定义的事件是在模块里的组件created时才加入监听者队列,而methods定义的事件是js被加载就会加入监听者队列。methods里面提供的接口,应该是跟视图无关的,大多是请求数据。
85+
86+
87+
## 页面
88+
模块和ui组件组装起来就是页面,需要在router中添加路由配置
89+
90+
### 规范
91+
1. 页面的根dom样式为xxx-page
92+
2. index.scss需@import(variables.scss),保证风格的统一
93+

babel.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
presets: [
3+
'@vue/app'
4+
]
5+
}

mock.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module.exports = function (app, Mock) {
2+
}

package.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"name": "dws",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"serve": "vue-cli-service serve",
7+
"build": "vue-cli-service build",
8+
"lint": "vue-cli-service lint",
9+
"fix": "eslint --ext .js,.vue src --fix"
10+
},
11+
"dependencies": {
12+
"axios": "^0.16.2",
13+
"babel-polyfill": "^6.26.0",
14+
"core-js": "^2.6.5",
15+
"dexie": "^2.0.4",
16+
"dt-sql-parser": "^1.1.10",
17+
"highlight.js": "^9.12.0",
18+
"iview": "^3.4.1",
19+
"lodash": "^4.17.10",
20+
"md5": "^2.2.1",
21+
"mitt": "^1.1.3",
22+
"moment": "^2.22.2",
23+
"monaco-editor": "^0.15.1",
24+
"reconnecting-websocket": "^4.1.10",
25+
"sql-formatter": "^2.1.0",
26+
"vue": "^2.6.6",
27+
"vue-router": "^3.0.1",
28+
"vuescroll": "^4.10.5"
29+
},
30+
"devDependencies": {
31+
"@vue/cli-plugin-babel": "^3.8.0",
32+
"@vue/cli-plugin-eslint": "^3.8.0",
33+
"@vue/cli-service": "^3.8.0",
34+
"@vue/eslint-config-standard": "^4.0.0",
35+
"babel-eslint": "^10.0.1",
36+
"copy-webpack-plugin": "^4.5.2",
37+
"eslint": "^5.16.0",
38+
"eslint-config-google": "^0.13.0",
39+
"eslint-plugin-prettier": "^3.1.0",
40+
"eslint-plugin-vue": "^5.0.0",
41+
"monaco-editor-webpack-plugin": "^1.7.0",
42+
"node-sass": "^4.9.0",
43+
"sass-loader": "^7.1.0",
44+
"vue-cli-plugin-mockjs": "^0.1.3",
45+
"vue-template-compiler": "^2.6.10"
46+
}
47+
}

0 commit comments

Comments
 (0)