diff --git a/.babelrc b/.babelrc index 90541c3..8f4cafb 100644 --- a/.babelrc +++ b/.babelrc @@ -12,18 +12,7 @@ ["transform-imports", { "@material-ui/core": { "transform": "@material-ui/core/${member}" }, "lodash-es": { "transform": "lodash-es/${member}" } - }] - ], - "env": { - "development": { - "plugins": [ - ["emotion", { "sourceMap": true, "autoLabel": true }] - ] - }, - "production": { - "plugins": [ - ["emotion", { "hoist": true }] - ] - } - } + }], + ["babel-plugin-styled-components", { "ssr": false }] + ] } diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..b911e00 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,12 @@ + +language: node_js + +node_js: + - "10" + +install: + - npm install + +script: + - npm run type-check + - npm run build diff --git a/README.md b/README.md index 158c937..8e598dc 100644 --- a/README.md +++ b/README.md @@ -5,13 +5,13 @@ CC98 Forum PWA version. ## 项目技术栈 -- react@latest +- react@16.7.0-alpha.2 - @reach/router - @material-ui/core@3 -- emotion +- styled-component@4 - webpack@4 diff --git a/config/webpack.common.js b/config/webpack.common.js index 753268b..cf44cd5 100644 --- a/config/webpack.common.js +++ b/config/webpack.common.js @@ -59,6 +59,13 @@ module.exports = { outputPath: 'static/', }, }, + { + test: /\.(ttf|eot|woff|woff2)$/, + loader: 'file-loader', + options: { + name: 'fonts/[name].[ext]', + }, + }, ] }, @@ -79,9 +86,14 @@ module.exports = { inject: true, }), - new CopyWebpackPlugin([ - { from: 'public/manifest.json', to: 'manifest.json' }, - { from: 'public/icons/', to: 'icons/' }, + new CopyWebpackPlugin([{ + from: 'public/manifest.json', + to: 'manifest.json' + }, + { + from: 'public/icons/', + to: 'icons/' + }, ]), // workbox: https://developers.google.com/web/tools/workbox/modules/workbox-webpack-plugin @@ -92,4 +104,3 @@ module.exports = { }), ], } - diff --git a/docs/error.md b/docs/error.md new file mode 100644 index 0000000..d6edd7e --- /dev/null +++ b/docs/error.md @@ -0,0 +1,69 @@ +# 记录页面的报错处理情况 + +## 看帖页面(/topic) +对index发出的第一个请求,即请求topicinfo进行处理 + +**navigate** +* 401 -用户未登录、用户权限不够、用户使用代理查看某些帖子 +* 403 - +* 404 -用户输错路由 +* 50* -服务器内部错误 + +评分操作进行处理(通过message) + +**notification** +* 'cannot_rate_yourself' - '您不能给自己评分' +* 'has_rated_tody' -'您今天已经评过分了,请明天再来' +* 'you_cannot_rate' -'您发帖还不足500,不能评分' +* 'has_rated_this_post' -'您已经给这个贴评过分了' +* 'post_user_not_exists' -'这个回复的账号已经不存在了' + +回帖处理 + +TODO + +编辑处理 + +TODO + +## 版面页面(/board) + +**navigate** + +对index发出的第一个请求,即请求boardInfo进行处理 +* 401 -用户未登录、用户权限不够、用户使用代理查看某些帖子 +* 403 - +* 404 -用户输错路由 +* 50* -服务器内部错误 + +## 版面列表 (/boardList) + +**navigate** + +* 50* -服务器内部错误 + +## 主页 (/) + +**notification** + +* 50* -服务器内部错误 + +## 热门(/hottopic) +**notification** + +* 50* -服务器内部错误 + +## 登陆 (/login) + +**notification** + +* 401 -用户名密码错误 +* 50* -服务器内部错误 + +## 关注 (/myfollow)新帖 (/newTopics)搜索(/search) +对获取关注信息的api进行处理 + +**navigate** + +* 401 -用户未登录 +* 50* -服务器内部错误 diff --git a/package.json b/package.json index 256d93b..3e8c86d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cc98-pwa", - "version": "0.98.0-alpha", + "version": "1.0.0", "description": "CC98 Forum PWA version.", "author": "Hydrogen", "license": "MIT", @@ -8,69 +8,73 @@ "dev": "cross-env NODE_ENV=development webpack-dev-server --config config/webpack.dev.js --progress --hot", "build": "cross-env NODE_ENV=production webpack --config config/webpack.prod.js", "bundle-analyze": "cross-env NODE_ENV=production webpack --config config/webpack.bundle-analyze.js", + "type-check": "tsc --noEmit", "beautify-all": "yarn run prettier --config .prettierrc --write 'src/**/*.{ts,tsx}'", "lint:ts": "tslint -c tslint.json --project tsconfig.json 'src/**/*.{ts,tsx}'", "lint:ts-fix": "tslint -c tslint.json --project tsconfig.json 'src/**/*.{ts,tsx}' --fix" }, "dependencies": { - "@aspnet/signalr": "^1.0.4", - "@cc98/state": "^1.0.0", - "@cc98/ubb-react": "^1.0.0", - "@material-ui/core": "^3.4.0", + "@aspnet/signalr": "^1.1.0", + "@cc98/ubb-core": "1.1.0", + "@material-ui/core": "^3.7.0", "@material-ui/icons": "^3.0.1", "@reach/router": "^1.2.1", - "dayjs": "^1.6.10", - "emotion": "^9.2.12", + "@sentry/browser": "^4.4.2", + "copy-to-clipboard": "^3.0.8", + "dayjs": "^1.7.8", "lodash-es": "^4.17.11", "prop-types": "^15.6.2", - "react": "16.7.0-alpha.0", - "react-dom": "16.7.0-alpha.0", - "react-emotion": "^9.2.12", - "remark": "^10.0.0", - "remark-react": "^4.0.3" + "react": "^16.7.0-alpha.2", + "react-dom": "16.7.0-alpha.2", + "remark": "^10.0.1", + "remark-react": "^5.0.1", + "styled-components": "^4.1.3", + "typeface-roboto": "^0.0.54", + "url-parse": "^1.4.4" }, "devDependencies": { - "@babel/core": "^7.1.5", - "@babel/plugin-proposal-class-properties": "^7.1.0", - "@babel/preset-env": "^7.1.5", + "@babel/core": "^7.2.2", + "@babel/plugin-proposal-class-properties": "^7.2.1", + "@babel/preset-env": "^7.2.0", "@babel/preset-react": "^7.0.0", "@babel/preset-typescript": "^7.1.0", "@types/lodash-es": "^4.17.1", "@types/node": "^10.12.3", - "@types/reach__router": "^1.2.0", - "@types/react": "16.4.18", - "@types/react-dom": "^16.0.9", + "@types/reach__router": "^1.2.2", + "@types/react": "^16.7.17", + "@types/react-dom": "^16.0.11", + "@types/styled-components": "4.0.3", + "@types/url-parse": "^1.4.1", "babel-loader": "^8.0.4", - "babel-plugin-emotion": "^9.2.11", + "babel-plugin-styled-components": "^1.9.4", "babel-plugin-transform-imports": "^1.5.1", - "clean-webpack-plugin": "^0.1.19", - "copy-webpack-plugin": "^4.5.3", + "clean-webpack-plugin": "^1.0.0", + "copy-webpack-plugin": "^4.6.0", "cross-env": "^5.2.0", - "css-loader": "^1.0.0", - "eslint-plugin-emotion": "^9.2.6", + "css-loader": "^2.0.0", "file-loader": "^2.0.0", - "html-webpack-plugin": "^4.0.0-beta.2", - "husky": "^1.1.2", - "lint-staged": "^7.3.0", - "prettier": "^1.15.1", - "prettier-tslint": "^0.4.0", + "html-webpack-plugin": "^4.0.0-beta.5", + "husky": "^1.2.1", + "lint-staged": "^8.1.0", + "prettier": "^1.15.3", + "prettier-tslint": "^0.4.1", "style-loader": "^0.23.1", "terser-webpack-plugin": "^1.1.0", - "tslint": "^5.11.0", - "tslint-config-airbnb": "^5.11.0", - "tslint-consistent-codestyle": "^1.13.3", + "tslint": "^5.12.0", + "tslint-config-airbnb": "^5.11.1", + "tslint-consistent-codestyle": "^1.14.1", "tslint-eslint-rules": "^5.4.0", "tslint-lines-between-class-members": "^1.3.1", - "tslint-microsoft-contrib": "^5.2.1", + "tslint-microsoft-contrib": "^6.0.0", "tslint-react": "^3.6.0", - "typescript": "^3.1.3", + "typescript": "^3.2.2", "url-loader": "^1.1.2", - "webpack": "^4.21.0", + "webpack": "^4.27.1", "webpack-bundle-analyzer": "^3.0.3", "webpack-cli": "^3.1.2", - "webpack-dev-server": "^3.1.9", - "webpack-merge": "^4.1.4", - "workbox-webpack-plugin": "^3.6.2" + "webpack-dev-server": "^3.1.10", + "webpack-merge": "^4.1.5", + "workbox-webpack-plugin": "^3.6.3" }, "lint-staged": { "**/*.{ts,tsx}": [ @@ -80,7 +84,7 @@ }, "husky": { "hooks": { - "pre-commit": "lint-staged" + "pre-commit": "tsc --noEmit && lint-staged" } } } diff --git a/public/index.html b/public/index.html index 8ef3cce..7daec48 100644 --- a/public/index.html +++ b/public/index.html @@ -1,33 +1,37 @@ -
- - - - - - - - - - - -