Skip to content

Commit 17b5f9f

Browse files
committed
初始提交
0 parents  commit 17b5f9f

37 files changed

+8872
-0
lines changed

.DS_Store

6 KB
Binary file not shown.

.dockerignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.git
2+
node_modules
3+
npm-debug.log
4+
dist

.editorconfig

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_size = 2
6+
indent_style = space
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false

.eslintrc.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
browser: true,
5+
node: true
6+
},
7+
parserOptions: {
8+
parser: 'babel-eslint'
9+
},
10+
extends: [
11+
// https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
12+
// consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
13+
'plugin:vue/essential'
14+
],
15+
// required to lint *.vue files
16+
plugins: ['vue'],
17+
// add your custom rules here
18+
rules: {}
19+
}

.gitignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# dependencies
2+
node_modules
3+
4+
# logs
5+
npm-debug.log
6+
7+
# Nuxt build
8+
.nuxt
9+
10+
# Nuxt generate
11+
dist
12+
13+
# IDEA
14+
.idea

.npmignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
.nuxt
3+
dist

.prettierrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
semi: false
2+
singleQuote: true
3+
bracketSpacing: false

Dockerfile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM node:10.1.0
2+
COPY . /app
3+
WORKDIR /app
4+
RUN npm install --registry=https://registry.npm.taobao.org
5+
EXPOSE 3333
6+
CMD npm run build && npm run start

README.md

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# nuxt2 + element dashboard
2+
3+
## Build Setup
4+
5+
```bash
6+
# install dependencies
7+
$ npm install # Or yarn install
8+
9+
# serve with hot reload at localhost:3000
10+
# using mock api
11+
$ npm run dev
12+
13+
# using backend api
14+
$ npm run test
15+
16+
# build for production and launch server
17+
$ npm run build && npm start
18+
```
19+
20+
## deploy
21+
22+
support node/docker/now
23+
24+
### node
25+
26+
run nodejs in your server
27+
28+
```bash
29+
$ ./nohup.sh
30+
```
31+
32+
### docker
33+
34+
run docker in your server
35+
36+
```bash
37+
$ ./start.sh
38+
```
39+
40+
### now
41+
42+
deploy to now
43+
44+
```bash
45+
$ npm run deploy
46+
```
47+
48+
For detailed explanation on how things work, checkout the [Nuxt.js docs](https://github.com/nuxt/nuxt.js).
49+
50+
## 测试
51+
52+
项目默认添加了测试命令, 但是未安装测试依赖, 如果想使用 e2e 测试请先安装依赖
53+
54+
```shell
55+
npm i --save-dev nuxt-puppeteer-jest
56+
```
57+
58+
本项目测试默认集成了 **Jest****Puppeteer**, 对于该工具使用可参考
59+
60+
[Jest api doc](https://facebook.github.io/jest/docs/en/api.html)
61+
[Puppeteer doc](https://github.com/GoogleChrome/puppeteer)
62+
63+
安装后可以输入以下命令, 默认运行 test 目录下的 `*.test.js` 文件
64+
65+
```shell
66+
npm run test:e2e
67+
```
68+
69+
[nuxt-puppeteer-jest 的使用说明文档](https://github.com/PepperYan/nuxt-jest-puppeteer)
70+
71+
在项目 test 目录中, 预留一个 test demo, 可以查看 `test/login.test.js` 并尝试实现自己的测试用例.
72+
73+
## code style
74+
75+
when you npm i or yarn, prettier has already installed
76+
77+
the configuration file is .prettierrc
78+
79+
Pre-commit Hook use [pretty-quick](https://github.com/azz/pretty-quick), maybe commit in terminal will be better, in IDE
80+
like webstorm it may get confused behavior😕

doc/dev.md

+153
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
## 合作约定
2+
3+
### 背景
4+
5+
小组成员分工合作时, 每个人独立完成自己的页面, 但页面之间有可能有一定的关联性, 为提高代码可维护性, 降低合作成本, 故有产生了合作约定
6+
7+
### git 分支协作
8+
9+
### data-table generator
10+
11+
**忽略导出 datatable 的 TODO 和注释**
12+
13+
导出的.vue 文件目前能节省 50%以上的重复工作量, 可以尽情使用。
14+
15+
使用步骤:
16+
17+
1. 生成.vue 文件
18+
1. 拷贝至项目 pages 目录下的相应位置
19+
1. git add xxx
20+
1. git commit -m 'init xxx' (完成后, 则会使用 prettier 格式化代码)
21+
1. 进行二次开发
22+
23+
### query
24+
25+
页面之间通过 query 传参时, 后台 post/put 接口字段名是啥, query 就传啥。 如修改项目接口需要传一个字段为`projectId`, 则 query 为`{projectId: 1}`
26+
27+
也即, 往下个页面传 query 时, query 字段叫啥, 需要了解下个页面的请求接口, 所以:
28+
29+
1. 要么与后一个页面的开发人员协商讨论
30+
2. 要么关注后一个页面的接口
31+
32+
这也是要求分工合作之后, 还要有能与上下游协调作战的能力, 不然自己只会成为螺丝钉, 非常危险。
33+
34+
## data-table 相关
35+
36+
### 表头
37+
38+
表头不要换行, 通过设置 columns 的 `minWidth`, 让表头能在一行显示。不要设置`width`,大屏下展示不友好
39+
40+
### 操作列
41+
42+
目的:按钮不换行
43+
44+
约定:使用 el-button, 每个按钮文字为两个中文字符,size 为 small 的情况
45+
46+
1. 3 个按钮的操作列 width=210px
47+
2. 2 个按钮的操作列 width=144px
48+
3. 1 个按钮的操作列不设置宽度
49+
50+
对于操作列操作按钮根据条件显示与隐藏的,以展示所有按钮、不换行的宽度为准。
51+
52+
使用 extraButtons button 的点击回调从 onClick 修改为 atClick(因为 onClick 在被绑定到 dom 上时,点击会被执行)
53+
54+
### 时间
55+
56+
通过设置 columns 的 `width`, 让时间保留在一行, 不要换行
57+
58+
另外时间格式化时注意精确度, 详见后面的时间格式化说明
59+
60+
### border 与 居中
61+
62+
默认不用 border, 文字居左, 也即默认样式, 无特别说明, 一般不需要注入 table 属性
63+
64+
### 操作列按钮样式
65+
66+
默认第一个按钮`type``primary`
67+
68+
### 统一 button 尺寸
69+
70+
做一个精致的程序员 在 data-table 的 button 使用 size 为 small 的 button 显得精致一点 💄
71+
72+
```
73+
<el-button size="small"></el-button>
74+
```
75+
76+
dialog 的取消确定按钮 也是 small
77+
78+
查询按钮还是默认大小
79+
80+
### 空值
81+
82+
table 里空值就显示空白, 不需要显示占位符 `-`
83+
84+
所以不需要 formatter = v => v || '-'
85+
86+
### 从外部注入新的值
87+
88+
例如 我在使用<data-table> 新增的时候, 需要加上 projectId, 而 projectId 是一个存放在 query 的值假定 projectId 为 8
89+
这时候, 我们希望从外部传递一个 `projectId: 8` 到 data-table
90+
可以使用 extraParams 参数使用参考如下:
91+
92+
```vue
93+
<data-table
94+
ref="dataTable"
95+
:data="list"
96+
:columns="columns"
97+
:config="config"
98+
noPagination
99+
:form="form"
100+
:extraParams="extraParams"
101+
>
102+
</data-table>
103+
<script>
104+
export default () {
105+
data() {
106+
return (
107+
extraParams: {
108+
projectId: 8
109+
}
110+
)
111+
}
112+
}
113+
114+
</script>
115+
```
116+
117+
### 统一 footer 样式 .data-table-footer
118+
119+
已写在 /assets/global.styl 可直接使用
120+
121+
```stylus
122+
.data-table-footer
123+
margin-top 24px
124+
text-align right
125+
```
126+
127+
## form 表单
128+
129+
label 右对齐(element 默认就是如此), 不需要添加冒号 `:`
130+
131+
## 时间组件起止中间使用 -
132+
133+
注意 时间起止日期,如果被 clear 了,返回的值是 null,不是[]
134+
例如:
135+
136+
```vue
137+
<el-date-picker
138+
v-model="time"
139+
:clearable="false"
140+
type="daterange"
141+
range-separator="-"
142+
start-placeholder="开始日期"
143+
end-placeholder="结束日期"
144+
value-format="yyyy-MM-dd">
145+
</el-date-picker>
146+
```
147+
148+
## 时间格式化
149+
150+
一般而言
151+
152+
1. 选择时间范围, “叫做选择日期”, 那么时间控件格式是精确到**日期**
153+
2. 在后台管理系统, 一般文字叫“时间”的, 对应格式是精确到****

nohup.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# !/bin/sh
2+
n=`ps aux | grep node | awk '{print $2}' | sed -n '2p'`
3+
kill -9 $n
4+
git pull
5+
npm run build
6+
nohup npm run start &

0 commit comments

Comments
 (0)