diff --git a/GinSkeleton/app/http/validator/web/ai_recognition/pic_recognition.go b/GinSkeleton/app/http/validator/web/ai_recognition/pic_recognition.go index fcd0f4a..ea08d23 100644 --- a/GinSkeleton/app/http/validator/web/ai_recognition/pic_recognition.go +++ b/GinSkeleton/app/http/validator/web/ai_recognition/pic_recognition.go @@ -8,8 +8,8 @@ import ( "goskeleton/app/http/validator/core/data_transfer" "goskeleton/app/utils/response" "image" + _ "image/jpeg" "math" - "github.com/gin-gonic/gin" ) @@ -50,6 +50,7 @@ func (p PicRecognition) CheckParams(context *gin.Context) { // 将字节数据转换为图像以检查格式和尺寸 img, _, err := image.Decode(bytes.NewReader(decodedData)) if err != nil { + response.ErrorSystem(context, "PicRecognition表单参数验证器图片格式不正确", "") return } bounds := img.Bounds() diff --git a/coeditor_frontend/package-lock.json b/coeditor_frontend/package-lock.json index 4fdd72b..1bd911d 100644 --- a/coeditor_frontend/package-lock.json +++ b/coeditor_frontend/package-lock.json @@ -20,7 +20,7 @@ "jquery": "^3.7.1", "jwt-decode": "^4.0.0", "mitt": "^3.0.1", - "vue": "^3.2.13", + "vue": "^3.5.13", "vue-router": "^4.0.3", "vuex": "^4.0.0" }, @@ -8689,7 +8689,7 @@ }, "node_modules/mitt": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/mitt/-/mitt-3.0.1.tgz", + "resolved": "https://registry.npmmirror.com/mitt/-/mitt-3.0.1.tgz", "integrity": "sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==" }, "node_modules/mkdirp": { diff --git a/coeditor_frontend/src/components/plugins.js b/coeditor_frontend/src/components/plugins.js index d942913..120d799 100644 --- a/coeditor_frontend/src/components/plugins.js +++ b/coeditor_frontend/src/components/plugins.js @@ -608,20 +608,18 @@ class AiFormat extends Plugin { } // 智能识别发送消息 -function sendRecMsg(type) { - const selection = window.getSelection(); +function sendRecMsg(type, editor) { + //const selection = window.getSelection(); + // const editor = this.editor; + const model = editor.model; + const imageUtils=editor.plugins.get( 'ImageUtils' ); + const imageElement = imageUtils.getClosestSelectedImageElement( model.document.selection ); const formData = new FormData(); var src = ''; if (type === 'pic_recognition') { - const range = selection.getRangeAt(0); - const imageElements = range.commonAncestorContainer.parentNode.querySelectorAll('img'); - if (imageElements.length > 0) { - const selectedImage = imageElements[0]; - src = selectedImage.getAttribute('src'); - const prefix = "data:image/png;base64,"; - if (src.startsWith(prefix)) { - src = src.substring(prefix.length); - } + if (imageElement) { + var imageSrc = imageElement.getAttribute('src'); + src = imageSrc.replace(/^data:image\/\w+;base64,/, ""); } if (src.trim() === '') return; formData.append('pic', src); @@ -682,7 +680,7 @@ class PicRecog extends Plugin { // Execute a callback function when the button is clicked button.on('execute', () => { - sendRecMsg('pic_recognition'); + sendRecMsg('pic_recognition', this.editor); }); return button; diff --git a/coeditor_frontend/src/views/RegisterView.vue b/coeditor_frontend/src/views/RegisterView.vue index 05e1446..ab5e67a 100644 --- a/coeditor_frontend/src/views/RegisterView.vue +++ b/coeditor_frontend/src/views/RegisterView.vue @@ -44,7 +44,7 @@ export default { const register = () => { $.ajax({ - url:'http://47.106.113.194:8000/register/', + url:'http://1.94.171.222:8000/register/', type:'post', data:{ username:username.value,