Skip to content

Commit fa7c646

Browse files
committed
【迁移】变更域名、仓库名
1 parent ccd302d commit fa7c646

12 files changed

+123
-111
lines changed

.travis.yml

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
branches:
2-
only:
3-
- dev
2+
only:
3+
- dev
44

55
language: node_js
66
node_js:
7-
- lts/*
7+
- lts/*
88
cache:
9-
directories:
10-
- node_modules
9+
directories:
10+
- node_modules
1111

1212
install:
13-
- npm install
13+
- npm install
1414
script:
15-
- npm run build
15+
- npm run build
1616
deploy:
17-
provider: pages
18-
on:
19-
branch: dev
20-
skip_cleanup: true
21-
local_dir: dist/
22-
# fqdn: ${DOMAIN} # Custom Domain
23-
target_branch: master
24-
token: ${TOKEN}
17+
provider: pages
18+
on:
19+
branch: dev
20+
skip_cleanup: true
21+
local_dir: dist/
22+
fqdn: wuhan2020.kaiyuanshe.cn
23+
target_branch: master
24+
token: ${TOKEN}

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
[渐进式 Web 应用][1]项目
44

5-
[![NPM Dependency](https://david-dm.org/wuhan2020/wuhan2020.github.io.svg)][2]
6-
[![Build Status](https://travis-ci.com/wuhan2020/wuhan2020.github.io.svg?branch=dev)][3]
5+
[![NPM Dependency](https://david-dm.org/wuhan2020/WebApp.svg)][2]
6+
[![Build Status](https://travis-ci.com/wuhan2020/WebApp.svg?branch=dev)][3]
77

88
## 基本用法
99

@@ -31,7 +31,7 @@
3131

3232
1. [安装 Node.js](https://nodejs.org/en/download/package-manager/)
3333

34-
2. `git clone https://github.com/wuhan2020/wuhan2020.github.io.git`
34+
2. `git clone https://github.com/wuhan2020/WebApp.git`
3535

3636
3. 在本项目文件夹中执行命令
3737

@@ -43,8 +43,8 @@ npm start
4343
4. 安装、启动[后端项目](https://github.com/wuhan2020/rest-api)
4444

4545
[1]: https://developers.google.cn/web/progressive-web-apps
46-
[2]: https://david-dm.org/wuhan2020/wuhan2020.github.io
47-
[3]: https://travis-ci.com/wuhan2020/wuhan2020.github.io
46+
[2]: https://david-dm.org/wuhan2020/WebApp
47+
[3]: https://travis-ci.com/wuhan2020/WebApp
4848
[4]: https://www.w3.org/
4949
[5]: https://typescriptlang.org
5050
[6]: https://web-cell.dev/

package.json

+67-67
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,71 @@
11
{
2-
"name": "wuhan2020",
3-
"version": "0.5.0",
4-
"license": "AGPL-3.0",
5-
"author": "[email protected]",
6-
"description": "针对 2020 新冠病毒疫情中的武汉援助信息网站",
7-
"homepage": "https://wuhan2020.github.io/",
8-
"repository": {
9-
"type": "git",
10-
"url": "git+https://github.com/wuhan2020/wuhan2020.github.io.git"
11-
},
12-
"bugs": {
13-
"url": "https://github.com/EasyWebApp/wuhan2020/issues"
14-
},
15-
"main": "source/index.html",
16-
"dependencies": {
17-
"@octokit/rest": "^16.38.3",
18-
"boot-cell": "^0.24.0",
19-
"browser-unhandled-rejection": "^1.0.2",
20-
"cell-router": "^2.0.0-rc.6",
21-
"classnames": "^2.2.6",
22-
"clipboard-polyfill": "^2.8.6",
23-
"js-base64": "^2.5.1",
24-
"koajax": "^0.5.3",
25-
"mobx": "^5.15.3",
26-
"mobx-web-cell": "^0.2.5",
27-
"web-cell": "^2.0.0-rc.15",
28-
"yaml": "^1.7.2"
29-
},
30-
"devDependencies": {
31-
"@types/js-base64": "^2.3.1",
32-
"@types/yaml": "^1.2.0",
33-
"husky": "^4.2.1",
34-
"iterable-observer": "^1.0.0-beta.2",
35-
"lint-staged": "^10.0.2",
36-
"parcel-bundler": "^1.12.4",
37-
"prettier": "^1.19.1",
38-
"typescript": "^3.7.5",
39-
"workbox-cli": "^4.3.1"
40-
},
41-
"prettier": {
42-
"singleQuote": true,
43-
"tabWidth": 4,
44-
"overrides": [
45-
{
46-
"files": "*.yml",
47-
"options": {
48-
"tabWidth": 2
2+
"name": "wuhan2020",
3+
"version": "0.5.0",
4+
"license": "AGPL-3.0",
5+
"author": "[email protected]",
6+
"description": "针对 2020 新冠病毒疫情中的武汉援助信息网站",
7+
"homepage": "https://wuhan2020.kaiyuanshe.cn/",
8+
"repository": {
9+
"type": "git",
10+
"url": "git+https://github.com/wuhan2020/WebApp.git"
11+
},
12+
"bugs": {
13+
"url": "https://github.com/EasyWebApp/wuhan2020/issues"
14+
},
15+
"main": "source/index.html",
16+
"dependencies": {
17+
"@octokit/rest": "^16.38.3",
18+
"boot-cell": "^0.24.0",
19+
"browser-unhandled-rejection": "^1.0.2",
20+
"cell-router": "^2.0.0-rc.6",
21+
"classnames": "^2.2.6",
22+
"clipboard-polyfill": "^2.8.6",
23+
"iterable-observer": "^1.0.0-beta.2",
24+
"js-base64": "^2.5.1",
25+
"koajax": "^0.5.3",
26+
"mobx": "^5.15.3",
27+
"mobx-web-cell": "^0.2.5",
28+
"web-cell": "^2.0.0-rc.15",
29+
"yaml": "^1.7.2"
30+
},
31+
"devDependencies": {
32+
"@types/js-base64": "^2.3.1",
33+
"@types/yaml": "^1.2.0",
34+
"husky": "^4.2.1",
35+
"lint-staged": "^10.0.2",
36+
"parcel-bundler": "^1.12.4",
37+
"prettier": "^1.19.1",
38+
"typescript": "^3.7.5",
39+
"workbox-cli": "^4.3.1"
40+
},
41+
"prettier": {
42+
"singleQuote": true,
43+
"tabWidth": 4,
44+
"overrides": [
45+
{
46+
"files": "*.yml",
47+
"options": {
48+
"tabWidth": 2
49+
}
50+
}
51+
]
52+
},
53+
"lint-staged": {
54+
"*.{html,md,less,js,json,yml,ts,tsx}": [
55+
"prettier --write"
56+
]
57+
},
58+
"scripts": {
59+
"test": "lint-staged",
60+
"start": "rm -rf dist/ && parcel source/index.html --open",
61+
"pack-dist": "parcel build source/index.html --public-url .",
62+
"pack-sw": "rm -f dist/sw.js.map && workbox generateSW",
63+
"build": "rm -rf dist/ && npm run pack-dist && npm run pack-sw"
64+
},
65+
"husky": {
66+
"hooks": {
67+
"pre-commit": "npm test",
68+
"pre-push": "npm run build"
4969
}
50-
}
51-
]
52-
},
53-
"lint-staged": {
54-
"*.{html,md,less,js,json,yml,ts,tsx}": [
55-
"prettier --write"
56-
]
57-
},
58-
"scripts": {
59-
"test": "lint-staged",
60-
"start": "rm -rf dist/ && parcel source/index.html --open",
61-
"pack-dist": "parcel build source/index.html --public-url .",
62-
"pack-sw": "rm -f dist/sw.js.map && workbox generateSW",
63-
"build": "rm -rf dist/ && npm run pack-dist && npm run pack-sw"
64-
},
65-
"husky": {
66-
"hooks": {
67-
"pre-commit": "npm test",
68-
"pre-push": "npm run build"
6970
}
70-
}
7171
}

source/index.webmanifest

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "2020 援助武汉",
33
"short_name": "援助武汉",
4-
"start_url": "https://wuhan2020.github.io/",
4+
"start_url": "https://wuhan2020.kaiyuanshe.cn/",
55
"description": "新冠病毒疫情中的武汉援助信息网站",
66
"scope": "/",
77
"display": "standalone",

source/model/GitHub.ts

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Octokit from '@octokit/rest';
22
import { Base64 } from 'js-base64';
3+
import { parse } from 'yaml';
34

45
interface GitHubOptions {
56
owner: string;
@@ -15,11 +16,22 @@ export class GitHubModel {
1516
}
1617

1718
async getContents(path: string) {
18-
const { data } = await this.client.repos.getContents({
19-
...this.options,
20-
path
21-
});
19+
const type = path.split('.').slice(-1)[0],
20+
{ data } = await this.client.repos.getContents({
21+
...this.options,
22+
path
23+
});
2224
// @ts-ignore
23-
return Base64.decode(data.content);
25+
const raw = Base64.decode(data.content);
26+
27+
switch (type) {
28+
case 'json':
29+
return JSON.parse(raw);
30+
case 'yaml':
31+
case 'yml':
32+
return parse(raw);
33+
default:
34+
return raw;
35+
}
2436
}
2537
}

source/model/GitService.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { GitHubModel } from './GitHub';
2+
3+
export const repository = new GitHubModel({
4+
owner: 'EasyWebApp',
5+
repo: 'wuhan2020'
6+
});

source/model/HTTPService.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { HTTPClient } from 'koajax';
22

3-
export default new HTTPClient({
3+
export const service = new HTTPClient({
44
baseURI:
55
location.hostname === 'localhost'
66
? 'http://localhost:3000'

source/model/Session.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { observable } from 'mobx';
22
import { blobOf } from 'koajax';
33

4-
import client, { User, FileData, Role } from './HTTPService';
4+
import { User, service, FileData, Role } from './HTTPService';
55

66
export class Session {
77
@observable
@@ -23,7 +23,7 @@ export class Session {
2323

2424
async getProfile() {
2525
try {
26-
const { body } = await client.get<User>('/session');
26+
const { body } = await service.get<User>('/session');
2727

2828
return this.save(body);
2929
} catch (error) {
@@ -32,17 +32,17 @@ export class Session {
3232
}
3333

3434
sendSMSCode(phone: string) {
35-
return client.post('/session/smsCode', { phone });
35+
return service.post('/session/smsCode', { phone });
3636
}
3737

3838
async signIn(phone: string, code: string) {
39-
const { body } = await client.post<User>('/session', { phone, code });
39+
const { body } = await service.post<User>('/session', { phone, code });
4040

4141
return this.save(body);
4242
}
4343

4444
async signOut() {
45-
await client.delete('/session');
45+
await service.delete('/session');
4646

4747
this.save(null);
4848
}
@@ -62,7 +62,7 @@ export class Session {
6262

6363
const {
6464
body: { url }
65-
} = await client.post<FileData>('/file', data);
65+
} = await service.post<FileData>('/file', data);
6666

6767
return url;
6868
}

source/model/SuppliesRequirement.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { observable } from 'mobx';
22

3-
import service, { DataItem, User, PageData } from './HTTPService';
3+
import { DataItem, User, service, PageData } from './HTTPService';
44

55
export interface Contact {
66
name: string;

source/model/index.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,12 @@ import { History } from 'cell-router/source';
22

33
import { Session } from './Session';
44
import { SuppliesRequirementModel } from './SuppliesRequirement';
5-
import { GitHubModel } from './GitHub';
65

76
export const history = new History();
87
export const session = new Session();
98
export const suppliesRequirement = new SuppliesRequirementModel();
109

11-
export const repository = new GitHubModel({
12-
owner: 'EasyWebApp',
13-
repo: 'wuhan2020'
14-
});
15-
1610
export * from './HTTPService';
11+
export * from './GitService';
1712
export * from './SuppliesRequirement';
1813
export * from './AMap';

source/page/Logistics.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { component, mixin, createCell } from 'web-cell';
22
import { SpinnerBox } from 'boot-cell/source/Prompt/Spinner';
33
import { Table } from 'boot-cell/source/Content/Table';
44
import { Button } from 'boot-cell/source/Form/Button';
5-
import { parse } from 'yaml';
65

76
import { repository } from '../model';
87

@@ -29,9 +28,9 @@ export class LogisticsPage extends mixin<{}, LogisticsPageState>() {
2928
async connectedCallback() {
3029
super.connectedCallback();
3130

32-
const data = await repository.getContents('data/Logistics.yml');
31+
const list = await repository.getContents('data/Logistics.yml');
3332

34-
await this.setState({ loading: false, list: parse(data) });
33+
await this.setState({ loading: false, list });
3534
}
3635

3736
render(_, { loading, list }: LogisticsPageState) {

source/page/menu.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ export default [
4040
},
4141
{
4242
title: '开放源代码',
43-
href: 'https://github.com/wuhan2020/wuhan2020.github.io'
43+
href: 'https://github.com/wuhan2020/WebApp'
4444
}
4545
];

0 commit comments

Comments
 (0)