vue-element-ui-x 1.0.3 → 1.0.5

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 (121) hide show
  1. package/README.md +20 -9
  2. package/components.json +13 -0
  3. package/lib/components/Attachments/index.js +987 -995
  4. package/lib/components/Bubble/index.js +10656 -10705
  5. package/lib/components/BubbleList/index.js +10951 -11038
  6. package/lib/components/Conversations/index.js +14026 -14063
  7. package/lib/components/FilesCard/index.js +606 -614
  8. package/lib/components/Prompts/index.js +457 -470
  9. package/lib/components/Sender/index.js +1701 -1678
  10. package/lib/components/Thinking/index.js +695 -703
  11. package/lib/components/ThoughtChain/index.js +24795 -24851
  12. package/lib/components/Typewriter/index.js +10247 -10302
  13. package/lib/components/Welcome/index.js +357 -370
  14. package/lib/index.common.js +1 -1
  15. package/lib/index.esm.js +1 -1
  16. package/lib/index.js +32189 -32214
  17. package/lib/index.umd.js +1 -1
  18. package/lib/mixins/index.js +61 -116
  19. package/package.json +20 -7
  20. package/lib/locale/lang/ar-SA.js +0 -18
  21. package/lib/locale/lang/ar-SA.umd.js +0 -26
  22. package/lib/locale/lang/de-DE.js +0 -18
  23. package/lib/locale/lang/de-DE.umd.js +0 -26
  24. package/lib/locale/lang/es-ES.js +0 -18
  25. package/lib/locale/lang/es-ES.umd.js +0 -26
  26. package/lib/locale/lang/fr-FR.js +0 -18
  27. package/lib/locale/lang/fr-FR.umd.js +0 -26
  28. package/lib/locale/lang/it-IT.js +0 -18
  29. package/lib/locale/lang/it-IT.umd.js +0 -26
  30. package/lib/locale/lang/ja-JP.js +0 -18
  31. package/lib/locale/lang/ja-JP.umd.js +0 -26
  32. package/lib/locale/lang/ko-KR.js +0 -18
  33. package/lib/locale/lang/ko-KR.umd.js +0 -26
  34. package/src/components/Attachments/index.js +0 -8
  35. package/src/components/Attachments/src/main.vue +0 -529
  36. package/src/components/Bubble/index.js +0 -6
  37. package/src/components/Bubble/src/main.vue +0 -288
  38. package/src/components/BubbleList/index.js +0 -8
  39. package/src/components/BubbleList/src/loading.vue +0 -75
  40. package/src/components/BubbleList/src/main.vue +0 -444
  41. package/src/components/Conversations/index.js +0 -8
  42. package/src/components/Conversations/src/components/item.vue +0 -350
  43. package/src/components/Conversations/src/main.vue +0 -587
  44. package/src/components/FilesCard/index.js +0 -8
  45. package/src/components/FilesCard/src/fileSvg/audio.vue +0 -38
  46. package/src/components/FilesCard/src/fileSvg/changeFileName.bat +0 -18
  47. package/src/components/FilesCard/src/fileSvg/code.vue +0 -35
  48. package/src/components/FilesCard/src/fileSvg/database.vue +0 -94
  49. package/src/components/FilesCard/src/fileSvg/excel.vue +0 -38
  50. package/src/components/FilesCard/src/fileSvg/file.vue +0 -40
  51. package/src/components/FilesCard/src/fileSvg/image.vue +0 -40
  52. package/src/components/FilesCard/src/fileSvg/index.js +0 -46
  53. package/src/components/FilesCard/src/fileSvg/link.vue +0 -54
  54. package/src/components/FilesCard/src/fileSvg/mark.vue +0 -38
  55. package/src/components/FilesCard/src/fileSvg/pdf.vue +0 -38
  56. package/src/components/FilesCard/src/fileSvg/ppt.vue +0 -38
  57. package/src/components/FilesCard/src/fileSvg/three.vue +0 -38
  58. package/src/components/FilesCard/src/fileSvg/txt.vue +0 -38
  59. package/src/components/FilesCard/src/fileSvg/unknown.vue +0 -54
  60. package/src/components/FilesCard/src/fileSvg/video.vue +0 -38
  61. package/src/components/FilesCard/src/fileSvg/word.vue +0 -38
  62. package/src/components/FilesCard/src/fileSvg/zip.vue +0 -38
  63. package/src/components/FilesCard/src/main.vue +0 -401
  64. package/src/components/FilesCard/src/options.js +0 -18
  65. package/src/components/Prompts/index.js +0 -8
  66. package/src/components/Prompts/src/main.vue +0 -248
  67. package/src/components/Sender/index.js +0 -8
  68. package/src/components/Sender/src/components/ClearButton.vue +0 -28
  69. package/src/components/Sender/src/components/Loading.vue +0 -53
  70. package/src/components/Sender/src/components/LoadingButton.vue +0 -37
  71. package/src/components/Sender/src/components/SendButton.vue +0 -26
  72. package/src/components/Sender/src/components/SpeechButton.vue +0 -24
  73. package/src/components/Sender/src/components/SpeechLoading.vue +0 -87
  74. package/src/components/Sender/src/components/SpeechLoadingButton.vue +0 -41
  75. package/src/components/Sender/src/main.vue +0 -769
  76. package/src/components/Thinking/index.js +0 -8
  77. package/src/components/Thinking/src/main.vue +0 -199
  78. package/src/components/ThoughtChain/index.js +0 -8
  79. package/src/components/ThoughtChain/src/main.vue +0 -291
  80. package/src/components/Typewriter/index.js +0 -8
  81. package/src/components/Typewriter/src/main.vue +0 -255
  82. package/src/components/Welcome/index.js +0 -8
  83. package/src/components/Welcome/src/main.vue +0 -151
  84. package/src/index.js +0 -106
  85. package/src/locale/index.js +0 -97
  86. package/src/locale/lang/ar.js +0 -18
  87. package/src/locale/lang/de.js +0 -18
  88. package/src/locale/lang/en.js +0 -18
  89. package/src/locale/lang/es.js +0 -18
  90. package/src/locale/lang/fr.js +0 -18
  91. package/src/locale/lang/index.js +0 -62
  92. package/src/locale/lang/it.js +0 -18
  93. package/src/locale/lang/ja.js +0 -18
  94. package/src/locale/lang/ko.js +0 -18
  95. package/src/locale/lang/pt-br.js +0 -18
  96. package/src/locale/lang/ru-RU.js +0 -18
  97. package/src/locale/lang/zh-CN.js +0 -18
  98. package/src/locale/lang/zh-TW.js +0 -18
  99. package/src/locale/mixin.js +0 -9
  100. package/src/mixins/index.js +0 -49
  101. package/src/mixins/recordMixin.js +0 -117
  102. package/src/mixins/sendMixin.js +0 -450
  103. package/src/mixins/streamMixin.js +0 -497
  104. package/src/styles/Attachments.scss +0 -236
  105. package/src/styles/Bubble.scss +0 -158
  106. package/src/styles/BubbleList.scss +0 -148
  107. package/src/styles/Conversations.scss +0 -283
  108. package/src/styles/FilesCard.scss +0 -222
  109. package/src/styles/Prompts.scss +0 -197
  110. package/src/styles/Sender.scss +0 -207
  111. package/src/styles/Thinking.scss +0 -142
  112. package/src/styles/ThoughtChain.scss +0 -113
  113. package/src/styles/Typewriter.scss +0 -66
  114. package/src/styles/Welcome.scss +0 -283
  115. package/src/styles/button.scss +0 -302
  116. package/src/styles/var.scss +0 -1051
  117. package/src/theme/var.scss +0 -183
  118. package/src/utils/index.js +0 -199
  119. package/src/utils/scrollDetector.js +0 -34
  120. /package/lib/locale/lang/{pt-BR.js → pt-br.js} +0 -0
  121. /package/lib/locale/lang/{pt-BR.umd.js → pt-br.umd.js} +0 -0
@@ -1,255 +0,0 @@
1
- <template>
2
- <div
3
- ref="typeWriterRef"
4
- class="typer-container"
5
- >
6
- <div
7
- ref="markdownContentRef"
8
- class="typer-content"
9
- :class="[
10
- {
11
- 'markdown-content': isMarkdown,
12
- 'typing-cursor': typing && mergedConfig.suffix && isTyping,
13
- 'typing-cursor-foggy': isFog && typing && mergedConfig.suffix && isTyping,
14
- 'typing-markdown-cursor-foggy': isMarkdown && isFog && typing && isTyping,
15
- },
16
- isMarkdown ? 'markdown-body' : '',
17
- ]"
18
- :style="{
19
- '--cursor-char': `'${mergedConfig.suffix}'`,
20
- '--cursor-fog-bg-color': isFog
21
- ? typeof isFog === 'object'
22
- ? isFog.bgColor || '#ffffff'
23
- : '#ffffff'
24
- : '',
25
- '--cursor-fog-width': isFog
26
- ? typeof isFog === 'object'
27
- ? isFog.width || '80px'
28
- : '80px'
29
- : '',
30
- }"
31
- v-html="renderedContent"
32
- />
33
- </div>
34
- </template>
35
-
36
- <script>
37
- import DOMPurify from 'dompurify';
38
- import MarkdownIt from 'markdown-it';
39
- import Prism from 'prismjs';
40
-
41
- export default {
42
- name: 'ElXTypewriter',
43
- props: {
44
- content: {
45
- type: String,
46
- default: '',
47
- },
48
- isMarkdown: {
49
- type: Boolean,
50
- default: false,
51
- },
52
- typing: {
53
- type: [Boolean, Object],
54
- default: false,
55
- },
56
- isFog: {
57
- type: [Boolean, Object],
58
- default: false,
59
- },
60
- highlight: Function,
61
- mdPlugins: Array,
62
- },
63
- data() {
64
- return {
65
- isTyping: false,
66
- typingIndex: 0,
67
- contentCache: '',
68
- timer: null,
69
- md: new MarkdownIt({
70
- html: true,
71
- linkify: true,
72
- typographer: true,
73
- breaks: true,
74
- highlight: (code, lang) => {
75
- try {
76
- const grammar = Prism.languages[lang];
77
- if (grammar) {
78
- const highlighted = Prism.highlight(code, grammar, lang);
79
- return highlighted;
80
- }
81
- return code;
82
- } catch {
83
- return code;
84
- }
85
- },
86
- }),
87
- };
88
- },
89
- computed: {
90
- mergedConfig() {
91
- const defaultConfig = {
92
- step:
93
- typeof this.typing === 'object'
94
- ? this.typing.step !== undefined
95
- ? this.typing.step
96
- : 2
97
- : 2,
98
- interval:
99
- typeof this.typing === 'object'
100
- ? this.typing.interval !== undefined
101
- ? this.typing.interval
102
- : 50
103
- : 50,
104
- suffix: this.isMarkdown
105
- ? ''
106
- : typeof this.typing === 'object'
107
- ? this.typing.suffix !== undefined
108
- ? this.typing.suffix
109
- : '|'
110
- : '|',
111
- };
112
- return defaultConfig;
113
- },
114
- processedContent() {
115
- if (!this.content) return '';
116
- if (!this.typing) return this.content;
117
- return this.contentCache.slice(0, this.typingIndex);
118
- },
119
- typingProgress() {
120
- return this.contentCache
121
- ? Math.min((this.typingIndex / this.contentCache.length) * 100, 100)
122
- : 0;
123
- },
124
- renderedContent() {
125
- if (!this.isMarkdown) return this.processedContent;
126
- return DOMPurify.sanitize(this.md.render(this.processedContent));
127
- },
128
- },
129
- watch: {
130
- content: {
131
- immediate: true,
132
- handler(newVal, oldVal) {
133
- if (!this.typing) {
134
- this.typingIndex = (newVal && newVal.length) || 0;
135
- this.isTyping = false;
136
- this.contentCache = newVal || '';
137
- return;
138
- }
139
-
140
- // 流式更新优化:如果新内容是旧内容的扩展,则不重置
141
- if (oldVal && newVal && newVal.startsWith(oldVal)) {
142
- // 增量更新,只更新缓存,不重置打字状态
143
- this.contentCache = newVal;
144
- // 如果当前没在打字,且有新内容,继续打字
145
- if (!this.isTyping && this.typingIndex < newVal.length) {
146
- this.startTyping();
147
- }
148
- } else if (!oldVal || newVal !== oldVal) {
149
- // 完全不同的内容才重置
150
- this.contentCache = newVal || '';
151
- if (!this.isTyping) {
152
- this.typingIndex = 0;
153
- this.startTyping();
154
- }
155
- }
156
- },
157
- },
158
- },
159
- mounted() {
160
- this.initMarkdownPlugins();
161
- this.$nextTick(() => {
162
- Prism.highlightAll();
163
- });
164
- },
165
- beforeDestroy() {
166
- this.destroy();
167
- },
168
- methods: {
169
- initMarkdownPlugins() {
170
- if (this.mdPlugins && this.mdPlugins.length) {
171
- this.mdPlugins.forEach(plugin => {
172
- this.md.use(plugin);
173
- });
174
- }
175
- },
176
- startTyping() {
177
- clearTimeout(this.timer);
178
-
179
- if (!this.typing || !this.contentCache) return;
180
-
181
- this.isTyping = true;
182
- this.$emit('start', this.getInstance());
183
-
184
- const typeNext = () => {
185
- this.typingIndex += this.mergedConfig.step;
186
- this.$emit('writing', this.getInstance());
187
-
188
- if (this.typingIndex >= this.contentCache.length) {
189
- this.finishTyping();
190
- return;
191
- }
192
-
193
- this.timer = setTimeout(typeNext, this.mergedConfig.interval);
194
- };
195
-
196
- this.timer = setTimeout(typeNext, this.mergedConfig.interval);
197
- },
198
- finishTyping() {
199
- this.isTyping = false;
200
- this.typingIndex = this.contentCache.length;
201
- this.$emit('finish', this.getInstance());
202
- },
203
- interrupt() {
204
- clearTimeout(this.timer);
205
- this.isTyping = false;
206
- // 保留当前打字进度不重置
207
- this.$emit('interrupt', this.getInstance());
208
- },
209
- continueTyping() {
210
- if (this.typingIndex < this.contentCache.length) {
211
- this.isTyping = true;
212
- this.$emit('continue', this.getInstance());
213
- this.startTyping();
214
- }
215
- },
216
- restart() {
217
- clearTimeout(this.timer);
218
- this.typingIndex = 0;
219
- this.isTyping = true;
220
- this.$emit('restart', this.getInstance());
221
- this.$nextTick(() => {
222
- this.startTyping();
223
- });
224
- },
225
- destroy() {
226
- clearTimeout(this.timer);
227
- this.timer = null;
228
- this.typingIndex = 0;
229
- this.isTyping = false;
230
- },
231
- getInstance() {
232
- return {
233
- interrupt: this.interrupt,
234
- continue: this.continueTyping,
235
- restart: this.restart,
236
- destroy: this.destroy,
237
- renderedContent: this.renderedContent,
238
- isTyping: this.isTyping,
239
- progress: this.typingProgress,
240
- };
241
- },
242
- },
243
- };
244
- </script>
245
-
246
- <style lang="scss" scoped>
247
- @import '../../../styles/Typewriter.scss';
248
- @import 'prismjs/themes/prism.css';
249
- // You can also use other themes from prismjs like:
250
- // @import 'prismjs/themes/prism-coy.css';
251
- // @import 'prismjs/themes/prism-dark.css';
252
- // @import 'prismjs/themes/prism-okaidia.css';
253
- // @import 'prismjs/themes/prism-tomorrow.css';
254
- // @import 'prismjs/themes/prism-twilight.css';
255
- </style>
@@ -1,8 +0,0 @@
1
- import ElXWelcome from './src/main.vue';
2
-
3
- /* istanbul ignore next */
4
- ElXWelcome.install = function (Vue) {
5
- Vue.component(ElXWelcome.name, ElXWelcome);
6
- };
7
-
8
- export default ElXWelcome;
@@ -1,151 +0,0 @@
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 DELETED
@@ -1,106 +0,0 @@
1
- import ElXAttachments from './components/Attachments/index.js';
2
- import ElXBubble from './components/Bubble/index.js';
3
- import ElXBubbleList from './components/BubbleList/index.js';
4
- import ElXConversations from './components/Conversations/index.js';
5
- import ElXFilesCard from './components/FilesCard/index.js';
6
- import ElXPrompts from './components/Prompts/index.js';
7
- import ElXSender from './components/Sender/index.js';
8
- import ElXThinking from './components/Thinking/index.js';
9
- import ElXThoughtChain from './components/ThoughtChain/index.js';
10
- import ElXTypewriter from './components/Typewriter/index.js';
11
- import ElXWelcome from './components/Welcome/index.js';
12
- // 导入所有 mixins
13
- import * as customMixins from './mixins';
14
- import {
15
- createSendUtils,
16
- createStreamUtils,
17
- recordMixin,
18
- sendMixin,
19
- streamMixin,
20
- XRequest,
21
- XStream,
22
- } from './mixins';
23
- // 导入国际化功能
24
- import locale from './locale';
25
- import lang from './locale/lang';
26
-
27
- const components = [
28
- ElXTypewriter,
29
- ElXBubble,
30
- ElXBubbleList,
31
- ElXPrompts,
32
- ElXConversations,
33
- ElXThinking,
34
- ElXThoughtChain,
35
- ElXSender,
36
- ElXFilesCard,
37
- ElXAttachments,
38
- ElXWelcome,
39
- ];
40
-
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
-
50
- components.forEach(component => {
51
- Vue.component(component.name, component);
52
- });
53
- };
54
-
55
- // 具名导出(按需引入)- 组件和Mixins
56
- export {
57
- // Mixins
58
- createSendUtils,
59
- createStreamUtils,
60
- customMixins,
61
- // 组件
62
- ElXAttachments,
63
- ElXBubble,
64
- ElXBubbleList,
65
- ElXConversations,
66
- ElXFilesCard,
67
- ElXPrompts,
68
- ElXSender,
69
- ElXThinking,
70
- ElXThoughtChain,
71
- ElXTypewriter,
72
- ElXWelcome,
73
- lang,
74
- // 国际化
75
- locale,
76
- recordMixin,
77
- sendMixin,
78
- streamMixin,
79
- XRequest,
80
- XStream,
81
- };
82
-
83
- // 默认导出(完整引入)
84
- const ElementUIX = {
85
- version: '0.2.2',
86
- install,
87
- locale,
88
- lang,
89
- };
90
-
91
- // 将组件添加到默认导出对象中
92
- components.forEach(component => {
93
- ElementUIX[component.name] = component;
94
- });
95
-
96
- // 添加mixins
97
- ElementUIX.customMixins = customMixins;
98
- ElementUIX.streamMixin = streamMixin;
99
- ElementUIX.sendMixin = sendMixin;
100
- ElementUIX.recordMixin = recordMixin;
101
- ElementUIX.createStreamUtils = createStreamUtils;
102
- ElementUIX.createSendUtils = createSendUtils;
103
- ElementUIX.XRequest = XRequest;
104
- ElementUIX.XStream = XStream;
105
-
106
- export default ElementUIX;
@@ -1,97 +0,0 @@
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
- };
@@ -1,18 +0,0 @@
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
- };
@@ -1,18 +0,0 @@
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
- };
@@ -1,18 +0,0 @@
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
- };
@@ -1,18 +0,0 @@
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
- };