From e2a491fea11502c429aaa9407b1eb18df94ca8ab Mon Sep 17 00:00:00 2001 From: zemal Date: Sat, 19 Aug 2017 17:27:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0vue=E7=89=88=E6=9C=AC,?= =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=B3=A8=E5=86=8C=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- oj/package-lock.json | 53 ++--- oj/package.json | 8 +- oj/src/App.vue | 6 +- oj/src/api.js | 24 +- oj/src/components/NavBar.vue | 10 +- oj/src/routers/routes.js | 10 +- oj/src/views/index.js | 4 +- oj/src/views/submission/SubmissionList.vue | 1 - oj/src/views/user/Register.vue | 256 +++++++++++++-------- 9 files changed, 229 insertions(+), 143 deletions(-) diff --git a/oj/package-lock.json b/oj/package-lock.json index 6adbb60..01e3763 100644 --- a/oj/package-lock.json +++ b/oj/package-lock.json @@ -1736,9 +1736,9 @@ "dev": true }, "cosmiconfig": { - "version": "2.1.3", - "resolved": "http://registry.npm.taobao.org/cosmiconfig/download/cosmiconfig-2.1.3.tgz", - "integrity": "sha1-lSdx6w3dwcs/ovb75RpSLpOz7go=", + "version": "2.2.2", + "resolved": "http://registry.npm.taobao.org/cosmiconfig/download/cosmiconfig-2.2.2.tgz", + "integrity": "sha1-YXPOvVb6wELB9DkO33r2wHx8uJI=", "dev": true, "requires": { "is-directory": "0.3.1", @@ -2195,14 +2195,15 @@ } }, "editorconfig": { - "version": "0.13.2", - "resolved": "http://registry.npm.taobao.org/editorconfig/download/editorconfig-0.13.2.tgz", - "integrity": "sha1-jleSbZ7mmrbLmZ8CfCFxRnrM6zU=", + "version": "0.13.3", + "resolved": "http://registry.npm.taobao.org/editorconfig/download/editorconfig-0.13.3.tgz", + "integrity": "sha1-5SGeWHlR1glY/ZTqmpoAjN7/GzQ=", "dev": true, "requires": { "bluebird": "3.5.0", "commander": "2.9.0", "lru-cache": "3.2.0", + "semver": "5.3.0", "sigmund": "1.0.1" }, "dependencies": { @@ -4650,7 +4651,7 @@ "dev": true, "requires": { "config-chain": "1.1.11", - "editorconfig": "0.13.2", + "editorconfig": "0.13.3", "mkdirp": "0.5.1", "nopt": "3.0.6" } @@ -5743,7 +5744,7 @@ "integrity": "sha1-U56a/J3chiASHr+djDZz4M5Q0oo=", "dev": true, "requires": { - "cosmiconfig": "2.1.3", + "cosmiconfig": "2.2.2", "object-assign": "4.1.1", "postcss-load-options": "1.2.0", "postcss-load-plugins": "2.3.0" @@ -5755,7 +5756,7 @@ "integrity": "sha1-sJixVZ3awt8EvAuzdfmaXP4rbYw=", "dev": true, "requires": { - "cosmiconfig": "2.1.3", + "cosmiconfig": "2.2.2", "object-assign": "4.1.1" } }, @@ -5765,7 +5766,7 @@ "integrity": "sha1-dFdoEWWZrKLwCfrUJrABdQSdjZI=", "dev": true, "requires": { - "cosmiconfig": "2.1.3", + "cosmiconfig": "2.2.2", "object-assign": "4.1.1" } }, @@ -7402,9 +7403,9 @@ } }, "vue": { - "version": "2.3.4", - "resolved": "http://registry.npm.taobao.org/vue/download/vue-2.3.4.tgz", - "integrity": "sha1-XsO4ehkdqAkLvvVrfPq9QVgDgXE=" + "version": "2.4.2", + "resolved": "http://registry.npm.taobao.org/vue/download/vue-2.4.2.tgz", + "integrity": "sha1-qYVSYfGRyXjMDcEVBTG40IFJtYw=" }, "vue-codemirror": { "version": "3.0.8", @@ -7438,9 +7439,9 @@ "dev": true }, "vue-loader": { - "version": "12.2.1", - "resolved": "http://registry.npm.taobao.org/vue-loader/download/vue-loader-12.2.1.tgz", - "integrity": "sha1-U/J8CXPThnaPWnUVb0Epte/GulU=", + "version": "12.2.2", + "resolved": "http://registry.npm.taobao.org/vue-loader/download/vue-loader-12.2.2.tgz", + "integrity": "sha1-Kzp2TycBj5dbx4y4sfVRN1SO4tc=", "dev": true, "requires": { "consolidate": "0.14.5", @@ -7455,13 +7456,13 @@ "source-map": "0.5.6", "vue-hot-reload-api": "2.1.0", "vue-style-loader": "3.0.1", - "vue-template-es2015-compiler": "1.5.2" + "vue-template-es2015-compiler": "1.5.3" } }, "vue-router": { - "version": "2.6.0", - "resolved": "http://registry.npm.taobao.org/vue-router/download/vue-router-2.6.0.tgz", - "integrity": "sha1-d7Jx9uCsbVfo5VbaWMZYL84KtxI=" + "version": "2.7.0", + "resolved": "http://registry.npm.taobao.org/vue-router/download/vue-router-2.7.0.tgz", + "integrity": "sha1-FtQkSTqlHDyMzot8chDqTDqJr/E=" }, "vue-style-loader": { "version": "3.0.1", @@ -7474,9 +7475,9 @@ } }, "vue-template-compiler": { - "version": "2.3.4", - "resolved": "http://registry.npm.taobao.org/vue-template-compiler/download/vue-template-compiler-2.3.4.tgz", - "integrity": "sha1-WoisLF5NXWIY5qqA5+Ih+35niUw=", + "version": "2.4.2", + "resolved": "http://registry.npm.taobao.org/vue-template-compiler/download/vue-template-compiler-2.4.2.tgz", + "integrity": "sha1-WkXYQ/FIsJj2wdHjWsIMSVbTCtE=", "dev": true, "requires": { "de-indent": "1.0.2", @@ -7484,9 +7485,9 @@ } }, "vue-template-es2015-compiler": { - "version": "1.5.2", - "resolved": "http://registry.npm.taobao.org/vue-template-es2015-compiler/download/vue-template-es2015-compiler-1.5.2.tgz", - "integrity": "sha1-oKbFDJQdKkq9qWPy9CwzesRQ7pU=", + "version": "1.5.3", + "resolved": "http://registry.npm.taobao.org/vue-template-es2015-compiler/download/vue-template-es2015-compiler-1.5.3.tgz", + "integrity": "sha1-Inh95ON+vZM5t0IjvEZ9Gt7jBUU=", "dev": true }, "watchpack": { diff --git a/oj/package.json b/oj/package.json index 00693ba..2eb1517 100644 --- a/oj/package.json +++ b/oj/package.json @@ -16,11 +16,11 @@ "font-awesome": "^4.7.0", "iview": "^2.0.0-rc.17", "moment": "^2.18.1", - "vue": "^2.3.3", + "vue": "^2.4.2", "vue-codemirror": "^3.0.8", "vue-echarts": "^2.4.0", "vue-highlightjs": "^1.3.3", - "vue-router": "^2.6.0" + "vue-router": "^2.7.0" }, "devDependencies": { "autoprefixer": "^6.7.2", @@ -58,9 +58,9 @@ "semver": "^5.3.0", "shelljs": "^0.7.6", "url-loader": "^0.5.8", - "vue-loader": "^12.1.0", + "vue-loader": "^12.2.2", "vue-style-loader": "^3.0.1", - "vue-template-compiler": "^2.3.3", + "vue-template-compiler": "^2.4.2", "webpack": "^2.6.1", "webpack-bundle-analyzer": "^2.2.1", "webpack-dev-middleware": "^1.10.0", diff --git a/oj/src/App.vue b/oj/src/App.vue index d6e3107..6b30d0a 100644 --- a/oj/src/App.vue +++ b/oj/src/App.vue @@ -50,14 +50,14 @@ margin: 0; padding: 0; font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif; - overflow: auto; -webkit-font-smoothing: antialiased; background-color: #eee;; - overflow-y: scroll; } .content-app { - padding: 80px 15px 0 15px; + margin-top: 80px; + padding: 0 15px 0 15px; + overflow-y: scroll; } .footer { diff --git a/oj/src/api.js b/oj/src/api.js index 640e365..428d8cb 100644 --- a/oj/src/api.js +++ b/oj/src/api.js @@ -24,20 +24,26 @@ export default { } }) }, - // 注册 - register(username, email, password, captcha) { - return ajax('register', 'post', { + checkUsernameOrEmail(username, email) { + return ajax('check_username_or_email', 'post', { data: { username, - email, - password, - captcha + email } }) }, + // 注册 + register(data) { + return ajax('register', 'post', { + data + }) + }, logout() { return ajax('logout', 'get') }, + getCaptcha() { + return ajax('captcha', 'get') + }, // 获取自身信息 getUserInfo(username = undefined) { return ajax('account/profile', 'get', { @@ -207,9 +213,9 @@ function ajax(url, method, options) { // } } else { resolve(res) - if (method !== 'get') { - Vue.prototype.$success('Success') - } + // if (method !== 'get') { + // Vue.prototype.$success('Success') + // } } }, res => { // API请求异常,一般为Server error 或 network error diff --git a/oj/src/components/NavBar.vue b/oj/src/components/NavBar.vue index 1605f43..0eb284a 100644 --- a/oj/src/components/NavBar.vue +++ b/oj/src/components/NavBar.vue @@ -11,7 +11,7 @@ @@ -29,7 +29,7 @@ - + @@ -39,9 +39,15 @@ import api from '@/api' import auth from '../utils/authHelper' + import Register from '@/views/user/Register' + export default { + components: { + Register + }, data() { return { + registerModalVisible: false, isAuthed: false, username: '' } diff --git a/oj/src/routers/routes.js b/oj/src/routers/routes.js index 181be48..0457668 100644 --- a/oj/src/routers/routes.js +++ b/oj/src/routers/routes.js @@ -1,6 +1,9 @@ // all routes here. import Test from '../views/test' -import {ProblemList, Logout, ContestList, ContestDetails, ContestProblemList, ContestAnnouncement} from '../views' +import { + ProblemList, ContestList, ContestDetails, ContestProblemList, ContestAnnouncement, + Logout, Register +} from '../views' export default [ { @@ -62,6 +65,11 @@ export default [ path: '/contest/:contestID/problem/:problemID', component: () => import('@/views/problem/Problem.vue') }, + { + name: 'register', + path: '/register', + component: Register + }, { name: 'logout', path: '/logout', diff --git a/oj/src/views/index.js b/oj/src/views/index.js index 5b3453e..3bf0dad 100644 --- a/oj/src/views/index.js +++ b/oj/src/views/index.js @@ -4,8 +4,8 @@ import ContestDetails from './contest/ContestDetail.vue' import ContestProblemList from './contest/children/ContestProblemList.vue' import ContestAnnouncement from './contest/children/ContestAnnouncement.vue' import Logout from './user/Logout.vue' -// -export {ProblemList, Logout, ContestList, ContestDetails, ContestProblemList, ContestAnnouncement} +import Register from './user/Register.vue' +export {ProblemList, ContestList, ContestDetails, ContestProblemList, ContestAnnouncement, Register, Logout} /* 组件导出分为两类, 一类常用的直接导出,另一类诸如Login, Logout等用懒加载,懒加载不在此处导出 * 在对应的route内加载 diff --git a/oj/src/views/submission/SubmissionList.vue b/oj/src/views/submission/SubmissionList.vue index dde0dbb..98c5e0b 100644 --- a/oj/src/views/submission/SubmissionList.vue +++ b/oj/src/views/submission/SubmissionList.vue @@ -153,7 +153,6 @@ contest_id: this.contestID } api.getSubmissionList(offset, limit, params).then((res) => { - console.log(res.data.data.results) this.submissions = res.data.data.results this.total = res.data.data.total }) diff --git a/oj/src/views/user/Register.vue b/oj/src/views/user/Register.vue index 3ab10f7..5c4a877 100644 --- a/oj/src/views/user/Register.vue +++ b/oj/src/views/user/Register.vue @@ -1,114 +1,180 @@ -