add copy feature

This commit is contained in:
RainSun 2020-03-07 20:43:26 +08:00
parent 5c2a0b5aa8
commit 95f6f3b8c9
2 changed files with 403 additions and 332 deletions

View File

@ -128,8 +128,10 @@ export function lang() {
options:['6 位', '12 位', '18 位', '24 位', '32 位']
},
settings:['包含大写', '包含小写', '包含数字', '包含符号'],
actions: ['生成','关闭'],
actions: ['生成', '复制', '关闭'],
code_res_empty: '未生成',
copy_successful: '(复制成功)',
copy_failed: '(复制失败)',
}
},
EN: {
@ -145,8 +147,10 @@ export function lang() {
options:['6 Digit', '12 Digit', '18 Digit', '24 Digit', '32 Digit']
},
settings:['Contain Uppercase', 'Contain Lowercase', 'Contain Number', 'Contain Symbol'],
actions: ['Generate','Close'],
actions: ['Generate', 'Copy','Close'],
code_res_empty: 'Not generated',
copy_successful: '(Copy successful)',
copy_failed: '(Failed to copy)',
}
}
},
@ -278,6 +282,14 @@ export function lang() {
CHS:{
title: '更新日志',
timeline: [
{
label: '新建密码记录生成的密码支持复制',
tag:'功能更新',
content: [
'在新建密码页生成密码支持一键复制',
'2020-03-07'
]
},
{
label: '修复云端最后修改时间不更新的问题',
tag:'bug修复',
@ -363,6 +375,14 @@ export function lang() {
EN:{
title: 'Update Log',
timeline: [
{
label: 'Generated passwords support replication',
tag:'Feature update',
content: [
'Generate a password on the new password page',
'2020-03-07'
]
},
{
label: 'Fix the problem that the last modification time of the cloud is not updated',
tag:'Bug fix',

View File

@ -3,7 +3,9 @@
<md-app md-waterfall md-mode="fixed">
<md-app-toolbar class="md-primary toolbar">
<div class="md-toolbar-section-start">
<md-button class="md-icon-button" @click="back()"><md-icon>arrow_back</md-icon></md-button>
<md-button class="md-icon-button" @click="back()">
<md-icon>arrow_back</md-icon>
</md-button>
<h3 class="md-title" style="flex: 1">{{ id_cache ? lang.title[1] : lang.title[0] }}</h3>
</div>
</md-app-toolbar>
@ -42,7 +44,7 @@
<md-button class="md-raised md-primary expand" @click="judgeContent()">{{ lang.enter }}</md-button>
<md-dialog :md-active.sync="show_dialog" style="min-width: 50%;">
<md-dialog-title>生成密码</md-dialog-title>
<md-dialog-title>生成密码{{copy_state}}</md-dialog-title>
<md-list>
<!-- 生成结果 -->
<md-subheader class="md-primary">{{ lang.generator.subheader[0] }}</md-subheader>
@ -88,7 +90,16 @@
<md-dialog-actions>
<md-button class="md-primary" @click="generateStart()">{{ lang.generator.actions[0] }}</md-button>
<md-button class="md-primary" @click="show_dialog = false">{{ lang.generator.actions[1] }}</md-button>
<md-button
class="md-primary"
v-clipboard:copy="password"
v-clipboard:success="onCopyCode"
v-clipboard:error="onErrorCode"
>{{ lang.generator.actions[1] }}</md-button>
<md-button
class="md-primary"
@click="show_dialog = false"
>{{ lang.generator.actions[2] }}</md-button>
</md-dialog-actions>
</md-dialog>
</v-touch>
@ -99,27 +110,32 @@
<script>
// @ is an alias to /src
import { mapState, mapActions } from 'vuex';
import { encrypt, decrypt, encryptMainCode, decryptMainCode } from '@/utils/aes.js';
import { lang } from '@/utils/language.js';
import { setHtmlFontSize } from '@/utils/px2rem.js';
import { generatePassword } from '@/utils/generator.js';
import { mapState, mapActions } from "vuex";
import {
encrypt,
decrypt,
encryptMainCode,
decryptMainCode
} from "@/utils/aes.js";
import { lang } from "@/utils/language.js";
import { setHtmlFontSize } from "@/utils/px2rem.js";
import { generatePassword } from "@/utils/generator.js";
export default {
name: 'Add',
name: "Add",
data() {
return {
clientHeight: '',
title: '',
user_name: '',
password: '',
node: '',
web_address: '',
id_cache: '',
open_count_cache: '',
clientHeight: "",
title: "",
user_name: "",
password: "",
node: "",
web_address: "",
id_cache: "",
open_count_cache: "",
title_verify: true,
user_name_verify: true,
password_verify: true,
lang: '',
lang: "",
show_dialog: false,
//
have_upper: true,
@ -130,27 +146,39 @@ export default {
//
have_symbol: false,
//
code_length: 12
code_length: 12,
//
copy_state: ""
};
},
computed: {
...mapState(['row_data', 'row_pwd', 'settings'])
...mapState(["row_data", "row_pwd", "settings"])
},
methods: {
...mapActions(['setRowData', 'setRowPwd']),
...mapActions(["setRowData", "setRowPwd"]),
// md-app
changeFixed(clientHeight) {
//
// console.log(clientHeight);
// window.document.getElementsByClassName('md-content')[0].style.minHeight = clientHeight + 'px';
this.$refs.list_placeholder.parentNode.parentNode.style.maxHeight = clientHeight + 'px';
this.$refs.list_placeholder.parentNode.style.minHeight = clientHeight - 32 + 'px';
window.document.documentElement.setAttribute('data-theme', this.settings.is_dark_mode ? 'dark' : 'light');
this.$refs.list_placeholder.parentNode.parentNode.style.maxHeight =
clientHeight + "px";
this.$refs.list_placeholder.parentNode.style.minHeight =
clientHeight - 32 + "px";
window.document.documentElement.setAttribute(
"data-theme",
this.settings.is_dark_mode ? "dark" : "light"
);
},
//
init() {
// vuex
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"))
)
);
//
if (Object.keys(this.row_pwd).length != 0) {
//
@ -173,11 +201,11 @@ export default {
return;
} else {
//
this.turnToHome('密码超时');
this.turnToHome("密码超时");
}
} else {
//
this.turnToHome('无密码');
this.turnToHome("无密码");
}
},
@ -188,7 +216,7 @@ export default {
} else {
this.lang = lang().add.EN;
}
console.log('语言配置完成');
console.log("语言配置完成");
},
//
@ -218,7 +246,7 @@ export default {
submit() {
//
if (this.id_cache) {
console.log('覆写拦截器生效');
console.log("覆写拦截器生效");
this.reWrite();
return;
}
@ -250,7 +278,7 @@ export default {
}
let data_list_aes = encrypt(main_code_decrpt, data_list);
this.setRowData([data_list_aes, this]);
console.log('新加密信息保存成功,返回Home');
console.log("新加密信息保存成功,返回Home");
this.back();
},
@ -282,7 +310,7 @@ export default {
}
let data_list_aes = encrypt(main_code_decrpt, data_list);
this.setRowData([data_list_aes, this]);
console.log('新加密信息覆写成功,返回详情');
console.log("新加密信息覆写成功,返回详情");
this.back();
},
//
@ -293,7 +321,7 @@ export default {
// Home
turnToHome(msg) {
console.log(msg);
this.$router.replace('/');
this.$router.replace("/");
},
//
@ -303,7 +331,9 @@ export default {
//
let random = Math.floor(Math.random() * 100);
// 100
random < 10 ? (random = '0' + random.toString()) : (random = random.toString());
random < 10
? (random = "0" + random.toString())
: (random = random.toString());
//
let id = time.toString() + random;
return id;
@ -311,12 +341,33 @@ export default {
//
generateStart() {
this.password = generatePassword(this.code_length, this.have_lower, this.have_upper, this.have_num, this.have_symbol);
this.password = generatePassword(
this.code_length,
this.have_lower,
this.have_upper,
this.have_num,
this.have_symbol
);
},
//
onCopyCode() {
this.copy_state = this.lang.generator.copy_successful;
setTimeout(() => {
this.copy_state = "";
}, 2000);
},
//
onErrorCode() {
this.copy_state = this.lang.generator.copy_failed;
setTimeout(() => {
this.copy_state = "";
}, 2000);
}
},
created() {
this.lang = lang().add.CHS;
console.log('临时语言系统加载完成');
console.log("临时语言系统加载完成");
this.init();
},
mounted() {
@ -340,7 +391,7 @@ export default {
</script>
<style scoped lang="scss" type="text/scss">
@import '../../style/main';
@import "../../style/main";
.add {
width: 100%;
min-height: 100%;