vue-element-ui-x 0.2.2 → 1.0.1

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 (78) hide show
  1. package/lib/components/Attachments/index.js +8 -8
  2. package/lib/components/Bubble/index.js +116 -113
  3. package/lib/components/BubbleList/index.js +137 -134
  4. package/lib/components/Conversations/index.js +14176 -14176
  5. package/lib/components/FilesCard/index.js +4 -4
  6. package/lib/components/Prompts/index.js +4 -4
  7. package/lib/components/Sender/index.js +1594 -1448
  8. package/lib/components/Thinking/index.js +155 -15
  9. package/lib/components/ThoughtChain/index.js +121 -118
  10. package/lib/components/Typewriter/index.js +111 -108
  11. package/lib/components/Welcome/index.js +4 -4
  12. package/lib/index.common.js +1 -1
  13. package/lib/index.esm.js +1 -1
  14. package/lib/index.js +688 -225
  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 +6 -4
  58. package/src/components/Bubble/src/main.vue +299 -299
  59. package/src/components/Sender/src/main.vue +12 -3
  60. package/src/components/Thinking/src/main.vue +10 -5
  61. package/src/index.js +23 -6
  62. package/src/locale/index.js +97 -0
  63. package/src/locale/lang/ar.js +18 -0
  64. package/src/locale/lang/de.js +18 -0
  65. package/src/locale/lang/en.js +18 -0
  66. package/src/locale/lang/es.js +18 -0
  67. package/src/locale/lang/fr.js +18 -0
  68. package/src/locale/lang/index.js +62 -0
  69. package/src/locale/lang/it.js +18 -0
  70. package/src/locale/lang/ja.js +18 -0
  71. package/src/locale/lang/ko.js +18 -0
  72. package/src/locale/lang/pt-br.js +18 -0
  73. package/src/locale/lang/ru-RU.js +18 -0
  74. package/src/locale/lang/zh-CN.js +18 -0
  75. package/src/locale/lang/zh-TW.js +18 -0
  76. package/src/locale/mixin.js +9 -0
  77. package/src/styles/Conversations.scss +260 -260
  78. package/src/styles/Sender.scss +196 -199
@@ -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>
@@ -99,8 +99,11 @@
99
99
  </template>
100
100
 
101
101
  <script>
102
+ import Locale from '../../../locale/mixin';
103
+
102
104
  export default {
103
105
  name: 'ElXThinking',
106
+ mixins: [Locale],
104
107
  props: {
105
108
  content: {
106
109
  type: String,
@@ -154,7 +157,9 @@
154
157
  },
155
158
  computed: {
156
159
  displayedContent() {
157
- return this.localStatus === 'error' ? '思考过程中出现错误' : this.content;
160
+ return this.localStatus === 'error'
161
+ ? this.elXt('el_x.thinking.errorContent')
162
+ : this.content;
158
163
  },
159
164
  },
160
165
  watch: {
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
  // 将组件添加到默认导出对象中
@@ -0,0 +1,97 @@
1
+ import defaultLang from './lang/zh-CN';
2
+
3
+ let lang = defaultLang;
4
+ let merged = false;
5
+ let i18nHandler = function () {
6
+ // 检查是否存在 vue-i18n@5.x (Vue.locale)
7
+ if (typeof window !== 'undefined' && window.Vue && window.Vue.locale) {
8
+ const vuei18n = window.Vue.locale;
9
+ if (typeof vuei18n === 'function') {
10
+ if (!merged) {
11
+ merged = true;
12
+ window.Vue.locale(
13
+ window.Vue.config.lang,
14
+ deepMerge(lang, window.Vue.locale(window.Vue.config.lang) || {}, { clone: true }),
15
+ );
16
+ }
17
+ return vuei18n.apply(this, arguments);
18
+ }
19
+ }
20
+
21
+ // 检查是否存在 vue-i18n@6.x+ (this.$t)
22
+ if (this && this.$t && typeof this.$t === 'function') {
23
+ try {
24
+ return this.$t.apply(this, arguments);
25
+ } catch (e) {
26
+ // 如果出错,回退到内置翻译
27
+ }
28
+ }
29
+ };
30
+
31
+ const deepMerge = function (target, source, options) {
32
+ options = options || {};
33
+ const clone = options.clone !== false;
34
+ const mergedTarget = clone ? { ...target } : target;
35
+
36
+ for (const key in source) {
37
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
38
+ const value = source[key];
39
+ if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
40
+ mergedTarget[key] = deepMerge(mergedTarget[key] || {}, value, options);
41
+ } else {
42
+ mergedTarget[key] = value;
43
+ }
44
+ }
45
+ }
46
+
47
+ return mergedTarget;
48
+ };
49
+
50
+ const t = function (path, options) {
51
+ let value = i18nHandler.apply(this, arguments);
52
+ if (value !== null && value !== undefined) return value;
53
+
54
+ const array = path.split('.');
55
+ let current = lang;
56
+
57
+ for (let i = 0, j = array.length; i < j; i++) {
58
+ const property = array[i];
59
+ value = current[property];
60
+ if (i === j - 1) return format(value, options);
61
+ if (!value) return '';
62
+ current = value;
63
+ }
64
+ return '';
65
+ };
66
+
67
+ const format = function (template, ...args) {
68
+ if (typeof template === 'function') {
69
+ return template(...args);
70
+ }
71
+
72
+ if (typeof template !== 'string') {
73
+ return template;
74
+ }
75
+
76
+ const [options] = args;
77
+ if (!options) return template;
78
+
79
+ return template.replace(/\{(\w+)\}/g, (match, key) => {
80
+ return options[key] !== undefined ? options[key] : match;
81
+ });
82
+ };
83
+
84
+ const use = function (l) {
85
+ lang = l || lang;
86
+ merged = false;
87
+ };
88
+
89
+ const i18n = function (fn) {
90
+ i18nHandler = fn || i18nHandler;
91
+ };
92
+
93
+ export default {
94
+ use,
95
+ t,
96
+ i18n,
97
+ };
@@ -0,0 +1,18 @@
1
+ export default {
2
+ el_x: {
3
+ thinking: {
4
+ start: 'ابدأ التفكير',
5
+ processing: 'جاري التفكير...',
6
+ completed: 'اكتمل التفكير',
7
+ error: 'خطأ في التفكير',
8
+ errorContent: 'حدث خطأ أثناء التفكير',
9
+ },
10
+ sender: { placeholder: 'يرجى إدخال المحتوى' },
11
+ common: {
12
+ loading: 'جاري التحميل...',
13
+ success: 'نجح',
14
+ error: 'خطأ',
15
+ warning: 'تحذير',
16
+ },
17
+ },
18
+ };
@@ -0,0 +1,18 @@
1
+ export default {
2
+ el_x: {
3
+ thinking: {
4
+ start: 'Denken beginnen',
5
+ processing: 'Denken...',
6
+ completed: 'Denken abgeschlossen',
7
+ error: 'Denkfehler',
8
+ errorContent: 'Beim Denken ist ein Fehler aufgetreten',
9
+ },
10
+ sender: { placeholder: 'Bitte geben Sie Inhalt ein' },
11
+ common: {
12
+ loading: 'Laden...',
13
+ success: 'Erfolg',
14
+ error: 'Fehler',
15
+ warning: 'Warnung',
16
+ },
17
+ },
18
+ };
@@ -0,0 +1,18 @@
1
+ export default {
2
+ el_x: {
3
+ thinking: {
4
+ start: 'Start Thinking',
5
+ processing: 'Thinking...',
6
+ completed: 'Thinking Completed',
7
+ error: 'Thinking Error',
8
+ errorContent: 'An error occurred during thinking',
9
+ },
10
+ sender: { placeholder: 'Please enter content' },
11
+ common: {
12
+ loading: 'Loading...',
13
+ success: 'Success',
14
+ error: 'Error',
15
+ warning: 'Warning',
16
+ },
17
+ },
18
+ };
@@ -0,0 +1,18 @@
1
+ export default {
2
+ el_x: {
3
+ thinking: {
4
+ start: 'Comenzar a pensar',
5
+ processing: 'Pensando...',
6
+ completed: 'Pensamiento completado',
7
+ error: 'Error de pensamiento',
8
+ errorContent: 'Ocurrió un error durante el pensamiento',
9
+ },
10
+ sender: { placeholder: 'Por favor ingrese contenido' },
11
+ common: {
12
+ loading: 'Cargando...',
13
+ success: 'Éxito',
14
+ error: 'Error',
15
+ warning: 'Advertencia',
16
+ },
17
+ },
18
+ };
@@ -0,0 +1,18 @@
1
+ export default {
2
+ el_x: {
3
+ thinking: {
4
+ start: 'Commencer à réfléchir',
5
+ processing: 'Réflexion en cours...',
6
+ completed: 'Réflexion terminée',
7
+ error: 'Erreur de réflexion',
8
+ errorContent: "Une erreur s'est produite pendant la réflexion",
9
+ },
10
+ sender: { placeholder: 'Veuillez entrer le contenu' },
11
+ common: {
12
+ loading: 'Chargement...',
13
+ success: 'Succès',
14
+ error: 'Erreur',
15
+ warning: 'Avertissement',
16
+ },
17
+ },
18
+ };
@@ -0,0 +1,62 @@
1
+ import ar from './ar';
2
+ import de from './de';
3
+ import en from './en';
4
+ import es from './es';
5
+ import fr from './fr';
6
+ import it from './it';
7
+ import ja from './ja';
8
+ import ko from './ko';
9
+ import ptBr from './pt-br';
10
+ import ruRU from './ru-RU';
11
+ import zhCN from './zh-CN';
12
+ import zhTW from './zh-TW';
13
+
14
+ export default {
15
+ // 中文
16
+ 'zh-CN': zhCN,
17
+ 'zh-cn': zhCN,
18
+ 'zh-TW': zhTW,
19
+ 'zh-tw': zhTW,
20
+
21
+ // 英文
22
+ en: en,
23
+ 'en-US': en,
24
+ 'en-GB': en,
25
+
26
+ // 日语
27
+ 'ja-JP': ja,
28
+ ja: ja,
29
+
30
+ // 韩语
31
+ 'ko-KR': ko,
32
+ ko: ko,
33
+
34
+ // 法语
35
+ 'fr-FR': fr,
36
+ fr: fr,
37
+
38
+ // 德语
39
+ 'de-DE': de,
40
+ de: de,
41
+
42
+ // 西班牙语
43
+ 'es-ES': es,
44
+ es: es,
45
+
46
+ // 俄语
47
+ 'ru-RU': ruRU,
48
+ ru: ruRU,
49
+
50
+ // 葡萄牙语
51
+ 'pt-BR': ptBr,
52
+ 'pt-br': ptBr,
53
+ pt: ptBr,
54
+
55
+ // 意大利语
56
+ 'it-IT': it,
57
+ it: it,
58
+
59
+ // 阿拉伯语
60
+ 'ar-SA': ar,
61
+ ar: ar,
62
+ };
@@ -0,0 +1,18 @@
1
+ export default {
2
+ el_x: {
3
+ thinking: {
4
+ start: 'Inizia a pensare',
5
+ processing: 'Pensando...',
6
+ completed: 'Pensiero completato',
7
+ error: 'Errore di pensiero',
8
+ errorContent: 'Si è verificato un errore durante il pensiero',
9
+ },
10
+ sender: { placeholder: 'Inserisci il contenuto' },
11
+ common: {
12
+ loading: 'Caricamento...',
13
+ success: 'Successo',
14
+ error: 'Errore',
15
+ warning: 'Avvertimento',
16
+ },
17
+ },
18
+ };
@@ -0,0 +1,18 @@
1
+ export default {
2
+ el_x: {
3
+ thinking: {
4
+ start: '思考を開始',
5
+ processing: '思考中...',
6
+ completed: '思考完了',
7
+ error: '思考エラー',
8
+ errorContent: '思考中にエラーが発生しました',
9
+ },
10
+ sender: { placeholder: '内容を入力してください' },
11
+ common: {
12
+ loading: '読み込み中...',
13
+ success: '成功',
14
+ error: 'エラー',
15
+ warning: '警告',
16
+ },
17
+ },
18
+ };
@@ -0,0 +1,18 @@
1
+ export default {
2
+ el_x: {
3
+ thinking: {
4
+ start: '생각 시작',
5
+ processing: '생각 중...',
6
+ completed: '생각 완료',
7
+ error: '생각 오류',
8
+ errorContent: '생각 중 오류가 발생했습니다',
9
+ },
10
+ sender: { placeholder: '내용을 입력하세요' },
11
+ common: {
12
+ loading: '로딩 중...',
13
+ success: '성공',
14
+ error: '오류',
15
+ warning: '경고',
16
+ },
17
+ },
18
+ };
@@ -0,0 +1,18 @@
1
+ export default {
2
+ el_x: {
3
+ thinking: {
4
+ start: 'Começar a pensar',
5
+ processing: 'Pensando...',
6
+ completed: 'Pensamento concluído',
7
+ error: 'Erro de pensamento',
8
+ errorContent: 'Ocorreu um erro durante o pensamento',
9
+ },
10
+ sender: { placeholder: 'Por favor, insira o conteúdo' },
11
+ common: {
12
+ loading: 'Carregando...',
13
+ success: 'Sucesso',
14
+ error: 'Erro',
15
+ warning: 'Aviso',
16
+ },
17
+ },
18
+ };
@@ -0,0 +1,18 @@
1
+ export default {
2
+ el_x: {
3
+ thinking: {
4
+ start: 'Начать размышление',
5
+ processing: 'Размышление...',
6
+ completed: 'Размышление завершено',
7
+ error: 'Ошибка размышления',
8
+ errorContent: 'Произошла ошибка во время размышления',
9
+ },
10
+ sender: { placeholder: 'Пожалуйста, введите содержание' },
11
+ common: {
12
+ loading: 'Загрузка...',
13
+ success: 'Успех',
14
+ error: 'Ошибка',
15
+ warning: 'Предупреждение',
16
+ },
17
+ },
18
+ };
@@ -0,0 +1,18 @@
1
+ export default {
2
+ el_x: {
3
+ thinking: {
4
+ start: '开始思考',
5
+ processing: '思考中...',
6
+ completed: '思考完成',
7
+ error: '思考遇到问题',
8
+ errorContent: '思考过程中出现错误',
9
+ },
10
+ sender: { placeholder: '请输入内容' },
11
+ common: {
12
+ loading: '加载中...',
13
+ success: '成功',
14
+ error: '错误',
15
+ warning: '警告',
16
+ },
17
+ },
18
+ };
@@ -0,0 +1,18 @@
1
+ export default {
2
+ el_x: {
3
+ thinking: {
4
+ start: '開始思考',
5
+ processing: '思考中...',
6
+ completed: '思考完成',
7
+ error: '思考遇到問題',
8
+ errorContent: '思考過程中出現錯誤',
9
+ },
10
+ sender: { placeholder: '請輸入內容' },
11
+ common: {
12
+ loading: '載入中...',
13
+ success: '成功',
14
+ error: '錯誤',
15
+ warning: '警告',
16
+ },
17
+ },
18
+ };
@@ -0,0 +1,9 @@
1
+ import Locale from './index';
2
+
3
+ export default {
4
+ methods: {
5
+ elXt(...args) {
6
+ return Locale.t.apply(this, args);
7
+ },
8
+ },
9
+ };