From 9fb503757add05f4d671fec52ac1c0990db60b39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=8B=E4=BA=8E=E5=88=9D=E8=A7=81?= <752204717@qq.com> Date: Wed, 26 Mar 2025 15:05:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/index.js | 4 +- src/common/js/commonJS.js | 4 +- src/components/common/common.vue | 8 +- src/components/common/langs/en.js | 3 + src/components/common/langs/zh.js | 3 + src/components/page/articleAdd.vue | 19 +- .../page/components/Tinymce/index.vue | 160 +++---------- .../page/components/table/LateX.vue | 211 +++++++++++++++--- .../page/components/table/content.vue | 2 +- .../page/components/table/formulas.js | 168 ++++++++++++++ 10 files changed, 401 insertions(+), 181 deletions(-) create mode 100644 src/components/page/components/table/formulas.js diff --git a/src/api/index.js b/src/api/index.js index 170e883..0b11630 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -19,8 +19,8 @@ const service = axios.create({ // baseURL: 'https://submission.tmrjournals.com/', //正式 记得切换 // baseURL: 'http://www.tougao.com/', //测试本地 记得切换 // baseURL: 'http://192.168.110.110/tougao/public/index.php/', - baseURL: '/api', //本地 - // baseURL: '/', //正式 + // baseURL: '/api', //本地 + baseURL: '/', //正式 }); diff --git a/src/common/js/commonJS.js b/src/common/js/commonJS.js index 9043374..8ae2e47 100644 --- a/src/common/js/commonJS.js +++ b/src/common/js/commonJS.js @@ -1964,7 +1964,7 @@ export default { const uid = 'wmath-' + Math.random().toString(36).substr(2, 9); // 3. 创建一个 标签并插入到光标处 - const wmathHtml = `Insert formula here`; + const wmathHtml = ``; ed.insertContent(wmathHtml); // 在光标位置插入 wmath 标签 // 4. 打开公式编辑器窗口,并传递光标位置、编辑器 ID 和 wmathId @@ -1973,7 +1973,7 @@ export default { // editorId:editorId, // wmathId:uid, // }); - window.open(url, '_blank', 'width=600,height=460,scrollbars=no,resizable=no'); + window.open(url, '_blank', 'width=1000,height=800,scrollbars=no,resizable=no'); } }); diff --git a/src/components/common/common.vue b/src/components/common/common.vue index 78346a5..e985d78 100644 --- a/src/components/common/common.vue +++ b/src/components/common/common.vue @@ -2,12 +2,12 @@ //记得切换 //正式 -// const mediaUrl = '/public/'; -// const baseUrl = '/'; +const mediaUrl = '/public/'; +const baseUrl = '/'; -const mediaUrl = 'https://submission.tmrjournals.com/public/'; -const baseUrl = '/api'; +// const mediaUrl = 'https://submission.tmrjournals.com/public/'; +// const baseUrl = '/api'; diff --git a/src/components/common/langs/en.js b/src/components/common/langs/en.js index 4fa2d20..0e16142 100644 --- a/src/components/common/langs/en.js +++ b/src/components/common/langs/en.js @@ -412,6 +412,9 @@ Information:'Fill in information', }, +Formula:{ + FormulaTemplate:'Formula Template' +} } diff --git a/src/components/common/langs/zh.js b/src/components/common/langs/zh.js index 75c0541..2e10755 100644 --- a/src/components/common/langs/zh.js +++ b/src/components/common/langs/zh.js @@ -405,6 +405,9 @@ const zh = { }, + Formula:{ + FormulaTemplate:'公式模版' + } } diff --git a/src/components/page/articleAdd.vue b/src/components/page/articleAdd.vue index dc16599..51cbbfd 100644 --- a/src/components/page/articleAdd.vue +++ b/src/components/page/articleAdd.vue @@ -2630,10 +2630,14 @@ export default { // 点击进行下一步 onStep(e) { console.log('this.majorValueList at line 2604:', this.majorValueList); - console.log('this.form at line 2622:', this.form); + console.log('this.form at line 2622:', this.form.abstrart); this.$refs.articleform.validate((valid) => { if (valid) { + if (this.isAbstractTooShort(this.form.abstrart)) { + this.$message.error('The abstract should not be less than 200 Chinese characters or English words!'); + return false; + } if (e == 1) { if (this.form.journal == 0 || !this.form.journal) { this.$message.error('Please select the Journal'); @@ -2752,13 +2756,17 @@ export default { fstr += flist[fu].ke.trim() + ','; } } - console.log('this.form at line 2707:', this.form); + console.log('this.form at line 2707:', this.form.abstrart); this.form.keyWords = fstr == '' ? '' : fstr.substring(0, fstr.length - 1); this.form.major = this.majorValueList.map((item) => item.selectedValue[item.selectedValue.length - 1]).toString(','); if (this.form.major == '') { this.$message.error('Please select the Research areas'); return false; } + if (this.isAbstractTooShort(this.form.abstrart)) { + this.$message.error('The abstract should not be less than 200 Chinese characters or English words!'); + return false; + } this.$api.post('api/Article/addArticlePart1', this.form).then((res) => { if (res.code == 0) { this.stagingID = res.data.article_id; @@ -2875,7 +2883,14 @@ export default { }); } }, + isAbstractTooShort(text) { + let chineseCount = (text.match(/[\u4e00-\u9fa5]/g) || []).length; + let englishCount = (text.match(/[A-Za-z0-9]/g) || []).length; + const total = chineseCount + englishCount; + + return total < 200; // 不足 200,说明太短 + }, // 读取 Temporary() { this.$api diff --git a/src/components/page/components/Tinymce/index.vue b/src/components/page/components/Tinymce/index.vue index 1c6a77d..5a16955 100644 --- a/src/components/page/components/Tinymce/index.vue +++ b/src/components/page/components/Tinymce/index.vue @@ -253,7 +253,7 @@ export default { }, methods: { openLatexEditor(data) { - this.$emit('openLatexEditor',data) + this.$emit('openLatexEditor', data); console.log('at line 254:', '打开数字公式'); }, handleSubmit() { @@ -377,78 +377,6 @@ export default { }, 10); }, - // paste_preprocess: function (plugin, args) { - // let content = args.content; - - // // 创建一个临时 div 元素来解析粘贴的 HTML - // let tempDiv = document.createElement('div'); - // tempDiv.innerHTML = content; - - // // 检查粘贴的内容是否包含 元素 - // if (tempDiv.querySelector('table')) { - // console.log('粘贴的内容包含表格'); - // if (_this.type == 'table') { - // _this.$commonJS.parseTableToArray(content, (tableList) => { - // console.log('res at line 104:', tableList); - // var contentHtml = ` - //
- //
- // ${tableList - // .map((row) => { - // return ` - // - // ${row - // .map((cell) => { - // return ` - // - // `; - // }) - // .join('')} - // - // `; - // }) - // .join('')} - //
- // ${cell.text || ''} - //
- // - // `; - - // const container = document.createElement('div'); - // container.innerHTML = contentHtml; - - // // _this.updateTableStyles(container); // 根据需要应用额外的样式 - // args.content = container.innerHTML; // 更新处理后的内容 - // }); - // } else { - // } - // } else { - // const mathRegex = /\$\$([^$]+)\$\$/g; - // // 如果粘贴的内容包含 $$...$$ 格式的公式,进行处理 - // content = content.replace(mathRegex, function (match, formula) { - // console.log('Matched formula:', formula); // 输出每个匹配的公式 - // // 将公式包裹在 标签中,保留 $$...$$ 结构 - // return `${match}`; - // }); - - // // 更新 args.content 为处理后的内容 - - // if (_this.isAutomaticUpdate) { - // args.content = _this.$commonJS.transformHtmlString(content); // 更新处理后的内容 - // } - // setTimeout(() => { - // window.renderMathJax(_this.tinymceId); - // }, 50); - - // console.log('粘贴的内容不包含表格'); - // } - // // 阻止默认的粘贴行为 - // if (args.event) { - // args.event.preventDefault(); // 阻止默认的粘贴处理 - // args.event.stopPropagation(); // 阻止事件冒泡,确保自定义处理优先执行 - // } - // }, - content_style: ` ${tableStyle} ${_this.wordStyle} @@ -486,40 +414,39 @@ export default { var currentWmathElement = null; ed.on('click', function (e) { - const wmathElement = e.target.closest('wmath'); + const wmathElement = e.target.closest('wmath'); - if (wmathElement) { - currentWmathElement = wmathElement; // 👈 保存当前点击的元素 + if (wmathElement) { + currentWmathElement = wmathElement; // 👈 保存当前点击的元素 - const latexContentRaw = wmathElement.getAttribute('data-latex') || ''; - console.log('at line 488: raw =', latexContentRaw); + const latexContentRaw = wmathElement.getAttribute('data-latex') || ''; + console.log('at line 488: raw =', latexContentRaw); - // 去除所有 $ 符号 - const latexContent = latexContentRaw.replace(/\$/g, '').trim(); - console.log('at line 489: cleaned =', latexContent); + // 去除所有 $ 符号 + const latexContent = latexContentRaw.replace(/\$/g, '').trim(); + console.log('at line 489: cleaned =', latexContent); - // 编码后用于传递到弹窗 - const encoded = encodeURIComponent(latexContent); + // 编码后用于传递到弹窗 + const encoded = encodeURIComponent(latexContent); - // 给 wmath 添加唯一 data-id,方便后续精准替换 - let wmathId = wmathElement.getAttribute('data-id'); - if (!wmathId) { - wmathId = 'wmath-' + Math.random().toString(36).substr(2, 9); - wmathElement.setAttribute('data-id', wmathId); - } + // 给 wmath 添加唯一 data-id,方便后续精准替换 + let wmathId = wmathElement.getAttribute('data-id'); + if (!wmathId) { + wmathId = 'wmath-' + Math.random().toString(36).substr(2, 9); + wmathElement.setAttribute('data-id', wmathId); + } - // 当前编辑器 ID 也保存下来(如果你有多个编辑器) - const editorId = ed.id; - - // 打开编辑窗口并传参(传递 data-id + 内容) - window.open( - `/LateX?id=${encoded}&wmathId=${wmathId}&editorId=${editorId}`, - '_blank', - 'width=600,height=460,scrollbars=no,resizable=no' - ); - } -}); + // 当前编辑器 ID 也保存下来(如果你有多个编辑器) + const editorId = ed.id; + // 打开编辑窗口并传参(传递 data-id + 内容) + window.open( + `/LateX?id=${encoded}&wmathId=${wmathId}&editorId=${editorId}`, + '_blank', + 'width=1000,height=800,scrollbars=no,resizable=no' + ); + } + }); ed.ui.registry.addButton('uploadWord', { text: 'Word', @@ -651,7 +578,6 @@ export default { window.addEventListener('message', function (event) { const data = event.data; console.log('data at line 648:', data); - // ✅ 编辑现有公式:替换或删除 if (data && data.type === 'update-wmath') { const { editorId, wmathId, latex } = data; @@ -680,38 +606,6 @@ export default { } } } - - // ✅ 插入新公式 - // if (data && data.type === 'insert-new-wmath') { - // const latex = data.latex ? data.latex.trim() : ''; - // // if (!activeEditorId || !latexEditorBookmark) return; - - // const editor = window.tinymce.get(activeEditorId); - - // if (!editor) return; - - // // 恢复光标位置 - // editor.focus(); - // setTimeout(() => { - // editor.selection.moveToBookmark(latexEditorBookmark); - - // const uid = 'wmath-' + Math.random().toString(36).substr(2, 9); - // const wmathHtml = `${latex}`; - // editor.insertContent(wmathHtml); - - // // 清除焦点,防止影响渲染 - // editor.focus(false); // 取消焦点 - - // // 清除 - // latexEditorBookmark = null; - // activeEditorId = null; - // }, 20); - // setTimeout(() => { - // if (typeof renderMathJax === 'function') { - // _this.window.renderMathJax(_this.tinymceId); - // } - // }, 1000); - // } }); // 🚩 标记为已注册,防止重复 diff --git a/src/components/page/components/table/LateX.vue b/src/components/page/components/table/LateX.vue index 163caca..eaea12f 100644 --- a/src/components/page/components/table/LateX.vue +++ b/src/components/page/components/table/LateX.vue @@ -1,13 +1,9 @@