Skip to content

Commit

Permalink
feat: v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
surmon-china committed Sep 5, 2021
1 parent 8e3ecbf commit d4051a4
Show file tree
Hide file tree
Showing 35 changed files with 1,241 additions and 193 deletions.
3 changes: 3 additions & 0 deletions .env.demo
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Demo config
VITE_API_URL = '/'
VITE_ENABLE_AD = true
2 changes: 1 addition & 1 deletion .env.development
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Dev config
VITE_API_URL = '/api'
VITE_API_URL = 'http://localhost:8000'
2 changes: 2 additions & 0 deletions .env.proxy
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Dev config
VITE_API_URL = '/api'
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ module.exports = {
'@typescript-eslint/explicit-module-boundary-types': 0,
'@typescript-eslint/ban-ts-comment': 0,
'@typescript-eslint/no-non-null-asserted-optional-chain': 0,
'@typescript-eslint/no-inferrable-types': 0
'@typescript-eslint/no-inferrable-types': 0,
},
};
}
31 changes: 26 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,45 @@ on:
types: [created]
push:
tags:
- "v*"
- 'v*'

jobs:
deploy:
demo:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "14"
cache: "yarn"
node-version: '14'
cache: 'yarn'

- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Vite build
run: yarn build:demo

- name: Example branch
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: example
publish_dir: ./dist

blog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
cache: 'yarn'

- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Vite build
run: yarn build

- name: Relesae branch
- name: Release branch
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
File renamed without changes.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

All notable changes to this project will be documented in this file.

### v1.1.0 (2021-09-01)

- Upgrade deps
- Demo site: Axios `interceptor` > `adapter`
- Add AD for demo site

### v1.0.6 (2021-08-03)

- Add demo site (CI & ENV config & AD)

### v1.0.5 (2021-08-03)

- improve `ImageUploaderModal`
Expand Down
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<meta name="theme-color" content="#4691d1">
<meta name="keywords" content="surmon,surmon.me,angular-admin,nodepress,前端技术开发"/>
<meta name="description" content="Admin client for Surmon.me powered by Veact and AntDesign">
<!-- Google AdSense -->
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4710915636313788"
crossorigin="anonymous"></script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-84887611-4"></script>
<script>
Expand Down
40 changes: 21 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "veact-admin",
"version": "1.0.5",
"version": "1.1.0",
"author": "Surmon",
"license": "MIT",
"repository": {
Expand All @@ -9,31 +9,33 @@
},
"scripts": {
"dev": "vite",
"dev:proxy": "PROXY=true vite",
"dev:proxy": "vite --mode proxy",
"dev:demo": "vite --mode demo",
"build": "vite build",
"build:demo": "vite build --mode demo",
"serve": "vite preview",
"lint": "eslint --ext .ts,.tsx src/",
"format": "npm run lint --fix",
"build": "tsc && vite build",
"serve": "vite preview",
"release": ". ./scripts/release.sh"
},
"dependencies": {
"ali-oss": "^6.16.0",
"antd": "^4.16.10",
"axios": "^0.21.1",
"antd": "^4.16.13",
"axios": "^0.21.3",
"bezier-easing": "^2.1.0",
"classnames": "^2.3.1",
"gravatar": "^1.8.1",
"gravatar": "^1.8.2",
"highlight.js": "^11.2.0",
"js-base64": "^3.6.1",
"lodash": "^4.17.21",
"marked": "^2.1.3",
"marked": "^3.0.2",
"moment": "^2.29.1",
"monaco-editor": "^0.26.1",
"monaco-editor": "^0.27.0",
"performant-array-to-tree": "^1.9.1",
"query-string": "^7.0.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-router-dom": "^5.2.0",
"react-router-dom": "^5.3.0",
"react-top-loading-bar": "^2.0.1",
"react-transition-group": "^4.4.2",
"ua-parser-js": "^0.7.28",
Expand All @@ -43,23 +45,23 @@
"devDependencies": {
"@types/ali-oss": "^6.0.10",
"@types/gravatar": "^1.8.3",
"@types/lodash": "^4.14.171",
"@types/marked": "^2.0.4",
"@types/node": "^16.4.10",
"@types/react": "^17.0.15",
"@types/lodash": "^4.14.172",
"@types/marked": "^3.0.0",
"@types/node": "^16.7.10",
"@types/react": "^17.0.20",
"@types/react-dom": "^17.0.9",
"@types/react-router-dom": "^5.1.8",
"@types/react-transition-group": "^4.4.2",
"@types/ua-parser-js": "^0.7.36",
"@typescript-eslint/eslint-plugin": "^4.29.0",
"@typescript-eslint/parser": "^4.29.0",
"@typescript-eslint/eslint-plugin": "^4.30.0",
"@typescript-eslint/parser": "^4.30.0",
"@vitejs/plugin-react-refresh": "^1.3.6",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-prettier": "^4.0.0",
"less": "^4.1.1",
"prettier": "^2.3.2",
"typescript": "^4.3.5",
"vite": "^2.4.4"
"typescript": "^4.4.2",
"vite": "^2.5.3"
}
}
97 changes: 97 additions & 0 deletions public/__demo__/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// JSON actions
const fetchJSON = (filePath) => {
return fetch(`/__demo__/mock/${filePath}.json`).then((response) => response.json())
}
// first fetch cache data map
const _cacheData = new Map()
const ensureJSON = async (filePath) => {
if (_cacheData.has(filePath)) {
return _cacheData.get(filePath)
} else {
const data = await fetchJSON(filePath)
_cacheData.set(filePath, data)
return data
}
}

// mock token
console.info('mock token')
window.localStorage.setItem('id_token', 'veact_admin.mock.token')

// mock by axios adapter
console.info('mock axios')
window.__axiosAdapter = (config) => {
console.debug('mock request:', config)
// 1. 仅处理所有 Get 请求
// 2. Auth 相关的必要 Post 请求除外
// 3. 所有请求返回错误,提示:Demo 站点无法操作数据
const handlers = {
'/auth/login': {
post: () => ensureJSON('auth/login'),
},
'/auth/check': {
post: () => ensureJSON('auth/check'),
},
'/auth/admin': {
get: () => ensureJSON('auth/admin'),
},
'/expansion/statistic': {
get: () => ensureJSON('expansion/statistic'),
},
'/expansion/google-token': {
get: () => ensureJSON('expansion/google-token'),
},
'/expansion/uptoken': {
get: () => ensureJSON('expansion/uptoken'),
},
'/announcement': {
get: () => ensureJSON('announcement'),
},
'/category': {
get: () => ensureJSON('category'),
},
'/tag': {
get: () => ensureJSON('tag'),
},
'/comment': {
get: () => ensureJSON('comment'),
},
'/option': {
get: () => ensureJSON('option'),
},
'/article': {
get: () => ensureJSON('article/list'),
},
'/article/612c81321a53290533a7b782': {
get: () => ensureJSON('article/612c81321a53290533a7b782'),
},
'/article/610c29438a907384c63fef00': {
get: () => ensureJSON('article/610c29438a907384c63fef00'),
},
'/article/61030f5fcf1faa098ee126b2': {
get: () => ensureJSON('article/61030f5fcf1faa098ee126b2'),
},
}

return new Promise(async (resolve) => {
const target = handlers?.[config.url]?.[config.method]
if (target) {
return resolve({
status: 200,
statusText: 'OK',
data: await target(),
})
} else {
return resolve({
status: 500,
statusText: 'ERROR',
data: {
status: 'error',
message: '操作失败',
error: 'Demo 站点不支持数据操作',
result: null,
},
})
}
})
}
63 changes: 63 additions & 0 deletions public/__demo__/mock/announcement.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"status": "success",
"message": "获取公告成功",
"result": {
"data": [
{
"state": 0,
"_id": "60c2cf0dce41cd0b74cfb001",
"content": "今天天气很好",
"create_at": "2021-07-14T10:04:45.085Z",
"update_at": "2021-07-26T18:38:24.704Z",
"id": 6,
"__v": 0
},
{
"state": 1,
"_id": "60c2cf0dce41cd0b74cfb003",
"content": "今天的饭菜很好吃",
"create_at": "2021-06-11T02:48:45.477Z",
"update_at": "2021-06-11T02:48:45.477Z",
"id": 5,
"__v": 0
},
{
"state": 0,
"_id": "60c2cf0dce41cd0b74cfb002",
"content": "今天不开心",
"create_at": "2021-06-09T15:23:42.855Z",
"update_at": "2021-06-09T15:23:42.855Z",
"id": 4,
"__v": 0
},
{
"state": 0,
"_id": "60c2cf0dce41cd0b74cfb006",
"content": "今天 A 股大跌",
"create_at": "2021-03-03T08:35:51.788Z",
"update_at": "2021-03-03T08:35:51.788Z",
"id": 3,
"__v": 0
},
{
"state": 1,
"_id": "60c2cf0dce41cd0b74cfb007",
"content": "今天抄顶 😢",
"create_at": "2021-02-23T17:15:13.459Z",
"update_at": "2021-02-23T17:15:13.459Z",
"id": 2,
"__v": 0
},
{
"state": 1,
"_id": "60c2cf0dce41cd0b74cfb008",
"content": "Happy new year! 🎉",
"create_at": "2020-12-31T14:21:03.724Z",
"update_at": "2020-12-31T14:21:03.724Z",
"id": 1,
"__v": 0
}
],
"pagination": { "total": 6, "current_page": 1, "total_page": 1, "per_page": 16 }
}
}
24 changes: 24 additions & 0 deletions public/__demo__/mock/article/61030f5fcf1faa098ee126b2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"status": "success",
"message": "获取文章详情成功",
"result": {
"password": "",
"keywords": ["旅途日记", "西部之旅"],
"state": 0,
"public": 1,
"origin": 0,
"tag": ["594d2b1251c61940c28c854f", "59b18754c8bfdb5b0c06980b"],
"category": ["589e07c04a4ad562430953d0"],
"_id": "61030f5fcf1faa098ee126b2",
"id": 1,
"title": "旅途感想",
"description": "没有整理好的旅途感想",
"content": "\n旅途的开始,心情是轻松的。\n\n此处省略一万字...\n",
"thumb": "/images/profile/article-thumb.jpg",
"extends": [],
"meta": { "likes": 51, "views": 11672, "comments": 39 },
"update_at": "2019-07-24T15:53:33.133Z",
"create_at": "2017-05-10T16:17:04.716Z",
"__v": 0
}
}
24 changes: 24 additions & 0 deletions public/__demo__/mock/article/610c29438a907384c63fef00.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"status": "success",
"message": "获取文章详情成功",
"result": {
"password": "",
"keywords": ["每日一记", "上海天气"],
"state": 0,
"public": 1,
"origin": 0,
"tag": ["58c8a3dccc2ca807b19d23cd", "594d2b1251c61940c28c854f"],
"category": ["589e07c04a4ad562430953d0"],
"_id": "610c29438a907384c63fef00",
"id": 2,
"title": "今日日记",
"description": "今天发生的一些事情",
"content": "\n今天上海的天气非常好,万里无云。\n\n此处省略一万字...\n",
"thumb": "/images/profile/article-thumb.jpg",
"extends": [],
"meta": { "likes": 51, "views": 11672, "comments": 39 },
"update_at": "2019-07-24T15:53:33.133Z",
"create_at": "2017-05-10T16:17:04.716Z",
"__v": 0
}
}
Loading

0 comments on commit d4051a4

Please sign in to comment.