diff --git a/client/README.md b/client/README.md old mode 100755 new mode 100644 index 705cd39..db6a46f --- a/client/README.md +++ b/client/README.md @@ -1,29 +1,35 @@ -# poke-game-front-ts - -## Project setup -``` -yarn install -``` - -### Compiles and hot-reloads for development -``` -yarn run serve -``` - -### Compiles and minifies for production -``` -yarn run build -``` - -### Run your tests -``` -yarn run test -``` - -### Lints and fixes files -``` -yarn run lint -``` - -### Customize configuration -See [Configuration Reference](https://cli.vuejs.org/config/). +# poke-game-front-ts + +## Project setup + +``` +yarn install +``` + +### Compiles and hot-reloads for development + +``` +yarn run serve +``` + +### Compiles and minifies for production + +``` +yarn run build +``` + +### Run your tests + +``` +yarn run test +``` + +### Lints and fixes files + +``` +yarn run lint +``` + +### Customize configuration + +See [Configuration Reference](https://cli.vuejs.org/config/). diff --git a/client/babel.config.js b/client/babel.config.js old mode 100755 new mode 100644 index e955840..f6da51d --- a/client/babel.config.js +++ b/client/babel.config.js @@ -1,5 +1,3 @@ -module.exports = { - presets: [ - '@vue/cli-plugin-babel/preset' - ] -} +module.exports = { + presets: ["@vue/cli-plugin-babel/preset"] +}; diff --git a/client/package.json b/client/package.json old mode 100755 new mode 100644 index 7351cb3..091be65 --- a/client/package.json +++ b/client/package.json @@ -1,27 +1,30 @@ -{ - "name": "poke-game-front-ts", - "version": "0.1.0", - "private": true, - "scripts": { - "serve": "vue-cli-service serve", - "build": "vue-cli-service build", - "lint": "vue-cli-service lint" - }, - "dependencies": { - "core-js": "^3.6.4", - "vue": "^2.6.11", - "vue-class-component": "^7.2.3", - "vue-property-decorator": "^8.4.1", - "vue-router": "^3.1.6", - "vuex": "^3.1.3" - }, - "devDependencies": { - "@vue/cli-plugin-babel": "^4.3.0", - "@vue/cli-plugin-typescript": "^4.3.0", - "@vue/cli-service": "^4.3.0", - "less": "^3.0.4", - "less-loader": "^5.0.0", - "typescript": "~3.8.3", - "vue-template-compiler": "^2.6.11" - } -} +{ + "name": "poke-game-front-ts", + "version": "0.1.0", + "private": true, + "scripts": { + "serve": "vue-cli-service serve", + "build": "vue-cli-service build", + "lint": "vue-cli-service lint" + }, + "dependencies": { + "@types/js-cookie": "^2.2.6", + "axios": "^0.19.2", + "core-js": "^3.6.4", + "js-cookie": "^2.2.1", + "vue": "^2.6.11", + "vue-class-component": "^7.2.3", + "vue-property-decorator": "^8.4.1", + "vue-router": "^3.1.6", + "vuex": "^3.1.3" + }, + "devDependencies": { + "@vue/cli-plugin-babel": "^4.3.0", + "@vue/cli-plugin-typescript": "^4.3.0", + "@vue/cli-service": "^4.3.0", + "less": "^3.0.4", + "less-loader": "^5.0.0", + "typescript": "~3.8.3", + "vue-template-compiler": "^2.6.11" + } +} diff --git a/client/public/favicon.ico b/client/public/favicon.ico old mode 100755 new mode 100644 diff --git a/client/public/index.html b/client/public/index.html old mode 100755 new mode 100644 index 4123528..eecdaa0 --- a/client/public/index.html +++ b/client/public/index.html @@ -1,17 +1,17 @@ - - - - - - - - <%= htmlWebpackPlugin.options.title %> - - - -
- - - + + + + + + + + <%= htmlWebpackPlugin.options.title %> + + + +
+ + + diff --git a/client/src/App.vue b/client/src/App.vue old mode 100755 new mode 100644 index 87d7290..77ba4d6 --- a/client/src/App.vue +++ b/client/src/App.vue @@ -1,29 +1,29 @@ - - - - - + + + + + diff --git a/client/src/assets/logo.png b/client/src/assets/logo.png old mode 100755 new mode 100644 diff --git a/client/src/components/HelloWorld.vue b/client/src/components/HelloWorld.vue old mode 100755 new mode 100644 index d6e3f37..6b68edf --- a/client/src/components/HelloWorld.vue +++ b/client/src/components/HelloWorld.vue @@ -1,58 +1,58 @@ - - - - - - + + + + + + diff --git a/client/src/main.ts b/client/src/main.ts old mode 100755 new mode 100644 index eeab368..87b38f9 --- a/client/src/main.ts +++ b/client/src/main.ts @@ -8,5 +8,5 @@ Vue.config.productionTip = false; new Vue({ router, store, - render: (h) => h(App), + render: h => h(App), }).$mount('#app'); diff --git a/client/src/router/index.ts b/client/src/router/index.ts old mode 100755 new mode 100644 index a3b1c28..9b1ae1f --- a/client/src/router/index.ts +++ b/client/src/router/index.ts @@ -1,27 +1,27 @@ -import Vue from 'vue'; -import VueRouter, { RouteConfig } from 'vue-router'; -import Home from '../views/Home.vue'; - -Vue.use(VueRouter); - -const routes: RouteConfig[] = [ - { - path: '/', - name: 'Home', - component: Home, - }, - { - path: '/about', - name: 'About', - // route level code-splitting - // this generates a separate chunk (about.[hash].js) for this route - // which is lazy-loaded when the route is visited. - component: () => import(/* webpackChunkName: "about" */ '../views/About.vue'), - }, -]; - -const router = new VueRouter({ - routes, -}); - -export default router; +import Vue from 'vue'; +import VueRouter, { RouteConfig } from 'vue-router'; +import Home from '../views/Home.vue'; + +Vue.use(VueRouter); + +const routes: RouteConfig[] = [ + { + path: '/', + name: 'Home', + component: Home, + }, + { + path: '/login', + name: 'login', + // route level code-splitting + // this generates a separate chunk (about.[hash].js) for this route + // which is lazy-loaded when the route is visited. + component: () => import('../views/login.vue'), + }, +]; + +const router = new VueRouter({ + routes, +}); + +export default router; diff --git a/client/src/service/index.ts b/client/src/service/index.ts new file mode 100644 index 0000000..ba0622b --- /dev/null +++ b/client/src/service/index.ts @@ -0,0 +1,8 @@ +import request from '../utils/request'; + +export default { + register: (userName: string, password: string) => request({ + url: '', + body: { userName, password }, + }), +}; diff --git a/client/src/shims-tsx.d.ts b/client/src/shims-tsx.d.ts old mode 100755 new mode 100644 index 3b88b58..3575f49 --- a/client/src/shims-tsx.d.ts +++ b/client/src/shims-tsx.d.ts @@ -1,13 +1,13 @@ -import Vue, { VNode } from 'vue'; - -declare global { - namespace JSX { - // tslint:disable no-empty-interface - interface Element extends VNode {} - // tslint:disable no-empty-interface - interface ElementClass extends Vue {} - interface IntrinsicElements { - [elem: string]: any; - } - } -} +import Vue, { VNode } from 'vue'; + +declare global { + namespace JSX { + // tslint:disable no-empty-interface + interface Element extends VNode {} + // tslint:disable no-empty-interface + interface ElementClass extends Vue {} + interface IntrinsicElements { + [elem: string]: any; + } + } +} diff --git a/client/src/shims-vue.d.ts b/client/src/shims-vue.d.ts old mode 100755 new mode 100644 index 8f6f410..a6b6e52 --- a/client/src/shims-vue.d.ts +++ b/client/src/shims-vue.d.ts @@ -1,4 +1,4 @@ -declare module '*.vue' { - import Vue from 'vue'; - export default Vue; -} +declare module '*.vue' { + import Vue from 'vue'; + export default Vue; +} diff --git a/client/src/store/index.ts b/client/src/store/index.ts old mode 100755 new mode 100644 index 9ea7685..20f9f2f --- a/client/src/store/index.ts +++ b/client/src/store/index.ts @@ -1,15 +1,15 @@ -import Vue from 'vue'; -import Vuex from 'vuex'; - -Vue.use(Vuex); - -export default new Vuex.Store({ - state: { - }, - mutations: { - }, - actions: { - }, - modules: { - }, -}); +import Vue from 'vue'; +import Vuex from 'vuex'; + +Vue.use(Vuex); + +export default new Vuex.Store({ + state: { + }, + mutations: { + }, + actions: { + }, + modules: { + }, +}); diff --git a/client/src/utils/request.ts b/client/src/utils/request.ts new file mode 100644 index 0000000..9b44892 --- /dev/null +++ b/client/src/utils/request.ts @@ -0,0 +1,26 @@ +import axios, { AxiosRequestConfig, Method } from 'axios'; +import cookie from 'js-cookie'; +const request = async ({ method = 'post' as Method, url = '', body= {}, timeout = 8000 }) => { + const origin = ''; + if (!url) { + return Promise.reject('Request url is null!'); + } + const token = cookie.get('game_token'); + const headers = { + Authorization: `Bearer ${token}`, + }; + url = `${origin}/${url}`; + const option: AxiosRequestConfig = { + url, + method, + timeout, + withCredentials: true, + headers, + }; + try { + return await axios(option); + } catch (e) { + throw e; + } +}; +export default request; diff --git a/client/src/views/About.vue b/client/src/views/About.vue deleted file mode 100755 index 3fa2807..0000000 --- a/client/src/views/About.vue +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/client/src/views/Home.vue b/client/src/views/Home.vue old mode 100755 new mode 100644 index 8bd6c57..44aab74 --- a/client/src/views/Home.vue +++ b/client/src/views/Home.vue @@ -1,18 +1,16 @@ - - - + + + diff --git a/client/src/views/game.vue b/client/src/views/game.vue new file mode 100644 index 0000000..166abbd --- /dev/null +++ b/client/src/views/game.vue @@ -0,0 +1,22 @@ + + + + + + diff --git a/client/src/views/login.vue b/client/src/views/login.vue new file mode 100644 index 0000000..0e75719 --- /dev/null +++ b/client/src/views/login.vue @@ -0,0 +1,20 @@ + + diff --git a/client/src/views/register.vue b/client/src/views/register.vue new file mode 100644 index 0000000..ae83f05 --- /dev/null +++ b/client/src/views/register.vue @@ -0,0 +1,35 @@ + + + diff --git a/client/tsconfig.json b/client/tsconfig.json old mode 100755 new mode 100644 index b57578e..7723413 --- a/client/tsconfig.json +++ b/client/tsconfig.json @@ -1,39 +1,28 @@ -{ - "compilerOptions": { - "target": "esnext", - "module": "esnext", - "strict": true, - "jsx": "preserve", - "importHelpers": true, - "moduleResolution": "node", - "experimentalDecorators": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "sourceMap": true, - "baseUrl": ".", - "types": [ - "webpack-env" - ], - "paths": { - "@/*": [ - "src/*" - ] - }, - "lib": [ - "esnext", - "dom", - "dom.iterable", - "scripthost" - ] - }, - "include": [ - "src/**/*.ts", - "src/**/*.tsx", - "src/**/*.vue", - "tests/**/*.ts", - "tests/**/*.tsx" - ], - "exclude": [ - "node_modules" - ] -} +{ + "compilerOptions": { + "target": "esnext", + "module": "esnext", + "strict": true, + "jsx": "preserve", + "importHelpers": true, + "moduleResolution": "node", + "experimentalDecorators": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "sourceMap": true, + "baseUrl": ".", + "types": ["webpack-env"], + "paths": { + "@/*": ["src/*"] + }, + "lib": ["esnext", "dom", "dom.iterable", "scripthost"] + }, + "include": [ + "src/**/*.ts", + "src/**/*.tsx", + "src/**/*.vue", + "tests/**/*.ts", + "tests/**/*.tsx" + ], + "exclude": ["node_modules"] +} diff --git a/client/tslint.json b/client/tslint.json old mode 100755 new mode 100644 index 712fb18..cf0b84e --- a/client/tslint.json +++ b/client/tslint.json @@ -1,19 +1,15 @@ -{ - "defaultSeverity": "warning", - "extends": [ - "tslint:recommended" - ], - "linterOptions": { - "exclude": [ - "node_modules/**" - ] - }, - "rules": { - "indent": [true, "spaces", 2], - "interface-name": false, - "no-consecutive-blank-lines": false, - "object-literal-sort-keys": false, - "ordered-imports": false, - "quotemark": [true, "single"] - } -} +{ + "defaultSeverity": "warning", + "extends": ["tslint:recommended"], + "linterOptions": { + "exclude": ["node_modules/**"] + }, + "rules": { + "indent": [true, "spaces", 2], + "interface-name": false, + "no-consecutive-blank-lines": false, + "object-literal-sort-keys": false, + "ordered-imports": false, + "quotemark": [true, "single"] + } +} diff --git a/client/yarn.lock b/client/yarn.lock old mode 100755 new mode 100644 index a4cabc4..3a25dcf --- a/client/yarn.lock +++ b/client/yarn.lock @@ -883,6 +883,11 @@ "@types/minimatch" "*" "@types/node" "*" +"@types/js-cookie@^2.2.6": + version "2.2.6" + resolved "https://registry.npmjs.org/@types/js-cookie/-/js-cookie-2.2.6.tgz#f1a1cb35aff47bc5cfb05cb0c441ca91e914c26f" + integrity sha512-+oY0FDTO2GYKEV0YPvSshGq9t7YozVkgvXLty7zogQNuCxBhT9/3INX9Q7H1aRZ4SUDRXAKlJuA4EA5nTt7SNw== + "@types/minimatch@*": version "3.0.3" resolved "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d" @@ -1576,6 +1581,13 @@ aws4@^1.8.0: resolved "https://registry.npm.taobao.org/aws4/download/aws4-1.9.1.tgz#7e33d8f7d449b3f673cd72deb9abdc552dbe528e" integrity sha1-fjPY99RJs/ZzzXLeuavcVS2+Uo4= +axios@^0.19.2: + version "0.19.2" + resolved "https://registry.npm.taobao.org/axios/download/axios-0.19.2.tgz#3ea36c5d8818d0d5f8a8a97a6d36b86cdc00cb27" + integrity sha1-PqNsXYgY0NX4qKl6bTa4bNwAyyc= + dependencies: + follow-redirects "1.5.10" + babel-code-frame@^6.22.0: version "6.26.0" resolved "https://registry.npm.taobao.org/babel-code-frame/download/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" @@ -2688,6 +2700,13 @@ debug@2.6.9, debug@^2.2.0, debug@^2.3.3: dependencies: ms "2.0.0" +debug@=3.1.0: + version "3.1.0" + resolved "https://registry.npm.taobao.org/debug/download/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" + integrity sha1-W7WgZyYotkFJVmuhaBnmFRjGcmE= + dependencies: + ms "2.0.0" + debug@^3.0.0, debug@^3.1.1, debug@^3.2.5: version "3.2.6" resolved "https://registry.npm.taobao.org/debug/download/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" @@ -3428,6 +3447,13 @@ flush-write-stream@^1.0.0: inherits "^2.0.3" readable-stream "^2.3.6" +follow-redirects@1.5.10: + version "1.5.10" + resolved "https://registry.npm.taobao.org/follow-redirects/download/follow-redirects-1.5.10.tgz?cache=0&sync_timestamp=1585479417937&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ffollow-redirects%2Fdownload%2Ffollow-redirects-1.5.10.tgz#7b7a9f9aea2fdff36786a94ff643ed07f4ff5e2a" + integrity sha1-e3qfmuov3/NnhqlP9kPtB/T/Xio= + dependencies: + debug "=3.1.0" + follow-redirects@^1.0.0: version "1.11.0" resolved "https://registry.npm.taobao.org/follow-redirects/download/follow-redirects-1.11.0.tgz?cache=0&sync_timestamp=1585479417937&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ffollow-redirects%2Fdownload%2Ffollow-redirects-1.11.0.tgz#afa14f08ba12a52963140fe43212658897bc0ecb" @@ -4429,6 +4455,11 @@ jest-worker@^25.1.0: merge-stream "^2.0.0" supports-color "^7.0.0" +js-cookie@^2.2.1: + version "2.2.1" + resolved "https://registry.npm.taobao.org/js-cookie/download/js-cookie-2.2.1.tgz?cache=0&sync_timestamp=1583934793245&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fjs-cookie%2Fdownload%2Fjs-cookie-2.2.1.tgz#69e106dc5d5806894562902aa5baec3744e9b2b8" + integrity sha1-aeEG3F1YBolFYpAqpbrsN0Tpsrg= + js-message@1.0.5: version "1.0.5" resolved "https://registry.npm.taobao.org/js-message/download/js-message-1.0.5.tgz#2300d24b1af08e89dd095bc1a4c9c9cfcb892d15"