getSecretKey and jsonresult
This commit is contained in:
@@ -115,9 +115,9 @@
|
||||
@click="createNote(); switchMenu(); " icon="md-add"></Button>
|
||||
<!--
|
||||
|
||||
<Button type="error" icon="md-refresh" style="border-radius: 0px;font-size: 14px;font-size: 24px;"
|
||||
@click="refreshPage()"></Button>
|
||||
-->
|
||||
<Button type="error" icon="md-refresh" style="border-radius: 0px;font-size: 14px;font-size: 24px;"
|
||||
@click="refreshPage()"></Button>
|
||||
-->
|
||||
|
||||
<Button aria-label="download text" v-show="model.showDownloadText" type="error"
|
||||
style="border-radius: 0px;font-size: 24px;" @click="downLoadText(); switchMenu(); "
|
||||
@@ -151,8 +151,8 @@
|
||||
<Form :model="noteForm" :label-width="80">
|
||||
<div id="wrapper" style="border-left: 2px solid #ed4014;">
|
||||
<Input element-id="noteText" type="textarea" :border="false" v-model="noteForm.text" autofocus
|
||||
:autosize="{ minRows: 30, maxRows: 409600 }" :placeholder="$t('content.noteTip')"
|
||||
@input="recordText" @on-keydown="recordEventKdown" />
|
||||
:autosize="{ minRows: 30, maxRows: 409600 }" :placeholder="$t('content.noteTip')" @input="recordText"
|
||||
@on-keydown="recordEventKdown" />
|
||||
</div>
|
||||
</Form>
|
||||
</Card>
|
||||
@@ -171,10 +171,9 @@
|
||||
{{ $t("message.askTodelete") }}
|
||||
</p>
|
||||
<p style="text-align: center;">
|
||||
<Button type="error" :loading="model.deleting" style="border-radius: 0px;font-size: 19px;"
|
||||
@click="dropNote()">{{
|
||||
$t("button.yes")
|
||||
}}</Button>
|
||||
<Button type="error" :loading="model.deleting" style="border-radius: 0px;font-size: 19px;" @click="dropNote()">{{
|
||||
$t("button.yes")
|
||||
}}</Button>
|
||||
</p>
|
||||
</Modal>
|
||||
|
||||
@@ -184,22 +183,21 @@
|
||||
</p>
|
||||
<p style="text-align: center;">
|
||||
<Button type="error" style="border-radius: 0px;font-size: 19px;" @click="cloaseErrorMessage()">{{
|
||||
$t("button.close")
|
||||
$t("button.close")
|
||||
}}</Button>
|
||||
</p>
|
||||
</Modal>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { unwrap } from '../libs/secret'
|
||||
import { saveNote } from "@/api/note";
|
||||
import { getSecretKey, getStoreKey } from "@/api/lock";
|
||||
import { getStoreKey } from "@/api/lock";
|
||||
import storage from "@/libs/storage";
|
||||
import { setStoreText } from "@/libs/noteStorage";
|
||||
import { setStoreText,setNewStoreText } from "@/libs/noteStorage";
|
||||
import { saveAs } from 'file-saver';
|
||||
import { isWeixin } from "@/libs/utils";
|
||||
import NoteConstant from "@/libs/constants";
|
||||
@@ -237,10 +235,13 @@ export default {
|
||||
toTopState: false,
|
||||
showMenuState: false,
|
||||
showHeaderShade: false,
|
||||
pageSession: '',
|
||||
errorInfo: '',
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.pageSession = new Date().getTime();
|
||||
|
||||
// read $route
|
||||
this.noteForm.key = this.$route.params.name;
|
||||
let keyMeta = this.$route.meta.keyMeta;
|
||||
@@ -257,13 +258,12 @@ export default {
|
||||
// let noteMeta = this.$route.meta.noteMeta;
|
||||
let storeKey = getStoreKey(this.noteForm.key);
|
||||
this.secret.storeKey = storeKey;
|
||||
let secretKey = getSecretKey(this.noteForm.key, this.secret.password);
|
||||
this.secret.secretKey = secretKey;
|
||||
|
||||
// first edit
|
||||
if (keyMeta) {
|
||||
this.state.lock = 0;
|
||||
this.secret.cipher = keyMeta.cipher;
|
||||
this.secret.secretKey = keyMeta.secretKey;
|
||||
this.state.serverTime = keyMeta.serverTime;
|
||||
// key init Time
|
||||
this.state.initTime = keyMeta.serverTime;
|
||||
@@ -278,6 +278,9 @@ export default {
|
||||
storage.local.setText(storeKey, "0|" + this.secret.cipher + "|0|" + this.state.initTime + "|");
|
||||
} else {
|
||||
// second edit
|
||||
let noteMeta = this.$route.meta.noteMeta;
|
||||
this.secret.secretKey = noteMeta.secretKey;
|
||||
|
||||
let storeInfo = storage.local.getText(storeKey);
|
||||
let starray = storeInfo.split('|');
|
||||
this.state.lock = parseInt(starray[0]);
|
||||
@@ -286,7 +289,7 @@ export default {
|
||||
|
||||
//draw text;
|
||||
if (starray[4]) {
|
||||
this.noteForm.text = unwrap(starray[4], secretKey);
|
||||
this.noteForm.text = unwrap(starray[4], this.secret.secretKey);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,7 +348,7 @@ export default {
|
||||
recordText() {
|
||||
let text = this.noteForm.text;
|
||||
if (text.length > NoteConstant.noteMaxCount) {
|
||||
this.errorInfo = this.$t('error.100012',[NoteConstant.noteMaxDesc]);
|
||||
this.errorInfo = this.$t('error.100012', [NoteConstant.noteMaxDesc]);
|
||||
this.model.showError = true;
|
||||
return;
|
||||
}
|
||||
@@ -374,7 +377,7 @@ export default {
|
||||
let text = event.currentTarget.value;
|
||||
|
||||
if (text.length > NoteConstant.noteMaxCount) {
|
||||
this.errorInfo = this.$t('error.100012',[NoteConstant.noteMaxDesc]);
|
||||
this.errorInfo = this.$t('error.100012', [NoteConstant.noteMaxDesc]);
|
||||
this.model.showError = true;
|
||||
return;
|
||||
}
|
||||
@@ -393,25 +396,8 @@ export default {
|
||||
setStoreText(this.noteForm, this.state, this.secret);
|
||||
|
||||
} else if (event.ctrlKey && (event.which == 13)) {
|
||||
|
||||
if (this.state.locking == 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.validateForm()) {
|
||||
this.state.locking = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
//save
|
||||
let that = this;
|
||||
this.save().then(res => {
|
||||
if (res) {
|
||||
that.state.commited = 1;
|
||||
setStoreText(this.noteForm, this.state, this.secret);
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
this.submitNote();
|
||||
}
|
||||
},
|
||||
save() {
|
||||
@@ -420,7 +406,7 @@ export default {
|
||||
validateForm() {
|
||||
let text = this.noteForm.text;
|
||||
if (text.length > NoteConstant.noteMaxCount) {
|
||||
this.errorInfo = this.$t('error.100012',[NoteConstant.noteMaxDesc]);
|
||||
this.errorInfo = this.$t('error.100012', [NoteConstant.noteMaxDesc]);
|
||||
this.model.showError = true;
|
||||
return false;
|
||||
}
|
||||
@@ -449,14 +435,26 @@ export default {
|
||||
|
||||
let that = this;
|
||||
this.save().then(res => {
|
||||
if (res) {
|
||||
let storeInfo = storage.local.getText(that.secret.storeKey);
|
||||
let starray = storeInfo.split("|");
|
||||
storage.local.setText(that.secret.storeKey, starray[0] + '|' + starray[1] + '|1|' + starray[3] + '|' + starray[4]);
|
||||
if (res.data && res.data.code == "000000") {
|
||||
storage.session.setText(that.secret.storeKey + "_share", '1');
|
||||
|
||||
that.state.commited = 1;
|
||||
setStoreText(this.noteForm, this.state, this.secret);
|
||||
|
||||
location.reload();
|
||||
this.state.locking = 0;
|
||||
} else {
|
||||
alert(res.data.code);
|
||||
this.model.submitting = false;
|
||||
this.state.locking = 0;
|
||||
if(res.data.code=="100013"||res.data.code=="800001"){
|
||||
let key = setNewStoreText(this.noteForm);
|
||||
location.href="/"+key;
|
||||
}
|
||||
|
||||
}
|
||||
}).catch(error => {
|
||||
alert(error);
|
||||
});
|
||||
},
|
||||
refresh() {
|
||||
|
||||
Reference in New Issue
Block a user