Skip to content

Commit

Permalink
update version step1
Browse files Browse the repository at this point in the history
  • Loading branch information
changzhn committed Aug 20, 2020
1 parent b6098e7 commit a3de126
Show file tree
Hide file tree
Showing 160 changed files with 3,532 additions and 2,367 deletions.
Empty file modified .editorconfig
100755 → 100644
Empty file.
2 changes: 0 additions & 2 deletions .env

This file was deleted.

4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/lambda/
/scripts
/config
.history
3 changes: 0 additions & 3 deletions .eslintrc

This file was deleted.

8 changes: 8 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
extends: [require.resolve('@umijs/fabric/dist/eslint')],
globals: {
ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: true,
page: true,
REACT_APP_ENV: true,
},
};
32 changes: 27 additions & 5 deletions .gitignore
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,18 +1,40 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/npm-debug.log*
/yarn-error.log
/yarn.lock
/package-lock.json
**/node_modules
# roadhog-api-doc ignore
/src/utils/request-temp.js
_roadhog-api-doc

# production
/dist
/.vscode

# misc
.DS_Store
npm-debug.log*
yarn-error.log

/coverage
.idea
yarn.lock
package-lock.json
*bak
.vscode

# visual studio code
.history
*.log
functions/*
.temp/**

# umi
.umi
.umi-production

# screenshot
screenshot
.firebase
.eslintcache

build
21 changes: 18 additions & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
**/*.md
**/*.svg
**/*.ejs
**/*.html
package.json
.umi
.umi-production
/dist
.dockerignore
.DS_Store
.eslintignore
*.png
*.toml
docker
.editorconfig
Dockerfile*
.gitignore
.prettierignore
LICENSE
.eslintcache
*.lock
yarn-error.log
.history
CNAME
/build
11 changes: 0 additions & 11 deletions .prettierrc

This file was deleted.

5 changes: 5 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const fabric = require('@umijs/fabric');

module.exports = {
...fabric.prettier,
};
5 changes: 5 additions & 0 deletions .stylelintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const fabric = require('@umijs/fabric');

module.exports = {
...fabric.stylelint,
};
31 changes: 0 additions & 31 deletions .umirc.ts

This file was deleted.

21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

163 changes: 43 additions & 120 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,134 +1,57 @@
# 答题卡的在线生成器
# Ant Design Pro

```shell
cd answer-card
This project is initialized with [Ant Design Pro](https://pro.ant.design). Follow is the quick guide for how to use.

## Environment Prepare

Install `node_modules`:

```bash
npm install
```

or

```bash
yarn
yarn start
```

## Provided Scripts

# test
yarn run test
Ant Design Pro provides some useful script to help you quick start and build with web project, code style check and test.

# build
yarn run build
Scripts provided in `package.json`. It's safe to modify or add additional script:

### Start project

```bash
npm start
```

## 想实现的功能:
1. 支持多种标准纸型如A4/A3/B5,最后会支持自定义纸张尺寸;
2. 支持考号区域的手填和贴码两种方式;
3. 支持选择题,包括分组、自定义选项功能;
4. 支持填空题,包括自定义高度、自定义多行一题功能;
5. 支持解答题,包括自定义高度、插入富文本功能;
6. ~~支持中文方格作文题~~
7. 支持英文横线作文题;

## 设计标准
![img](./public/design.png)

paper type|actual width|actual height|content width|content height
----------|------------|-------------|-------------|--------------
A4 |210mm |297mm |190mm |277mm

说明:
- 标准纸型的实现物理尺寸是确实的,比如A4纸张是21mmx297mm,实际使用的内容区域是物理尺寸每边向内缩进了10mm,则计算出A4纸的内容区域是190mmx277mm;
- 同时为扫描端提供了左上、右上、左下3个定位点,每个定位点的尺寸是5mmx5mm,则扫描切图的尺寸是200mmx287mm;
- 所有尺寸标注的原点为TODO:待定,理论上使用纸张的左上角或者左上角定位点都可以,后续需要看哪个计算方便(使用纸纸左上角时,扫描后需要进行转换);
- 所有尺寸的标注为4个值:x、y、w、h分别代表了距原点的偏移值和自身的宽高;

### 标题
![img](./public/title.png)
- 标题的高度一致为8mm并且不换行(理论上大题说明一行搞定);
- 标题涉及到分页时,一律放到下页;
<br />

[代码路径](https://github.com/Joo-fanChang/answer-card/blob/0.0.1/src/tools/QuestionClasses/TitleClass.ts#L18)

```typescript
public splitSelf(currentPage: PageClass) {
const nextQuestion = this;
return {
currentPage,
nextQuestion,
}
}
### Build project

```bash
npm run build
```

### 解答题
![img](./public/answerQuestion.png)
- 宽度为纸型栏位的宽度,高度可以设置和自由调整;
- 涉及分页时,依次递减上页可以高度;
<br />

[代码路径](https://github.com/Joo-fanChang/answer-card/blob/0.0.1/src/tools/QuestionClasses/AnswerQuestionClass.ts#L21)

```typescript
public splitSelf(currentPage: PageClass) {
const delta = this.requiredHeight - currentPage.availableHeight;
this.requiredHeight = currentPage.availableHeight;
let nextQuestion = null;

if (delta >= 10) { // 下页不足10mm时,省略掉
nextQuestion = new AnswerQuestionClass(this.question, delta);
nextQuestion.partNo = this.partNo + 1;
}
currentPage.components.push(this);
return {
currentPage,
nextQuestion,
}
}
### Check code style

```bash
npm run lint
```

### 中文作文题
![img](./public/essay.png)
- 中文方格标准为8mmx8mm,两行之间间隔为2.5mm,最后一行不带间隔;
- 每逢整百有标记;
- 分页时剩余格子数 = 总格子数 - 上页容纳格子数;
<br />

[代码路径](https://github.com/Joo-fanChang/answer-card/blob/0.0.1/src/tools/QuestionClasses/EssayQuestionClass.ts#L37)

```typescript
public splitSelf(currentPage: PageClass) {
this.rows = Math.floor((currentPage.availableHeight - 10) / (8 + 2.5));
const restLength = this.restLength - this.rows * this.lenPerRow;
const nextQuestion = new EssayQuestionClass(this.question, this.paperType, restLength);
nextQuestion.partNo = this.partNo + 1;
nextQuestion.prevRows = this.prevRows + this.rows;
currentPage.components.push(this);
return {
currentPage,
nextQuestion,
}
}
You can also use script to auto fix some lint error:

```bash
npm run lint:fix
```

### 选择题
```typescript
public splitSelf(currentPage: PageClass) {
const { contentHeight, availableHeight } = currentPage;
let splitIdx = 0;
let totalHeight = 0;

for(let i = 0; i < this.groupRows.length; i++) {
totalHeight += this.groupRows[i].height;
if (totalHeight > availableHeight) {
splitIdx = i;
break;
}
}

const currentGroupRows = this.groupRows.slice(0, splitIdx);
const nextGroupRows = this.groupRows.slice(splitIdx);
this.groupRows = currentGroupRows;
this.offsetY = contentHeight - availableHeight;
currentPage.addComponents(this);
const nextQuestion = new ChoiceQuestionCLass(this.question, this.paperType, nextGroupRows);
return {
currentPage,
nextQuestion,
}
}
### Test code

```bash
npm test
```

### 填空题
实现与选择题一致
## More

You can view full document on our [official website](https://pro.ant.design). And welcome any feedback in our [github](https://github.com/ant-design/ant-design-pro).
Loading

0 comments on commit a3de126

Please sign in to comment.