add constant
This commit is contained in:
@@ -2,13 +2,8 @@ import axios from "axios";
|
||||
import { getStoreKey } from "@/api/lock";
|
||||
import storage from "@/libs/storage";
|
||||
import { md5 } from "@/libs/secret";
|
||||
import NoteConstant from "@/libs/constants";
|
||||
|
||||
const servicePath = process.env.VUE_APP_BASE_URL;
|
||||
const noteMaxWords = parseInt(process.env.NOTE_MAX_WORDS);
|
||||
|
||||
export {
|
||||
noteMaxWords
|
||||
}
|
||||
|
||||
export function saveNote(noteForm, secret) {
|
||||
let storeKey = secret.storeKey;
|
||||
@@ -19,6 +14,7 @@ export function saveNote(noteForm, secret) {
|
||||
let note = {
|
||||
lock: starray[0],
|
||||
cipher: starray[1],
|
||||
initTime: starray[3],
|
||||
text: starray[4],
|
||||
key: noteForm.key,
|
||||
};
|
||||
@@ -32,13 +28,14 @@ export function saveNote(noteForm, secret) {
|
||||
form.append("lock", note.lock);
|
||||
form.append("key", note.key);
|
||||
form.append("md5", md5(note.text));
|
||||
form.append("initTime",note.initTime)
|
||||
|
||||
let config = {
|
||||
headers: { "Content-Type": "multipart/form-data" },
|
||||
};
|
||||
|
||||
return axios({
|
||||
url: servicePath + "/note/" + noteForm.key,
|
||||
url: NoteConstant.servicePath + "/note/" + noteForm.key,
|
||||
method: "post",
|
||||
data: form,
|
||||
config: config,
|
||||
@@ -54,7 +51,7 @@ export function deleteNote(key) {
|
||||
};
|
||||
|
||||
return axios({
|
||||
url: servicePath + "/note/" + key + "/delete",
|
||||
url: NoteConstant.servicePath + "/note/" + key + "/delete",
|
||||
method: "post",
|
||||
data: note,
|
||||
});
|
||||
@@ -62,7 +59,7 @@ export function deleteNote(key) {
|
||||
|
||||
export function getNoteBlob(key) {
|
||||
return axios({
|
||||
url: servicePath + "/note/" + key,
|
||||
url: NoteConstant.servicePath + "/note/" + key,
|
||||
method: "get",
|
||||
responseType: "blob",
|
||||
ignoreError: 1,
|
||||
@@ -72,7 +69,7 @@ export function getNoteBlob(key) {
|
||||
}
|
||||
|
||||
export function getNoteMeta(key) {
|
||||
let url = servicePath + "/note/" + key + "/noteMeta";
|
||||
let url = NoteConstant.servicePath + "/note/" + key + "/noteMeta";
|
||||
let noteMeta = null;
|
||||
try {
|
||||
noteMeta = ajaxGet(url);
|
||||
@@ -83,7 +80,7 @@ export function getNoteMeta(key) {
|
||||
}
|
||||
|
||||
export function getKeyMeta() {
|
||||
let url = servicePath + "/note/keyMeta";
|
||||
let url = NoteConstant.servicePath + "/note/keyMeta";
|
||||
let keyMeta = null;
|
||||
try {
|
||||
keyMeta = ajaxGet(url);
|
||||
|
||||
@@ -25,7 +25,7 @@ const en = {
|
||||
"100005": "Not Published!",
|
||||
"100006": "Server Unavailable!",
|
||||
"100011": "Empty Note!",
|
||||
"100012": "Too Large, Beyond 400K!",
|
||||
"100012": "Too Large, Beyond {0}!",
|
||||
}
|
||||
};
|
||||
export default en;
|
||||
|
||||
@@ -25,7 +25,7 @@ const zh = {
|
||||
"100005": "笔记未分享!",
|
||||
"100006": "服务器不可用!",
|
||||
"100011": "笔记为空!",
|
||||
"100012": "笔记过大,超过400K!",
|
||||
"100012": "笔记过大,超过{0}!",
|
||||
}
|
||||
};
|
||||
export default zh;
|
||||
|
||||
9
src/libs/constants.js
Normal file
9
src/libs/constants.js
Normal file
@@ -0,0 +1,9 @@
|
||||
const servicePath = process.env.VUE_APP_BASE_URL;
|
||||
const noteMaxCount = process.env.VUE_APP_NOTE_MAX_COUNT;
|
||||
const noteMaxDesc = process.env.VUE_APP_NOTE_MAX_DESC;
|
||||
|
||||
export default {
|
||||
servicePath,
|
||||
noteMaxCount,
|
||||
noteMaxDesc
|
||||
}
|
||||
@@ -5,8 +5,9 @@ import axios from 'axios'
|
||||
import VueAxios from 'vue-axios'
|
||||
import './plugins/iview.js'
|
||||
import i18n from './i18n/'
|
||||
import NoteConstant from "@/libs/constants";
|
||||
|
||||
axios.defaults.baseURL = process.env.VUE_APP_BASE_URL;
|
||||
axios.defaults.baseURL = NoteConstant.servicePath;
|
||||
|
||||
Vue.use(VueAxios, axios)
|
||||
|
||||
|
||||
@@ -203,6 +203,7 @@ import storage from "@/libs/storage";
|
||||
import { setStoreText } from "@/libs/noteStorage";
|
||||
import { saveAs } from 'file-saver';
|
||||
import { isWeixin } from "@/libs/utils";
|
||||
import NoteConstant from "@/libs/constants";
|
||||
|
||||
export default {
|
||||
name: 'EditNote',
|
||||
@@ -343,8 +344,8 @@ export default {
|
||||
},
|
||||
recordText() {
|
||||
let text = this.noteForm.text;
|
||||
if (text.length > 409600) {
|
||||
this.errorInfo = this.$t('error.100012');
|
||||
if (text.length > NoteConstant.noteMaxCount) {
|
||||
this.errorInfo = this.$t('error.100012',[NoteConstant.noteMaxDesc]);
|
||||
this.model.showError = true;
|
||||
return;
|
||||
}
|
||||
@@ -372,8 +373,8 @@ export default {
|
||||
let end = event.currentTarget.selectionEnd;
|
||||
let text = event.currentTarget.value;
|
||||
|
||||
if (text.length > 409600) {
|
||||
this.errorInfo = this.$t('error.100012');
|
||||
if (text.length > NoteConstant.noteMaxCount) {
|
||||
this.errorInfo = this.$t('error.100012',[NoteConstant.noteMaxDesc]);
|
||||
this.model.showError = true;
|
||||
return;
|
||||
}
|
||||
@@ -418,8 +419,8 @@ export default {
|
||||
},
|
||||
validateForm() {
|
||||
let text = this.noteForm.text;
|
||||
if (text.length > 409600) {
|
||||
this.errorInfo = this.$t('error.100012');
|
||||
if (text.length > NoteConstant.noteMaxCount) {
|
||||
this.errorInfo = this.$t('error.100012',[NoteConstant.noteMaxDesc]);
|
||||
this.model.showError = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -145,6 +145,10 @@ export default {
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.$nextTick(() => {
|
||||
window.scrollTo(0, 0);
|
||||
});
|
||||
|
||||
//this.bindCopyTextEvent();
|
||||
|
||||
const myObserver = new ResizeObserver(entries => {
|
||||
@@ -161,6 +165,7 @@ export default {
|
||||
const someOtherEl = document.querySelector('#wrapper');
|
||||
myObserver.observe(someOtherEl);
|
||||
|
||||
|
||||
},
|
||||
methods: {
|
||||
refreshPage() {
|
||||
|
||||
Reference in New Issue
Block a user