Skip to content

Commit 1254afa

Browse files
committed
feat: 修改 Sender和MentionSender
1 parent baaed5a commit 1254afa

File tree

7 files changed

+141
-24
lines changed

7 files changed

+141
-24
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* eslint-disable */
2+
// @ts-nocheck
3+
// Generated by unplugin-vue-components
4+
// Read more: https://github.com/vuejs/core/pull/3399
5+
// biome-ignore lint: disable
6+
export {}
7+
8+
/* prettier-ignore */
9+
declare module 'vue' {
10+
export interface GlobalComponents {
11+
ElAvatar: typeof import('element-plus/es')['ElAvatar']
12+
ElButton: typeof import('element-plus/es')['ElButton']
13+
ElCollapse: typeof import('element-plus/es')['ElCollapse']
14+
ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem']
15+
ElIcon: typeof import('element-plus/es')['ElIcon']
16+
ElImage: typeof import('element-plus/es')['ElImage']
17+
ElInput: typeof import('element-plus/es')['ElInput']
18+
ElMention: typeof import('element-plus/es')['ElMention']
19+
ElPopover: typeof import('element-plus/es')['ElPopover']
20+
ElTimeline: typeof import('element-plus/es')['ElTimeline']
21+
ElTimelineItem: typeof import('element-plus/es')['ElTimelineItem']
22+
}
23+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/* eslint-disable */
2+
/* prettier-ignore */
3+
// @ts-nocheck
4+
// noinspection JSUnusedGlobalSymbols
5+
// Generated by unplugin-auto-import
6+
// biome-ignore lint: disable
7+
export {}
8+
declare global {
9+
const EffectScope: typeof import('vue')['EffectScope']
10+
const computed: typeof import('vue')['computed']
11+
const createApp: typeof import('vue')['createApp']
12+
const customRef: typeof import('vue')['customRef']
13+
const defineAsyncComponent: typeof import('vue')['defineAsyncComponent']
14+
const defineComponent: typeof import('vue')['defineComponent']
15+
const effectScope: typeof import('vue')['effectScope']
16+
const getCurrentInstance: typeof import('vue')['getCurrentInstance']
17+
const getCurrentScope: typeof import('vue')['getCurrentScope']
18+
const h: typeof import('vue')['h']
19+
const inject: typeof import('vue')['inject']
20+
const isProxy: typeof import('vue')['isProxy']
21+
const isReactive: typeof import('vue')['isReactive']
22+
const isReadonly: typeof import('vue')['isReadonly']
23+
const isRef: typeof import('vue')['isRef']
24+
const markRaw: typeof import('vue')['markRaw']
25+
const nextTick: typeof import('vue')['nextTick']
26+
const onActivated: typeof import('vue')['onActivated']
27+
const onBeforeMount: typeof import('vue')['onBeforeMount']
28+
const onBeforeUnmount: typeof import('vue')['onBeforeUnmount']
29+
const onBeforeUpdate: typeof import('vue')['onBeforeUpdate']
30+
const onDeactivated: typeof import('vue')['onDeactivated']
31+
const onErrorCaptured: typeof import('vue')['onErrorCaptured']
32+
const onMounted: typeof import('vue')['onMounted']
33+
const onRenderTracked: typeof import('vue')['onRenderTracked']
34+
const onRenderTriggered: typeof import('vue')['onRenderTriggered']
35+
const onScopeDispose: typeof import('vue')['onScopeDispose']
36+
const onServerPrefetch: typeof import('vue')['onServerPrefetch']
37+
const onUnmounted: typeof import('vue')['onUnmounted']
38+
const onUpdated: typeof import('vue')['onUpdated']
39+
const onWatcherCleanup: typeof import('vue')['onWatcherCleanup']
40+
const provide: typeof import('vue')['provide']
41+
const reactive: typeof import('vue')['reactive']
42+
const readonly: typeof import('vue')['readonly']
43+
const ref: typeof import('vue')['ref']
44+
const resolveComponent: typeof import('vue')['resolveComponent']
45+
const shallowReactive: typeof import('vue')['shallowReactive']
46+
const shallowReadonly: typeof import('vue')['shallowReadonly']
47+
const shallowRef: typeof import('vue')['shallowRef']
48+
const toRaw: typeof import('vue')['toRaw']
49+
const toRef: typeof import('vue')['toRef']
50+
const toRefs: typeof import('vue')['toRefs']
51+
const toValue: typeof import('vue')['toValue']
52+
const triggerRef: typeof import('vue')['triggerRef']
53+
const unref: typeof import('vue')['unref']
54+
const useAttrs: typeof import('vue')['useAttrs']
55+
const useCssModule: typeof import('vue')['useCssModule']
56+
const useCssVars: typeof import('vue')['useCssVars']
57+
const useId: typeof import('vue')['useId']
58+
const useModel: typeof import('vue')['useModel']
59+
const useSlots: typeof import('vue')['useSlots']
60+
const useTemplateRef: typeof import('vue')['useTemplateRef']
61+
const watch: typeof import('vue')['watch']
62+
const watchEffect: typeof import('vue')['watchEffect']
63+
const watchPostEffect: typeof import('vue')['watchPostEffect']
64+
const watchSyncEffect: typeof import('vue')['watchSyncEffect']
65+
}
66+
// for type re-export
67+
declare global {
68+
// @ts-ignore
69+
export type { Component, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue'
70+
import('vue')
71+
}

packages/components/src/components/MentionSender/index.vue

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const props = withDefaults(defineProps<MentionSenderProps>(), {
2121
2222
variant: 'default',
2323
showUpdown: true,
24+
submitBtnDisabled: undefined,
2425
2526
// el-input 属性透传
2627
inputStyle: '',
@@ -29,12 +30,12 @@ const props = withDefaults(defineProps<MentionSenderProps>(), {
2930
options: () => [],
3031
filterOption: () => true,
3132
whole: false,
32-
checkIsWhole: () => false,
33+
checkIsWhole: () => true,
3334
triggerLoading: false,
3435
triggerStrings: () => [],
36+
triggerSplit: ' ',
3537
triggerPopoverPlacement: 'top',
3638
triggerPopoverOffset: 20,
37-
triggerPopoverClass: '',
3839
})
3940
4041
const emits = defineEmits(['update:modelValue', 'submit', 'cancel', 'recordingChange', 'search', 'select'])
@@ -61,6 +62,16 @@ const hasOnRecordingChangeListener = computed(() => {
6162
const senderRef = ref()
6263
const inputRef = ref()
6364
65+
// 计算提交按钮禁用状态
66+
const isSubmitDisabled = computed(() => {
67+
// 用户显式设置了 submitBtnDisabled 时优先使用
68+
if (typeof props.submitBtnDisabled === 'boolean') {
69+
return props.submitBtnDisabled
70+
}
71+
// 否则保持默认逻辑:无内容时禁用
72+
return !internalValue.value
73+
})
74+
6475
/* 内容容器聚焦 开始 */
6576
function onContentMouseDown(e: MouseEvent) {
6677
// 点击容器后设置输入框的聚焦,会触发 &:focus-within 样式
@@ -150,7 +161,7 @@ function stopRecognition() {
150161
151162
/* 输入框事件 开始 */
152163
function submit() {
153-
if (props.readOnly || props.loading || props.disabled || !internalValue.value)
164+
if (props.readOnly || props.loading || props.disabled || isSubmitDisabled.value)
154165
return
155166
emits('submit', internalValue.value)
156167
}
@@ -343,9 +354,9 @@ defineExpose({
343354
:check-is-whole="props.checkIsWhole"
344355
:loading="props.triggerLoading"
345356
:prefix="props.triggerStrings"
357+
:split="props.triggerSplit"
346358
:placement="props.triggerPopoverPlacement"
347359
:offset="props.triggerPopoverOffset"
348-
:popper-class="props.triggerPopoverClass"
349360
@keydown.stop="handleKeyDown"
350361
@search="handleSearch"
351362
@select="handleSelect"
@@ -374,7 +385,7 @@ defineExpose({
374385
<div
375386
class="el-sender-action-list-presets"
376387
>
377-
<SendButton v-if="!loading" :disabled="!internalValue" @submit="submit" />
388+
<SendButton v-if="!loading" :disabled="isSubmitDisabled" @submit="submit" />
378389

379390
<LoadingButton v-if="loading" @cancel="cancel" />
380391

@@ -406,7 +417,7 @@ defineExpose({
406417
<div
407418
class="el-sender-action-list-presets"
408419
>
409-
<SendButton v-if="!loading" :disabled="!internalValue" @submit="submit" />
420+
<SendButton v-if="!loading" :disabled="isSubmitDisabled" @submit="submit" />
410421

411422
<LoadingButton v-if="loading" @cancel="cancel" />
412423

packages/components/src/components/MentionSender/types.d.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export interface MentionSenderProps {
2424
// 变体属性
2525
variant?: 'default' | 'updown'
2626
showUpdown?: boolean
27+
submitBtnDisabled?: boolean
2728

2829
// 新增 el-input 样式透传
2930
inputStyle?: string | CSSProperties | CSSProperties[] | string[]
@@ -40,8 +41,10 @@ export interface MentionSenderProps {
4041
triggerLoading?: boolean
4142
// 触发字段的前缀。 字符串长度必须且只能为 1
4243
triggerStrings?: string[]
44+
// 触发字段的分隔符, 默认为空字符串。字符串长度必须且只能为 1
45+
triggerSplit?: string
46+
// 触发字段的下拉面板的弹出位置
4347
triggerPopoverPlacement?: 'bottom' | 'top'
48+
// 触发字段的下拉面板的弹出位置偏移量
4449
triggerPopoverOffset?: number
45-
// 自定义浮层类名
46-
triggerPopoverClass?: string
4750
}

packages/components/src/components/Sender/index.vue

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const props = withDefaults(defineProps<SenderProps>(), {
2121
2222
variant: 'default',
2323
showUpdown: true,
24+
submitBtnDisabled: undefined,
2425
2526
// el-input 属性透传
2627
inputStyle: () => {},
@@ -74,6 +75,16 @@ const hasOnTriggerListener = computed(() => {
7475
return !!instance?.vnode.props?.onTrigger
7576
})
7677
78+
// 计算提交按钮禁用状态
79+
const isSubmitDisabled = computed(() => {
80+
// 用户显式设置了 submitBtnDisabled 时优先使用
81+
if (typeof props.submitBtnDisabled === 'boolean') {
82+
return props.submitBtnDisabled
83+
}
84+
// 否则保持默认逻辑:无内容时禁用
85+
return !internalValue.value
86+
})
87+
7788
const popoverVisible = computed({
7889
get() {
7990
return props.triggerPopoverVisible
@@ -241,7 +252,7 @@ function stopRecognition() {
241252
242253
/* 输入框事件 开始 */
243254
function submit() {
244-
if (props.readOnly || props.loading || props.disabled || !internalValue.value)
255+
if (props.readOnly || props.loading || props.disabled || isSubmitDisabled.value)
245256
return
246257
emits('submit', internalValue.value)
247258
}
@@ -441,7 +452,7 @@ defineExpose({
441452
<div
442453
class="el-sender-action-list-presets"
443454
>
444-
<SendButton v-if="!loading" :disabled="!internalValue" @submit="submit" />
455+
<SendButton v-if="!loading" :disabled="isSubmitDisabled" @submit="submit" />
445456

446457
<LoadingButton v-if="loading" @cancel="cancel" />
447458

@@ -473,7 +484,7 @@ defineExpose({
473484
<div
474485
class="el-sender-action-list-presets"
475486
>
476-
<SendButton v-if="!loading" :disabled="!internalValue" @submit="submit" />
487+
<SendButton v-if="!loading" :disabled="isSubmitDisabled" @submit="submit" />
477488

478489
<LoadingButton v-if="loading" @cancel="cancel" />
479490

packages/components/src/components/Sender/types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export interface SenderProps {
1717
// 变体属性
1818
variant?: 'default' | 'updown'
1919
showUpdown?: boolean
20+
submitBtnDisabled?: boolean
2021

2122
// 新增 el-input 样式透传
2223
inputStyle?: string | CSSProperties | CSSProperties[] | string[]

packages/components/src/components/Thinking/index.vue

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const props = withDefaults(defineProps<ThinkingProps>(), {
99
disabled: false,
1010
autoCollapse: false,
1111
buttonWidth: '160px',
12-
duration: '0.25s',
12+
duration: '0.2s',
1313
maxWidth: '500px',
1414
backgroundColor: '#fcfcfc',
1515
color: 'var(--el-color-info)',
@@ -140,7 +140,7 @@ watch(() => props.status, (newVal) => {
140140
</template>
141141

142142
<style scoped lang="scss">
143-
.el-thought-chain {
143+
.el-thinking {
144144
font-family: system-ui, sans-serif;
145145
margin: 0 auto;
146146
}
@@ -149,14 +149,13 @@ watch(() => props.status, (newVal) => {
149149
display: flex;
150150
align-items: center;
151151
height: 100%;
152-
width: var(--el-thought-chaian-button-width);
152+
width: var(--el-thinking-button-width);
153153
gap: 8px;
154154
padding: var(--el-padding-sm) calc(var(--el-padding-sm) + 4px);
155155
border: 1px solid #e4e4e4;
156156
border-radius: 8px;
157157
background: white;
158158
cursor: pointer;
159-
transition: all 0.2s;
160159
margin-bottom: 8px;
161160
162161
/* 居中 */
@@ -206,7 +205,7 @@ watch(() => props.status, (newVal) => {
206205
207206
.arrow {
208207
margin-left: auto;
209-
transition: transform var(--el-thought-chaian-animation-duration);
208+
transition: transform var(--el-thinking-animation-duration);
210209
}
211210
212211
.arrow.expanded {
@@ -218,8 +217,8 @@ watch(() => props.status, (newVal) => {
218217
.slide-leave-active {
219218
height: calc-size(max-content, size);
220219
transition:
221-
height var(--el-thought-chaian-animation-duration) ease-in-out,
222-
opacity var(--el-thought-chaian-animation-duration) ease-in-out;
220+
height var(--el-thinking-animation-duration) ease-in-out,
221+
opacity var(--el-thinking-animation-duration) ease-in-out;
223222
overflow: hidden;
224223
}
225224
@@ -236,13 +235,13 @@ watch(() => props.status, (newVal) => {
236235
}
237236
238237
.content pre {
239-
max-width: var(--el-thought-chaian-content-wrapper-width);
240-
background: var(--el-thought-chaian-content-wrapper-background-color);
241238
border: 1px solid #eee;
242-
border-radius: calc(var(--el-border-radius-base) + 4px);
239+
background: var(--el-thinking-content-wrapper-background-color);
243240
padding: var(--el-padding-sm) calc(var(--el-padding-sm) + 4px);
241+
border-radius: calc(var(--el-border-radius-base) + 4px);
242+
max-width: var(--el-thinking-content-wrapper-width);
244243
font-size: 14px;
245-
color: var(--el-thought-chaian-content-wrapper-color);
244+
color: var(--el-thinking-content-wrapper-color);
246245
white-space: pre-wrap;
247246
font-family: DeepSeek-CJK-patch,Inter,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Noto Sans,Ubuntu,Cantarell,Helvetica Neue,Oxygen,Open Sans,sans-serif;
248247
margin: 0;
@@ -255,8 +254,6 @@ watch(() => props.status, (newVal) => {
255254
}
256255
257256
.error-message {
258-
border: 1px solid #e76875;
259-
border-radius: calc(var(--el-border-radius-base) + 4px);
260257
color: #dc3545;
261258
height: fit-content;
262259
padding: 8px;

0 commit comments

Comments
 (0)