@opentiny/tiny-robot 0.1.0-alpha.0 → 0.1.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/dist/{bubble-item → bubble}/components/actions/copy.vue.d.ts +3 -3
- package/dist/{bubble-item → bubble}/components/actions/refresh.vue.d.ts +1 -1
- package/dist/bubble/index.d.ts +12 -0
- package/dist/bubble/index.type.d.ts +53 -0
- package/dist/bubble/useScroll.d.ts +4 -0
- package/dist/index.d.ts +9 -5
- package/dist/index.js +25 -18
- package/dist/node_modules/.pnpm/@opentiny_utils@1.0.0/node_modules/@opentiny/utils/dist/opentiny-utils.es.js +832 -0
- package/dist/node_modules/.pnpm/@opentiny_utils@3.22.0/node_modules/@opentiny/utils/dist/index.es.js +959 -1496
- package/dist/node_modules/.pnpm/{@opentiny_vue-button@3.22.0 → @opentiny_vue-button@3.21.0}/node_modules/@opentiny/vue-button/lib/index.js +21 -21
- package/dist/node_modules/.pnpm/{@opentiny_vue-button@3.22.0 → @opentiny_vue-button@3.21.0}/node_modules/@opentiny/vue-button/lib/pc.js +3 -3
- package/dist/node_modules/.pnpm/@opentiny_vue-common@3.21.0/node_modules/@opentiny/vue-common/lib/index.js +727 -0
- package/dist/node_modules/.pnpm/@opentiny_vue-common@3.22.0/node_modules/@opentiny/vue-common/lib/index.js +144 -675
- package/dist/node_modules/.pnpm/{@opentiny_vue-dialog-box@3.22.0 → @opentiny_vue-dialog-box@3.21.0}/node_modules/@opentiny/vue-dialog-box/lib/index.js +9 -9
- package/dist/node_modules/.pnpm/{@opentiny_vue-dialog-box@3.22.0 → @opentiny_vue-dialog-box@3.21.0}/node_modules/@opentiny/vue-dialog-box/lib/pc.js +5 -5
- package/dist/node_modules/.pnpm/@opentiny_vue-icon@3.21.0/node_modules/@opentiny/vue-icon/lib/close.js +29 -0
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/eyeclose.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/eyeopen.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/finish.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/fullscreen.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/loading-shadow.js +21 -22
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/minscreen.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-add-column-after.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-add-column-before.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-add-row-after.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-add-row-before.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-align-center.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-align-left.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-align-right.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-bold.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-code-block.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-code-view.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-color.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-delete-column.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-delete-row.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-delete-table.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-font-size.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-format-clear.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-h1.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-h2.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-h3.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-h4.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-h5.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-h6.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-heading.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-high-light.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-image.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-italic.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-line-height.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-link-unlink.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-link.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-list-ordered.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-list-unordered.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-merge-cells-vertical.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-merge-cells.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-node-delete.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-paragraph.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-quote-text.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-redo.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-split-cells-horizontal.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-split-cells-vertical.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-strike-through.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-subscript.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-superscript.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-table.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-task-list.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-underline.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/rich-text-undo.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/sub-script.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-icon@3.22.0 → @opentiny_vue-icon@3.21.0}/node_modules/@opentiny/vue-icon/lib/warn.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-input@3.22.0 → @opentiny_vue-input@3.21.0}/node_modules/@opentiny/vue-input/lib/index.js +3 -3
- package/dist/node_modules/.pnpm/{@opentiny_vue-input@3.22.0 → @opentiny_vue-input@3.21.0}/node_modules/@opentiny/vue-input/lib/pc.js +36 -36
- package/dist/node_modules/.pnpm/{@opentiny_vue-locale@3.22.0 → @opentiny_vue-locale@3.21.0}/node_modules/@opentiny/vue-locale/lib/index.js +63 -63
- package/dist/node_modules/.pnpm/{@opentiny_vue-renderless@3.22.0 → @opentiny_vue-renderless@3.21.2}/node_modules/@opentiny/vue-renderless/button/index.js +1 -1
- package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/browser.js +36 -0
- package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/deps/clickoutside.js +47 -0
- package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/deps/debounce.js +7 -0
- package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/deps/dom.js +45 -0
- package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/deps/popper.js +320 -0
- package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/deps/popup-manager.js +118 -0
- package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/deps/throttle.js +23 -0
- package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/deps/useEventListener.js +9 -0
- package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/deps/useInstanceSlots.js +14 -0
- package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/deps/useRelation.js +54 -0
- package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/deps/vue-popper.js +84 -0
- package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/deps/vue-popup.js +73 -0
- package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/event.js +13 -0
- package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/function.js +5 -0
- package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/index.js +11 -0
- package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/object.js +84 -0
- package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/string.js +28 -0
- package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/common/type.js +28 -0
- package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/dialog-box/index.js +136 -0
- package/dist/node_modules/.pnpm/{@opentiny_vue-renderless@3.22.0 → @opentiny_vue-renderless@3.21.2}/node_modules/@opentiny/vue-renderless/dialog-box/vue.js +33 -34
- package/dist/node_modules/.pnpm/{@opentiny_vue-renderless@3.22.0 → @opentiny_vue-renderless@3.21.2}/node_modules/@opentiny/vue-renderless/input/index.js +22 -22
- package/dist/node_modules/.pnpm/{@opentiny_vue-renderless@3.22.0 → @opentiny_vue-renderless@3.21.2}/node_modules/@opentiny/vue-renderless/input/vue.js +9 -9
- package/dist/node_modules/.pnpm/{@opentiny_vue-renderless@3.22.0 → @opentiny_vue-renderless@3.21.2}/node_modules/@opentiny/vue-renderless/tall-storage/index.js +1 -1
- package/dist/node_modules/.pnpm/{@opentiny_vue-renderless@3.22.0 → @opentiny_vue-renderless@3.21.2}/node_modules/@opentiny/vue-renderless/tall-storage/vue.js +5 -5
- package/dist/node_modules/.pnpm/{@opentiny_vue-renderless@3.22.0 → @opentiny_vue-renderless@3.21.2}/node_modules/@opentiny/vue-renderless/tooltip/index.js +41 -40
- package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.21.2/node_modules/@opentiny/vue-renderless/tooltip/vue.js +90 -0
- package/dist/node_modules/.pnpm/{@opentiny_vue-tooltip@3.22.0 → @opentiny_vue-tooltip@3.21.0}/node_modules/@opentiny/vue-tooltip/lib/index.js +3 -6
- package/dist/node_modules/.pnpm/{@opentiny_vue-tooltip@3.22.0 → @opentiny_vue-tooltip@3.21.0}/node_modules/@opentiny/vue-tooltip/lib/pc.js +2 -2
- package/dist/packages/components/src/{bubble-list → bubble}/bubble-list.vue.js +2 -2
- package/dist/packages/components/src/bubble/bubble-list.vue2.js +38 -0
- package/dist/packages/components/src/bubble/bubble.vue.js +7 -0
- package/dist/packages/components/src/bubble/bubble.vue2.js +118 -0
- package/dist/packages/components/src/bubble/components/actions/copy.vue.js +7 -0
- package/dist/packages/components/src/bubble/components/actions/copy.vue2.js +35 -0
- package/dist/packages/components/src/bubble/components/actions/refresh.vue.js +7 -0
- package/dist/packages/components/src/bubble/components/actions/refresh.vue2.js +16 -0
- package/dist/packages/components/src/bubble/index.js +18 -0
- package/dist/packages/components/src/bubble/useScroll.js +13 -0
- package/dist/packages/components/src/conversations/index.js +1 -1
- package/dist/packages/components/src/prompts/index.js +18 -0
- package/dist/packages/components/src/prompts/prompt.vue.js +7 -0
- package/dist/packages/components/src/prompts/prompt.vue2.js +37 -0
- package/dist/packages/components/src/prompts/prompts.vue.js +7 -0
- package/dist/packages/components/src/prompts/prompts.vue2.js +36 -0
- package/dist/packages/components/src/question/components/CommonQuestions.vue.js +89 -0
- package/dist/packages/components/src/question/components/CommonQuestions.vue2.js +4 -0
- package/dist/packages/components/src/question/components/HotQuestions.vue.js +140 -0
- package/dist/packages/components/src/question/components/HotQuestions.vue2.js +4 -0
- package/dist/packages/components/src/question/composables/useQuestions.js +48 -0
- package/dist/packages/components/src/question/index.js +9 -0
- package/dist/packages/components/src/question/index.vue.js +113 -0
- package/dist/packages/components/src/question/index.vue2.js +4 -0
- package/dist/packages/components/src/sender/components/ActionButtons.vue.js +105 -123
- package/dist/packages/components/src/sender/composables/useInputHandler.js +26 -22
- package/dist/packages/components/src/sender/composables/useKeyboardHandler.js +11 -11
- package/dist/packages/components/src/sender/composables/useSpeechHandler.js +9 -9
- package/dist/packages/components/src/sender/index.vue.js +67 -66
- package/dist/packages/components/src/welcome/index.vue.js +5 -7
- package/dist/packages/components/src/welcome/index.vue2.js +32 -0
- package/dist/packages/svgs/dist/tiny-robot-svgs.js +144 -0
- package/dist/prompts/index.d.ts +12 -0
- package/dist/prompts/index.type.d.ts +55 -0
- package/dist/prompts/prompt.vue.d.ts +3 -0
- package/dist/prompts/prompts.vue.d.ts +20 -0
- package/dist/question/components/CommonQuestions.vue.d.ts +32 -0
- package/dist/question/components/HotQuestions.vue.d.ts +89 -0
- package/dist/question/composables/useQuestions.d.ts +17 -0
- package/dist/question/index.d.ts +7 -0
- package/dist/question/index.type.d.ts +74 -0
- package/dist/question/index.vue.d.ts +46 -0
- package/dist/sender/components/ActionButtons.vue.d.ts +6 -4
- package/dist/sender/composables/useSpeechHandler.d.ts +0 -6
- package/dist/sender/index.type.d.ts +1 -1
- package/dist/sender/index.vue.d.ts +1 -2
- package/dist/style.css +1 -1
- package/dist/welcome/index.type.d.ts +10 -0
- package/dist/welcome/index.vue.d.ts +17 -1
- package/package.json +5 -3
- package/src/bubble/bubble-list.vue +44 -0
- package/src/bubble/bubble.vue +247 -0
- package/src/bubble/components/actions/copy.vue +54 -0
- package/src/bubble/components/actions/refresh.vue +31 -0
- package/src/bubble/index.ts +23 -0
- package/src/bubble/index.type.ts +63 -0
- package/src/bubble/useScroll.ts +14 -0
- package/src/conversations/index.ts +1 -1
- package/src/index.ts +23 -12
- package/src/prompts/index.ts +25 -0
- package/src/prompts/index.type.ts +59 -0
- package/src/prompts/prompt.vue +115 -0
- package/src/prompts/prompts.vue +50 -0
- package/src/question/components/CommonQuestions.vue +146 -0
- package/src/question/components/HotQuestions.vue +148 -0
- package/src/question/composables/useQuestions.ts +106 -0
- package/src/question/index.less +448 -0
- package/src/question/index.ts +12 -0
- package/src/question/index.type.ts +86 -0
- package/src/question/index.vue +140 -0
- package/src/question/vars.less +135 -0
- package/src/sender/components/ActionButtons.vue +42 -39
- package/src/sender/composables/useInputHandler.ts +15 -10
- package/src/sender/composables/useKeyboardHandler.ts +6 -4
- package/src/sender/composables/useSpeechHandler.ts +5 -11
- package/src/sender/index.less +3 -5
- package/src/sender/index.type.ts +1 -1
- package/src/sender/index.vue +3 -2
- package/src/welcome/index.type.ts +12 -0
- package/src/welcome/index.vue +68 -2
- package/dist/bubble-item/components/icons/ai.vue.d.ts +0 -2
- package/dist/bubble-item/components/icons/index.d.ts +0 -2
- package/dist/bubble-item/components/icons/user.vue.d.ts +0 -2
- package/dist/bubble-item/index.d.ts +0 -7
- package/dist/bubble-list/index.d.ts +0 -8
- package/dist/bubble-list/index.type.d.ts +0 -55
- package/dist/node_modules/.pnpm/@opentiny_vue-directive@3.22.0/node_modules/@opentiny/vue-directive/index.js +0 -57
- package/dist/node_modules/.pnpm/@opentiny_vue-hooks@3.22.0/node_modules/@opentiny/vue-hooks/dist/src/vue-popper.js +0 -85
- package/dist/node_modules/.pnpm/@opentiny_vue-hooks@3.22.0/node_modules/@opentiny/vue-hooks/dist/src/vue-popup.js +0 -69
- package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.22.0/node_modules/@opentiny/vue-renderless/dialog-box/index.js +0 -135
- package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.22.0/node_modules/@opentiny/vue-renderless/tooltip/vue.js +0 -90
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Symbol.js +0 -5
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseGetTag.js +0 -10
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseTrim.js +0 -8
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_freeGlobal.js +0 -4
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getRawTag.js +0 -15
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_objectToString.js +0 -7
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_root.js +0 -5
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_trimmedEndIndex.js +0 -9
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/debounce.js +0 -54
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isObject.js +0 -7
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isObjectLike.js +0 -6
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isSymbol.js +0 -9
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/now.js +0 -7
- package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/toNumber.js +0 -22
- package/dist/packages/components/src/bubble-item/bubble-item.vue.js +0 -7
- package/dist/packages/components/src/bubble-item/bubble-item.vue2.js +0 -111
- package/dist/packages/components/src/bubble-item/components/actions/copy.vue.js +0 -46
- package/dist/packages/components/src/bubble-item/components/actions/copy.vue2.js +0 -4
- package/dist/packages/components/src/bubble-item/components/actions/refresh.vue.js +0 -12
- package/dist/packages/components/src/bubble-item/components/icons/ai.vue.js +0 -45
- package/dist/packages/components/src/bubble-item/components/icons/user.vue.js +0 -63
- package/dist/packages/components/src/bubble-item/index.js +0 -9
- package/dist/packages/components/src/bubble-list/bubble-list.vue2.js +0 -52
- package/dist/packages/components/src/bubble-list/index.js +0 -9
- package/src/bubble-item/bubble-item.vue +0 -264
- package/src/bubble-item/components/actions/copy.vue +0 -47
- package/src/bubble-item/components/actions/refresh.vue +0 -27
- package/src/bubble-item/components/icons/ai.vue +0 -30
- package/src/bubble-item/components/icons/index.ts +0 -2
- package/src/bubble-item/components/icons/user.vue +0 -78
- package/src/bubble-item/index.ts +0 -12
- package/src/bubble-list/bubble-list.vue +0 -53
- package/src/bubble-list/index.ts +0 -14
- package/src/bubble-list/index.type.ts +0 -65
- package/src/sender/global.d.ts +0 -44
- /package/dist/{bubble-list → bubble}/bubble-list.vue.d.ts +0 -0
- /package/dist/{bubble-item → bubble}/components/actions/index.d.ts +0 -0
- /package/dist/node_modules/.pnpm/{@opentiny_vue-renderless@3.22.0 → @opentiny_vue-renderless@3.21.2}/node_modules/@opentiny/vue-renderless/button/vue.js +0 -0
- /package/dist/node_modules/.pnpm/{@opentiny_vue-renderless@3.22.0 → @opentiny_vue-renderless@3.21.2}/node_modules/@opentiny/vue-renderless/chunk-G2ADBYYC.js +0 -0
- /package/dist/node_modules/.pnpm/{@opentiny_vue-renderless@3.22.0 → @opentiny_vue-renderless@3.21.2}/node_modules/@opentiny/vue-renderless/tall-storage/vue-storage-box.js +0 -0
- /package/src/{bubble-item → bubble}/components/actions/index.ts +0 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, defineComponent, VNode } from 'vue'
|
|
3
|
+
import { PromptProps } from './index.type'
|
|
4
|
+
|
|
5
|
+
const props = defineProps<PromptProps>()
|
|
6
|
+
|
|
7
|
+
const vnodeToComponent = (vnode?: VNode | string) => {
|
|
8
|
+
if (!vnode) {
|
|
9
|
+
return null
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return defineComponent(() => {
|
|
13
|
+
return () => vnode
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const iconComp = computed(() => {
|
|
18
|
+
return vnodeToComponent(props.icon)
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
const badgeComp = computed(() => {
|
|
22
|
+
return vnodeToComponent(props.badge)
|
|
23
|
+
})
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<template>
|
|
27
|
+
<div :class="['tr-prompt', { disabled: props.disabled }]">
|
|
28
|
+
<div class="tr-prompt__icon">
|
|
29
|
+
<component :is="iconComp"></component>
|
|
30
|
+
</div>
|
|
31
|
+
<div class="tr-prompt__content">
|
|
32
|
+
<h6 class="tr-prompt__content-label">{{ props.label }}</h6>
|
|
33
|
+
<p v-if="props.description" class="tr-prompt__content-description">{{ props.description }}</p>
|
|
34
|
+
</div>
|
|
35
|
+
<div :class="['tr-prompt__badge', { label: typeof props.badge === 'string' }]">
|
|
36
|
+
<component :is="badgeComp"></component>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
</template>
|
|
40
|
+
|
|
41
|
+
<style lang="less" scoped>
|
|
42
|
+
.tr-prompt {
|
|
43
|
+
--tr-prompt-bg-color: white;
|
|
44
|
+
--tr-prompt-hover-color: rgba(0, 0, 0, 0.04);
|
|
45
|
+
--tr-prompt-active-color: rgba(0, 0, 0, 0.15);
|
|
46
|
+
--tr-prompt-disabled-color: rgba(0, 0, 0, 0.04);
|
|
47
|
+
--tr-prompt-box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
|
|
48
|
+
--tr-prompt-text: rgb(25, 25, 25);
|
|
49
|
+
--tr-prompt-text-muted: rgb(89, 89, 89);
|
|
50
|
+
|
|
51
|
+
flex: none;
|
|
52
|
+
display: flex;
|
|
53
|
+
gap: 12px;
|
|
54
|
+
border-radius: 16px;
|
|
55
|
+
box-shadow: var(--tr-prompt-box-shadow);
|
|
56
|
+
padding: 16px 24px;
|
|
57
|
+
position: relative;
|
|
58
|
+
cursor: pointer;
|
|
59
|
+
transition: background 0.3s;
|
|
60
|
+
background-color: var(--tr-prompt-bg-color);
|
|
61
|
+
|
|
62
|
+
&:hover {
|
|
63
|
+
background-color: var(--tr-prompt-hover-color);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&.disabled {
|
|
67
|
+
cursor: default;
|
|
68
|
+
pointer-events: none;
|
|
69
|
+
background-color: var(--tr-prompt-disabled-color);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
&:active {
|
|
73
|
+
background-color: var(--tr-prompt-active-color);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.tr-prompt__content {
|
|
78
|
+
display: flex;
|
|
79
|
+
flex-direction: column;
|
|
80
|
+
gap: 4px;
|
|
81
|
+
align-items: start;
|
|
82
|
+
|
|
83
|
+
font-size: 14px;
|
|
84
|
+
line-height: 24px;
|
|
85
|
+
color: var(--tr-prompt-text);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.tr-prompt__content-label {
|
|
89
|
+
margin: 0;
|
|
90
|
+
padding: 0;
|
|
91
|
+
font-weight: 500;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.tr-prompt__content-description {
|
|
95
|
+
margin: 0;
|
|
96
|
+
padding: 0;
|
|
97
|
+
color: var(--tr-prompt-text-muted);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.tr-prompt__badge {
|
|
101
|
+
position: absolute;
|
|
102
|
+
top: 0;
|
|
103
|
+
right: 0;
|
|
104
|
+
padding: 0 12px;
|
|
105
|
+
border-top-right-radius: 16px;
|
|
106
|
+
border-bottom-left-radius: 16px;
|
|
107
|
+
background-color: rgb(255, 234, 232);
|
|
108
|
+
|
|
109
|
+
&.label {
|
|
110
|
+
color: rgb(242, 48, 48);
|
|
111
|
+
font-size: 14px;
|
|
112
|
+
line-height: 22px;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
</style>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { toRaw } from 'vue'
|
|
3
|
+
import { PromptProps, PromptsEvents, PromptsProps, PromptsSlots } from './index.type'
|
|
4
|
+
import Prompt from './prompt.vue'
|
|
5
|
+
|
|
6
|
+
const props = defineProps<PromptsProps>()
|
|
7
|
+
|
|
8
|
+
const emit = defineEmits<PromptsEvents>()
|
|
9
|
+
|
|
10
|
+
defineSlots<PromptsSlots>()
|
|
11
|
+
|
|
12
|
+
const handleClick = (ev: MouseEvent, item: PromptProps) => {
|
|
13
|
+
emit('item-click', ev, toRaw(item))
|
|
14
|
+
}
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<template>
|
|
18
|
+
<div class="tr-prompts">
|
|
19
|
+
<div :class="['tr-prompts__list-container', { wrap: props.wrap, vertical: props.vertical }]">
|
|
20
|
+
<Prompt
|
|
21
|
+
v-for="(item, index) in props.items"
|
|
22
|
+
:key="item.id || index"
|
|
23
|
+
v-bind="item"
|
|
24
|
+
:style="props.itemStyle"
|
|
25
|
+
:class="props.itemClass"
|
|
26
|
+
@click="handleClick($event, item)"
|
|
27
|
+
></Prompt>
|
|
28
|
+
</div>
|
|
29
|
+
<slot name="footer"></slot>
|
|
30
|
+
</div>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
<style lang="less" scoped>
|
|
34
|
+
.tr-prompts {
|
|
35
|
+
.tr-prompts__list-container {
|
|
36
|
+
display: flex;
|
|
37
|
+
gap: 16px;
|
|
38
|
+
overflow-x: auto;
|
|
39
|
+
|
|
40
|
+
&.wrap {
|
|
41
|
+
flex-wrap: wrap;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&.vertical {
|
|
45
|
+
flex-direction: column;
|
|
46
|
+
align-items: flex-start;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
</style>
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref, watch, onMounted, onBeforeUnmount, nextTick, PropType } from 'vue'
|
|
3
|
+
import type { Question } from '../index.type'
|
|
4
|
+
import { IconEdit } from '@opentiny/tiny-robot-svgs'
|
|
5
|
+
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
questions: {
|
|
8
|
+
type: Array as PropType<Question[]>,
|
|
9
|
+
required: true,
|
|
10
|
+
},
|
|
11
|
+
isExpanded: {
|
|
12
|
+
type: Boolean,
|
|
13
|
+
default: false,
|
|
14
|
+
},
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const emit = defineEmits(['question-click', 'show-expand-button'])
|
|
18
|
+
|
|
19
|
+
const commonQuestionsRef = ref<HTMLElement | null>(null)
|
|
20
|
+
const showExpandButton = ref(false)
|
|
21
|
+
const isExpandedRef = ref(false)
|
|
22
|
+
const visibleQuestions = ref<Question[]>([])
|
|
23
|
+
const hiddenQuestions = ref<Question[]>([])
|
|
24
|
+
|
|
25
|
+
watch(
|
|
26
|
+
() => props.isExpanded,
|
|
27
|
+
(val) => {
|
|
28
|
+
isExpandedRef.value = val
|
|
29
|
+
},
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
// 检查是否需要显示展开/收起按钮并计算能够容纳的最大胶囊数
|
|
33
|
+
const checkOverflow = async () => {
|
|
34
|
+
await nextTick()
|
|
35
|
+
if (commonQuestionsRef.value) {
|
|
36
|
+
const container = commonQuestionsRef.value
|
|
37
|
+
const containerWidth = container.clientWidth
|
|
38
|
+
|
|
39
|
+
// 重置胶囊分组
|
|
40
|
+
visibleQuestions.value = []
|
|
41
|
+
hiddenQuestions.value = []
|
|
42
|
+
|
|
43
|
+
if (props.questions.length === 0) {
|
|
44
|
+
showExpandButton.value = false
|
|
45
|
+
return
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// 计算一行可以容纳多少个胶囊
|
|
49
|
+
let accumulatedWidth = 0
|
|
50
|
+
const margin = 8 // 胶囊之间的间距
|
|
51
|
+
|
|
52
|
+
// 克隆一个胶囊元素来测量其基本尺寸
|
|
53
|
+
const tempItem = document.createElement('div')
|
|
54
|
+
tempItem.className = 'tr-common-questions_item'
|
|
55
|
+
tempItem.style.visibility = 'hidden'
|
|
56
|
+
tempItem.style.position = 'absolute'
|
|
57
|
+
container.appendChild(tempItem)
|
|
58
|
+
|
|
59
|
+
// 计算每个胶囊的宽度并确定一行能容纳多少个
|
|
60
|
+
for (let i = 0; i < props.questions.length; i++) {
|
|
61
|
+
const question = props.questions[i]
|
|
62
|
+
|
|
63
|
+
// 设置临时元素内容来测量其宽度
|
|
64
|
+
tempItem.textContent = question.text
|
|
65
|
+
const itemWidth = tempItem.offsetWidth + margin
|
|
66
|
+
|
|
67
|
+
// 检查是否还能容纳下一个胶囊
|
|
68
|
+
if (accumulatedWidth + itemWidth <= containerWidth) {
|
|
69
|
+
accumulatedWidth += itemWidth
|
|
70
|
+
visibleQuestions.value.push(question)
|
|
71
|
+
} else {
|
|
72
|
+
hiddenQuestions.value.push(question)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// 移除临时元素
|
|
77
|
+
container.removeChild(tempItem)
|
|
78
|
+
|
|
79
|
+
// 如果有隐藏的胶囊,显示展开按钮
|
|
80
|
+
showExpandButton.value = hiddenQuestions.value.length > 0
|
|
81
|
+
// 初始状态设为未展开
|
|
82
|
+
isExpandedRef.value = false
|
|
83
|
+
|
|
84
|
+
emit('show-expand-button', showExpandButton.value)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// 处理问题点击
|
|
89
|
+
const handleQuestionClick = (question: Question) => {
|
|
90
|
+
emit('question-click', question)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// 监听 props 变化
|
|
94
|
+
watch(
|
|
95
|
+
() => props.questions,
|
|
96
|
+
() => {
|
|
97
|
+
// 当问题列表变化时重新计算
|
|
98
|
+
checkOverflow()
|
|
99
|
+
},
|
|
100
|
+
{ deep: true },
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
// 处理窗口大小变化
|
|
104
|
+
const handleResize = () => {
|
|
105
|
+
checkOverflow()
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// 组件挂载时添加窗口大小变化监听
|
|
109
|
+
onMounted(() => {
|
|
110
|
+
checkOverflow()
|
|
111
|
+
window.addEventListener('resize', handleResize)
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
// 组件卸载时移除监听器
|
|
115
|
+
onBeforeUnmount(() => {
|
|
116
|
+
window.removeEventListener('resize', handleResize)
|
|
117
|
+
})
|
|
118
|
+
</script>
|
|
119
|
+
|
|
120
|
+
<template>
|
|
121
|
+
<div class="tr-common-questions" ref="commonQuestionsRef" :class="{ expanded: isExpandedRef }">
|
|
122
|
+
<!-- 渲染可见的胶囊 -->
|
|
123
|
+
<div
|
|
124
|
+
v-for="(question, index) in visibleQuestions"
|
|
125
|
+
:key="`visible-${question.id}-${index}`"
|
|
126
|
+
class="tr-common-questions_item"
|
|
127
|
+
@click="handleQuestionClick(question)"
|
|
128
|
+
>
|
|
129
|
+
<div style="display: flex; align-items: center"><IconEdit /></div>
|
|
130
|
+
{{ question.text }}
|
|
131
|
+
</div>
|
|
132
|
+
|
|
133
|
+
<!-- 渲染被隐藏的胶囊(展开时显示) -->
|
|
134
|
+
<div v-if="isExpandedRef">
|
|
135
|
+
<div
|
|
136
|
+
v-for="(question, index) in hiddenQuestions"
|
|
137
|
+
:key="`hidden-${question.id}-${index}`"
|
|
138
|
+
class="tr-common-questions_item"
|
|
139
|
+
@click="handleQuestionClick(question)"
|
|
140
|
+
>
|
|
141
|
+
<IconEdit />
|
|
142
|
+
{{ question.text }}
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
</template>
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref, defineProps, defineEmits, watch, PropType, computed } from 'vue'
|
|
3
|
+
import { IconClose } from '@opentiny/vue-icon'
|
|
4
|
+
import { TinyButton } from '@opentiny/vue'
|
|
5
|
+
import type { Category, Question } from '../index.type'
|
|
6
|
+
|
|
7
|
+
import { IconHotQuestion, IconTypeAll } from '@opentiny/tiny-robot-svgs'
|
|
8
|
+
|
|
9
|
+
const TinyIconClose = IconClose()
|
|
10
|
+
|
|
11
|
+
const props = defineProps({
|
|
12
|
+
visible: {
|
|
13
|
+
type: Boolean,
|
|
14
|
+
default: false,
|
|
15
|
+
},
|
|
16
|
+
categories: {
|
|
17
|
+
type: Array as PropType<Category[]>,
|
|
18
|
+
default: () => [],
|
|
19
|
+
},
|
|
20
|
+
modalWidth: {
|
|
21
|
+
type: String,
|
|
22
|
+
default: '640px',
|
|
23
|
+
},
|
|
24
|
+
loading: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: false,
|
|
27
|
+
},
|
|
28
|
+
closeOnClickOutside: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
default: true,
|
|
31
|
+
},
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const emit = defineEmits(['update:visible', 'close', 'select-category', 'question-click'])
|
|
35
|
+
|
|
36
|
+
// 当前激活的分类
|
|
37
|
+
const activeCategory = ref<string>('')
|
|
38
|
+
|
|
39
|
+
// 计算当前激活分类的问题列表
|
|
40
|
+
const activeQuestions = computed(() => {
|
|
41
|
+
if (!activeCategory.value && props.categories.length > 0) {
|
|
42
|
+
return props.categories[0].questions || []
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const category = props.categories.find((cat) => cat.id === activeCategory.value)
|
|
46
|
+
return category ? category.questions : []
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
// 初始化激活的分类
|
|
50
|
+
watch(
|
|
51
|
+
() => props.categories,
|
|
52
|
+
(categories) => {
|
|
53
|
+
if (categories.length > 0 && !activeCategory.value) {
|
|
54
|
+
activeCategory.value = categories[0].id
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
{ immediate: true },
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
// 关闭弹窗
|
|
61
|
+
const closeModal = () => {
|
|
62
|
+
emit('update:visible', false)
|
|
63
|
+
emit('close')
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// 处理分类选择
|
|
67
|
+
const handleCategorySelect = (categoryId: string) => {
|
|
68
|
+
activeCategory.value = categoryId
|
|
69
|
+
emit(
|
|
70
|
+
'select-category',
|
|
71
|
+
props.categories.find((cat) => cat.id === categoryId),
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// 处理问题点击
|
|
76
|
+
const handleQuestionClick = (question: Question) => {
|
|
77
|
+
emit('question-click', question)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// 处理点击外部关闭
|
|
81
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
82
|
+
if (props.closeOnClickOutside && !event.composedPath().includes(modalRef.value!)) {
|
|
83
|
+
closeModal()
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const modalRef = ref<HTMLElement | null>(null)
|
|
88
|
+
</script>
|
|
89
|
+
|
|
90
|
+
<template>
|
|
91
|
+
<div v-if="visible" class="tr-question-modal-backdrop" @mousedown="handleClickOutside">
|
|
92
|
+
<div ref="modalRef" class="tr-question-panel" :style="{ width: modalWidth }" @mousedown.stop>
|
|
93
|
+
<div class="tr-question-header">
|
|
94
|
+
<div style="display: flex; align-items: center; gap: 12px">
|
|
95
|
+
<div><IconHotQuestion /></div>
|
|
96
|
+
<div class="tr-question-header-title">热门问题</div>
|
|
97
|
+
</div>
|
|
98
|
+
<span class="tr-question-close-btn" @click="closeModal">
|
|
99
|
+
<TinyButton :icon="TinyIconClose" type="text" />
|
|
100
|
+
</span>
|
|
101
|
+
</div>
|
|
102
|
+
|
|
103
|
+
<div v-if="categories.length > 0" class="tr-question-categories">
|
|
104
|
+
<div
|
|
105
|
+
v-for="category in categories"
|
|
106
|
+
:key="category.id"
|
|
107
|
+
class="tr-question-categories-item"
|
|
108
|
+
:class="{ active: activeCategory === category.id }"
|
|
109
|
+
@click="handleCategorySelect(category.id)"
|
|
110
|
+
>
|
|
111
|
+
<slot name="category-label" :category="category">
|
|
112
|
+
<div class="category-icon">
|
|
113
|
+
<IconTypeAll />
|
|
114
|
+
</div>
|
|
115
|
+
<span>{{ category.label }}</span>
|
|
116
|
+
</slot>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
|
|
120
|
+
<div class="tr-question-content">
|
|
121
|
+
<div v-if="loading" class="tr-question-loading">
|
|
122
|
+
<slot name="loading-indicator">
|
|
123
|
+
<div class="tr-question-loading-spinner"></div>
|
|
124
|
+
</slot>
|
|
125
|
+
</div>
|
|
126
|
+
|
|
127
|
+
<ul v-else-if="activeQuestions.length > 0">
|
|
128
|
+
<li
|
|
129
|
+
v-for="(question, index) in activeQuestions"
|
|
130
|
+
:key="question.id"
|
|
131
|
+
class="tr-question-list-item"
|
|
132
|
+
@click="handleQuestionClick(question)"
|
|
133
|
+
>
|
|
134
|
+
<slot name="question-item" :question="question" :index="index">
|
|
135
|
+
<span>{{ index + 1 }}.</span> {{ question.text }}
|
|
136
|
+
</slot>
|
|
137
|
+
</li>
|
|
138
|
+
</ul>
|
|
139
|
+
|
|
140
|
+
<div v-else class="tr-question-empty">
|
|
141
|
+
<slot name="empty-state">
|
|
142
|
+
<p>暂无相关问题</p>
|
|
143
|
+
</slot>
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
</div>
|
|
147
|
+
</div>
|
|
148
|
+
</template>
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { ref, computed, Ref, watch } from 'vue'
|
|
2
|
+
import type { Category, ThemeType } from '../index.type'
|
|
3
|
+
|
|
4
|
+
export function useQuestions(categories: Ref<Category[]> = ref([])) {
|
|
5
|
+
// 当前激活的分类ID
|
|
6
|
+
const activeCategory = ref<string>('')
|
|
7
|
+
|
|
8
|
+
// 是否展开悬浮面板
|
|
9
|
+
const isFloatingExpanded = ref(false)
|
|
10
|
+
|
|
11
|
+
// 弹窗是否可见
|
|
12
|
+
const modalVisible = ref(false)
|
|
13
|
+
|
|
14
|
+
// 当前主题
|
|
15
|
+
const currentTheme = ref<ThemeType>('light')
|
|
16
|
+
|
|
17
|
+
// 计算当前激活分类的问题列表
|
|
18
|
+
const activeQuestions = computed(() => {
|
|
19
|
+
if (!activeCategory.value && categories.value.length > 0) {
|
|
20
|
+
return categories.value[0].questions
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const category = categories.value.find((cat) => cat.id === activeCategory.value)
|
|
24
|
+
return category ? category.questions : []
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
// 设置激活的分类
|
|
28
|
+
const setActiveCategory = (categoryId: string) => {
|
|
29
|
+
activeCategory.value = categoryId
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// 打开弹窗
|
|
33
|
+
const openModal = () => {
|
|
34
|
+
modalVisible.value = true
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// 关闭弹窗
|
|
38
|
+
const closeModal = () => {
|
|
39
|
+
modalVisible.value = false
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// 切换悬浮面板展开状态
|
|
43
|
+
const toggleFloating = () => {
|
|
44
|
+
isFloatingExpanded.value = !isFloatingExpanded.value
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// 防止滚动穿透的函数
|
|
48
|
+
const toggleBodyScroll = (isOpen: boolean) => {
|
|
49
|
+
const body = document.body
|
|
50
|
+
|
|
51
|
+
if (isOpen) {
|
|
52
|
+
// 保存当前滚动位置
|
|
53
|
+
const scrollTop = window.scrollY || document.documentElement.scrollTop
|
|
54
|
+
body.style.position = 'fixed'
|
|
55
|
+
body.style.width = '100%'
|
|
56
|
+
body.style.top = `-${scrollTop}px`
|
|
57
|
+
body.style.overflowY = 'scroll' // 保持滚动条宽度,防止页面抖动
|
|
58
|
+
body.classList.add('tr-modal-open')
|
|
59
|
+
} else {
|
|
60
|
+
body.style.position = ''
|
|
61
|
+
body.style.width = ''
|
|
62
|
+
body.style.top = ''
|
|
63
|
+
body.style.overflowY = ''
|
|
64
|
+
body.classList.remove('tr-modal-open')
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// 监听弹窗变化应用滚动锁定
|
|
69
|
+
watch(modalVisible, (value) => {
|
|
70
|
+
toggleBodyScroll(value)
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
// 切换主题
|
|
74
|
+
const toggleTheme = () => {
|
|
75
|
+
currentTheme.value = currentTheme.value === 'light' ? 'dark' : 'light'
|
|
76
|
+
document.documentElement.setAttribute('data-theme', currentTheme.value)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// 设置主题
|
|
80
|
+
const setTheme = (theme: ThemeType) => {
|
|
81
|
+
currentTheme.value = theme
|
|
82
|
+
document.documentElement.setAttribute('data-theme', theme)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// 刷新数据(模拟异步操作)
|
|
86
|
+
const refreshData = async () => {
|
|
87
|
+
// 这里可以添加实际的数据刷新逻辑
|
|
88
|
+
return Promise.resolve()
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return {
|
|
92
|
+
activeCategory,
|
|
93
|
+
isFloatingExpanded,
|
|
94
|
+
modalVisible,
|
|
95
|
+
currentTheme,
|
|
96
|
+
activeQuestions,
|
|
97
|
+
setActiveCategory,
|
|
98
|
+
openModal,
|
|
99
|
+
closeModal,
|
|
100
|
+
toggleFloating,
|
|
101
|
+
toggleTheme,
|
|
102
|
+
setTheme,
|
|
103
|
+
refreshData,
|
|
104
|
+
toggleBodyScroll,
|
|
105
|
+
}
|
|
106
|
+
}
|