vue-element-ui-x 0.1.7-beta → 0.1.8-beta

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-element-ui-x",
3
- "version": "0.1.7-beta",
3
+ "version": "0.1.8-beta",
4
4
  "description": "基于Vue 2 + Element UI的AI聊天组件库",
5
5
  "main": "lib/index.esm.js",
6
6
  "module": "lib/index.umd.js",
@@ -1,195 +1,195 @@
1
- <template>
2
- <div
3
- class="el-x-thinking"
4
- :style="{
5
- '--el-x-thinking-button-width': buttonWidth,
6
- '--el-x-thinking-animation-duration': duration,
7
- '--el-x-thinking-content-wrapper-width': maxWidth,
8
- '--el-x-thinking-content-wrapper-background-color': backgroundColor,
9
- '--el-x-thinking-content-wrapper-color': color,
10
- }"
11
- >
12
- <button
13
- class="trigger"
14
- :class="[localStatus, { disabled: !disabled }]"
15
- :disabled="disabled"
16
- @click="changeExpand"
17
- >
18
- <span class="status-icon">
19
- <slot
20
- name="status-icon"
21
- :status="localStatus"
22
- >
23
- <i
24
- v-if="localStatus === 'thinking'"
25
- class="is-loading el-icon-center el-icon-loading"
26
- ></i>
27
- <i
28
- v-if="localStatus === 'start'"
29
- class="el-icon-center start-color el-icon-opportunity"
30
- ></i>
31
- <i
32
- v-if="localStatus === 'end'"
33
- class="el-icon-center end-color el-icon-success"
34
- ></i>
35
- <i
36
- v-if="localStatus === 'error'"
37
- class="el-icon-center error-color el-icon-circle-close"
38
- ></i>
39
- </slot>
40
- </span>
41
-
42
- <span class="label">
43
- <slot
44
- name="label"
45
- :status="localStatus"
46
- >
47
- {{
48
- localStatus === 'thinking'
49
- ? '思考中...'
50
- : localStatus === 'error'
51
- ? '思考遇到问题'
52
- : localStatus === 'end'
53
- ? '思考完成'
54
- : '开始思考'
55
- }}
56
- </slot>
57
- </span>
58
-
59
- <transition name="rotate">
60
- <span
61
- v-if="!disabled"
62
- class="arrow el-icon-center"
63
- :class="{ expanded: isExpanded }"
64
- >
65
- <slot name="arrow">
66
- <i class="el-icon-center el-icon-arrow-up"></i>
67
- </slot>
68
- </span>
69
- </transition>
70
- </button>
71
-
72
- <Transition name="slide">
73
- <div
74
- v-show="isExpanded"
75
- v-if="displayedContent"
76
- class="content-wrapper"
77
- :class="{ 'error-state': localStatus === 'error' }"
78
- >
79
- <div class="content">
80
- <slot
81
- v-if="localStatus !== 'error'"
82
- name="content"
83
- :content="displayedContent"
84
- >
85
- <pre>{{ displayedContent }}</pre>
86
- </slot>
87
-
88
- <slot
89
- v-else
90
- name="error"
91
- :error-content="displayedContent"
92
- >
93
- <div class="error-message">{{ displayedContent }}</div>
94
- </slot>
95
- </div>
96
- </div>
97
- </Transition>
98
- </div>
99
- </template>
100
-
101
- <script>
102
- export default {
103
- name: 'ElXThinking',
104
- props: {
105
- content: {
106
- type: String,
107
- default: '',
108
- },
109
- modelValue: {
110
- type: Boolean,
111
- default: true,
112
- },
113
- status: {
114
- type: String,
115
- default: 'start',
116
- validator: function (value) {
117
- return ['start', 'thinking', 'end', 'error'].indexOf(value) !== -1;
118
- },
119
- },
120
- disabled: {
121
- type: Boolean,
122
- default: false,
123
- },
124
- autoCollapse: {
125
- type: Boolean,
126
- default: false,
127
- },
128
- buttonWidth: {
129
- type: String,
130
- default: '160px',
131
- },
132
- duration: {
133
- type: String,
134
- default: '0.2s',
135
- },
136
- maxWidth: {
137
- type: String,
138
- default: '500px',
139
- },
140
- backgroundColor: {
141
- type: String,
142
- default: '#fcfcfc',
143
- },
144
- color: {
145
- type: String,
146
- default: '#909399',
147
- },
148
- },
149
- data() {
150
- return {
151
- isExpanded: this.modelValue,
152
- localStatus: this.status,
153
- };
154
- },
155
- computed: {
156
- displayedContent() {
157
- return this.localStatus === 'error' ? '思考过程中出现错误' : this.content;
158
- },
159
- },
160
- watch: {
161
- modelValue(newVal) {
162
- this.isExpanded = newVal;
163
- },
164
- status(newVal) {
165
- this.localStatus = newVal;
166
- if (newVal === 'end' && this.autoCollapse) {
167
- this.isExpanded = false;
168
- }
169
- },
170
- $attrs: {
171
- handler(newVal) {
172
- if (newVal['onUpdate:status']) {
173
- this.$emit('update:status', this.localStatus);
174
- }
175
- },
176
- immediate: true,
177
- },
178
- },
179
- methods: {
180
- changeExpand() {
181
- if (this.disabled) return;
182
- this.isExpanded = !this.isExpanded;
183
- this.$emit('change', {
184
- value: this.isExpanded,
185
- status: this.localStatus,
186
- });
187
- this.$emit('update:expanded', this.isExpanded);
188
- },
189
- },
190
- };
191
- </script>
192
-
193
- <style lang="scss" scoped>
194
- @import '../../../styles/Thinking.scss';
195
- </style>
1
+ <template>
2
+ <div
3
+ class="el-x-thinking"
4
+ :style="{
5
+ '--el-x-thinking-button-width': buttonWidth,
6
+ '--el-x-thinking-animation-duration': duration,
7
+ '--el-x-thinking-content-wrapper-width': maxWidth,
8
+ '--el-x-thinking-content-wrapper-background-color': backgroundColor,
9
+ '--el-x-thinking-content-wrapper-color': color,
10
+ }"
11
+ >
12
+ <button
13
+ class="trigger"
14
+ :class="[localStatus, { disabled: !disabled }]"
15
+ :disabled="disabled"
16
+ @click="changeExpand"
17
+ >
18
+ <span class="status-icon">
19
+ <slot
20
+ name="status-icon"
21
+ :status="localStatus"
22
+ >
23
+ <i
24
+ v-if="localStatus === 'thinking'"
25
+ class="is-loading el-icon-center el-icon-loading"
26
+ ></i>
27
+ <i
28
+ v-if="localStatus === 'start'"
29
+ class="el-icon-center start-color el-icon-opportunity"
30
+ ></i>
31
+ <i
32
+ v-if="localStatus === 'end'"
33
+ class="el-icon-center end-color el-icon-success"
34
+ ></i>
35
+ <i
36
+ v-if="localStatus === 'error'"
37
+ class="el-icon-center error-color el-icon-circle-close"
38
+ ></i>
39
+ </slot>
40
+ </span>
41
+
42
+ <span class="label">
43
+ <slot
44
+ name="label"
45
+ :status="localStatus"
46
+ >
47
+ {{
48
+ localStatus === 'thinking'
49
+ ? '思考中...'
50
+ : localStatus === 'error'
51
+ ? '思考遇到问题'
52
+ : localStatus === 'end'
53
+ ? '思考完成'
54
+ : '开始思考'
55
+ }}
56
+ </slot>
57
+ </span>
58
+
59
+ <transition name="rotate">
60
+ <span
61
+ v-if="!disabled"
62
+ class="thinking-arrow el-icon-center"
63
+ :class="{ expanded: isExpanded }"
64
+ >
65
+ <slot name="arrow">
66
+ <i class="el-icon-center el-icon-arrow-up"></i>
67
+ </slot>
68
+ </span>
69
+ </transition>
70
+ </button>
71
+
72
+ <Transition name="slide">
73
+ <div
74
+ v-show="isExpanded"
75
+ v-if="displayedContent"
76
+ class="content-wrapper"
77
+ :class="{ 'error-state': localStatus === 'error' }"
78
+ >
79
+ <div class="content">
80
+ <slot
81
+ v-if="localStatus !== 'error'"
82
+ name="content"
83
+ :content="displayedContent"
84
+ >
85
+ <pre>{{ displayedContent }}</pre>
86
+ </slot>
87
+
88
+ <slot
89
+ v-else
90
+ name="error"
91
+ :error-content="displayedContent"
92
+ >
93
+ <div class="error-message">{{ displayedContent }}</div>
94
+ </slot>
95
+ </div>
96
+ </div>
97
+ </Transition>
98
+ </div>
99
+ </template>
100
+
101
+ <script>
102
+ export default {
103
+ name: 'ElXThinking',
104
+ props: {
105
+ content: {
106
+ type: String,
107
+ default: '',
108
+ },
109
+ modelValue: {
110
+ type: Boolean,
111
+ default: true,
112
+ },
113
+ status: {
114
+ type: String,
115
+ default: 'start',
116
+ validator: function (value) {
117
+ return ['start', 'thinking', 'end', 'error'].indexOf(value) !== -1;
118
+ },
119
+ },
120
+ disabled: {
121
+ type: Boolean,
122
+ default: false,
123
+ },
124
+ autoCollapse: {
125
+ type: Boolean,
126
+ default: false,
127
+ },
128
+ buttonWidth: {
129
+ type: String,
130
+ default: '160px',
131
+ },
132
+ duration: {
133
+ type: String,
134
+ default: '0.2s',
135
+ },
136
+ maxWidth: {
137
+ type: String,
138
+ default: '500px',
139
+ },
140
+ backgroundColor: {
141
+ type: String,
142
+ default: '#fcfcfc',
143
+ },
144
+ color: {
145
+ type: String,
146
+ default: '#909399',
147
+ },
148
+ },
149
+ data() {
150
+ return {
151
+ isExpanded: this.modelValue,
152
+ localStatus: this.status,
153
+ };
154
+ },
155
+ computed: {
156
+ displayedContent() {
157
+ return this.localStatus === 'error' ? '思考过程中出现错误' : this.content;
158
+ },
159
+ },
160
+ watch: {
161
+ modelValue(newVal) {
162
+ this.isExpanded = newVal;
163
+ },
164
+ status(newVal) {
165
+ this.localStatus = newVal;
166
+ if (newVal === 'end' && this.autoCollapse) {
167
+ this.isExpanded = false;
168
+ }
169
+ },
170
+ $attrs: {
171
+ handler(newVal) {
172
+ if (newVal['onUpdate:status']) {
173
+ this.$emit('update:status', this.localStatus);
174
+ }
175
+ },
176
+ immediate: true,
177
+ },
178
+ },
179
+ methods: {
180
+ changeExpand() {
181
+ if (this.disabled) return;
182
+ this.isExpanded = !this.isExpanded;
183
+ this.$emit('change', {
184
+ value: this.isExpanded,
185
+ status: this.localStatus,
186
+ });
187
+ this.$emit('update:expanded', this.isExpanded);
188
+ },
189
+ },
190
+ };
191
+ </script>
192
+
193
+ <style lang="scss" scoped>
194
+ @import '../../../styles/Thinking.scss';
195
+ </style>
@@ -1,112 +1,112 @@
1
- @import '../theme/var';
2
-
3
- .el-x-thinking {
4
- margin: 0 auto;
5
- }
6
-
7
- .trigger {
8
- display: flex;
9
- align-items: center;
10
- height: 100%;
11
- width: var(--el-x-thinking-button-width);
12
- gap: $--el-x-spacing-xs;
13
- padding: $--el-x-padding-sm calc($--el-x-padding-sm + 4px);
14
- border: $--el-x-border-width $--border-style-base $--el-x-border-color;
15
- border-radius: $--el-x-border-radius-md;
16
- background: $--color-white;
17
- cursor: pointer;
18
- margin-bottom: $--el-x-spacing-xs;
19
-
20
- .el-icon-center {
21
- height: 100%;
22
- display: flex;
23
- align-items: center;
24
- }
25
-
26
- .start-color {
27
- color: $--color-warning;
28
- }
29
-
30
- .end-color {
31
- color: $--color-success;
32
- }
33
-
34
- .is-loading {
35
- color: $--el-x-color-primary;
36
- }
37
-
38
- .error-color {
39
- color: $--color-danger;
40
- }
41
- }
42
-
43
- .trigger:hover {
44
- background: $--background-color-base;
45
- }
46
-
47
- .trigger.disabled {
48
- cursor: pointer;
49
- }
50
-
51
- .trigger:disabled {
52
- cursor: not-allowed;
53
- opacity: 0.7;
54
- }
55
-
56
- .status-icon {
57
- font-size: $--el-x-font-size-medium;
58
- }
59
-
60
- .arrow {
61
- margin-left: auto;
62
- transition: transform var(--el-x-thinking-animation-duration);
63
- }
64
-
65
- .arrow.expanded {
66
- transform: rotate(180deg);
67
- }
68
-
69
- .slide-enter-active,
70
- .slide-leave-active {
71
- height: max-content;
72
- transition: height var(--el-x-thinking-animation-duration) ease-in-out,
73
- opacity var(--el-x-thinking-animation-duration) ease-in-out;
74
- overflow: hidden;
75
- }
76
-
77
- .slide-enter-from,
78
- .slide-leave-to {
79
- height: 0 !important;
80
- opacity: 0;
81
- }
82
-
83
- .content-wrapper {
84
- box-sizing: border-box;
85
- min-width: 0;
86
- }
87
-
88
- .content pre {
89
- border: $--el-x-border-width $--border-style-base $--el-x-border-color;
90
- background: var(--el-x-thinking-content-wrapper-background-color);
91
- padding: $--el-x-padding-sm calc($--el-x-padding-sm + 4px);
92
- border-radius: $--el-x-border-radius-lg;
93
- max-width: var(--el-x-thinking-content-wrapper-width);
94
- font-size: $--el-x-font-size-base;
95
- color: var(--el-x-thinking-content-wrapper-color);
96
- white-space: pre-wrap;
97
- margin: 0;
98
- line-height: $--el-x-font-line-height-primary;
99
- }
100
-
101
- .error-state {
102
- border-color: $--color-danger-lighter;
103
- background: $--color-danger-lighter;
104
- }
105
-
106
- .error-message {
107
- color: $--color-danger;
108
- height: fit-content;
109
- padding: $--el-x-spacing-xs;
110
- background: $--color-danger-lighter;
111
- border-radius: $--el-x-border-radius-md;
112
- }
1
+ @import '../theme/var';
2
+
3
+ .el-x-thinking {
4
+ margin: 0 auto;
5
+ }
6
+
7
+ .trigger {
8
+ display: flex;
9
+ align-items: center;
10
+ height: 100%;
11
+ width: var(--el-x-thinking-button-width);
12
+ gap: $--el-x-spacing-xs;
13
+ padding: $--el-x-padding-sm calc($--el-x-padding-sm + 4px);
14
+ border: $--el-x-border-width $--border-style-base $--el-x-border-color;
15
+ border-radius: $--el-x-border-radius-md;
16
+ background: $--color-white;
17
+ cursor: pointer;
18
+ margin-bottom: $--el-x-spacing-xs;
19
+
20
+ .el-icon-center {
21
+ height: 100%;
22
+ display: flex;
23
+ align-items: center;
24
+ }
25
+
26
+ .start-color {
27
+ color: $--color-warning;
28
+ }
29
+
30
+ .end-color {
31
+ color: $--color-success;
32
+ }
33
+
34
+ .is-loading {
35
+ color: $--el-x-color-primary;
36
+ }
37
+
38
+ .error-color {
39
+ color: $--color-danger;
40
+ }
41
+ }
42
+
43
+ .trigger:hover {
44
+ background: $--background-color-base;
45
+ }
46
+
47
+ .trigger.disabled {
48
+ cursor: pointer;
49
+ }
50
+
51
+ .trigger:disabled {
52
+ cursor: not-allowed;
53
+ opacity: 0.7;
54
+ }
55
+
56
+ .status-icon {
57
+ font-size: $--el-x-font-size-medium;
58
+ }
59
+
60
+ .thinking-arrow {
61
+ margin-left: auto;
62
+ transition: transform var(--el-x-thinking-animation-duration);
63
+ }
64
+
65
+ .thinking-arrow.expanded {
66
+ transform: rotate(180deg);
67
+ }
68
+
69
+ .slide-enter-active,
70
+ .slide-leave-active {
71
+ height: max-content;
72
+ transition: height var(--el-x-thinking-animation-duration) ease-in-out,
73
+ opacity var(--el-x-thinking-animation-duration) ease-in-out;
74
+ overflow: hidden;
75
+ }
76
+
77
+ .slide-enter-from,
78
+ .slide-leave-to {
79
+ height: 0 !important;
80
+ opacity: 0;
81
+ }
82
+
83
+ .content-wrapper {
84
+ box-sizing: border-box;
85
+ min-width: 0;
86
+ }
87
+
88
+ .content pre {
89
+ border: $--el-x-border-width $--border-style-base $--el-x-border-color;
90
+ background: var(--el-x-thinking-content-wrapper-background-color);
91
+ padding: $--el-x-padding-sm calc($--el-x-padding-sm + 4px);
92
+ border-radius: $--el-x-border-radius-lg;
93
+ max-width: var(--el-x-thinking-content-wrapper-width);
94
+ font-size: $--el-x-font-size-base;
95
+ color: var(--el-x-thinking-content-wrapper-color);
96
+ white-space: pre-wrap;
97
+ margin: 0;
98
+ line-height: $--el-x-font-line-height-primary;
99
+ }
100
+
101
+ .error-state {
102
+ border-color: $--color-danger-lighter;
103
+ background: $--color-danger-lighter;
104
+ }
105
+
106
+ .error-message {
107
+ color: $--color-danger;
108
+ height: fit-content;
109
+ padding: $--el-x-spacing-xs;
110
+ background: $--color-danger-lighter;
111
+ border-radius: $--el-x-border-radius-md;
112
+ }