update to netdisk
This commit is contained in:
parent
1cf44893e9
commit
247776e149
@ -15,11 +15,13 @@
|
|||||||
"material-design-icons": "^3.0.1",
|
"material-design-icons": "^3.0.1",
|
||||||
"register-service-worker": "^1.6.2",
|
"register-service-worker": "^1.6.2",
|
||||||
"roboto-fontface": "^0.6.0",
|
"roboto-fontface": "^0.6.0",
|
||||||
|
"vconsole": "^3.3.4",
|
||||||
"vue": "^2.6.11",
|
"vue": "^2.6.11",
|
||||||
"vue-clipboard2": "^0.3.1",
|
"vue-clipboard2": "^0.3.1",
|
||||||
"vue-material": "^1.0.0-beta-11",
|
"vue-material": "^1.0.0-beta-11",
|
||||||
"vue-router": "^3.1.5",
|
"vue-router": "^3.1.5",
|
||||||
"vue-svg-icon": "^1.2.9",
|
"vue-svg-icon": "^1.2.9",
|
||||||
|
"vue-touch": "^1.1.0",
|
||||||
"vuex": "^3.1.2"
|
"vuex": "^3.1.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -3,25 +3,7 @@ import { api } from "./fetch";
|
|||||||
|
|
||||||
var CryptoJS = require("crypto-js");
|
var CryptoJS = require("crypto-js");
|
||||||
|
|
||||||
// 登录 传参 data => mail_addr, password, update_time
|
// 更新本地 传参 data => cid pwd
|
||||||
export function login(data) {
|
|
||||||
var sign = CryptoJS.MD5(JSON.stringify(data).replace(/\"/g,"'")).toString().toUpperCase();
|
|
||||||
data.sign = sign
|
|
||||||
let params = new URLSearchParams();
|
|
||||||
params.append('data', JSON.stringify(data));
|
|
||||||
return api.post('/login', params)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 激活 传参 data => uuid mail_addr
|
|
||||||
export function activation(data) {
|
|
||||||
var sign = CryptoJS.MD5(JSON.stringify(data).replace(/\"/g,"'")).toString().toUpperCase();
|
|
||||||
data.sign = sign
|
|
||||||
let params = new URLSearchParams();
|
|
||||||
params.append('data', JSON.stringify(data));
|
|
||||||
return api.post('/activation', params)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 更新本地 传参 data => mail_addr password
|
|
||||||
export function syncLocal(data) {
|
export function syncLocal(data) {
|
||||||
var sign = CryptoJS.MD5(JSON.stringify(data).replace(/\"/g,"'")).toString().toUpperCase();
|
var sign = CryptoJS.MD5(JSON.stringify(data).replace(/\"/g,"'")).toString().toUpperCase();
|
||||||
data.sign = sign
|
data.sign = sign
|
||||||
@ -30,9 +12,11 @@ export function syncLocal(data) {
|
|||||||
return api.post('/download', params)
|
return api.post('/download', params)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新云端 传参 data => mail_addr password codebook update_time
|
// 更新云端 传参 data => cid pwd content
|
||||||
export function syncCloud(data) {
|
export function syncCloud(data) {
|
||||||
var sign = CryptoJS.MD5(JSON.stringify(data).replace(/\"/g,"'")).toString().toUpperCase();
|
let data_cache = Object.assign({}, data)
|
||||||
|
delete data_cache.content
|
||||||
|
var sign = CryptoJS.MD5(JSON.stringify(data_cache).replace(/\"/g,"'")).toString().toUpperCase();
|
||||||
data.sign = sign
|
data.sign = sign
|
||||||
let params = new URLSearchParams();
|
let params = new URLSearchParams();
|
||||||
params.append('data', JSON.stringify(data));
|
params.append('data', JSON.stringify(data));
|
||||||
|
@ -2,8 +2,9 @@ import axios from 'axios'
|
|||||||
|
|
||||||
export const api = axios.create({
|
export const api = axios.create({
|
||||||
// baseURL: 'https://ccb.canary.moe/api/',
|
// baseURL: 'https://ccb.canary.moe/api/',
|
||||||
baseURL: window.location.origin + '/api/',
|
// baseURL: window.location.origin + '/api/',
|
||||||
// baseURL: 'https://canary.lacus.site/api/',
|
// baseURL: 'https://canary.lacus.site/api/',
|
||||||
|
baseURL: 'http://canary.lacus.icu/api/',
|
||||||
// baseURL: 'http://beta.lacus.site/api/',
|
// baseURL: 'http://beta.lacus.site/api/',
|
||||||
// baseURL: 'http://152.136.99.231:8001' + '/api/',
|
// baseURL: 'http://152.136.99.231:8001' + '/api/',
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -170,28 +170,21 @@ export function lang() {
|
|||||||
CHS: {
|
CHS: {
|
||||||
title: '账户',
|
title: '账户',
|
||||||
login: {
|
login: {
|
||||||
input_placeholder: ['邮箱地址', '密码'],
|
input_placeholder: ['教务账号', '密码'],
|
||||||
password_errmsg: '密码不能为空',
|
password_errmsg: '密码不能为空',
|
||||||
submit: '登录 / 注册'
|
submit: '登录'
|
||||||
},
|
|
||||||
activation: {
|
|
||||||
title: '恭喜! 激活码已经下发到你的邮箱',
|
|
||||||
subheader: '激活码',
|
|
||||||
input_errmsg: '激活码不可为空',
|
|
||||||
submit: '立即激活'
|
|
||||||
},
|
},
|
||||||
account: {
|
account: {
|
||||||
label: ['云端信息最后修改时间', '同步本地密码本至云端', '同步云端密码本至本地'],
|
label: ['云端信息最后修改时间','云端信息最后修改设备名', '同步本地密码本至云端', '同步云端密码本至本地'],
|
||||||
logout: '退出登录'
|
logout: '退出登录'
|
||||||
},
|
},
|
||||||
mail_addr_errmsg: ['邮箱地址不能为空', '邮箱地址不合法'],
|
cid_errmsg: ['教务账号不能为空'],
|
||||||
snakebar_msg: ['抱歉, 网络错误',
|
snakebar_msg: ['抱歉, 网络错误',
|
||||||
'恭喜! 登录成功!',
|
'抱歉,统一认证系统挂了',
|
||||||
'恭喜! 请在您的邮箱里找到激活码!',
|
'抱歉,账号或者密码错误',
|
||||||
'抱歉, 密码错误, 请重新输入',
|
|
||||||
'抱歉, 网络错误. 错误码:',
|
'抱歉, 网络错误. 错误码:',
|
||||||
'恭喜! 激活成功!',
|
'恭喜! 登录成功!',
|
||||||
'抱歉, 激活码错误, 请重新输入',
|
'抱歉,数据获取成功,内容有误',
|
||||||
'恭喜! 本地数据更新成功!',
|
'恭喜! 本地数据更新成功!',
|
||||||
'恭喜! 云端数据更新成功!'
|
'恭喜! 云端数据更新成功!'
|
||||||
]
|
]
|
||||||
@ -199,28 +192,21 @@ export function lang() {
|
|||||||
EN: {
|
EN: {
|
||||||
title: 'Account',
|
title: 'Account',
|
||||||
login: {
|
login: {
|
||||||
input_placeholder: ['Mail addr', 'Password'],
|
input_placeholder: ['Educational Administration Account', 'Password'],
|
||||||
password_errmsg: 'Password can not be none.',
|
password_errmsg: 'Password can not be none.',
|
||||||
submit: 'Login / Sign'
|
submit: 'Login'
|
||||||
},
|
|
||||||
activation: {
|
|
||||||
title: 'Congratulations! Activation code has been sent to your email',
|
|
||||||
subheader: 'Activation Code',
|
|
||||||
input_errmsg: 'Activation Code can not be none.',
|
|
||||||
submit: 'activation'
|
|
||||||
},
|
},
|
||||||
account: {
|
account: {
|
||||||
label: ['Cloud last modified time', 'Sync local codebook to cloud', 'Sync cloud codebook to local'],
|
label: ['Cloud last modified time','Cloud last modified drivce', 'Sync local codebook to cloud', 'Sync cloud codebook to local'],
|
||||||
logout: 'Logout'
|
logout: 'Logout'
|
||||||
},
|
},
|
||||||
mail_addr_errmsg: ['Mail addr can not be none.', 'Mail addr is invalid.'],
|
cid_errmsg: ['Mail addr can not be none.'],
|
||||||
snakebar_msg: ['Sorry, network error',
|
snakebar_msg: ['Sorry, network error',
|
||||||
'Congratulations! Login is successful!',
|
'Sorry, Educational System error',
|
||||||
'Congratulations! Please find the activation code in your email!',
|
'Sorry, account or password is wrong',
|
||||||
'Sorry, the password is wrong, please re-enter',
|
|
||||||
'Sorry, network error. errcode:',
|
'Sorry, network error. errcode:',
|
||||||
'Congratulations! Activation is successful!',
|
'Congratulations! Login is successful!',
|
||||||
'Sorry, the activation is wrong, please re-enter',
|
'Sorry, content get successful but content is wrong',
|
||||||
'Congratulations! Local data update completed!',
|
'Congratulations! Local data update completed!',
|
||||||
'Congratulations! Cloud data update completed!'
|
'Congratulations! Cloud data update completed!'
|
||||||
]
|
]
|
||||||
@ -232,6 +218,7 @@ export function lang() {
|
|||||||
subheader: ['创建主密码', '解锁Canary Codebook'],
|
subheader: ['创建主密码', '解锁Canary Codebook'],
|
||||||
pwd_label: ['主密码','解锁密码'],
|
pwd_label: ['主密码','解锁密码'],
|
||||||
repeat_pwd: '再次输入主密码',
|
repeat_pwd: '再次输入主密码',
|
||||||
|
drivce_label: '请输入本设备名(多端同步用)',
|
||||||
enter: '提交',
|
enter: '提交',
|
||||||
dialog: {
|
dialog: {
|
||||||
title: '确认提交',
|
title: '确认提交',
|
||||||
|
@ -13,10 +13,10 @@
|
|||||||
<div ref="list_placeholder" style="height: 54px;"></div>
|
<div ref="list_placeholder" style="height: 54px;"></div>
|
||||||
<icon class="logo" name="canary"></icon>
|
<icon class="logo" name="canary"></icon>
|
||||||
<template v-if="page_type == 'login'">
|
<template v-if="page_type == 'login'">
|
||||||
<md-field :class="mail_addr_verify ? '' : 'md-invalid'">
|
<md-field :class="cid_verify ? '' : 'md-invalid'">
|
||||||
<label>{{ lang.login.input_placeholder[0] }}</label>
|
<label>{{ lang.login.input_placeholder[0] }}</label>
|
||||||
<md-input v-model="mail_addr" required></md-input>
|
<md-input v-model="cid" required></md-input>
|
||||||
<span class="md-error">{{ mail_addr_errmsg }}</span>
|
<span class="md-error">{{ cid_errmsg }}</span>
|
||||||
</md-field>
|
</md-field>
|
||||||
|
|
||||||
<md-field :class="password_verify ? '' : 'md-invalid'">
|
<md-field :class="password_verify ? '' : 'md-invalid'">
|
||||||
@ -30,23 +30,10 @@
|
|||||||
</md-button>
|
</md-button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-if="page_type == 'activation'">
|
|
||||||
<p class="md-caption">{{ lang.activation.title }}</p>
|
|
||||||
<md-field :class="activation_code_verify ? '' : 'md-invalid'">
|
|
||||||
<label>{{ lang.activation.subheader }}</label>
|
|
||||||
<md-input v-model="activation_code" required></md-input>
|
|
||||||
<span class="md-error">{{ lang.activation.input_errmsg }}</span>
|
|
||||||
</md-field>
|
|
||||||
<md-button class="md-raised md-primary expand" :disabled="activation_loading" @click="judgeActivation()">
|
|
||||||
{{ lang.activation.submit }}
|
|
||||||
<div class="loading-box"><md-progress-spinner v-if="activation_loading" :md-diameter="22" :md-stroke="3" md-mode="indeterminate"></md-progress-spinner></div>
|
|
||||||
</md-button>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template v-if="page_type == 'account'">
|
<template v-if="page_type == 'account'">
|
||||||
<md-list>
|
<md-list>
|
||||||
<md-list-item>
|
<md-list-item>
|
||||||
<span class="md-list-item-text">{{ user_infos.mail_addr }}</span>
|
<span class="md-list-item-text">{{ user_infos.cid }} | {{ user_infos.user_name }}</span>
|
||||||
</md-list-item>
|
</md-list-item>
|
||||||
|
|
||||||
<md-divider></md-divider>
|
<md-divider></md-divider>
|
||||||
@ -58,12 +45,17 @@
|
|||||||
|
|
||||||
<md-list-item>
|
<md-list-item>
|
||||||
<span class="md-list-item-text">{{ lang.account.label[1] }}</span>
|
<span class="md-list-item-text">{{ lang.account.label[1] }}</span>
|
||||||
|
<span class="time-content">{{ user_infos.cloud_drivce }}</span>
|
||||||
|
</md-list-item>
|
||||||
|
|
||||||
|
<md-list-item>
|
||||||
|
<span class="md-list-item-text">{{ lang.account.label[2] }}</span>
|
||||||
<md-button @click="syncCloudStart()" v-if="!sync_cloud_loading" class="md-icon-button md-list-action"><md-icon>cloud_upload</md-icon></md-button>
|
<md-button @click="syncCloudStart()" v-if="!sync_cloud_loading" class="md-icon-button md-list-action"><md-icon>cloud_upload</md-icon></md-button>
|
||||||
<md-progress-spinner v-else :md-diameter="22" :md-stroke="3" md-mode="indeterminate"></md-progress-spinner>
|
<md-progress-spinner v-else :md-diameter="22" :md-stroke="3" md-mode="indeterminate"></md-progress-spinner>
|
||||||
</md-list-item>
|
</md-list-item>
|
||||||
|
|
||||||
<md-list-item>
|
<md-list-item>
|
||||||
<span class="md-list-item-text">{{ lang.account.label[2] }}</span>
|
<span class="md-list-item-text">{{ lang.account.label[3] }}</span>
|
||||||
<md-button @click="syncLocalStart()" v-if="!sync_local_loading" class="md-icon-button md-list-action"><md-icon>cloud_download</md-icon></md-button>
|
<md-button @click="syncLocalStart()" v-if="!sync_local_loading" class="md-icon-button md-list-action"><md-icon>cloud_download</md-icon></md-button>
|
||||||
<md-progress-spinner v-else :md-diameter="22" :md-stroke="3" md-mode="indeterminate"></md-progress-spinner>
|
<md-progress-spinner v-else :md-diameter="22" :md-stroke="3" md-mode="indeterminate"></md-progress-spinner>
|
||||||
</md-list-item>
|
</md-list-item>
|
||||||
@ -84,7 +76,7 @@
|
|||||||
// @ is an alias to /src
|
// @ is an alias to /src
|
||||||
import { mapState, mapActions } from 'vuex';
|
import { mapState, mapActions } from 'vuex';
|
||||||
import { encrypt, decrypt, encryptMainCode, decryptMainCode } from '@/utils/aes.js';
|
import { encrypt, decrypt, encryptMainCode, decryptMainCode } from '@/utils/aes.js';
|
||||||
import { login, activation, syncLocal, syncCloud } from '@/axios/api.js';
|
import { syncLocal, syncCloud } from '@/axios/api.js';
|
||||||
import { lang } from '@/utils/language.js';
|
import { lang } from '@/utils/language.js';
|
||||||
import { setHtmlFontSize } from '@/utils/px2rem.js';
|
import { setHtmlFontSize } from '@/utils/px2rem.js';
|
||||||
|
|
||||||
@ -92,18 +84,15 @@ export default {
|
|||||||
name: 'Add',
|
name: 'Add',
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
page_type: 'login', // login activation account
|
page_type: 'login', // login account
|
||||||
mail_addr: '',
|
cid: '',
|
||||||
mail_addr_verify: true,
|
cid_verify: true,
|
||||||
mail_addr_errmsg: '',
|
cid_errmsg: '',
|
||||||
password: '',
|
password: '',
|
||||||
password_verify: true,
|
password_verify: true,
|
||||||
activation_code: '',
|
|
||||||
activation_code_verify: true,
|
|
||||||
sync_local_loading: false,
|
sync_local_loading: false,
|
||||||
sync_cloud_loading: false,
|
sync_cloud_loading: false,
|
||||||
login_loading: false,
|
login_loading: false,
|
||||||
activation_loading: false,
|
|
||||||
show_snackbar: false,
|
show_snackbar: false,
|
||||||
snakebar_msg: '',
|
snakebar_msg: '',
|
||||||
lang: '',
|
lang: '',
|
||||||
@ -133,19 +122,8 @@ export default {
|
|||||||
this.$store.replaceState(Object.assign(this.$store.state, JSON.parse(localStorage.getItem('storeState'))));
|
this.$store.replaceState(Object.assign(this.$store.state, JSON.parse(localStorage.getItem('storeState'))));
|
||||||
this.initLanguage();
|
this.initLanguage();
|
||||||
// 判断页面类型
|
// 判断页面类型
|
||||||
if (this.user_infos.has_login) {
|
if(this.user_infos && this.user_infos.cid && this.user_infos.row_login_pwd) this.page_type = 'account'
|
||||||
// 已经登录
|
else this.page_type = 'login'
|
||||||
if (this.user_infos.activation) {
|
|
||||||
// 已经激活用户
|
|
||||||
this.page_type = 'account';
|
|
||||||
} else {
|
|
||||||
// 登录但是没激活
|
|
||||||
this.page_type = 'activation';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 还没登录
|
|
||||||
this.page_type = 'login';
|
|
||||||
}
|
|
||||||
console.log('当前用户状态为' + this.page_type);
|
console.log('当前用户状态为' + this.page_type);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -176,16 +154,10 @@ export default {
|
|||||||
let can_continue = true;
|
let can_continue = true;
|
||||||
|
|
||||||
// 处理mail_addr
|
// 处理mail_addr
|
||||||
if (!(this.mail_addr = this.mail_addr.trim())) {
|
if (!(this.cid = this.cid.trim())) {
|
||||||
can_continue = false;
|
can_continue = false;
|
||||||
this.mail_addr_verify = false;
|
this.cid_verify = false;
|
||||||
this.mail_addr_errmsg = this.lang.mail_addr_errmsg[0];
|
this.cid_errmsg = this.lang.cid_errmsg[0];
|
||||||
}
|
|
||||||
let reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
|
|
||||||
if (!reg.test(this.mail_addr)) {
|
|
||||||
can_continue = false;
|
|
||||||
this.mail_addr_verify = false;
|
|
||||||
this.mail_addr_errmsg = this.lang.mail_addr_errmsg[1];
|
|
||||||
}
|
}
|
||||||
// 处理password
|
// 处理password
|
||||||
if (!(this.password = this.password.trim())) {
|
if (!(this.password = this.password.trim())) {
|
||||||
@ -200,131 +172,49 @@ export default {
|
|||||||
startLogin() {
|
startLogin() {
|
||||||
this.login_loading = true;
|
this.login_loading = true;
|
||||||
let data = {
|
let data = {
|
||||||
mail_addr: this.mail_addr,
|
cid: this.cid,
|
||||||
password: encryptMainCode(this.password),
|
pwd: this.password,
|
||||||
update_time: new Date().getTime()
|
|
||||||
};
|
};
|
||||||
login(data)
|
syncLocal(data)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
// console.log(res.data)
|
console.log(res.data)
|
||||||
this.manageLoginRes(res.data);
|
this.manageLoginRes(res.data);
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
this.login_loading = false;
|
this.login_loading = false;
|
||||||
this.snakebar_msg = this.lang.snakebar_msg[0];
|
if(!err.response){
|
||||||
|
this.snakebar_msg = this.lang.snakebar_msg[0];
|
||||||
|
} else if(err.response.status == 512) {
|
||||||
|
this.snakebar_msg = this.lang.snakebar_msg[1];
|
||||||
|
} else if(err.response.status == 510) {
|
||||||
|
this.snakebar_msg = this.lang.snakebar_msg[2];
|
||||||
|
} else {
|
||||||
|
this.snakebar_msg = this.lang.snakebar_msg[3] + err.response.status;
|
||||||
|
}
|
||||||
this.show_snackbar = true;
|
this.show_snackbar = true;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// 处理登录后端返回的信息
|
// 处理登录后端返回的信息
|
||||||
manageLoginRes(data) {
|
manageLoginRes(data) {
|
||||||
if (data.errcode == 200) {
|
// 登录成功
|
||||||
// 登录成功,正常用户
|
let user_infos = {
|
||||||
let user_infos = {
|
cid: this.cid,
|
||||||
mail_addr: this.mail_addr,
|
row_login_pwd: encryptMainCode(this.password),
|
||||||
has_login: true,
|
user_name: data.username,
|
||||||
activation: true,
|
update_time: data.modified,
|
||||||
row_login_pwd: encryptMainCode(this.password),
|
drivce: this.user_infos.drivce,
|
||||||
update_time: data.update_time
|
cloud_drivce: this.settings.is_chinese ? '暂无' : 'unknown'
|
||||||
};
|
};
|
||||||
this.setUserInfo([user_infos, this]);
|
this.setUserInfo([user_infos, this]);
|
||||||
console.log('正常用户登录,用户信息覆写完成');
|
console.log('正常用户登录,用户信息覆写完成');
|
||||||
this.snakebar_msg = this.lang.snakebar_msg[1];
|
this.snakebar_msg = this.lang.snakebar_msg[4];
|
||||||
this.show_snackbar = true;
|
this.show_snackbar = true;
|
||||||
this.page_type = 'account';
|
this.page_type = 'account';
|
||||||
} else if (data.errcode == 107 || data.errcode == 108 || data.errcode == 105) {
|
|
||||||
// 注册成功等待验证
|
|
||||||
let user_infos = {
|
|
||||||
mail_addr: this.mail_addr,
|
|
||||||
has_login: true,
|
|
||||||
activation: false,
|
|
||||||
row_login_pwd: encryptMainCode(this.password),
|
|
||||||
update_time: this.user_infos.update_time
|
|
||||||
};
|
|
||||||
this.setUserInfo([user_infos, this]);
|
|
||||||
console.log('用户注册成功,验证码已下发,用户信息覆写完成');
|
|
||||||
this.snakebar_msg = this.lang.snakebar_msg[2];
|
|
||||||
this.show_snackbar = true;
|
|
||||||
this.page_type = 'activation';
|
|
||||||
} else if (data.errcode == 106) {
|
|
||||||
this.password = '';
|
|
||||||
console.log('用户密码错误');
|
|
||||||
this.snakebar_msg = this.lang.snakebar_msg[3];
|
|
||||||
this.show_snackbar = true;
|
|
||||||
} else {
|
|
||||||
console.log('请求出错');
|
|
||||||
console.log(data);
|
|
||||||
this.snakebar_msg = this.lang.snakebar_msg[4] + data.errcode;
|
|
||||||
this.show_snackbar = true;
|
|
||||||
}
|
|
||||||
this.login_loading = false;
|
this.login_loading = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
// 点击激活
|
|
||||||
judgeActivation() {
|
|
||||||
// 设置flag
|
|
||||||
let can_continue = true;
|
|
||||||
// 处理password
|
|
||||||
if (!(this.activation_code = this.activation_code.trim())) {
|
|
||||||
can_continue = false;
|
|
||||||
this.activation_code_verify = false;
|
|
||||||
}
|
|
||||||
// 根据flag判断是否提交
|
|
||||||
if (can_continue) this.startActivation();
|
|
||||||
},
|
|
||||||
|
|
||||||
// 开始激活
|
|
||||||
startActivation() {
|
|
||||||
this.activation_loading = true;
|
|
||||||
let data = {
|
|
||||||
mail_addr: this.user_infos.mail_addr,
|
|
||||||
uuid: this.activation_code
|
|
||||||
};
|
|
||||||
activation(data)
|
|
||||||
.then(res => {
|
|
||||||
// console.log(res.data)
|
|
||||||
this.manageActivation(res.data);
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
console.log(err);
|
|
||||||
this.activation_loading = false;
|
|
||||||
this.snakebar_msg = this.lang.snakebar_msg[0];
|
|
||||||
this.show_snackbar = true;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
// 处理激活后端返回的信息
|
|
||||||
manageActivation(data) {
|
|
||||||
if (data.errcode == 200) {
|
|
||||||
// 激活成功
|
|
||||||
let user_infos = {
|
|
||||||
mail_addr: this.user_infos.mail_addr,
|
|
||||||
has_login: true,
|
|
||||||
activation: true,
|
|
||||||
row_login_pwd: this.user_infos.row_login_pwd,
|
|
||||||
update_time: data.update_time
|
|
||||||
};
|
|
||||||
this.setUserInfo([user_infos, this]);
|
|
||||||
console.log('验证成功,用户信息覆写完成');
|
|
||||||
this.snakebar_msg = this.lang.snakebar_msg[5];
|
|
||||||
this.show_snackbar = true;
|
|
||||||
this.page_type = 'account';
|
|
||||||
} else if (data.errcode == 401 || data.errcode == 404 || data.errcode == 407) {
|
|
||||||
// 验证码输入的问题
|
|
||||||
this.activation_code = '';
|
|
||||||
console.log('验证码错误');
|
|
||||||
console.log(data);
|
|
||||||
this.snakebar_msg = this.lang.snakebar_msg[6];
|
|
||||||
this.show_snackbar = true;
|
|
||||||
} else {
|
|
||||||
console.log('请求出错');
|
|
||||||
console.log(data);
|
|
||||||
this.snakebar_msg = this.lang.snakebar_msg[4] + data.errcode;
|
|
||||||
this.show_snackbar = true;
|
|
||||||
}
|
|
||||||
this.activation_loading = false;
|
|
||||||
},
|
|
||||||
// 处理时间
|
// 处理时间
|
||||||
formatDateTime(inputTime) {
|
formatDateTime(inputTime) {
|
||||||
var date = new Date(inputTime);
|
var date = new Date(inputTime);
|
||||||
@ -348,40 +238,61 @@ export default {
|
|||||||
syncLocalStart() {
|
syncLocalStart() {
|
||||||
this.sync_local_loading = true;
|
this.sync_local_loading = true;
|
||||||
let data = {
|
let data = {
|
||||||
mail_addr: this.user_infos.mail_addr,
|
cid: this.user_infos.cid,
|
||||||
password: this.user_infos.row_login_pwd
|
pwd: decryptMainCode(this.user_infos.row_login_pwd)
|
||||||
};
|
};
|
||||||
syncLocal(data)
|
syncLocal(data)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
console.log(res.data)
|
let data = res.data
|
||||||
if (res.data.errcode == 200) {
|
// 获取成功
|
||||||
// 获取成功
|
let content = ''
|
||||||
this.setRowData([res.data.codebook, this]);
|
try{
|
||||||
|
content = JSON.parse(data.content)
|
||||||
|
if(typeof content == 'string') throw new Error()
|
||||||
|
if(!content || !content.codebook){
|
||||||
|
// 无数据自动初始化
|
||||||
|
content = {
|
||||||
|
codebook: '',
|
||||||
|
drivce: content.drivce ? content.drivce : (this.settings.is_chinese ? '暂无' : 'unknown')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!content.drivce) content.drivce = content.drivce ? content.drivce : (this.settings.is_chinese ? '暂无' : 'unknown')
|
||||||
|
this.setRowData([content.codebook, this]);
|
||||||
console.log('数据获取成功,密码本覆写成功');
|
console.log('数据获取成功,密码本覆写成功');
|
||||||
let user_infos = this.user_infos;
|
let user_infos = this.user_infos;
|
||||||
user_infos.update_time = res.data.update_time;
|
user_infos.update_time = data.modified - 60 * 4;
|
||||||
|
user_infos.user_name = data.username;
|
||||||
|
user_infos.cloud_drivce = content.drivce
|
||||||
this.setUserInfo([user_infos, this]);
|
this.setUserInfo([user_infos, this]);
|
||||||
console.log('数据获取成功,用户信息覆写成功');
|
console.log('数据获取成功,用户信息覆写成功');
|
||||||
this.snakebar_msg = this.lang.snakebar_msg[7];
|
this.snakebar_msg = this.lang.snakebar_msg[6];
|
||||||
this.show_snackbar = true;
|
this.show_snackbar = true;
|
||||||
} else {
|
} catch(e) {
|
||||||
// 获取失败
|
console.log(e)
|
||||||
console.log('数据获取失败');
|
console.log('数据获取成功,内容有误')
|
||||||
console.log(res.data);
|
this.snakebar_msg = this.lang.snakebar_msg[5];
|
||||||
this.snakebar_msg = this.lang.snakebar_msg[4] + res.data.errcode;
|
|
||||||
this.show_snackbar = true;
|
this.show_snackbar = true;
|
||||||
}
|
} finally {
|
||||||
setTimeout(
|
setTimeout(
|
||||||
function() {
|
function() {
|
||||||
this.sync_local_loading = false;
|
this.sync_local_loading = false;
|
||||||
}.bind(this),
|
}.bind(this),
|
||||||
1000
|
1000
|
||||||
);
|
);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
this.sync_local_loading = false;
|
this.sync_local_loading = false;
|
||||||
this.snakebar_msg = this.lang.snakebar_msg[0];
|
if(!err.response){
|
||||||
|
this.snakebar_msg = this.lang.snakebar_msg[0];
|
||||||
|
} else if(err.response.status == 512) {
|
||||||
|
this.snakebar_msg = this.lang.snakebar_msg[1];
|
||||||
|
} else if(err.response.status == 510) {
|
||||||
|
this.snakebar_msg = this.lang.snakebar_msg[2];
|
||||||
|
} else {
|
||||||
|
this.snakebar_msg = this.lang.snakebar_msg[3] + err.response.status;
|
||||||
|
}
|
||||||
this.show_snackbar = true;
|
this.show_snackbar = true;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -389,30 +300,27 @@ export default {
|
|||||||
// 更新云端密码本
|
// 更新云端密码本
|
||||||
syncCloudStart() {
|
syncCloudStart() {
|
||||||
this.sync_cloud_loading = true;
|
this.sync_cloud_loading = true;
|
||||||
let data = {
|
let content = {
|
||||||
mail_addr: this.user_infos.mail_addr,
|
|
||||||
password: this.user_infos.row_login_pwd,
|
|
||||||
codebook: this.row_data,
|
codebook: this.row_data,
|
||||||
update_time: new Date().getTime()
|
drivce: this.user_infos.drivce
|
||||||
|
}
|
||||||
|
let data = {
|
||||||
|
cid: this.user_infos.cid,
|
||||||
|
pwd: decryptMainCode(this.user_infos.row_login_pwd),
|
||||||
|
content: JSON.stringify(content)
|
||||||
};
|
};
|
||||||
syncCloud(data)
|
syncCloud(data)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
// console.log(res.data)
|
let user_infos = this.user_infos;
|
||||||
if (res.data.errcode == 200) {
|
user_infos.update_time = new Date().getTime();
|
||||||
// 获取成功
|
console.log(user_infos)
|
||||||
let user_infos = this.user_infos;
|
user_infos.cloud_drivce = user_infos.drivce ? user_infos.drivce : (this.settings.is_chinese ? '暂无' : 'unknown')
|
||||||
user_infos.update_time = res.data.update_time;
|
console.log(user_infos)
|
||||||
this.setUserInfo([user_infos, this]);
|
|
||||||
console.log('数据获取成功,用户信息覆写成功');
|
this.setUserInfo([user_infos, this]);
|
||||||
this.snakebar_msg = this.lang.snakebar_msg[8];
|
console.log('数据上传成功,用户信息覆写成功');
|
||||||
this.show_snackbar = true;
|
this.snakebar_msg = this.lang.snakebar_msg[7];
|
||||||
} else {
|
this.show_snackbar = true;
|
||||||
// 获取失败
|
|
||||||
console.log('数据获取失败');
|
|
||||||
console.log(res.data);
|
|
||||||
this.snakebar_msg = this.lang.snakebar_msg[4] + res.data.errcode;
|
|
||||||
this.show_snackbar = true;
|
|
||||||
}
|
|
||||||
setTimeout(
|
setTimeout(
|
||||||
function() {
|
function() {
|
||||||
this.sync_cloud_loading = false;
|
this.sync_cloud_loading = false;
|
||||||
@ -423,7 +331,15 @@ export default {
|
|||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
this.sync_cloud_loading = false;
|
this.sync_cloud_loading = false;
|
||||||
this.snakebar_msg = this.lang.snakebar_msg[0];
|
if(!err.response){
|
||||||
|
this.snakebar_msg = this.lang.snakebar_msg[0];
|
||||||
|
} else if(err.response.status == 512) {
|
||||||
|
this.snakebar_msg = this.lang.snakebar_msg[1];
|
||||||
|
} else if(err.response.status == 510) {
|
||||||
|
this.snakebar_msg = this.lang.snakebar_msg[2];
|
||||||
|
} else {
|
||||||
|
this.snakebar_msg = this.lang.snakebar_msg[3] + err.response.status;
|
||||||
|
}
|
||||||
this.show_snackbar = true;
|
this.show_snackbar = true;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -432,10 +348,12 @@ export default {
|
|||||||
startLogout() {
|
startLogout() {
|
||||||
// 初始化用户信息
|
// 初始化用户信息
|
||||||
let user_infos = {
|
let user_infos = {
|
||||||
mail_addr: 'A Little Canary',
|
user_name: 'A Little Canary',
|
||||||
has_login: false,
|
cid: 'Codebook',
|
||||||
activation: false,
|
row_login_pwd: '',
|
||||||
update_time: '1582282494434'
|
drivce: this.settings.is_chinese ? '暂无' : 'unknown',
|
||||||
|
cloud_drivce: this.settings.is_chinese ? '暂无' : 'unknown',
|
||||||
|
update_time: new Date().getTime()
|
||||||
};
|
};
|
||||||
this.setUserInfo([user_infos, this]);
|
this.setUserInfo([user_infos, this]);
|
||||||
console.log('用户信息覆写完成');
|
console.log('用户信息覆写完成');
|
||||||
@ -461,9 +379,9 @@ export default {
|
|||||||
clientHeight: function() {
|
clientHeight: function() {
|
||||||
this.changeFixed(this.clientHeight);
|
this.changeFixed(this.clientHeight);
|
||||||
},
|
},
|
||||||
// 如果 `mail_addr` 发生改变,就会清空错误状态
|
// 如果 `cid` 发生改变,就会清空错误状态
|
||||||
mail_addr: function() {
|
cid: function() {
|
||||||
this.mail_addr_verify = true;
|
this.cid_verify = true;
|
||||||
},
|
},
|
||||||
// 如果 `password` 发生改变,就会清空错误状态
|
// 如果 `password` 发生改变,就会清空错误状态
|
||||||
password: function() {
|
password: function() {
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
<div class="drawer-banner" @click="toggleVc()">
|
<div class="drawer-banner" @click="toggleVc()">
|
||||||
<md-icon class="default-avatar md-size-2x face">face</md-icon>
|
<md-icon class="default-avatar md-size-2x face">face</md-icon>
|
||||||
<p class="md-title">Canary Codebook</p>
|
<p class="md-title">Canary Codebook</p>
|
||||||
<p class="md-caption">{{ user_infos.mail_addr }}</p>
|
<p class="md-caption">{{ user_infos.user_name }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<md-list>
|
<md-list>
|
||||||
@ -224,10 +224,12 @@ export default {
|
|||||||
if (Object.keys(this.user_infos).length == 0) {
|
if (Object.keys(this.user_infos).length == 0) {
|
||||||
// 初始化用户信息
|
// 初始化用户信息
|
||||||
let user_infos = {
|
let user_infos = {
|
||||||
mail_addr: 'A Little Canary',
|
user_name: 'A Little Canary',
|
||||||
has_login: false,
|
cid: 'Codebook',
|
||||||
activation: false,
|
row_login_pwd: '',
|
||||||
update_time: '1582282494434'
|
drivce: this.settings.is_chinese ? '暂无' : 'unknown',
|
||||||
|
cloud_drivce: this.settings.is_chinese ? '暂无' : 'unknown',
|
||||||
|
update_time: new Date().getTime()
|
||||||
};
|
};
|
||||||
this.setUserInfo([user_infos, this]);
|
this.setUserInfo([user_infos, this]);
|
||||||
console.log('用户信息覆写完成');
|
console.log('用户信息覆写完成');
|
||||||
|
@ -219,10 +219,11 @@ export default {
|
|||||||
}
|
}
|
||||||
// 初始化用户信息
|
// 初始化用户信息
|
||||||
let user_infos = {
|
let user_infos = {
|
||||||
mail_addr: 'A Little Canary',
|
user_name: 'A Little Canary',
|
||||||
has_login: false,
|
cid: '',
|
||||||
activation: false,
|
row_login_pwd: '',
|
||||||
update_time: '1582282494434'
|
drivce: '',
|
||||||
|
update_time: new Date().getTime()
|
||||||
};
|
};
|
||||||
this.setUserInfo([user_infos, this]);
|
this.setUserInfo([user_infos, this]);
|
||||||
console.log('用户信息覆写完成');
|
console.log('用户信息覆写完成');
|
||||||
|
@ -20,6 +20,12 @@
|
|||||||
<span class="md-error">{{ err_msg }}</span>
|
<span class="md-error">{{ err_msg }}</span>
|
||||||
</md-field>
|
</md-field>
|
||||||
|
|
||||||
|
<md-field class="input-box" :class="messageClass" v-if="is_create">
|
||||||
|
<label>{{ lang.repeat_pwd }}</label>
|
||||||
|
<md-input v-model="repeat" type="password"></md-input>
|
||||||
|
<span class="md-error">{{ err_msg }}</span>
|
||||||
|
</md-field>
|
||||||
|
|
||||||
<md-button class="md-raised md-primary center" @click="judgePwd()">{{ lang.enter }}</md-button>
|
<md-button class="md-raised md-primary center" @click="judgePwd()">{{ lang.enter }}</md-button>
|
||||||
|
|
||||||
<md-dialog-confirm
|
<md-dialog-confirm
|
||||||
|
Loading…
x
Reference in New Issue
Block a user