add copy feature
This commit is contained in:
parent
5c2a0b5aa8
commit
95f6f3b8c9
@ -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',
|
||||
|
@ -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);
|
||||
// 小于10填0
|
||||
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%;
|
||||
|
Loading…
x
Reference in New Issue
Block a user