@opentiny/tiny-robot 0.2.0-alpha.0 → 0.2.0-alpha.2
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/action-group/ActionGroup.vue.d.ts +26 -0
- package/dist/action-group/ActionGroupItem.vue.d.ts +18 -0
- package/dist/action-group/index.d.ts +12 -0
- package/dist/action-group/index.type.d.ts +17 -0
- package/dist/bubble/index.d.ts +2 -2
- package/dist/bubble/index.type.d.ts +16 -18
- package/dist/feedback/components/SourceList.vue.d.ts +11 -0
- package/dist/feedback/components/index.d.ts +1 -0
- package/dist/feedback/index.d.ts +7 -0
- package/dist/feedback/index.type.d.ts +25 -0
- package/dist/feedback/index.vue.d.ts +13 -0
- package/dist/history/components/index.d.ts +2 -0
- package/dist/history/components/item-tag.vue.d.ts +5 -0
- package/dist/history/components/search-empty.vue.d.ts +7 -0
- package/dist/history/composables/index.d.ts +1 -0
- package/dist/history/composables/useEditItemTitle.d.ts +12 -0
- package/dist/history/index.d.ts +6 -0
- package/dist/history/index.type.d.ts +43 -0
- package/dist/history/index.vue.d.ts +2 -0
- package/dist/icon-button/index.d.ts +7 -0
- package/dist/icon-button/index.type.d.ts +6 -0
- package/dist/icon-button/index.vue.d.ts +6 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.js +57 -27
- package/dist/node_modules/.pnpm/@opentiny_utils@3.22.0/node_modules/@opentiny/utils/dist/index.es.js +1335 -884
- package/dist/node_modules/.pnpm/@opentiny_vue-common@3.22.0/node_modules/@opentiny/vue-common/lib/index.js +660 -144
- package/dist/node_modules/.pnpm/@opentiny_vue-hooks@3.22.0/node_modules/@opentiny/vue-hooks/dist/src/vue-popper.js +85 -0
- package/dist/node_modules/.pnpm/@opentiny_vue-locale@3.22.0/node_modules/@opentiny/vue-locale/lib/index.js +1783 -0
- package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.22.0/node_modules/@opentiny/vue-renderless/tooltip/index.js +77 -0
- package/dist/node_modules/.pnpm/@opentiny_vue-renderless@3.22.0/node_modules/@opentiny/vue-renderless/tooltip/vue.js +90 -0
- package/dist/node_modules/.pnpm/@opentiny_vue-tooltip@3.22.0/node_modules/@opentiny/vue-tooltip/lib/index.js +176 -0
- package/dist/node_modules/.pnpm/@opentiny_vue-tooltip@3.22.0/node_modules/@opentiny/vue-tooltip/lib/pc.js +248 -0
- package/dist/node_modules/.pnpm/@vueuse_core@13.1.0_vue@3.5.13/node_modules/@vueuse/core/index.js +310 -0
- package/dist/node_modules/.pnpm/@vueuse_shared@13.1.0_vue@3.5.13/node_modules/@vueuse/shared/index.js +110 -0
- package/dist/packages/components/src/action-group/ActionGroup.vue.js +7 -0
- package/dist/packages/components/src/action-group/ActionGroup.vue2.js +121 -0
- package/dist/packages/components/src/action-group/ActionGroupItem.vue.js +14 -0
- package/dist/packages/components/src/action-group/ActionGroupItem.vue2.js +4 -0
- package/dist/packages/components/src/action-group/index.js +17 -0
- package/dist/packages/components/src/bubble/Bubble.vue.js +7 -0
- package/dist/packages/components/src/bubble/Bubble.vue2.js +76 -0
- package/dist/packages/components/src/bubble/BubbleList.vue.js +7 -0
- package/dist/packages/components/src/bubble/BubbleList.vue2.js +50 -0
- package/dist/packages/components/src/bubble/index.js +2 -2
- package/dist/packages/components/src/container/index.vue.js +2 -2
- package/dist/packages/components/src/container/index.vue2.js +36 -36
- package/dist/packages/components/src/feedback/components/SourceList.vue.js +7 -0
- package/dist/packages/components/src/feedback/components/SourceList.vue2.js +52 -0
- package/dist/packages/components/src/feedback/index.js +9 -0
- package/dist/packages/components/src/feedback/index.vue.js +7 -0
- package/dist/packages/components/src/feedback/index.vue2.js +143 -0
- package/dist/packages/components/src/history/components/item-tag.vue.js +7 -0
- package/dist/packages/components/src/history/components/item-tag.vue2.js +21 -0
- package/dist/packages/components/src/history/components/search-empty.vue.js +7 -0
- package/dist/packages/components/src/history/components/search-empty.vue2.js +20 -0
- package/dist/packages/components/src/history/composables/useEditItemTitle.js +43 -0
- package/dist/packages/components/src/history/index.js +11 -0
- package/dist/packages/components/src/history/index.vue.js +7 -0
- package/dist/packages/components/src/history/index.vue2.js +130 -0
- package/dist/packages/components/src/icon-button/index.js +9 -0
- package/dist/packages/components/src/icon-button/index.vue.js +7 -0
- package/dist/packages/components/src/icon-button/index.vue2.js +22 -0
- package/dist/packages/components/src/prompts/prompt.vue.js +2 -2
- package/dist/packages/components/src/prompts/prompt.vue2.js +17 -15
- package/dist/packages/components/src/question/components/HotQuestions.vue.js +23 -23
- package/dist/packages/components/src/question/index.vue.js +18 -18
- package/dist/packages/components/src/sender/components/TemplateEditor.vue.js +7 -0
- package/dist/packages/components/src/sender/components/TemplateEditor.vue2.js +175 -0
- package/dist/packages/components/src/sender/index.vue.js +149 -128
- package/dist/packages/components/src/suggestion/components/CategoryNav.vue.js +38 -0
- package/dist/packages/components/src/suggestion/components/CategoryNav.vue2.js +4 -0
- package/dist/packages/components/src/suggestion/components/SuggestionCapsule.vue.js +107 -0
- package/dist/packages/components/src/suggestion/components/SuggestionCapsule.vue2.js +4 -0
- package/dist/packages/components/src/suggestion/components/SuggestionPanel.vue.js +123 -0
- package/dist/packages/components/src/suggestion/components/SuggestionPanel.vue2.js +4 -0
- package/dist/packages/components/src/suggestion/composables/useKeyboardNavigation.js +45 -0
- package/dist/packages/components/src/suggestion/composables/useTriggerDetection.js +17 -0
- package/dist/packages/components/src/suggestion/index.js +9 -0
- package/dist/packages/components/src/suggestion/index.vue.js +179 -0
- package/dist/packages/components/src/suggestion/index.vue2.js +4 -0
- package/dist/packages/components/src/suggestion/utils/dom.js +18 -0
- package/dist/packages/svgs/dist/tiny-robot-svgs.js +306 -90
- package/dist/question/components/HotQuestions.vue.d.ts +2 -2
- package/dist/sender/components/TemplateEditor.vue.d.ts +18 -0
- package/dist/sender/index.type.d.ts +47 -0
- package/dist/sender/index.vue.d.ts +70 -5
- package/dist/style.css +1 -1
- package/dist/suggestion/components/CategoryNav.vue.d.ts +45 -0
- package/dist/suggestion/components/SuggestionCapsule.vue.d.ts +32 -0
- package/dist/suggestion/components/SuggestionPanel.vue.d.ts +84 -0
- package/dist/suggestion/composables/useKeyboardNavigation.d.ts +18 -0
- package/dist/suggestion/composables/useSuggestionFilter.d.ts +10 -0
- package/dist/suggestion/composables/useTriggerDetection.d.ts +11 -0
- package/dist/suggestion/index.d.ts +7 -0
- package/dist/suggestion/index.type.d.ts +94 -0
- package/dist/suggestion/index.vue.d.ts +343 -0
- package/dist/suggestion/utils/dom.d.ts +20 -0
- package/package.json +4 -3
- package/src/action-group/ActionGroup.vue +247 -0
- package/src/action-group/ActionGroupItem.vue +9 -0
- package/src/action-group/index.ts +25 -0
- package/src/action-group/index.type.ts +21 -0
- package/src/bubble/Bubble.vue +153 -0
- package/src/bubble/BubbleList.vue +55 -0
- package/src/bubble/index.ts +2 -2
- package/src/bubble/index.type.ts +7 -21
- package/src/container/index.vue +10 -36
- package/src/feedback/components/SourceList.vue +112 -0
- package/src/feedback/components/index.ts +1 -0
- package/src/feedback/index.ts +12 -0
- package/src/feedback/index.type.ts +27 -0
- package/src/feedback/index.vue +166 -0
- package/src/history/components/index.ts +2 -0
- package/src/history/components/item-tag.vue +49 -0
- package/src/history/components/search-empty.vue +38 -0
- package/src/history/composables/index.ts +1 -0
- package/src/history/composables/useEditItemTitle.ts +75 -0
- package/src/history/index.ts +12 -0
- package/src/history/index.type.ts +50 -0
- package/src/history/index.vue +292 -0
- package/src/icon-button/index.ts +12 -0
- package/src/icon-button/index.type.ts +7 -0
- package/src/icon-button/index.vue +58 -0
- package/src/index.ts +33 -1
- package/src/prompts/prompt.vue +7 -21
- package/src/question/components/HotQuestions.vue +1 -1
- package/src/question/index.less +9 -10
- package/src/sender/components/TemplateEditor.vue +465 -0
- package/src/sender/index.less +17 -7
- package/src/sender/index.type.ts +51 -0
- package/src/sender/index.vue +56 -8
- package/src/sender/vars.less +3 -3
- package/src/suggestion/components/CategoryNav.vue +38 -0
- package/src/suggestion/components/SuggestionCapsule.vue +183 -0
- package/src/suggestion/components/SuggestionPanel.vue +147 -0
- package/src/suggestion/composables/useKeyboardNavigation.ts +101 -0
- package/src/suggestion/composables/useSuggestionFilter.ts +34 -0
- package/src/suggestion/composables/useTriggerDetection.ts +46 -0
- package/src/suggestion/index.less +497 -0
- package/src/suggestion/index.ts +12 -0
- package/src/suggestion/index.type.ts +101 -0
- package/src/suggestion/index.vue +338 -0
- package/src/suggestion/utils/dom.ts +66 -0
- package/src/suggestion/vars.less +141 -0
- package/dist/bubble/components/actions/copy.vue.d.ts +0 -10
- package/dist/bubble/components/actions/index.d.ts +0 -2
- package/dist/bubble/components/actions/refresh.vue.d.ts +0 -2
- package/dist/bubble/useScroll.d.ts +0 -4
- package/dist/packages/components/src/bubble/bubble-list.vue.js +0 -7
- package/dist/packages/components/src/bubble/bubble-list.vue2.js +0 -37
- package/dist/packages/components/src/bubble/bubble.vue.js +0 -7
- package/dist/packages/components/src/bubble/bubble.vue2.js +0 -118
- package/dist/packages/components/src/bubble/components/actions/copy.vue.js +0 -7
- package/dist/packages/components/src/bubble/components/actions/copy.vue2.js +0 -35
- package/dist/packages/components/src/bubble/components/actions/refresh.vue.js +0 -7
- package/dist/packages/components/src/bubble/components/actions/refresh.vue2.js +0 -16
- package/dist/packages/components/src/bubble/useScroll.js +0 -13
- package/src/bubble/bubble-list.vue +0 -42
- package/src/bubble/bubble.vue +0 -247
- package/src/bubble/components/actions/copy.vue +0 -54
- package/src/bubble/components/actions/index.ts +0 -2
- package/src/bubble/components/actions/refresh.vue +0 -31
- package/src/bubble/useScroll.ts +0 -14
- /package/dist/bubble/{bubble-list.vue.d.ts → BubbleList.vue.d.ts} +0 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { IconArrowUp } from '@opentiny/tiny-robot-svgs'
|
|
3
|
+
import { computed, nextTick, onMounted, ref, watch } from 'vue'
|
|
4
|
+
|
|
5
|
+
const props = withDefaults(
|
|
6
|
+
defineProps<{
|
|
7
|
+
sources: { label: string; link: string }[]
|
|
8
|
+
linesLimit?: number
|
|
9
|
+
}>(),
|
|
10
|
+
{
|
|
11
|
+
linesLimit: Number.MAX_SAFE_INTEGER,
|
|
12
|
+
},
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
const showAll = ref(false)
|
|
16
|
+
const pillRefs = ref<(HTMLElement | null)[]>([])
|
|
17
|
+
const morePillIndex = ref<number | null>(null)
|
|
18
|
+
|
|
19
|
+
const updateMoreIndex = () => {
|
|
20
|
+
nextTick(() => {
|
|
21
|
+
const tops = pillRefs.value.map((el) => el?.offsetTop || 0)
|
|
22
|
+
const uniqueTops = Array.from(new Set(tops))
|
|
23
|
+
|
|
24
|
+
if (uniqueTops.length > props.linesLimit) {
|
|
25
|
+
// 超过 linesLimit 行,找到第 linesLimit 行最后一个的index
|
|
26
|
+
const lastLineTop = uniqueTops[props.linesLimit - 1]
|
|
27
|
+
const lastIndex = tops.lastIndexOf(lastLineTop)
|
|
28
|
+
morePillIndex.value = lastIndex
|
|
29
|
+
} else {
|
|
30
|
+
morePillIndex.value = null
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const leftPillCount = computed(() => {
|
|
36
|
+
return props.sources.length - (morePillIndex.value || 0)
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
onMounted(updateMoreIndex)
|
|
40
|
+
|
|
41
|
+
watch(() => props.sources, updateMoreIndex)
|
|
42
|
+
|
|
43
|
+
const setPillRef = (el: HTMLElement | null, idx: number) => {
|
|
44
|
+
if (el) {
|
|
45
|
+
pillRefs.value[idx] = el
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<template>
|
|
51
|
+
<div class="tr-feedback__source-list">
|
|
52
|
+
<template v-for="(source, index) in props.sources" :key="index">
|
|
53
|
+
<a
|
|
54
|
+
v-if="!morePillIndex || showAll || index < morePillIndex"
|
|
55
|
+
class="pill"
|
|
56
|
+
:href="source.link"
|
|
57
|
+
target="_blank"
|
|
58
|
+
:ref="(el) => setPillRef(el as HTMLElement, index)"
|
|
59
|
+
>
|
|
60
|
+
{{ source.label }}
|
|
61
|
+
</a>
|
|
62
|
+
<span v-if="morePillIndex && !showAll && index === morePillIndex" class="pill" @click="showAll = true">
|
|
63
|
+
{{ leftPillCount }}+
|
|
64
|
+
</span>
|
|
65
|
+
</template>
|
|
66
|
+
<span v-if="showAll" class="pill collapse-pill" @click="showAll = false">
|
|
67
|
+
<IconArrowUp />
|
|
68
|
+
</span>
|
|
69
|
+
</div>
|
|
70
|
+
</template>
|
|
71
|
+
|
|
72
|
+
<style lang="less" scoped>
|
|
73
|
+
.tr-feedback__source-list {
|
|
74
|
+
display: flex;
|
|
75
|
+
flex-wrap: wrap;
|
|
76
|
+
gap: 8px;
|
|
77
|
+
|
|
78
|
+
.pill {
|
|
79
|
+
padding: 4px 12px;
|
|
80
|
+
font-size: 12px;
|
|
81
|
+
line-height: 20px;
|
|
82
|
+
border-radius: 999px;
|
|
83
|
+
border: none;
|
|
84
|
+
background-color: rgba(20, 118, 255, 0.06);
|
|
85
|
+
color: rgb(20, 118, 255);
|
|
86
|
+
cursor: pointer;
|
|
87
|
+
|
|
88
|
+
&:hover {
|
|
89
|
+
text-decoration: underline;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
&.collapse {
|
|
93
|
+
font-size: 16px;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.collapse-pill {
|
|
98
|
+
padding: 0;
|
|
99
|
+
font-size: 16px;
|
|
100
|
+
width: 28px;
|
|
101
|
+
height: 28px;
|
|
102
|
+
display: flex;
|
|
103
|
+
align-items: center;
|
|
104
|
+
justify-content: center;
|
|
105
|
+
transition: background-color 0.3s ease;
|
|
106
|
+
|
|
107
|
+
&:hover {
|
|
108
|
+
background-color: rgba(20, 118, 255, 0.12);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as SourceList } from './SourceList.vue'
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { App } from 'vue'
|
|
2
|
+
import Feedback from './index.vue'
|
|
3
|
+
|
|
4
|
+
Feedback.name = 'TrFeedback'
|
|
5
|
+
|
|
6
|
+
const install = function <T>(app: App<T>) {
|
|
7
|
+
app.component(Feedback.name!, Feedback)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
Feedback.install = install
|
|
11
|
+
|
|
12
|
+
export default Feedback as typeof Feedback & { install: typeof install }
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Component, VNode } from 'vue'
|
|
2
|
+
|
|
3
|
+
export interface FeedbackProps {
|
|
4
|
+
operations?: {
|
|
5
|
+
name: string
|
|
6
|
+
label: string
|
|
7
|
+
onClick?: () => void
|
|
8
|
+
}[]
|
|
9
|
+
operationsLimit?: number
|
|
10
|
+
actions?: {
|
|
11
|
+
name: string
|
|
12
|
+
label: string
|
|
13
|
+
icon?: 'copy' | 'refresh' | 'like' | 'dislike' | VNode | Component
|
|
14
|
+
onClick?: () => void
|
|
15
|
+
}[]
|
|
16
|
+
actionsLimit?: number
|
|
17
|
+
sources?: {
|
|
18
|
+
label: string
|
|
19
|
+
link: string
|
|
20
|
+
}[]
|
|
21
|
+
sourcesLinesLimit?: number
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface FeedbackEvents {
|
|
25
|
+
(e: 'operation', name: string): void
|
|
26
|
+
(e: 'action', name: string): void
|
|
27
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { IconArrowDown, IconArrowUp, IconCopy, IconDislike, IconLike, IconRefresh } from '@opentiny/tiny-robot-svgs'
|
|
3
|
+
import TinyButton from '@opentiny/vue-button'
|
|
4
|
+
import { ref } from 'vue'
|
|
5
|
+
import ActionGroup, { ActionGroupItem } from '../action-group'
|
|
6
|
+
import IconButton from '../icon-button'
|
|
7
|
+
import { SourceList } from './components'
|
|
8
|
+
import type { FeedbackEvents, FeedbackProps } from './index.type'
|
|
9
|
+
|
|
10
|
+
const props = withDefaults(defineProps<FeedbackProps>(), {
|
|
11
|
+
operationsLimit: Number.MAX_SAFE_INTEGER,
|
|
12
|
+
actionsLimit: Number.MAX_SAFE_INTEGER,
|
|
13
|
+
sourcesLinesLimit: Number.MAX_SAFE_INTEGER,
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
const iconMap = {
|
|
17
|
+
copy: IconCopy,
|
|
18
|
+
refresh: IconRefresh,
|
|
19
|
+
like: IconLike,
|
|
20
|
+
dislike: IconDislike,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const emit = defineEmits<FeedbackEvents>()
|
|
24
|
+
|
|
25
|
+
const handleOperation = (name: string) => {
|
|
26
|
+
props.operations?.find((operation) => operation.name === name)?.onClick?.()
|
|
27
|
+
emit('operation', name)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const handleAction = (name: string) => {
|
|
31
|
+
props.actions?.find((action) => action.name === name)?.onClick?.()
|
|
32
|
+
emit('action', name)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const showSourceList = ref(false)
|
|
36
|
+
|
|
37
|
+
const handleSourceList = () => {
|
|
38
|
+
showSourceList.value = !showSourceList.value
|
|
39
|
+
}
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<template>
|
|
43
|
+
<div class="tr-feedback">
|
|
44
|
+
<div class="tr-feedback__operations">
|
|
45
|
+
<div class="tr-feedback__operations-left">
|
|
46
|
+
<action-group
|
|
47
|
+
v-if="props.operations?.length"
|
|
48
|
+
:max-num="props.operationsLimit"
|
|
49
|
+
:drop-down-show-label-only="true"
|
|
50
|
+
@item-click="handleOperation"
|
|
51
|
+
class="tr-feedback__operations-left-action-group"
|
|
52
|
+
>
|
|
53
|
+
<action-group-item
|
|
54
|
+
v-for="operation in props.operations"
|
|
55
|
+
:key="operation.name"
|
|
56
|
+
:name="operation.name"
|
|
57
|
+
:label="operation.label"
|
|
58
|
+
>
|
|
59
|
+
<tiny-button round :reset-time="0" size="mini">
|
|
60
|
+
{{ operation.label }}
|
|
61
|
+
</tiny-button>
|
|
62
|
+
</action-group-item>
|
|
63
|
+
<template #moreBtn>
|
|
64
|
+
<tiny-button round size="mini" :reset-time="0" class="tr-feedback__operations-more-btn">
|
|
65
|
+
<span>更多</span>
|
|
66
|
+
<icon-arrow-down />
|
|
67
|
+
</tiny-button>
|
|
68
|
+
</template>
|
|
69
|
+
</action-group>
|
|
70
|
+
<div v-else-if="props.sources?.length">
|
|
71
|
+
<span class="tr-feedback__source" @click="handleSourceList">
|
|
72
|
+
<span>{{ props.sources?.length }}条来源</span>
|
|
73
|
+
<component :is="showSourceList ? IconArrowUp : IconArrowDown" />
|
|
74
|
+
</span>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
<div class="tr-feedback__operations-right">
|
|
78
|
+
<action-group :max-num="props.actionsLimit" :show-tooltip="true" @item-click="handleAction">
|
|
79
|
+
<action-group-item
|
|
80
|
+
v-for="action in props.actions"
|
|
81
|
+
:key="action.name"
|
|
82
|
+
:name="action.name"
|
|
83
|
+
:label="action.label"
|
|
84
|
+
>
|
|
85
|
+
<icon-button v-if="typeof action.icon === 'string'" :icon="iconMap[action.icon]"></icon-button>
|
|
86
|
+
<component v-else :is="action.icon"></component>
|
|
87
|
+
</action-group-item>
|
|
88
|
+
</action-group>
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
<div
|
|
92
|
+
v-if="(props.operations?.length && props.sources?.length) || (showSourceList && props.sources)"
|
|
93
|
+
class="tr-feedback__footer"
|
|
94
|
+
>
|
|
95
|
+
<div v-if="props.operations?.length && props.sources?.length">
|
|
96
|
+
<span class="tr-feedback__source" @click="handleSourceList">
|
|
97
|
+
<span>{{ props.sources?.length }}条来源</span>
|
|
98
|
+
<component :is="showSourceList ? IconArrowUp : IconArrowDown" />
|
|
99
|
+
</span>
|
|
100
|
+
</div>
|
|
101
|
+
<source-list
|
|
102
|
+
v-if="showSourceList && props.sources"
|
|
103
|
+
:sources="props.sources"
|
|
104
|
+
:lines-limit="props.sourcesLinesLimit"
|
|
105
|
+
/>
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
</template>
|
|
109
|
+
|
|
110
|
+
<style lang="less" scoped>
|
|
111
|
+
.tr-feedback {
|
|
112
|
+
.tr-feedback__operations {
|
|
113
|
+
display: flex;
|
|
114
|
+
justify-content: space-between;
|
|
115
|
+
align-items: center;
|
|
116
|
+
gap: 8px;
|
|
117
|
+
|
|
118
|
+
.tr-feedback__operations-left {
|
|
119
|
+
.tr-feedback__operations-left-action-group {
|
|
120
|
+
gap: 8px;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.tr-feedback__operations-more-btn {
|
|
124
|
+
display: inline-flex;
|
|
125
|
+
align-items: center;
|
|
126
|
+
gap: 4px;
|
|
127
|
+
|
|
128
|
+
svg {
|
|
129
|
+
font-size: 12px;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.tr-feedback__operations-right {
|
|
135
|
+
display: flex;
|
|
136
|
+
align-items: center;
|
|
137
|
+
gap: 4px;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
.tr-feedback__footer {
|
|
141
|
+
margin-top: 8px;
|
|
142
|
+
display: flex;
|
|
143
|
+
flex-direction: column;
|
|
144
|
+
gap: 8px;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.tr-feedback__source {
|
|
148
|
+
height: 24px;
|
|
149
|
+
display: inline-flex;
|
|
150
|
+
align-items: center;
|
|
151
|
+
font-size: 12px;
|
|
152
|
+
line-height: 20px;
|
|
153
|
+
color: rgb(128, 128, 128);
|
|
154
|
+
cursor: pointer;
|
|
155
|
+
gap: 2px;
|
|
156
|
+
|
|
157
|
+
&:hover {
|
|
158
|
+
text-decoration: underline;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
svg {
|
|
162
|
+
font-size: 16px;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
</style>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HistoryItemTagProps } from '../index.type'
|
|
3
|
+
|
|
4
|
+
const props = withDefaults(defineProps<HistoryItemTagProps>(), {
|
|
5
|
+
type: 'default',
|
|
6
|
+
})
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<template>
|
|
10
|
+
<div :class="['tr-history__item-tag', props.type]" :style="props.style">
|
|
11
|
+
<span>{{ props.text }}</span>
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<style lang="less" scoped>
|
|
16
|
+
.tr-history__item-tag {
|
|
17
|
+
padding: 0 4px;
|
|
18
|
+
font-size: 12px;
|
|
19
|
+
line-height: 18px;
|
|
20
|
+
border-radius: 2px;
|
|
21
|
+
|
|
22
|
+
&.default {
|
|
23
|
+
color: rgb(25, 25, 25);
|
|
24
|
+
background-color: rgb(245, 245, 245);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&.success {
|
|
28
|
+
// TODO 成功
|
|
29
|
+
color: rgb(25, 25, 25);
|
|
30
|
+
background-color: rgb(245, 245, 245);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&.warning {
|
|
34
|
+
// TODO 警告
|
|
35
|
+
color: rgb(25, 25, 25);
|
|
36
|
+
background-color: rgb(245, 245, 245);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&.error {
|
|
40
|
+
color: rgb(242, 48, 48);
|
|
41
|
+
background-color: rgb(252, 227, 224);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&.info {
|
|
45
|
+
color: rgb(20, 118, 255);
|
|
46
|
+
background-color: rgb(222, 236, 255);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
</style>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="tr-history__empty">
|
|
3
|
+
<span class="tr-history__empty-icon">
|
|
4
|
+
<IconEmptySearch />
|
|
5
|
+
</span>
|
|
6
|
+
<span class="tr-history__empty-text">{{ props.text }}</span>
|
|
7
|
+
</div>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script setup lang="ts">
|
|
11
|
+
import { IconEmptySearch } from '@opentiny/tiny-robot-svgs'
|
|
12
|
+
|
|
13
|
+
const props = withDefaults(defineProps<{ text: string }>(), {
|
|
14
|
+
text: '暂无内容',
|
|
15
|
+
})
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<style lang="less" scoped>
|
|
19
|
+
.tr-history__empty {
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-direction: column;
|
|
22
|
+
align-items: center;
|
|
23
|
+
justify-content: center;
|
|
24
|
+
gap: 12px;
|
|
25
|
+
padding: 84px;
|
|
26
|
+
padding-bottom: 0;
|
|
27
|
+
|
|
28
|
+
.tr-history__empty-icon {
|
|
29
|
+
font-size: 16px;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.tr-history__empty-text {
|
|
33
|
+
font-size: 12px;
|
|
34
|
+
line-height: 24px;
|
|
35
|
+
color: rgb(25, 25, 25);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useEditItemTitle'
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { onClickOutside } from '@vueuse/core'
|
|
2
|
+
import { ComponentPublicInstance, nextTick, ref, watchEffect } from 'vue'
|
|
3
|
+
import { HistoryEvents, HistoryItem } from '../index.type'
|
|
4
|
+
|
|
5
|
+
export const useEditItemTitle = (emit: HistoryEvents) => {
|
|
6
|
+
const editingItem = ref<Pick<HistoryItem, 'id' | 'title'> & { rawData: HistoryItem }>()
|
|
7
|
+
|
|
8
|
+
const handleEdit = (item: HistoryItem) => {
|
|
9
|
+
editingItem.value = {
|
|
10
|
+
id: item.id,
|
|
11
|
+
title: item.title,
|
|
12
|
+
rawData: item,
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const inputRef = ref<HTMLInputElement | null>(null)
|
|
17
|
+
|
|
18
|
+
const handleEditorInputRef = (el: Element | ComponentPublicInstance | null) => {
|
|
19
|
+
if (!el) {
|
|
20
|
+
return
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
nextTick(() => {
|
|
24
|
+
inputRef.value = el as HTMLInputElement
|
|
25
|
+
inputRef.value.focus()
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let stopFn: (() => void) | undefined = undefined
|
|
30
|
+
|
|
31
|
+
const handleConfirm = () => {
|
|
32
|
+
if (editingItem.value) {
|
|
33
|
+
if (editingItem.value.title !== editingItem.value.rawData.title) {
|
|
34
|
+
const { title, rawData } = editingItem.value
|
|
35
|
+
emit('item-title-change', title, rawData)
|
|
36
|
+
}
|
|
37
|
+
editingItem.value = undefined
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
stopFn?.()
|
|
41
|
+
stopFn = undefined
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const handleCancel = () => {
|
|
45
|
+
editingItem.value = undefined
|
|
46
|
+
stopFn?.()
|
|
47
|
+
stopFn = undefined
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const handleKeyDown = (e: KeyboardEvent) => {
|
|
51
|
+
if (e.key === 'Enter') {
|
|
52
|
+
handleConfirm()
|
|
53
|
+
} else if (e.key === 'Escape') {
|
|
54
|
+
handleCancel()
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
watchEffect(() => {
|
|
59
|
+
if (!inputRef.value) {
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
stopFn?.()
|
|
64
|
+
stopFn = onClickOutside(inputRef, () => {
|
|
65
|
+
handleConfirm()
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
editingItem,
|
|
71
|
+
handleEdit,
|
|
72
|
+
handleEditorInputRef,
|
|
73
|
+
handleKeyDown,
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { CSSProperties } from 'vue'
|
|
2
|
+
|
|
3
|
+
interface BaseHistoryProps {
|
|
4
|
+
activeTab?: string
|
|
5
|
+
searchBar?: boolean
|
|
6
|
+
searchQuery?: string
|
|
7
|
+
searchPlaceholder?: string
|
|
8
|
+
searchFn?: (query: string, item: HistoryItem) => boolean
|
|
9
|
+
selected?: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type SingleTabHistoryProps = {
|
|
13
|
+
tabTitle: string
|
|
14
|
+
data: HistoryGroup[]
|
|
15
|
+
} & BaseHistoryProps
|
|
16
|
+
|
|
17
|
+
export type MultiTabHistoryProps = {
|
|
18
|
+
tabs: {
|
|
19
|
+
title: string
|
|
20
|
+
id: string
|
|
21
|
+
}[]
|
|
22
|
+
data: Record<string, HistoryGroup[]>
|
|
23
|
+
} & BaseHistoryProps
|
|
24
|
+
|
|
25
|
+
export type HistoryProps = SingleTabHistoryProps | MultiTabHistoryProps
|
|
26
|
+
|
|
27
|
+
export interface HistoryGroup<T = Record<string, unknown>> {
|
|
28
|
+
date: string
|
|
29
|
+
items: HistoryItem<T>[]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface HistoryItemTagProps {
|
|
33
|
+
text: string
|
|
34
|
+
type?: 'success' | 'warning' | 'error' | 'info' | 'default'
|
|
35
|
+
style?: CSSProperties
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface HistoryItem<T = Record<string, unknown>> {
|
|
39
|
+
id: string
|
|
40
|
+
title: string
|
|
41
|
+
tag?: HistoryItemTagProps
|
|
42
|
+
data?: T
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface HistoryEvents {
|
|
46
|
+
(e: 'close'): void
|
|
47
|
+
(e: 'item-click', item: HistoryItem): void
|
|
48
|
+
(e: 'item-title-change', newTitle: string, rawData: HistoryItem): void
|
|
49
|
+
(e: 'item-delete', item: HistoryItem): void
|
|
50
|
+
}
|