vue-element-ui-x 0.2.2 → 1.0.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.
Files changed (97) hide show
  1. package/lib/components/Attachments/index.js +18 -18
  2. package/lib/components/Bubble/index.js +145 -155
  3. package/lib/components/BubbleList/index.js +180 -207
  4. package/lib/components/Conversations/index.js +14370 -14370
  5. package/lib/components/FilesCard/index.js +5 -5
  6. package/lib/components/Prompts/index.js +25 -25
  7. package/lib/components/Sender/index.js +1606 -1459
  8. package/lib/components/Thinking/index.js +157 -23
  9. package/lib/components/ThoughtChain/index.js +143 -144
  10. package/lib/components/Typewriter/index.js +124 -125
  11. package/lib/components/Welcome/index.js +5 -5
  12. package/lib/index.common.js +1 -1
  13. package/lib/index.esm.js +1 -1
  14. package/lib/index.js +817 -389
  15. package/lib/index.umd.js +1 -1
  16. package/lib/locale/index.js +97 -0
  17. package/lib/locale/lang/ar-SA.js +18 -0
  18. package/lib/locale/lang/ar-SA.umd.js +26 -0
  19. package/lib/locale/lang/ar.js +18 -0
  20. package/lib/locale/lang/ar.umd.js +26 -0
  21. package/lib/locale/lang/de-DE.js +18 -0
  22. package/lib/locale/lang/de-DE.umd.js +26 -0
  23. package/lib/locale/lang/de.js +18 -0
  24. package/lib/locale/lang/de.umd.js +26 -0
  25. package/lib/locale/lang/en.js +18 -0
  26. package/lib/locale/lang/en.umd.js +26 -0
  27. package/lib/locale/lang/es-ES.js +18 -0
  28. package/lib/locale/lang/es-ES.umd.js +26 -0
  29. package/lib/locale/lang/es.js +18 -0
  30. package/lib/locale/lang/es.umd.js +26 -0
  31. package/lib/locale/lang/fr-FR.js +18 -0
  32. package/lib/locale/lang/fr-FR.umd.js +26 -0
  33. package/lib/locale/lang/fr.js +18 -0
  34. package/lib/locale/lang/fr.umd.js +26 -0
  35. package/lib/locale/lang/index.js +50 -0
  36. package/lib/locale/lang/it-IT.js +18 -0
  37. package/lib/locale/lang/it-IT.umd.js +26 -0
  38. package/lib/locale/lang/it.js +18 -0
  39. package/lib/locale/lang/it.umd.js +26 -0
  40. package/lib/locale/lang/ja-JP.js +18 -0
  41. package/lib/locale/lang/ja-JP.umd.js +26 -0
  42. package/lib/locale/lang/ja.js +18 -0
  43. package/lib/locale/lang/ja.umd.js +26 -0
  44. package/lib/locale/lang/ko-KR.js +18 -0
  45. package/lib/locale/lang/ko-KR.umd.js +26 -0
  46. package/lib/locale/lang/ko.js +18 -0
  47. package/lib/locale/lang/ko.umd.js +26 -0
  48. package/lib/locale/lang/pt-BR.js +18 -0
  49. package/lib/locale/lang/pt-BR.umd.js +26 -0
  50. package/lib/locale/lang/ru-RU.js +18 -0
  51. package/lib/locale/lang/ru-RU.umd.js +26 -0
  52. package/lib/locale/lang/zh-CN.js +18 -0
  53. package/lib/locale/lang/zh-CN.umd.js +26 -0
  54. package/lib/locale/lang/zh-TW.js +18 -0
  55. package/lib/locale/lang/zh-TW.umd.js +26 -0
  56. package/lib/locale/mixin.js +9 -0
  57. package/package.json +15 -10
  58. package/src/components/Attachments/src/main.vue +2 -10
  59. package/src/components/Bubble/src/main.vue +288 -299
  60. package/src/components/BubbleList/src/main.vue +2 -19
  61. package/src/components/Conversations/src/main.vue +0 -41
  62. package/src/components/Prompts/src/main.vue +248 -248
  63. package/src/components/Sender/src/components/LoadingButton.vue +37 -39
  64. package/src/components/Sender/src/components/SpeechLoadingButton.vue +41 -43
  65. package/src/components/Sender/src/main.vue +13 -3
  66. package/src/components/Thinking/src/main.vue +13 -9
  67. package/src/components/ThoughtChain/src/main.vue +1 -3
  68. package/src/components/Typewriter/src/main.vue +3 -7
  69. package/src/components/Welcome/src/main.vue +151 -151
  70. package/src/index.js +23 -6
  71. package/src/locale/index.js +97 -0
  72. package/src/locale/lang/ar.js +18 -0
  73. package/src/locale/lang/de.js +18 -0
  74. package/src/locale/lang/en.js +18 -0
  75. package/src/locale/lang/es.js +18 -0
  76. package/src/locale/lang/fr.js +18 -0
  77. package/src/locale/lang/index.js +62 -0
  78. package/src/locale/lang/it.js +18 -0
  79. package/src/locale/lang/ja.js +18 -0
  80. package/src/locale/lang/ko.js +18 -0
  81. package/src/locale/lang/pt-br.js +18 -0
  82. package/src/locale/lang/ru-RU.js +18 -0
  83. package/src/locale/lang/zh-CN.js +18 -0
  84. package/src/locale/lang/zh-TW.js +18 -0
  85. package/src/locale/mixin.js +9 -0
  86. package/src/styles/Attachments.scss +236 -236
  87. package/src/styles/Bubble.scss +5 -4
  88. package/src/styles/BubbleList.scss +148 -148
  89. package/src/styles/Conversations.scss +260 -260
  90. package/src/styles/FilesCard.scss +222 -221
  91. package/src/styles/Prompts.scss +197 -195
  92. package/src/styles/Sender.scss +207 -199
  93. package/src/styles/Thinking.scss +36 -6
  94. package/src/styles/ThoughtChain.scss +113 -113
  95. package/src/styles/Typewriter.scss +66 -66
  96. package/src/styles/var.scss +4 -5
  97. package/src/theme/var.scss +183 -72
@@ -1,43 +1,41 @@
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>
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: { SpeechLoading },
19
+ methods: {
20
+ onClick() {
21
+ this.$emit('click');
22
+ },
23
+ },
24
+ };
25
+ </script>
26
+
27
+ <style scoped lang="scss">
28
+ @import '../../../../theme/var.scss';
29
+
30
+ .el-x-send-button {
31
+ .el-button {
32
+ padding: 0;
33
+ width: 32px;
34
+ height: 32px;
35
+ }
36
+ .loading-svg {
37
+ color: $--color-primary;
38
+ width: 16px;
39
+ }
40
+ }
41
+ </style>
@@ -2,6 +2,7 @@
2
2
  <div
3
3
  class="el-x-sender-wrap"
4
4
  :style="{
5
+ display: 'block',
5
6
  cursor: disabled ? 'not-allowed' : 'default',
6
7
  '--el-x-sender-trigger-popover-width': triggerPopoverWidth,
7
8
  '--el-x-sender-trigger-popover-left': triggerPopoverLeft,
@@ -56,7 +57,7 @@
56
57
  :autosize="computedAutoSize"
57
58
  type="textarea"
58
59
  :validate-event="false"
59
- :placeholder="placeholder"
60
+ :placeholder="computedPlaceholder"
60
61
  :readonly="readOnly || disabled"
61
62
  :disabled="disabled"
62
63
  @keydown.native="handleKeyDown"
@@ -163,6 +164,7 @@
163
164
  v-model="popoverVisible"
164
165
  :disabled="disabled"
165
166
  :visible-arrow="false"
167
+ :appendToBody="false"
166
168
  :placement="triggerPopoverPlacement"
167
169
  :offset="triggerPopoverOffset"
168
170
  popper-class="el-x-sender-trigger-popover"
@@ -185,6 +187,7 @@
185
187
  </template>
186
188
 
187
189
  <script>
190
+ import Locale from '../../../locale/mixin';
188
191
  import ClearButton from './components/ClearButton.vue';
189
192
  import LoadingButton from './components/LoadingButton.vue';
190
193
  import SendButton from './components/SendButton.vue';
@@ -193,6 +196,7 @@
193
196
 
194
197
  export default {
195
198
  name: 'ElXSender',
199
+ mixins: [Locale],
196
200
 
197
201
  components: {
198
202
  ClearButton,
@@ -209,7 +213,7 @@
209
213
  },
210
214
  placeholder: {
211
215
  type: String,
212
- default: '请输入内容',
216
+ default: '',
213
217
  },
214
218
  autoSize: {
215
219
  type: Object,
@@ -344,6 +348,11 @@
344
348
  maxRows: 6,
345
349
  };
346
350
  },
351
+
352
+ // 计算 placeholder
353
+ computedPlaceholder() {
354
+ return this.placeholder || this.elXt('el_x.sender.placeholder');
355
+ },
347
356
  },
348
357
 
349
358
  watch: {
@@ -479,8 +488,9 @@
479
488
 
480
489
  // 设置默认基础样式
481
490
  const defaultStyles = {
491
+ width: this.inputWidth || '100%',
492
+ height: '24px',
482
493
  maxHeight: '176px',
483
- maxWidth: this.inputWidth || '100%',
484
494
  boxSizing: 'border-box',
485
495
  };
486
496
 
@@ -46,12 +46,12 @@
46
46
  >
47
47
  {{
48
48
  localStatus === 'thinking'
49
- ? '思考中...'
49
+ ? elXt('el_x.thinking.processing')
50
50
  : localStatus === 'error'
51
- ? '思考遇到问题'
51
+ ? elXt('el_x.thinking.error')
52
52
  : localStatus === 'end'
53
- ? '思考完成'
54
- : '开始思考'
53
+ ? elXt('el_x.thinking.completed')
54
+ : elXt('el_x.thinking.start')
55
55
  }}
56
56
  </slot>
57
57
  </span>
@@ -69,10 +69,9 @@
69
69
  </transition>
70
70
  </button>
71
71
 
72
- <Transition name="slide">
72
+ <transition name="slide">
73
73
  <div
74
- v-show="isExpanded"
75
- v-if="displayedContent"
74
+ v-if="isExpanded && displayedContent"
76
75
  class="content-wrapper"
77
76
  :class="{ 'error-state': localStatus === 'error' }"
78
77
  >
@@ -94,13 +93,16 @@
94
93
  </slot>
95
94
  </div>
96
95
  </div>
97
- </Transition>
96
+ </transition>
98
97
  </div>
99
98
  </template>
100
99
 
101
100
  <script>
101
+ import Locale from '../../../locale/mixin';
102
+
102
103
  export default {
103
104
  name: 'ElXThinking',
105
+ mixins: [Locale],
104
106
  props: {
105
107
  content: {
106
108
  type: String,
@@ -154,7 +156,9 @@
154
156
  },
155
157
  computed: {
156
158
  displayedContent() {
157
- return this.localStatus === 'error' ? '思考过程中出现错误' : this.content;
159
+ return this.localStatus === 'error'
160
+ ? this.elXt('el_x.thinking.errorContent')
161
+ : this.content;
158
162
  },
159
163
  },
160
164
  watch: {
@@ -102,9 +102,7 @@
102
102
  import ElXTypewriter from '../../Typewriter/index.js';
103
103
  export default {
104
104
  name: 'ElXThoughtChain',
105
- components: {
106
- ElXTypewriter,
107
- },
105
+ components: { ElXTypewriter },
108
106
  props: {
109
107
  thinkingItems: {
110
108
  type: Array,
@@ -76,11 +76,11 @@
76
76
  const grammar = Prism.languages[lang];
77
77
  if (grammar) {
78
78
  const highlighted = Prism.highlight(code, grammar, lang);
79
- return `<pre class="language-${lang}"><code class="language-${lang}">${highlighted}</code></pre>`;
79
+ return highlighted;
80
80
  }
81
- return `<pre class="language-${lang}"><code class="language-${lang}">${code}</code></pre>`;
81
+ return code;
82
82
  } catch {
83
- return `<pre><code>${code}</code></pre>`;
83
+ return code;
84
84
  }
85
85
  },
86
86
  }),
@@ -158,7 +158,6 @@
158
158
  },
159
159
  mounted() {
160
160
  this.initMarkdownPlugins();
161
- this.updateFogColor();
162
161
  this.$nextTick(() => {
163
162
  Prism.highlightAll();
164
163
  });
@@ -240,9 +239,6 @@
240
239
  progress: this.typingProgress,
241
240
  };
242
241
  },
243
- updateFogColor() {
244
- // 实现雾化颜色更新逻辑
245
- },
246
242
  },
247
243
  };
248
244
  </script>
@@ -1,151 +1,151 @@
1
- <template>
2
- <div
3
- :class="containerClass"
4
- :style="styleConfig"
5
- class="el-x-welcome"
6
- >
7
- <!-- image -->
8
- <slot name="image">
9
- <div
10
- v-if="hasIcon"
11
- :class="iconClass"
12
- :style="styles && styles.icon"
13
- class="el-x-welcome-icon"
14
- >
15
- <el-image
16
- :src="icon"
17
- class="icon-image"
18
- />
19
- </div>
20
- </slot>
21
-
22
- <div class="content-wrapper">
23
- <!-- extra -->
24
- <div
25
- v-if="hasTitleOrExtra"
26
- class="title-wrapper"
27
- >
28
- <div
29
- v-if="title"
30
- :class="titleClass"
31
- :style="styles && styles.title"
32
- class="el-x-welcome-title"
33
- >
34
- {{ title }}
35
- </div>
36
- <div
37
- v-if="hasExtraOrSlot"
38
- :class="extraClass"
39
- :style="styles && styles.extra"
40
- class="el-x-welcome-extra"
41
- >
42
- <slot name="extra">{{ extra }}</slot>
43
- </div>
44
- </div>
45
-
46
- <!-- description -->
47
- <div
48
- v-if="hasDescription"
49
- :class="descriptionClass"
50
- :style="styles && styles.description"
51
- class="el-x-welcome-description"
52
- >
53
- {{ description }}
54
- </div>
55
- </div>
56
- </div>
57
- </template>
58
-
59
- <script>
60
- export default {
61
- name: 'ElXWelcome',
62
- props: {
63
- className: {
64
- type: String,
65
- default: '',
66
- },
67
- rootClassName: {
68
- type: String,
69
- default: '',
70
- },
71
- variant: {
72
- type: String,
73
- default: 'filled',
74
- validator: value => ['filled', 'borderless'].includes(value),
75
- },
76
- direction: {
77
- type: String,
78
- default: 'ltr',
79
- validator: value => ['ltr', 'rtl'].includes(value),
80
- },
81
- classNames: {
82
- type: Object,
83
- default: () => ({}),
84
- },
85
- icon: {
86
- type: String,
87
- default: '',
88
- },
89
- title: {
90
- type: String,
91
- default: '',
92
- },
93
- extra: {
94
- type: [String, Object],
95
- default: '',
96
- },
97
- description: {
98
- type: String,
99
- default: '',
100
- },
101
- styleConfig: {
102
- type: Object,
103
- default: () => ({}),
104
- },
105
- styles: {
106
- type: Object,
107
- default: () => ({}),
108
- },
109
- },
110
- computed: {
111
- hasIcon() {
112
- return !!this.icon;
113
- },
114
- hasTitleOrExtra() {
115
- return !!this.title || !!this.extra;
116
- },
117
- hasExtraOrSlot() {
118
- return !!this.extra || !!this.$slots.extra;
119
- },
120
- hasDescription() {
121
- return !!this.description;
122
- },
123
- containerClass() {
124
- return [
125
- this.className,
126
- this.rootClassName,
127
- `el-x-welcome-${this.variant}`,
128
- {
129
- 'el-x-welcome-rtl': this.direction === 'rtl',
130
- },
131
- ];
132
- },
133
- iconClass() {
134
- return this.classNames && this.classNames.icon;
135
- },
136
- titleClass() {
137
- return this.classNames && this.classNames.title;
138
- },
139
- extraClass() {
140
- return this.classNames && this.classNames.extra;
141
- },
142
- descriptionClass() {
143
- return this.classNames && this.classNames.description;
144
- },
145
- },
146
- };
147
- </script>
148
-
149
- <style lang="scss" scoped>
150
- @import '../../../styles/Welcome.scss';
151
- </style>
1
+ <template>
2
+ <div
3
+ :class="containerClass"
4
+ :style="styleConfig"
5
+ class="el-x-welcome"
6
+ >
7
+ <!-- image -->
8
+ <slot name="image">
9
+ <div
10
+ v-if="hasIcon"
11
+ :class="iconClass"
12
+ :style="styles && styles.icon"
13
+ class="el-x-welcome-icon"
14
+ >
15
+ <el-image
16
+ :src="icon"
17
+ class="icon-image"
18
+ />
19
+ </div>
20
+ </slot>
21
+
22
+ <div class="content-wrapper">
23
+ <!-- extra -->
24
+ <div
25
+ v-if="hasTitleOrExtra"
26
+ class="title-wrapper"
27
+ >
28
+ <div
29
+ v-if="title"
30
+ :class="titleClass"
31
+ :style="styles && styles.title"
32
+ class="el-x-welcome-title"
33
+ >
34
+ {{ title }}
35
+ </div>
36
+ <div
37
+ v-if="hasExtraOrSlot"
38
+ :class="extraClass"
39
+ :style="styles && styles.extra"
40
+ class="el-x-welcome-extra"
41
+ >
42
+ <slot name="extra">{{ extra }}</slot>
43
+ </div>
44
+ </div>
45
+
46
+ <!-- description -->
47
+ <div
48
+ v-if="hasDescription"
49
+ :class="descriptionClass"
50
+ :style="styles && styles.description"
51
+ class="el-x-welcome-description"
52
+ >
53
+ {{ description }}
54
+ </div>
55
+ </div>
56
+ </div>
57
+ </template>
58
+
59
+ <script>
60
+ export default {
61
+ name: 'ElXWelcome',
62
+ props: {
63
+ className: {
64
+ type: String,
65
+ default: '',
66
+ },
67
+ rootClassName: {
68
+ type: String,
69
+ default: '',
70
+ },
71
+ variant: {
72
+ type: String,
73
+ default: 'filled',
74
+ validator: value => ['filled', 'borderless'].includes(value),
75
+ },
76
+ direction: {
77
+ type: String,
78
+ default: 'ltr',
79
+ validator: value => ['ltr', 'rtl'].includes(value),
80
+ },
81
+ classNames: {
82
+ type: Object,
83
+ default: () => ({}),
84
+ },
85
+ icon: {
86
+ type: String,
87
+ default: '',
88
+ },
89
+ title: {
90
+ type: String,
91
+ default: '',
92
+ },
93
+ extra: {
94
+ type: [String, Object],
95
+ default: '',
96
+ },
97
+ description: {
98
+ type: String,
99
+ default: '',
100
+ },
101
+ styleConfig: {
102
+ type: Object,
103
+ default: () => ({}),
104
+ },
105
+ styles: {
106
+ type: Object,
107
+ default: () => ({}),
108
+ },
109
+ },
110
+ computed: {
111
+ hasIcon() {
112
+ return !!this.icon;
113
+ },
114
+ hasTitleOrExtra() {
115
+ return !!this.title || !!this.extra;
116
+ },
117
+ hasExtraOrSlot() {
118
+ return !!this.extra || !!this.$slots.extra;
119
+ },
120
+ hasDescription() {
121
+ return !!this.description;
122
+ },
123
+ containerClass() {
124
+ return [
125
+ this.className,
126
+ this.rootClassName,
127
+ `el-x-welcome-${this.variant}`,
128
+ {
129
+ 'el-x-welcome-rtl': this.direction === 'rtl',
130
+ },
131
+ ];
132
+ },
133
+ iconClass() {
134
+ return this.classNames && this.classNames.icon;
135
+ },
136
+ titleClass() {
137
+ return this.classNames && this.classNames.title;
138
+ },
139
+ extraClass() {
140
+ return this.classNames && this.classNames.extra;
141
+ },
142
+ descriptionClass() {
143
+ return this.classNames && this.classNames.description;
144
+ },
145
+ },
146
+ };
147
+ </script>
148
+
149
+ <style lang="scss" scoped>
150
+ @import '../../../styles/Welcome.scss';
151
+ </style>
package/src/index.js CHANGED
@@ -20,6 +20,9 @@ import {
20
20
  XRequest,
21
21
  XStream,
22
22
  } from './mixins';
23
+ // 导入国际化功能
24
+ import locale from './locale';
25
+ import lang from './locale/lang';
23
26
 
24
27
  const components = [
25
28
  ElXTypewriter,
@@ -35,7 +38,15 @@ const components = [
35
38
  ElXWelcome,
36
39
  ];
37
40
 
38
- const install = function (Vue) {
41
+ const install = function (Vue, opts = {}) {
42
+ // 处理国际化配置
43
+ if (opts.locale) {
44
+ locale.use(opts.locale);
45
+ }
46
+ if (opts.i18n) {
47
+ locale.i18n(opts.i18n);
48
+ }
49
+
39
50
  components.forEach(component => {
40
51
  Vue.component(component.name, component);
41
52
  });
@@ -43,6 +54,10 @@ const install = function (Vue) {
43
54
 
44
55
  // 具名导出(按需引入)- 组件和Mixins
45
56
  export {
57
+ // Mixins
58
+ createSendUtils,
59
+ createStreamUtils,
60
+ customMixins,
46
61
  // 组件
47
62
  ElXAttachments,
48
63
  ElXBubble,
@@ -55,20 +70,22 @@ export {
55
70
  ElXThoughtChain,
56
71
  ElXTypewriter,
57
72
  ElXWelcome,
58
- // Mixins
59
- createSendUtils,
60
- createStreamUtils,
61
- customMixins,
73
+ lang,
74
+ // 国际化
75
+ locale,
62
76
  recordMixin,
63
77
  sendMixin,
64
78
  streamMixin,
65
79
  XRequest,
66
80
  XStream,
67
81
  };
82
+
68
83
  // 默认导出(完整引入)
69
84
  const ElementUIX = {
70
- version: '1.0.0',
85
+ version: '0.2.2',
71
86
  install,
87
+ locale,
88
+ lang,
72
89
  };
73
90
 
74
91
  // 将组件添加到默认导出对象中