Skip to content

Commit dbed309

Browse files
committed
Add user signup
1 parent 9e525f2 commit dbed309

4 files changed

Lines changed: 65 additions & 13 deletions

File tree

src/App.vue

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@
55
<img src="./assets/logo.png">
66
<span>{{ $t( '代码帮' ) }} </span>
77
</div>
8-
<div class="cb-searchbox" style="display: none;">
9-
<el-input
10-
:placeholder="$t( '请输入搜索内容' )"
11-
prefix-icon="el-icon-search"
12-
size="mini"
13-
clearable>
14-
</el-input>
15-
</div>
168
<el-button
179
@click="pageIndex=0"
1810
type="text">{{ $t( '代码' ) }}</el-button>
@@ -23,9 +15,17 @@
2315
<el-button
2416
@click="pageIndex=2"
2517
type="text">{{ $t( '运行' ) }}</el-button>
26-
<div class="cb-title">
18+
<div class="cb-title" v-show="pageIndex==0" style="flex-grow: 1">
2719
{{ title }}
2820
</div>
21+
<div class="cb-searchbox" v-show="pageIndex==0">
22+
<el-input
23+
:placeholder="$t( '请输入搜索内容' )"
24+
prefix-icon="el-icon-search"
25+
size="mini"
26+
clearable>
27+
</el-input>
28+
</div>
2929
<yix-controlbar v-show="pageIndex==2"></yix-controlbar>
3030
<div class="cb-toolbox">
3131
<el-button
@@ -217,15 +217,31 @@ body {
217217
color: #ccc;
218218
}
219219
220+
.cb-navbar .y-controlbox {
221+
flex-grow: 1;
222+
}
223+
224+
.cb-navbar .y-controlbox button {
225+
color: #f8f8f8;
226+
background: #333;
227+
}
228+
229+
.cb-navbar .y-controlbox button:hover {
230+
color: #ccc;
231+
background: #333;
232+
}
233+
220234
.cb-toolbox > * {
221-
padding-left: 9px;
235+
padding-left: 16px;
222236
}
223237
224238
.cb-title {
225239
background-color: #3f3f3f;
226240
text-align: center;
227241
margin-left: 16px;
228242
margin-right: 16px;
243+
padding-left: 16px;
244+
flex-grow: 1;
229245
}
230246
231247
.cb-brand {

src/components/LaunchManager.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<template>
22
<div class="cb-launcher">
3-
<yix-engineer>This is launcher for CodeBang</yix-engineer>
3+
<yix-engineer ref="engineer">This is launcher for CodeBang</yix-engineer>
44
</div>
55
</template>
66

77
<script>
8+
import Vue from "vue"
9+
import { RealComputer } from 'yix-engineer/src/lib.js'
810
import connector from '../connector.js'
911
1012
export default {
@@ -23,6 +25,12 @@ export default {
2325
if (success)
2426
connector.getLogon()
2527
} )
28+
let engineer = this.$refs.engineer
29+
Vue.prototype.$i_engineer = engineer
30+
31+
const RealComputerObject = Vue.extend( RealComputer )
32+
let computer = new RealComputerObject()
33+
engineer.initMainDomain( computer )
2634
},
2735
methods: {
2836
runCodeWithArguments ( obj, args ) {

src/components/LoginDialog.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
label-width="auto"
1414
class="ruleForm">
1515
<el-form-item label="账户" prop="name">
16-
<el-input v-model="ruleForm.name" autocomplete="off" placeholder="用户名/邮箱/手机号"></el-input>
16+
<el-input v-model="ruleForm.name" autocomplete="off" placeholder="用户名"></el-input>
1717
</el-form-item>
1818
<el-form-item v-if="!isRetrivePass" label="密码" prop="pass">
1919
<el-input type="password" v-model="ruleForm.pass" autocomplete="off" show-password></el-input>
@@ -188,7 +188,7 @@ export default {
188188
if(this.isRegister) {
189189
this.$refs[formName].validate((valid) => {
190190
if (valid) {
191-
connector.showError("现在还不能注册");
191+
connector.signup(this.ruleForm.name, this.ruleForm.pass);
192192
return true;
193193
}
194194
return false;

src/connector.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,28 @@ const error_callback = function (req, msg, err) {
7979
} )
8080
}
8181

82+
const register_user = function (username, password, success, fail) {
83+
const url = serverUrl + '/signup/'
84+
const data = {
85+
username: username,
86+
password: password
87+
}
88+
reqwest( {
89+
url: url,
90+
method: 'post',
91+
type: 'json',
92+
contentType: 'application/x-www-form-urlencoded',
93+
data: data,
94+
crossOrigin: crossOrigin,
95+
success: success,
96+
error: resp => {
97+
fail( resp.status === 400
98+
? JSON.parse(resp.responseText).username
99+
: resp.responseText )
100+
}
101+
} )
102+
}
103+
82104
const request_token = function (url, data, callback) {
83105
reqwest( {
84106
url: url,
@@ -252,6 +274,12 @@ export default new Vue({
252274
request_api(api, method, paras, callback, vnode.close)
253275
}
254276
},
277+
signup: function (username, password) {
278+
register_user(username, password,
279+
() => this.login(username, password),
280+
msg => this.showError(msg)
281+
)
282+
},
255283
login: function (username, password, silent) {
256284
const callback = function (success, result) {
257285
if (!success && !silent)

0 commit comments

Comments
 (0)