vue-element-ui-x 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.
Files changed (91) hide show
  1. package/README.md +47 -0
  2. package/lib/attachments.js +3046 -0
  3. package/lib/bubble-list.js +13845 -0
  4. package/lib/bubble.js +13130 -0
  5. package/lib/conversations.js +18817 -0
  6. package/lib/files-card.js +2457 -0
  7. package/lib/index.common.js +19 -0
  8. package/lib/index.esm.js +19 -0
  9. package/lib/index.js +38282 -0
  10. package/lib/index.umd.js +19 -0
  11. package/lib/mixins.js +1016 -0
  12. package/lib/prompts.js +832 -0
  13. package/lib/sender.js +1901 -0
  14. package/lib/think.js +799 -0
  15. package/lib/thinking.js +809 -0
  16. package/lib/thought-chain.js +30396 -0
  17. package/lib/typewriter.js +12793 -0
  18. package/lib/welcome.js +755 -0
  19. package/package.json +42 -0
  20. package/src/components/Attachments/index.js +8 -0
  21. package/src/components/Attachments/src/main.vue +537 -0
  22. package/src/components/Bubble/index.js +6 -0
  23. package/src/components/Bubble/src/main.vue +299 -0
  24. package/src/components/BubbleList/index.js +8 -0
  25. package/src/components/BubbleList/src/loading.vue +75 -0
  26. package/src/components/BubbleList/src/main.vue +466 -0
  27. package/src/components/Conversations/index.js +8 -0
  28. package/src/components/Conversations/src/components/item.vue +371 -0
  29. package/src/components/Conversations/src/main.vue +635 -0
  30. package/src/components/FilesCard/index.js +8 -0
  31. package/src/components/FilesCard/src/fileSvg/audio.vue +38 -0
  32. package/src/components/FilesCard/src/fileSvg/changeFileName.bat +18 -0
  33. package/src/components/FilesCard/src/fileSvg/code.vue +35 -0
  34. package/src/components/FilesCard/src/fileSvg/database.vue +94 -0
  35. package/src/components/FilesCard/src/fileSvg/excel.vue +38 -0
  36. package/src/components/FilesCard/src/fileSvg/file.vue +40 -0
  37. package/src/components/FilesCard/src/fileSvg/image.vue +40 -0
  38. package/src/components/FilesCard/src/fileSvg/index.js +46 -0
  39. package/src/components/FilesCard/src/fileSvg/link.vue +54 -0
  40. package/src/components/FilesCard/src/fileSvg/mark.vue +38 -0
  41. package/src/components/FilesCard/src/fileSvg/pdf.vue +38 -0
  42. package/src/components/FilesCard/src/fileSvg/ppt.vue +38 -0
  43. package/src/components/FilesCard/src/fileSvg/three.vue +38 -0
  44. package/src/components/FilesCard/src/fileSvg/txt.vue +38 -0
  45. package/src/components/FilesCard/src/fileSvg/unknown.vue +54 -0
  46. package/src/components/FilesCard/src/fileSvg/video.vue +38 -0
  47. package/src/components/FilesCard/src/fileSvg/word.vue +38 -0
  48. package/src/components/FilesCard/src/fileSvg/zip.vue +38 -0
  49. package/src/components/FilesCard/src/main.vue +405 -0
  50. package/src/components/FilesCard/src/options.js +18 -0
  51. package/src/components/Prompts/index.js +8 -0
  52. package/src/components/Prompts/src/main.vue +248 -0
  53. package/src/components/Sender/index.js +8 -0
  54. package/src/components/Sender/src/components/ClearButton.vue +28 -0
  55. package/src/components/Sender/src/components/Loading.vue +53 -0
  56. package/src/components/Sender/src/components/LoadingButton.vue +39 -0
  57. package/src/components/Sender/src/components/SendButton.vue +26 -0
  58. package/src/components/Sender/src/components/SpeechButton.vue +24 -0
  59. package/src/components/Sender/src/components/SpeechLoading.vue +87 -0
  60. package/src/components/Sender/src/components/SpeechLoadingButton.vue +43 -0
  61. package/src/components/Sender/src/main.vue +758 -0
  62. package/src/components/Think/index.js +8 -0
  63. package/src/components/Think/src/main.vue +190 -0
  64. package/src/components/Thinking/index.js +8 -0
  65. package/src/components/Thinking/src/main.vue +195 -0
  66. package/src/components/ThoughtChain/index.js +8 -0
  67. package/src/components/ThoughtChain/src/main.vue +293 -0
  68. package/src/components/Typewriter/index.js +8 -0
  69. package/src/components/Typewriter/src/main.vue +251 -0
  70. package/src/components/Welcome/index.js +8 -0
  71. package/src/components/Welcome/src/main.vue +151 -0
  72. package/src/index.js +63 -0
  73. package/src/mixins/index.js +49 -0
  74. package/src/mixins/recordMixin.js +118 -0
  75. package/src/mixins/sendMixin.js +357 -0
  76. package/src/mixins/streamMixin.js +499 -0
  77. package/src/styles/Attachments.scss +236 -0
  78. package/src/styles/Bubble.scss +157 -0
  79. package/src/styles/BubbleList.scss +148 -0
  80. package/src/styles/Conversations.scss +260 -0
  81. package/src/styles/FilesCard.scss +221 -0
  82. package/src/styles/Prompts.scss +195 -0
  83. package/src/styles/Sender.scss +199 -0
  84. package/src/styles/Think.scss +134 -0
  85. package/src/styles/Thinking.scss +112 -0
  86. package/src/styles/ThoughtChain.scss +113 -0
  87. package/src/styles/Typewriter.scss +66 -0
  88. package/src/styles/Welcome.scss +283 -0
  89. package/src/theme/var.scss +72 -0
  90. package/src/utils/index.js +199 -0
  91. package/src/utils/scrollDetector.js +34 -0
@@ -0,0 +1,8 @@
1
+ import ElXPrompts from './src/main.vue';
2
+
3
+ /* istanbul ignore next */
4
+ ElXPrompts.install = function (Vue) {
5
+ Vue.component(ElXPrompts.name, ElXPrompts);
6
+ };
7
+
8
+ export default ElXPrompts;
@@ -0,0 +1,248 @@
1
+ <template>
2
+ <div
3
+ :class="['el-x-prompts', { 'el-x-prompts-rtl': direction === 'rtl' }, rootClassName]"
4
+ :style="customStyle"
5
+ >
6
+ <!-- 标题 -->
7
+ <h5
8
+ v-if="title"
9
+ class="el-x-prompts-title"
10
+ :class="[classNames.title]"
11
+ :style="titleStyle"
12
+ >
13
+ {{ title }}
14
+ </h5>
15
+
16
+ <!-- 提示列表 -->
17
+ <div
18
+ :class="[
19
+ 'el-x-prompts-list',
20
+ {
21
+ 'el-x-prompts-list-wrap': wrap,
22
+ 'el-x-prompts-list-vertical': vertical,
23
+ },
24
+ classNames.list,
25
+ ]"
26
+ :style="listStyle"
27
+ >
28
+ <div
29
+ v-for="(info, index) in items"
30
+ :key="info.key || `key_${index}`"
31
+ :class="[
32
+ 'el-x-prompts-item',
33
+ {
34
+ 'el-x-prompts-item-disabled': info.disabled,
35
+ 'el-x-prompts-item-has-nest': hasChildren(info),
36
+ },
37
+ classNames.item,
38
+ ]"
39
+ :style="itemStyle"
40
+ @click="handleItemClick(info)"
41
+ >
42
+ <!-- 图标 -->
43
+ <div
44
+ v-if="info.icon"
45
+ class="el-x-prompts-icon"
46
+ >
47
+ <slot
48
+ name="icon"
49
+ :item="info"
50
+ >
51
+ <i :class="info.icon"></i>
52
+ </slot>
53
+ </div>
54
+
55
+ <!-- 内容 -->
56
+ <div
57
+ :class="['el-x-prompts-content', classNames.itemContent]"
58
+ :style="itemContentStyle"
59
+ >
60
+ <!-- 标签 -->
61
+ <h6
62
+ v-if="info.label"
63
+ class="el-x-prompts-label"
64
+ >
65
+ <slot
66
+ name="label"
67
+ :item="info"
68
+ >{{ info.label }}</slot
69
+ >
70
+ </h6>
71
+
72
+ <!-- 描述 -->
73
+ <p
74
+ v-if="info.description"
75
+ class="el-x-prompts-desc"
76
+ >
77
+ <slot
78
+ name="description"
79
+ :item="info"
80
+ >{{ info.description }}</slot
81
+ >
82
+ </p>
83
+
84
+ <!-- 子项 -->
85
+ <component
86
+ :is="$options.name"
87
+ v-if="hasChildren(info)"
88
+ class="el-x-prompts-nested"
89
+ :items="info.children"
90
+ :vertical="true"
91
+ @on-item-click="$emit('on-item-click', $event)"
92
+ :class-names="{
93
+ list: classNames.subList,
94
+ item: classNames.subItem,
95
+ }"
96
+ :styles="{
97
+ list: styles.subList,
98
+ item: styles.subItem,
99
+ }"
100
+ />
101
+ </div>
102
+ </div>
103
+ </div>
104
+ </div>
105
+ </template>
106
+
107
+ <script>
108
+ export default {
109
+ name: 'ElXPrompts',
110
+
111
+ props: {
112
+ /**
113
+ * 包含多个提示项的列表
114
+ */
115
+ items: {
116
+ type: Array,
117
+ default: () => [],
118
+ },
119
+
120
+ /**
121
+ * 显示在提示列表顶部的标题
122
+ */
123
+ title: {
124
+ type: String,
125
+ default: '',
126
+ },
127
+
128
+ /**
129
+ * Item 提示项被点击时的回调函数
130
+ */
131
+ onItemClick: {
132
+ type: Function,
133
+ default: null,
134
+ },
135
+
136
+ /**
137
+ * 提示列表是否垂直排列
138
+ */
139
+ vertical: {
140
+ type: Boolean,
141
+ default: false,
142
+ },
143
+
144
+ /**
145
+ * 提示列表是否换行
146
+ */
147
+ wrap: {
148
+ type: Boolean,
149
+ default: false,
150
+ },
151
+
152
+ /**
153
+ * 自定义样式,用于各个提示项的不同部分
154
+ */
155
+ styles: {
156
+ type: Object,
157
+ default: () => ({}),
158
+ },
159
+
160
+ /**
161
+ * 自定义样式类名,用于各个提示项的不同部分
162
+ */
163
+ classNames: {
164
+ type: Object,
165
+ default: () => ({}),
166
+ },
167
+
168
+ /**
169
+ * 根节点的样式类名
170
+ */
171
+ rootClassName: {
172
+ type: String,
173
+ default: '',
174
+ },
175
+
176
+ /**
177
+ * 自定义样式
178
+ */
179
+ customStyle: {
180
+ type: Object,
181
+ default: () => ({}),
182
+ },
183
+
184
+ /**
185
+ * 方向
186
+ */
187
+ direction: {
188
+ type: String,
189
+ default: 'ltr',
190
+ },
191
+ },
192
+
193
+ computed: {
194
+ titleStyle() {
195
+ return {
196
+ ...this.styles.title,
197
+ };
198
+ },
199
+
200
+ listStyle() {
201
+ return {
202
+ ...this.styles.list,
203
+ };
204
+ },
205
+
206
+ itemStyle() {
207
+ return {
208
+ ...this.styles.item,
209
+ };
210
+ },
211
+
212
+ itemContentStyle() {
213
+ return {
214
+ ...this.styles.itemContent,
215
+ };
216
+ },
217
+ },
218
+
219
+ methods: {
220
+ hasChildren(item) {
221
+ return item.children && item.children.length > 0;
222
+ },
223
+
224
+ handleItemClick(info) {
225
+ if (info.disabled) {
226
+ return;
227
+ }
228
+ // 如果有子项,不触发点击事件
229
+ if (this.hasChildren(info)) {
230
+ return;
231
+ }
232
+ this.$emit('on-item-click', {
233
+ data: info,
234
+ });
235
+ // 向后兼容性
236
+ if (this.onItemClick) {
237
+ this.onItemClick({
238
+ data: info,
239
+ });
240
+ }
241
+ },
242
+ },
243
+ };
244
+ </script>
245
+
246
+ <style lang="scss" scoped>
247
+ @import '../../../styles/Prompts.scss';
248
+ </style>
@@ -0,0 +1,8 @@
1
+ import ElXSender from './src/main.vue';
2
+
3
+ /* istanbul ignore next */
4
+ ElXSender.install = function (Vue) {
5
+ Vue.component(ElXSender.name, ElXSender);
6
+ };
7
+
8
+ export default ElXSender;
@@ -0,0 +1,28 @@
1
+ <template>
2
+ <div class="el-x-send-button">
3
+ <el-button
4
+ circle
5
+ @click="$emit('clear')"
6
+ size="small"
7
+ >
8
+ <i class="el-icon-brush"></i>
9
+ </el-button>
10
+ </div>
11
+ </template>
12
+
13
+ <script>
14
+ export default {
15
+ name: 'ClearButton',
16
+ };
17
+ </script>
18
+
19
+ <style scoped lang="scss">
20
+ .el-x-send-button {
21
+ .el-button {
22
+ .el-icon-brush {
23
+ // 旋转180
24
+ transform: rotate(180deg);
25
+ }
26
+ }
27
+ }
28
+ </style>
@@ -0,0 +1,53 @@
1
+ <template>
2
+ <svg
3
+ viewBox="0 0 1000 1000"
4
+ xmlns="http://www.w3.org/2000/svg"
5
+ xmlns:xlink="http://www.w3.org/1999/xlink"
6
+ >
7
+ <title>Loading</title>
8
+ <rect
9
+ fill="currentColor"
10
+ height="250"
11
+ rx="24"
12
+ ry="24"
13
+ width="250"
14
+ x="375"
15
+ y="375"
16
+ />
17
+ <circle
18
+ cx="500"
19
+ cy="500"
20
+ fill="none"
21
+ r="450"
22
+ stroke="currentColor"
23
+ stroke-width="100"
24
+ opacity="0.45"
25
+ />
26
+ <circle
27
+ cx="500"
28
+ cy="500"
29
+ fill="none"
30
+ r="450"
31
+ stroke="currentColor"
32
+ stroke-width="100"
33
+ stroke-dasharray="600 9999999"
34
+ >
35
+ <animateTransform
36
+ attributeName="transform"
37
+ dur="1s"
38
+ from="0 500 500"
39
+ repeatCount="indefinite"
40
+ to="360 500 500"
41
+ type="rotate"
42
+ />
43
+ </circle>
44
+ </svg>
45
+ </template>
46
+
47
+ <script>
48
+ export default {
49
+ name: 'Loading',
50
+ };
51
+ </script>
52
+
53
+ <style scoped></style>
@@ -0,0 +1,39 @@
1
+ <template>
2
+ <div class="el-x-send-button">
3
+ <el-button
4
+ circle
5
+ @click="$emit('cancel')"
6
+ size="small"
7
+ >
8
+ <loading class="loading-svg" />
9
+ </el-button>
10
+ </div>
11
+ </template>
12
+
13
+ <script>
14
+ import Loading from './Loading.vue';
15
+
16
+ export default {
17
+ name: 'LoadingButton',
18
+ components: {
19
+ Loading,
20
+ },
21
+ };
22
+ </script>
23
+
24
+ <style scoped lang="scss">
25
+ @import '~element-ui/packages/theme-chalk/src/common/var';
26
+
27
+ .el-x-send-button {
28
+ height: 32px;
29
+ .el-button {
30
+ padding: 0;
31
+ width: 32px;
32
+ height: 32px;
33
+ }
34
+ .loading-svg {
35
+ color: $--color-primary;
36
+ width: 100%;
37
+ }
38
+ }
39
+ </style>
@@ -0,0 +1,26 @@
1
+ <template>
2
+ <div class="el-x-send-button">
3
+ <el-button
4
+ circle
5
+ :disabled="disabled"
6
+ @click="$emit('submit')"
7
+ size="small"
8
+ >
9
+ <i class="el-icon-top"></i>
10
+ </el-button>
11
+ </div>
12
+ </template>
13
+
14
+ <script>
15
+ export default {
16
+ name: 'SendButton',
17
+ props: {
18
+ disabled: {
19
+ type: Boolean,
20
+ default: false,
21
+ },
22
+ },
23
+ };
24
+ </script>
25
+
26
+ <style scoped lang="scss"></style>
@@ -0,0 +1,24 @@
1
+ <template>
2
+ <div class="el-x-send-button">
3
+ <el-button
4
+ circle
5
+ size="small"
6
+ @click="onClick"
7
+ >
8
+ <i class="el-icon-microphone"></i>
9
+ </el-button>
10
+ </div>
11
+ </template>
12
+
13
+ <script>
14
+ export default {
15
+ name: 'SpeechButton',
16
+ methods: {
17
+ onClick() {
18
+ this.$emit('click');
19
+ },
20
+ },
21
+ };
22
+ </script>
23
+
24
+ <style scoped lang="scss"></style>
@@ -0,0 +1,87 @@
1
+ <template>
2
+ <svg
3
+ :class="className"
4
+ color="currentColor"
5
+ :viewBox="`0 0 ${SIZE} ${SIZE}`"
6
+ xmlns="http://www.w3.org/2000/svg"
7
+ xmlns:xlink="http://www.w3.org/1999/xlink"
8
+ >
9
+ <title>Speech Recording</title>
10
+
11
+ <rect
12
+ v-for="(item, index) in rects"
13
+ :key="index"
14
+ fill="currentColor"
15
+ :rx="RECT_RADIUS"
16
+ :ry="RECT_RADIUS"
17
+ :height="RECT_HEIGHT_MIN"
18
+ :width="RECT_WIDTH"
19
+ :x="item.x"
20
+ :y="item.yMin"
21
+ >
22
+ <animate
23
+ attributeName="height"
24
+ :values="`${RECT_HEIGHT_MIN}; ${RECT_HEIGHT_MAX}; ${RECT_HEIGHT_MIN}`"
25
+ keyTimes="0; 0.5; 1"
26
+ :dur="`${DURATION}s`"
27
+ :begin="`${(DURATION / COUNT) * index}s`"
28
+ repeatCount="indefinite"
29
+ />
30
+ <animate
31
+ attributeName="y"
32
+ :values="`${item.yMin}; ${item.yMax}; ${item.yMin}`"
33
+ keyTimes="0; 0.5; 1"
34
+ :dur="`${DURATION}s`"
35
+ :begin="`${(DURATION / COUNT) * index}s`"
36
+ repeatCount="indefinite"
37
+ />
38
+ </rect>
39
+ </svg>
40
+ </template>
41
+
42
+ <script>
43
+ export default {
44
+ name: 'SpeechLoading',
45
+
46
+ props: {
47
+ className: {
48
+ type: String,
49
+ default: '',
50
+ },
51
+ },
52
+
53
+ data() {
54
+ return {
55
+ // 定义常量
56
+ SIZE: 1000,
57
+ COUNT: 4,
58
+ RECT_WIDTH: 140,
59
+ RECT_RADIUS: 70, // RECT_WIDTH / 2
60
+ RECT_HEIGHT_MIN: 250,
61
+ RECT_HEIGHT_MAX: 500,
62
+ DURATION: 0.8,
63
+ };
64
+ },
65
+
66
+ computed: {
67
+ // 计算矩形的位置和高度范围
68
+ rects() {
69
+ const dest = (this.SIZE - this.RECT_WIDTH * this.COUNT) / (this.COUNT - 1);
70
+ return Array.from({
71
+ length: this.COUNT,
72
+ }).map((_, index) => {
73
+ const x = index * (dest + this.RECT_WIDTH);
74
+ const yMin = this.SIZE / 2 - this.RECT_HEIGHT_MIN / 2;
75
+ const yMax = this.SIZE / 2 - this.RECT_HEIGHT_MAX / 2;
76
+ return {
77
+ x,
78
+ yMin,
79
+ yMax,
80
+ };
81
+ });
82
+ },
83
+ },
84
+ };
85
+ </script>
86
+
87
+ <style scoped></style>
@@ -0,0 +1,43 @@
1
+ <template>
2
+ <div class="el-x-send-button">
3
+ <el-button
4
+ circle
5
+ size="small"
6
+ @click="onClick"
7
+ >
8
+ <speech-loading class="loading-svg" />
9
+ </el-button>
10
+ </div>
11
+ </template>
12
+
13
+ <script>
14
+ import SpeechLoading from './SpeechLoading.vue';
15
+
16
+ export default {
17
+ name: 'SpeechLoadingButton',
18
+ components: {
19
+ SpeechLoading,
20
+ },
21
+ methods: {
22
+ onClick() {
23
+ this.$emit('click');
24
+ },
25
+ },
26
+ };
27
+ </script>
28
+
29
+ <style scoped lang="scss">
30
+ @import '~element-ui/packages/theme-chalk/src/common/var';
31
+
32
+ .el-x-send-button {
33
+ .el-button {
34
+ padding: 0;
35
+ width: 32px;
36
+ height: 32px;
37
+ }
38
+ .loading-svg {
39
+ color: $--color-primary;
40
+ width: 16px;
41
+ }
42
+ }
43
+ </style>