diff --git a/src/renderer/src/views/Home/index.vue b/src/renderer/src/views/Home/index.vue index ee8ac2e..c9ace5b 100644 --- a/src/renderer/src/views/Home/index.vue +++ b/src/renderer/src/views/Home/index.vue @@ -213,7 +213,7 @@ - 润色 @@ -290,7 +290,7 @@ 润色 @@ -993,9 +993,10 @@ const sendMessage = () => { }; -// 润色文本功能 -const polishText = async () => { - if (!inputValue.value.trim()) { + +const polishTextBackStr = async (_inputStr) => { + + if (_inputStr && !_inputStr.trim()) { message.warning('请输入需要润色的文本'); return; } @@ -1005,6 +1006,53 @@ const polishText = async () => { return; } + polishLoading.value = true; + + //加123的测试效果 + // const originalText = _inputStr+123; + // console.log("originalText",originalText) + // return originalText; + + try { + console.log('开始润色文本:', originalText); + const result = await window.electron.ipcRenderer.invoke('polish-text', originalText); + console.log('润色结果:', result); + + if (result.success) { + const outstr = result.data; + message.success('文本润色完成'); + return outstr; + } else { + message.error('润色失败: ' + result.error); + console.error('润色失败:', result.error); + return ""; + } + } catch (error) { + console.error('润色文本出错:', error); + message.error('润色服务出错: ' + error.message); + return ""; + } finally { + polishLoading.value = false; + } + +} + +// 润色文本功能 +const polishText = async (targetInputStr) => { + + if(targetInputStr == 'inputValue'){ + inputValue.value = await polishTextBackStr(inputValue.value); + }else if (targetInputStr == 'gangwei'){ + console.log("formData.infoin",formData.infoin) + formData.infoin = await polishTextBackStr(formData.infoin); + } + + /* + if (polishLoading.value) { + message.warning('正在润色中,请稍候...'); + return; + } + polishLoading.value = true; const originalText = inputValue.value; @@ -1026,6 +1074,7 @@ const polishText = async () => { } finally { polishLoading.value = false; } + */ }; // 文件处理函数