error message

This commit is contained in:
Jesse-Ma
2022-12-05 13:18:12 +08:00
parent 7fb00c8cf5
commit ca5f4ad8a0
10 changed files with 106 additions and 58 deletions

View File

@@ -149,7 +149,7 @@
<div id="wrapper" style="border-left: 0px solid #FF3366;">
<Input element-id="noteText" type="textarea" :border="false" v-model="noteForm.text" autofocus
:autosize="{ minRows: 30, maxRows: 20480 }" :placeholder="$t('content.noteTip')" @input="recordText"
@on-keydown="recordEventKdown" />
@on-keydown="recordEventKdown" @on-keyup="recordEventKup"/>
</div>
</Form>
</Card>
@@ -174,6 +174,16 @@
</p>
</Modal>
<Modal v-model="model.showError" width="360" footer-hide class-name="fnmodal" :styles="{ borderRadius: 0 }">
<p style="text-align: center;font-size:medium ;margin-bottom: 20px;">
{{ errorInfo }}
</p>
<p style="text-align: center;">
<Button type="error" style="border-radius: 0px;font-size: 19px;"
@click="cloaseErrorMessage()">{{ $t("button.close") }}</Button>
</p>
</Modal>
</div>
@@ -216,9 +226,11 @@ export default {
showDelete: false,
deleting: false,
showDownloadText: false,
showError: false,
},
toTopState: false,
showMenuState: false,
errorInfo: '',
}
},
created() {
@@ -325,24 +337,28 @@ export default {
},
recordText() {
let text = this.noteForm.text;
if (text.length > 102400) {
alert("text length is " + text.length + ",beyond 102400!!!");
if (text.length > 204800) {
this.errorInfo = this.$t('error.100012');
this.model.showError = true;
return;
}
setStoreText(this.noteForm, this.state, this.secret);
},
// recordEventKup(event) {
// let tn = event.currentTarget.value;
// let ss = event.currentTarget.selectionStart;
// let cline = tn.substring(0, ss).split('\n').length;
recordEventKup(event) {
let tn = event.currentTarget.value;
let ss = event.currentTarget.selectionStart;
let cline = tn.substring(0, ss).split('\n').length;
// var noteTop = parseFloat(window.getComputedStyle(event.currentTarget).lineHeight) * cline;
// var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
// if (noteTop < scrollTop + 10) {
// window.scrollTo(0, noteTop - 10);
// }
var noteTop = parseFloat(window.getComputedStyle(event.currentTarget).lineHeight) * cline;
console.log(noteTop)
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
console.log(scrollTop)
if (noteTop < scrollTop+10) {
window.scrollTo(0, noteTop-10);
}
// },
},
recordEventKdown(event) {
if (event.key == "Tab") {
@@ -351,8 +367,10 @@ export default {
let end = event.currentTarget.selectionEnd;
let text = event.currentTarget.value;
if (text.length > 102400) {
alert("text length is " + text.length + ",beyond 102400!!!");
if (text.length > 204800) {
this.errorInfo = this.$t('error.100012');
this.model.showError = true;
return;
}
let tab = '\t';//\t
@@ -395,16 +413,22 @@ export default {
},
validateForm() {
let text = this.noteForm.text;
if (text.length > 102400) {
alert("text length is " + text.length + ",beyond 102400!!!");
if (text.length > 204800) {
this.errorInfo = this.$t('error.100012');
this.model.showError = true;
return false;
}
if (text.length == 0) {
alert("text is empty!!!");
this.errorInfo = this.$t('error.100011');
this.model.showError = true;
return false;
}
return true;
},
cloaseErrorMessage(){
this.errorInfo = '';
this.model.showError = false;
},
submitNote() {
if (this.state.locking == 1) {
return;