cd-aichat 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +188 -0
- package/dist/ailogo.png +0 -0
- package/dist/cd-aichat.css +1 -0
- package/dist/cd-aichat.es.js +32223 -0
- package/dist/cd-aichat.umd.js +279 -0
- package/dist/index.css +1 -0
- package/package.json +61 -0
- package/src/ailogo.png +0 -0
- package/src/components/AiChat.test.js +538 -0
- package/src/components/AiChat.vue +2206 -0
- package/src/components/AiChatWidget.test.js +312 -0
- package/src/components/AiChatWidget.vue +963 -0
- package/src/components/BurnAfterReadDialog.test.js +121 -0
- package/src/components/BurnAfterReadDialog.vue +511 -0
- package/src/components/BurnAfterReadMessage.test.js +188 -0
- package/src/components/BurnAfterReadMessage.vue +193 -0
- package/src/components/BurnIndicator.test.js +101 -0
- package/src/components/BurnIndicator.vue +164 -0
- package/src/components/ChatWindow.vue +0 -0
- package/src/components/MentionList.vue +163 -0
- package/src/components/ResourceList.vue +194 -0
- package/src/components/RichTextEditor.vue +437 -0
- package/src/components/ScheduledSendDialog.vue +476 -0
- package/src/components/ScreenshotOverlay.vue +78 -0
- package/src/components/SendButtonGroup.test.js +174 -0
- package/src/components/SendButtonGroup.vue +166 -0
- package/src/components/UserDrawer.vue +0 -0
- package/src/components/screenshot/ScreenshotsBackground/getBoundsByPoints.ts +41 -0
- package/src/components/screenshot/ScreenshotsBackground/index.scss +27 -0
- package/src/components/screenshot/ScreenshotsBackground/index.tsx +145 -0
- package/src/components/screenshot/ScreenshotsButton/index.scss +29 -0
- package/src/components/screenshot/ScreenshotsButton/index.tsx +58 -0
- package/src/components/screenshot/ScreenshotsCanvas/getBoundsByPoints.ts +55 -0
- package/src/components/screenshot/ScreenshotsCanvas/getPoints.ts +60 -0
- package/src/components/screenshot/ScreenshotsCanvas/index.scss +84 -0
- package/src/components/screenshot/ScreenshotsCanvas/index.tsx +277 -0
- package/src/components/screenshot/ScreenshotsCanvas/isPointInDraw.ts +35 -0
- package/src/components/screenshot/ScreenshotsColor/index.scss +45 -0
- package/src/components/screenshot/ScreenshotsColor/index.tsx +39 -0
- package/src/components/screenshot/ScreenshotsContext.ts +56 -0
- package/src/components/screenshot/ScreenshotsMagnifier/index.scss +61 -0
- package/src/components/screenshot/ScreenshotsMagnifier/index.tsx +126 -0
- package/src/components/screenshot/ScreenshotsOperations/index.scss +25 -0
- package/src/components/screenshot/ScreenshotsOperations/index.tsx +118 -0
- package/src/components/screenshot/ScreenshotsOption/index.scss +50 -0
- package/src/components/screenshot/ScreenshotsOption/index.tsx +150 -0
- package/src/components/screenshot/ScreenshotsSize/index.scss +28 -0
- package/src/components/screenshot/ScreenshotsSize/index.tsx +41 -0
- package/src/components/screenshot/ScreenshotsSizeColor/index.scss +8 -0
- package/src/components/screenshot/ScreenshotsSizeColor/index.tsx +25 -0
- package/src/components/screenshot/ScreenshotsTextarea/calculateNodeSize.ts +117 -0
- package/src/components/screenshot/ScreenshotsTextarea/index.scss +19 -0
- package/src/components/screenshot/ScreenshotsTextarea/index.tsx +96 -0
- package/src/components/screenshot/composeImage.ts +57 -0
- package/src/components/screenshot/exports.ts +4 -0
- package/src/components/screenshot/hooks/useBounds.ts +35 -0
- package/src/components/screenshot/hooks/useCall.ts +17 -0
- package/src/components/screenshot/hooks/useCanvasContextRef.ts +8 -0
- package/src/components/screenshot/hooks/useCanvasMousedown.ts +13 -0
- package/src/components/screenshot/hooks/useCanvasMousemove.ts +13 -0
- package/src/components/screenshot/hooks/useCanvasMouseup.ts +13 -0
- package/src/components/screenshot/hooks/useCursor.ts +34 -0
- package/src/components/screenshot/hooks/useDispatcher.ts +8 -0
- package/src/components/screenshot/hooks/useDrawSelect.ts +16 -0
- package/src/components/screenshot/hooks/useEmiter.ts +61 -0
- package/src/components/screenshot/hooks/useHistory.ts +160 -0
- package/src/components/screenshot/hooks/useLang.ts +8 -0
- package/src/components/screenshot/hooks/useOperation.ts +37 -0
- package/src/components/screenshot/hooks/useReset.ts +26 -0
- package/src/components/screenshot/hooks/useStore.ts +8 -0
- package/src/components/screenshot/icons/iconfont.scss +88 -0
- package/src/components/screenshot/icons/iconfont.ttf +0 -0
- package/src/components/screenshot/icons/iconfont.woff +0 -0
- package/src/components/screenshot/icons/iconfont.woff2 +0 -0
- package/src/components/screenshot/index.tsx +169 -0
- package/src/components/screenshot/operations/Arrow/draw.ts +56 -0
- package/src/components/screenshot/operations/Arrow/index.tsx +193 -0
- package/src/components/screenshot/operations/Brush/draw.ts +45 -0
- package/src/components/screenshot/operations/Brush/index.tsx +169 -0
- package/src/components/screenshot/operations/Cancel/index.tsx +18 -0
- package/src/components/screenshot/operations/Ellipse/draw.ts +96 -0
- package/src/components/screenshot/operations/Ellipse/index.tsx +245 -0
- package/src/components/screenshot/operations/Mosaic/index.tsx +223 -0
- package/src/components/screenshot/operations/Ok/index.tsx +37 -0
- package/src/components/screenshot/operations/Pin/index.tsx +37 -0
- package/src/components/screenshot/operations/Rectangle/draw.ts +80 -0
- package/src/components/screenshot/operations/Rectangle/index.tsx +245 -0
- package/src/components/screenshot/operations/Redo/index.tsx +22 -0
- package/src/components/screenshot/operations/Save/index.tsx +37 -0
- package/src/components/screenshot/operations/Scan/index.tsx +46 -0
- package/src/components/screenshot/operations/Search/index.tsx +39 -0
- package/src/components/screenshot/operations/Text/index.tsx +307 -0
- package/src/components/screenshot/operations/Undo/index.tsx +22 -0
- package/src/components/screenshot/operations/index.ts +34 -0
- package/src/components/screenshot/operations/utils.ts +34 -0
- package/src/components/screenshot/screenshots.scss +13 -0
- package/src/components/screenshot/types.ts +53 -0
- package/src/components/screenshot/useGetLoadedImage.ts +29 -0
- package/src/components/screenshot/var.scss +107 -0
- package/src/components/screenshot/zh_CN.ts +37 -0
- package/src/emoji/100.gif +0 -0
- package/src/emoji/101.gif +0 -0
- package/src/emoji/102.gif +0 -0
- package/src/emoji/103.gif +0 -0
- package/src/emoji/104.gif +0 -0
- package/src/emoji/105.gif +0 -0
- package/src/emoji/106.gif +0 -0
- package/src/emoji/107.gif +0 -0
- package/src/emoji/108.gif +0 -0
- package/src/emoji/109.gif +0 -0
- package/src/emoji/110.gif +0 -0
- package/src/emoji/111.gif +0 -0
- package/src/emoji/112.gif +0 -0
- package/src/emoji/113.gif +0 -0
- package/src/emoji/114.gif +0 -0
- package/src/emoji/115.gif +0 -0
- package/src/emoji/116.gif +0 -0
- package/src/emoji/117.gif +0 -0
- package/src/emoji/118.gif +0 -0
- package/src/emoji/119.gif +0 -0
- package/src/emoji/120.gif +0 -0
- package/src/emoji/121.gif +0 -0
- package/src/emoji/122.gif +0 -0
- package/src/emoji/123.gif +0 -0
- package/src/emoji/124.gif +0 -0
- package/src/emoji/125.gif +0 -0
- package/src/emoji/126.gif +0 -0
- package/src/emoji/127.gif +0 -0
- package/src/emoji/128.gif +0 -0
- package/src/emoji/129.gif +0 -0
- package/src/emoji/130.gif +0 -0
- package/src/emoji/131.gif +0 -0
- package/src/emoji/132.gif +0 -0
- package/src/emoji/133.gif +0 -0
- package/src/emoji/134.gif +0 -0
- package/src/emoji/135.gif +0 -0
- package/src/emoji/136.gif +0 -0
- package/src/emoji/137.gif +0 -0
- package/src/emoji/138.gif +0 -0
- package/src/emoji/139.gif +0 -0
- package/src/emoji/140.gif +0 -0
- package/src/emoji/141.gif +0 -0
- package/src/emoji/142.gif +0 -0
- package/src/emoji/143.gif +0 -0
- package/src/emoji/144.gif +0 -0
- package/src/emoji/145.gif +0 -0
- package/src/emoji/146.gif +0 -0
- package/src/emoji/147.gif +0 -0
- package/src/emoji/148.gif +0 -0
- package/src/emoji/149.gif +0 -0
- package/src/emoji/150.gif +0 -0
- package/src/emoji/151.gif +0 -0
- package/src/emoji/152.gif +0 -0
- package/src/emoji/153.gif +0 -0
- package/src/emoji/154.gif +0 -0
- package/src/emoji/155.gif +0 -0
- package/src/emoji/156.gif +0 -0
- package/src/emoji/157.gif +0 -0
- package/src/emoji/158.gif +0 -0
- package/src/emoji/159.gif +0 -0
- package/src/emoji/160.gif +0 -0
- package/src/emoji/161.gif +0 -0
- package/src/emoji/162.gif +0 -0
- package/src/emoji/163.gif +0 -0
- package/src/emoji/164.gif +0 -0
- package/src/emoji/165.gif +0 -0
- package/src/emoji/166.gif +0 -0
- package/src/emoji/167.gif +0 -0
- package/src/emoji/168.gif +0 -0
- package/src/emoji/169.gif +0 -0
- package/src/emoji/170.gif +0 -0
- package/src/emoji/171.gif +0 -0
- package/src/emoji/172.gif +0 -0
- package/src/emoji/173.gif +0 -0
- package/src/emoji/174.gif +0 -0
- package/src/emoji/175.gif +0 -0
- package/src/emoji/176.gif +0 -0
- package/src/emoji/177.gif +0 -0
- package/src/emoji/178.gif +0 -0
- package/src/emoji/179.gif +0 -0
- package/src/emoji/180.gif +0 -0
- package/src/emoji/181.gif +0 -0
- package/src/emoji/182.gif +0 -0
- package/src/emoji/183.gif +0 -0
- package/src/emoji/184.gif +0 -0
- package/src/emoji/185.gif +0 -0
- package/src/emoji/186.gif +0 -0
- package/src/emoji/187.gif +0 -0
- package/src/emoji/188.gif +0 -0
- package/src/emoji/189.gif +0 -0
- package/src/emoji/190.gif +0 -0
- package/src/emoji/191.gif +0 -0
- package/src/emoji/192.gif +0 -0
- package/src/emoji/193.gif +0 -0
- package/src/emoji/194.gif +0 -0
- package/src/emoji/195.gif +0 -0
- package/src/emoji/196.gif +0 -0
- package/src/emoji/197.gif +0 -0
- package/src/emoji/198.gif +0 -0
- package/src/emoji/199.gif +0 -0
- package/src/emoji/200.png +0 -0
- package/src/emoji/201.png +0 -0
- package/src/emoji/202.png +0 -0
- package/src/emoji/203.png +0 -0
- package/src/emoji/204.png +0 -0
- package/src/emoji/205.png +0 -0
- package/src/emoji/206.png +0 -0
- package/src/emoji/207.png +0 -0
- package/src/emoji/208.png +0 -0
- package/src/emoji/209.png +0 -0
- package/src/emoji/210.png +0 -0
- package/src/emoji/211.png +0 -0
- package/src/emoji/212.png +0 -0
- package/src/emoji/213.png +0 -0
- package/src/emoji/214.png +0 -0
- package/src/emoji/215.png +0 -0
- package/src/emoji/216.png +0 -0
- package/src/emoji/217.png +0 -0
- package/src/emoji/218.png +0 -0
- package/src/emoji/219.png +0 -0
- package/src/emoji2/101--Streamline-The-Team.png +0 -0
- package/src/emoji2/128--Streamline-The-Team.png +0 -0
- package/src/emoji2/134--Streamline-The-Team.png +0 -0
- package/src/emoji2/173--Streamline-The-Team.png +0 -0
- package/src/emoji2/Airplane--Streamline-Emoji.svg +24 -0
- package/src/emoji2/Alien--Streamline-Emoji.svg +21 -0
- package/src/emoji2/Amazed-Face--Streamline-Emoji.svg +16 -0
- package/src/emoji2/Amusing-Face--Streamline-Emoji.svg +20 -0
- package/src/emoji2/Anguished-Face--Streamline-Emoji.svg +19 -0
- package/src/emoji2/Anxious-Face--Streamline-Emoji.svg +17 -0
- package/src/emoji2/Astonished-Face--Streamline-Emoji.svg +20 -0
- package/src/emoji2/Backhand-Index-Pointing-Down-1--Streamline-Emoji.svg +12 -0
- package/src/emoji2/Backhand-Index-Pointing-Left-1--Streamline-Emoji.svg +13 -0
- package/src/emoji2/Backhand-Index-Pointing-Right-1--Streamline-Emoji.svg +13 -0
- package/src/emoji2/Backhand-Index-Pointing-Up-1--Streamline-Emoji.svg +14 -0
- package/src/emoji2/Bar-Chart--Streamline-Emoji.svg +22 -0
- package/src/emoji2/Beaming-Face-With-Smiling-Eyes--Streamline-Emoji.svg +20 -0
- package/src/emoji2/Boy-1--Streamline-Emoji.svg +17 -0
- package/src/emoji2/Boy-2--Streamline-Emoji.svg +17 -0
- package/src/emoji2/Boy-3--Streamline-Emoji.svg +17 -0
- package/src/emoji2/Broken-Heart--Streamline-Emoji.svg +12 -0
- package/src/emoji2/Clapping-Hands-1--Streamline-Emoji.svg +23 -0
- package/src/emoji2/Clinking-Glasses-2--Streamline-Emoji.svg +43 -0
- package/src/emoji2/Confounded-Face--Streamline-Emoji.svg +17 -0
- package/src/emoji2/Confused-Face--Streamline-Emoji.svg +15 -0
- package/src/emoji2/Construction-Worker--Streamline-Emoji.svg +21 -0
- package/src/emoji2/Couple-With-Heart-Woman-Man-1--Streamline-Emoji.svg +40 -0
- package/src/emoji2/Couple-With-Heart-Woman-Man-2--Streamline-Emoji.svg +40 -0
- package/src/emoji2/Cowboy-Hat-Face--Streamline-Emoji.svg +22 -0
- package/src/emoji2/Crazy-Face--Streamline-Emoji.svg +25 -0
- package/src/emoji2/Crossed-Fingers-1--Streamline-Emoji.svg +25 -0
- package/src/emoji2/Crown--Streamline-Emoji.svg +35 -0
- package/src/emoji2/Crying-Face--Streamline-Emoji.svg +26 -0
- package/src/emoji2/Delivery-Truck--Streamline-Emoji.svg +31 -0
- package/src/emoji2/Determined-Face--Streamline-Emoji.svg +25 -0
- package/src/emoji2/Disappointed-Face--Streamline-Emoji.svg +15 -0
- package/src/emoji2/Dizzy-Face--Streamline-Emoji.svg +20 -0
- package/src/emoji2/Downcast-Face-With-Sweat--Streamline-Emoji.svg +18 -0
- package/src/emoji2/Drooling-Face-1--Streamline-Emoji.svg +19 -0
- package/src/emoji2/Drooling-Face-2--Streamline-Emoji.svg +18 -0
- package/src/emoji2/Ear--Streamline-Emoji.svg +14 -0
- package/src/emoji2/Exclamation-Mark--Streamline-Emoji.svg +12 -0
- package/src/emoji2/Exploding-Head--Streamline-Emoji.svg +24 -0
- package/src/emoji2/Expressionless-Face--Streamline-Emoji.svg +15 -0
- package/src/emoji2/Face-Blowing-A-Kiss--Streamline-Emoji.svg +18 -0
- package/src/emoji2/Face-Savoring-Food--Streamline-Emoji.svg +18 -0
- package/src/emoji2/Face-Screaming-In-Fear--Streamline-Emoji.svg +18 -0
- package/src/emoji2/Face-Vomiting--Streamline-Emoji.svg +28 -0
- package/src/emoji2/Face-With-Head-Bandage--Streamline-Emoji.svg +25 -0
- package/src/emoji2/Face-With-Medical-Mask--Streamline-Emoji.svg +23 -0
- package/src/emoji2/Face-With-Monocle--Streamline-Emoji.svg +26 -0
- package/src/emoji2/Face-With-Raised-Eyebrow--Streamline-Emoji.svg +17 -0
- package/src/emoji2/Face-With-Rolling-Eyes--Streamline-Emoji.svg +17 -0
- package/src/emoji2/Face-With-Steam-From-Nose--Streamline-Emoji.svg +19 -0
- package/src/emoji2/Face-With-Symbols-On-Mouth--Streamline-Emoji.svg +22 -0
- package/src/emoji2/Face-With-Tears-Of-Joy--Streamline-Emoji.svg +34 -0
- package/src/emoji2/Face-With-Thermometer--Streamline-Emoji.svg +31 -0
- package/src/emoji2/Face-With-Tongue--Streamline-Emoji.svg +18 -0
- package/src/emoji2/Face-Without-Mouth--Streamline-Emoji.svg +14 -0
- package/src/emoji2/Fearful-Face--Streamline-Emoji.svg +18 -0
- package/src/emoji2/Flexed-Biceps-1--Streamline-Emoji.svg +13 -0
- package/src/emoji2/Flushed-Face--Streamline-Emoji.svg +19 -0
- package/src/emoji2/Folded-Hands-1--Streamline-Emoji.svg +29 -0
- package/src/emoji2/Frowning-Face--Streamline-Emoji.svg +15 -0
- package/src/emoji2/Fuel-Pump--Streamline-Emoji.svg +30 -0
- package/src/emoji2/Girl-1--Streamline-Emoji.svg +23 -0
- package/src/emoji2/Glasses-1--Streamline-Emoji.svg +27 -0
- package/src/emoji2/Grimacing-Face--Streamline-Emoji.svg +19 -0
- package/src/emoji2/Grinning-Cat-Face--Streamline-Emoji.svg +32 -0
- package/src/emoji2/Grinning-Face--Streamline-Emoji.svg +16 -0
- package/src/emoji2/Grinning-Face-With-Sweat--Streamline-Emoji.svg +19 -0
- package/src/emoji2/Grinning-Squinting-Face--Streamline-Emoji.svg +16 -0
- package/src/emoji2/Hand-With-Fingers-Splayed-1--Streamline-Emoji.svg +14 -0
- package/src/emoji2/Heart-Suit--Streamline-Emoji.svg +9 -0
- package/src/emoji2/Hushed-Face-1--Streamline-Emoji.svg +17 -0
- package/src/emoji2/Hushed-Face-2--Streamline-Emoji.svg +15 -0
- package/src/emoji2/Index-Pointing-Up-1--Streamline-Emoji.svg +17 -0
- package/src/emoji2/Kissing-Face-With-Closed-Eyes--Streamline-Emoji.svg +18 -0
- package/src/emoji2/Loudly-Crying-Face--Streamline-Emoji.svg +16 -0
- package/src/emoji2/Lying-Face--Streamline-Emoji.svg +15 -0
- package/src/emoji2/Man-1--Streamline-Emoji.svg +17 -0
- package/src/emoji2/Man-Facepalming-1--Streamline-Emoji.svg +21 -0
- package/src/emoji2/Man-Gesturing-No-1--Streamline-Emoji.svg +34 -0
- package/src/emoji2/Man-Gesturing-Ok-1--Streamline-Emoji.svg +25 -0
- package/src/emoji2/Man-Health-Worker-1--Streamline-Emoji.svg +41 -0
- package/src/emoji2/Man-Raising-Hand-1--Streamline-Emoji.svg +26 -0
- package/src/emoji2/Man-Shrugging-1--Streamline-Emoji.svg +31 -0
- package/src/emoji2/Money-Mouth-Face-2--Streamline-Emoji.svg +30 -0
- package/src/emoji2/Mouth--Streamline-Emoji.svg +12 -0
- package/src/emoji2/Nauseated-Face-2--Streamline-Emoji.svg +19 -0
- package/src/emoji2/Neutral-Face--Streamline-Emoji.svg +15 -0
- package/src/emoji2/Ok-Hand-1--Streamline-Emoji.svg +14 -0
- package/src/emoji2/Old-Man-1--Streamline-Emoji.svg +27 -0
- package/src/emoji2/Old-Woman-1--Streamline-Emoji.svg +23 -0
- package/src/emoji2/Oncoming-Fist-1--Streamline-Emoji.svg +15 -0
- package/src/emoji2/Person-Wearing-Turban-2--Streamline-Emoji.svg +20 -0
- package/src/emoji2/Pile-Of-Poo--Streamline-Emoji.svg +15 -0
- package/src/emoji2/Police-Car-Light--Streamline-Emoji.svg +26 -0
- package/src/emoji2/Rocket--Streamline-Emoji.svg +32 -0
- package/src/emoji2/Sailboat--Streamline-Emoji.svg +18 -0
- package/src/emoji2/Shaved-Ice--Streamline-Emoji.svg +21 -0
- package/src/emoji2/Shortcake-2--Streamline-Emoji.svg +18 -0
- package/src/emoji2/Shushing-Face--Streamline-Emoji.svg +21 -0
- package/src/emoji2/Sign-Of-The-Horns-1--Streamline-Emoji.svg +19 -0
- package/src/emoji2/Sleeping-Face--Streamline-Emoji.svg +21 -0
- package/src/emoji2/Slightly-Smiling-Face--Streamline-Emoji.svg +15 -0
- package/src/emoji2/Smiling-Face-With-Halo--Streamline-Emoji.svg +20 -0
- package/src/emoji2/Smiling-Face-With-Heart-Eyes--Streamline-Emoji.svg +21 -0
- package/src/emoji2/Smirking-Face--Streamline-Emoji.svg +17 -0
- package/src/emoji2/Sun-With-Face--Streamline-Emoji.svg +24 -0
- package/src/emoji2/Thumbs-Down-1--Streamline-Emoji.svg +20 -0
- package/src/emoji2/Thumbs-Up-1--Streamline-Emoji.svg +19 -0
- package/src/emoji2/Winking-Face--Streamline-Emoji.svg +18 -0
- package/src/emoji2/Woman-Gesturing-No-1--Streamline-Emoji.svg +34 -0
- package/src/emoji2/Woman-Gesturing-Ok-2--Streamline-Emoji.svg +25 -0
- package/src/emoji2/Woman-Raising-Hand-1--Streamline-Emoji.svg +26 -0
- package/src/emoji2/Womans-Sandal--Streamline-Emoji.svg +13 -0
- package/src/emoji2/Worried-Face--Streamline-Emoji.svg +17 -0
- package/src/emoji2/Writing-Hand-1--Streamline-Emoji.svg +17 -0
- package/src/emoji2/Zipper-Mouth-Face--Streamline-Emoji.svg +21 -0
- package/src/index.js +19 -0
- package/src/services/burn-after-read-service.js +313 -0
- package/src/services/burn-after-read-service.test.js +325 -0
- package/src/services/dify-api.js +338 -0
- package/src/services/dify-api.test.js +376 -0
- package/src/services/scheduled-send-service.js +311 -0
- package/src/services/scheduled-send-service.test.js +317 -0
- package/src/styles/index.css +2368 -0
- package/src/utils/emoji.js +125 -0
- package/src/utils/emojiData.js +267 -0
- package/src/utils/eventEmitter.js +114 -0
- package/src/utils/state.js +224 -0
- package/src/utils/state.test.js +198 -0
- package/src/utils/storage.js +122 -0
- package/src/utils/storage.test.js +162 -0
- package/src/utils/validation.js +249 -0
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
|
2
|
+
import { mount } from '@vue/test-utils';
|
|
3
|
+
import AiChatWidget from './AiChatWidget.vue';
|
|
4
|
+
|
|
5
|
+
// Mock AiChat 组件
|
|
6
|
+
vi.mock('./AiChat.vue', () => {
|
|
7
|
+
return {
|
|
8
|
+
default: {
|
|
9
|
+
name: 'AiChat',
|
|
10
|
+
template: '<div class="mock-ai-chat">Mock AiChat</div>',
|
|
11
|
+
props: ['chatType', 'chatUser', 'currentUserId', 'aiConfig'],
|
|
12
|
+
emits: ['send', 'aiResponseStart', 'aiResponseComplete']
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
describe('AiChatWidget', () => {
|
|
18
|
+
const defaultProps = {
|
|
19
|
+
aiConfig: {
|
|
20
|
+
url: 'https://api.dify.ai/v1',
|
|
21
|
+
agentId: 'test-agent'
|
|
22
|
+
},
|
|
23
|
+
currentUserId: 'user-001'
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
describe('基础功能', () => {
|
|
27
|
+
it('应该渲染浮动触发按钮', () => {
|
|
28
|
+
const wrapper = mount(AiChatWidget, {
|
|
29
|
+
props: defaultProps
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
expect(wrapper.find('.ai-chat-trigger').exists()).toBe(true);
|
|
33
|
+
expect(wrapper.find('.ai-chat-dialog').exists()).toBe(false);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('应该在点击触发按钮后打开对话框', async () => {
|
|
37
|
+
const wrapper = mount(AiChatWidget, {
|
|
38
|
+
props: defaultProps
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
await wrapper.find('.ai-chat-trigger').trigger('click');
|
|
42
|
+
|
|
43
|
+
expect(wrapper.find('.ai-chat-dialog').exists()).toBe(true);
|
|
44
|
+
expect(wrapper.emitted('open')).toBeTruthy();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('应该在点击关闭按钮后关闭对话框', async () => {
|
|
48
|
+
const wrapper = mount(AiChatWidget, {
|
|
49
|
+
props: {
|
|
50
|
+
...defaultProps,
|
|
51
|
+
defaultOpen: true
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
await wrapper.find('.close-btn').trigger('click');
|
|
56
|
+
|
|
57
|
+
expect(wrapper.find('.ai-chat-dialog').exists()).toBe(false);
|
|
58
|
+
expect(wrapper.emitted('close')).toBeTruthy();
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
describe('位置配置', () => {
|
|
63
|
+
it('应该根据 position 属性设置正确的位置', () => {
|
|
64
|
+
const wrapper = mount(AiChatWidget, {
|
|
65
|
+
props: {
|
|
66
|
+
...defaultProps,
|
|
67
|
+
position: 'bottom-right',
|
|
68
|
+
offset: { x: 20, y: 20 }
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const trigger = wrapper.find('.ai-chat-trigger');
|
|
73
|
+
const style = trigger.attributes('style');
|
|
74
|
+
|
|
75
|
+
expect(style).toContain('bottom: 20px');
|
|
76
|
+
expect(style).toContain('right: 20px');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('应该支持不同的位置选项', () => {
|
|
80
|
+
const positions = ['bottom-right', 'bottom-left', 'top-right', 'top-left'];
|
|
81
|
+
|
|
82
|
+
positions.forEach(position => {
|
|
83
|
+
const wrapper = mount(AiChatWidget, {
|
|
84
|
+
props: {
|
|
85
|
+
...defaultProps,
|
|
86
|
+
position
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// 检查位置样式是否正确设置
|
|
91
|
+
const trigger = wrapper.find('.ai-chat-trigger');
|
|
92
|
+
const style = trigger.attributes('style');
|
|
93
|
+
|
|
94
|
+
if (position.includes('bottom')) {
|
|
95
|
+
expect(style).toContain('bottom:');
|
|
96
|
+
} else {
|
|
97
|
+
expect(style).toContain('top:');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (position.includes('right')) {
|
|
101
|
+
expect(style).toContain('right:');
|
|
102
|
+
} else {
|
|
103
|
+
expect(style).toContain('left:');
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
describe('窗口控制', () => {
|
|
110
|
+
it('应该支持最小化功能', async () => {
|
|
111
|
+
const wrapper = mount(AiChatWidget, {
|
|
112
|
+
props: {
|
|
113
|
+
...defaultProps,
|
|
114
|
+
defaultOpen: true
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const minimizeBtn = wrapper.findAll('.header-btn')[0];
|
|
119
|
+
await minimizeBtn.trigger('click');
|
|
120
|
+
|
|
121
|
+
expect(wrapper.find('.ai-chat-dialog').exists()).toBe(false);
|
|
122
|
+
expect(wrapper.emitted('minimize')).toBeTruthy();
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it('应该支持最大化和还原功能', async () => {
|
|
126
|
+
const wrapper = mount(AiChatWidget, {
|
|
127
|
+
props: {
|
|
128
|
+
...defaultProps,
|
|
129
|
+
defaultOpen: true
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
const maximizeBtn = wrapper.findAll('.header-btn')[1];
|
|
134
|
+
|
|
135
|
+
// 最大化
|
|
136
|
+
await maximizeBtn.trigger('click');
|
|
137
|
+
expect(wrapper.find('.ai-chat-dialog').classes()).toContain('maximized');
|
|
138
|
+
expect(wrapper.emitted('maximize')).toBeTruthy();
|
|
139
|
+
|
|
140
|
+
// 还原
|
|
141
|
+
await maximizeBtn.trigger('click');
|
|
142
|
+
expect(wrapper.find('.ai-chat-dialog').classes()).not.toContain('maximized');
|
|
143
|
+
expect(wrapper.emitted('restore')).toBeTruthy();
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
describe('徽章功能', () => {
|
|
148
|
+
it('应该显示未读消息徽章', () => {
|
|
149
|
+
const wrapper = mount(AiChatWidget, {
|
|
150
|
+
props: {
|
|
151
|
+
...defaultProps,
|
|
152
|
+
showBadge: true,
|
|
153
|
+
badgeCount: 5
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
const badge = wrapper.find('.badge');
|
|
158
|
+
expect(badge.exists()).toBe(true);
|
|
159
|
+
expect(badge.text()).toBe('5');
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it('应该在打开对话框后清除徽章', async () => {
|
|
163
|
+
const wrapper = mount(AiChatWidget, {
|
|
164
|
+
props: {
|
|
165
|
+
...defaultProps,
|
|
166
|
+
showBadge: true,
|
|
167
|
+
badgeCount: 5
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
await wrapper.find('.ai-chat-trigger').trigger('click');
|
|
172
|
+
|
|
173
|
+
// 徽章应该被清零
|
|
174
|
+
const badge = wrapper.find('.badge');
|
|
175
|
+
expect(badge.exists()).toBe(false);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('应该正确显示超过 99 的徽章数', () => {
|
|
179
|
+
const wrapper = mount(AiChatWidget, {
|
|
180
|
+
props: {
|
|
181
|
+
...defaultProps,
|
|
182
|
+
showBadge: true,
|
|
183
|
+
badgeCount: 150
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
const badge = wrapper.find('.badge');
|
|
188
|
+
expect(badge.text()).toBe('99+');
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
describe('遮罩层', () => {
|
|
193
|
+
it('应该在配置时显示遮罩层', async () => {
|
|
194
|
+
const wrapper = mount(AiChatWidget, {
|
|
195
|
+
props: {
|
|
196
|
+
...defaultProps,
|
|
197
|
+
showMask: true
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
await wrapper.find('.ai-chat-trigger').trigger('click');
|
|
202
|
+
|
|
203
|
+
expect(wrapper.find('.ai-chat-mask').exists()).toBe(true);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it('应该在点击遮罩层时关闭对话框', async () => {
|
|
207
|
+
const wrapper = mount(AiChatWidget, {
|
|
208
|
+
props: {
|
|
209
|
+
...defaultProps,
|
|
210
|
+
showMask: true,
|
|
211
|
+
closeOnMaskClick: true,
|
|
212
|
+
defaultOpen: true
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
await wrapper.find('.ai-chat-mask').trigger('click');
|
|
217
|
+
|
|
218
|
+
expect(wrapper.find('.ai-chat-dialog').exists()).toBe(false);
|
|
219
|
+
expect(wrapper.emitted('close')).toBeTruthy();
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
it('应该在配置不关闭时保持对话框打开', async () => {
|
|
223
|
+
const wrapper = mount(AiChatWidget, {
|
|
224
|
+
props: {
|
|
225
|
+
...defaultProps,
|
|
226
|
+
showMask: true,
|
|
227
|
+
closeOnMaskClick: false,
|
|
228
|
+
defaultOpen: true
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
await wrapper.find('.ai-chat-mask').trigger('click');
|
|
233
|
+
|
|
234
|
+
expect(wrapper.find('.ai-chat-dialog').exists()).toBe(true);
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
describe('暴露的方法', () => {
|
|
239
|
+
it('应该暴露 open 方法', () => {
|
|
240
|
+
const wrapper = mount(AiChatWidget, {
|
|
241
|
+
props: defaultProps
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
wrapper.vm.open();
|
|
245
|
+
|
|
246
|
+
expect(wrapper.find('.ai-chat-dialog').exists()).toBe(true);
|
|
247
|
+
expect(wrapper.emitted('open')).toBeTruthy();
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it('应该暴露 close 方法', () => {
|
|
251
|
+
const wrapper = mount(AiChatWidget, {
|
|
252
|
+
props: {
|
|
253
|
+
...defaultProps,
|
|
254
|
+
defaultOpen: true
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
wrapper.vm.close();
|
|
259
|
+
|
|
260
|
+
expect(wrapper.find('.ai-chat-dialog').exists()).toBe(false);
|
|
261
|
+
expect(wrapper.emitted('close')).toBeTruthy();
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
it('应该暴露 isOpen 方法', async () => {
|
|
265
|
+
const wrapper = mount(AiChatWidget, {
|
|
266
|
+
props: defaultProps
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
expect(wrapper.vm.isOpen()).toBe(false);
|
|
270
|
+
|
|
271
|
+
await wrapper.find('.ai-chat-trigger').trigger('click');
|
|
272
|
+
|
|
273
|
+
expect(wrapper.vm.isOpen()).toBe(true);
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
describe('AI 事件转发', () => {
|
|
278
|
+
it('应该转发 send 事件', async () => {
|
|
279
|
+
const wrapper = mount(AiChatWidget, {
|
|
280
|
+
props: {
|
|
281
|
+
...defaultProps,
|
|
282
|
+
defaultOpen: true
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
const aiChat = wrapper.findComponent({ name: 'AiChat' });
|
|
287
|
+
const sendData = { message: { content: 'test' } };
|
|
288
|
+
|
|
289
|
+
await aiChat.vm.$emit('send', sendData);
|
|
290
|
+
|
|
291
|
+
expect(wrapper.emitted('send')).toBeTruthy();
|
|
292
|
+
expect(wrapper.emitted('send')[0][0]).toEqual(sendData);
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
it('应该转发 aiResponseComplete 事件', async () => {
|
|
296
|
+
const wrapper = mount(AiChatWidget, {
|
|
297
|
+
props: {
|
|
298
|
+
...defaultProps,
|
|
299
|
+
defaultOpen: true
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
const aiChat = wrapper.findComponent({ name: 'AiChat' });
|
|
304
|
+
const responseData = { response: 'AI response' };
|
|
305
|
+
|
|
306
|
+
await aiChat.vm.$emit('aiResponseComplete', responseData);
|
|
307
|
+
|
|
308
|
+
expect(wrapper.emitted('aiResponseComplete')).toBeTruthy();
|
|
309
|
+
expect(wrapper.emitted('aiResponseComplete')[0][0]).toEqual(responseData);
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
});
|