5353 class =" set"
5454 :round =" false"
5555 :disabled =" isDisabled"
56- :title =" resolve(props.item. title) "
56+ :title =" title"
5757 v-bind =" item.componentProps"
5858 />
5959
6464 :options =" normalizedOptions"
6565 class =" set"
6666 :disabled =" isDisabled"
67- :title =" resolve(props.item. title) "
67+ :title =" title"
6868 v-bind =" item.componentProps"
6969 />
7070
7777 :max =" resolve(item.max)"
7878 :step =" resolve(item.step)"
7979 :disabled =" isDisabled"
80- :title =" resolve(props.item. title) "
80+ :title =" title"
8181 v-bind =" item.componentProps"
8282 >
8383 <template #prefix v-if =" item .prefix " >{{ resolve(item.prefix) }}</template >
9393 :type =" item.componentProps?.type || 'text'"
9494 :show-password-on =" item.componentProps?.showPasswordOn"
9595 :disabled =" isDisabled"
96- :title =" resolve(props.item. title) "
96+ :title =" title"
9797 v-bind =" item.componentProps"
9898 >
9999 <template #prefix v-if =" item .prefix " >{{ resolve(item.prefix) }}</template >
111111 :marks =" item.marks"
112112 :format-tooltip =" item.formatTooltip"
113113 :disabled =" isDisabled"
114- :title =" resolve(props.item. title) "
114+ :title =" title"
115115 v-bind =" item.componentProps"
116116 />
117117
123123 secondary
124124 @click =" handleAction"
125125 :disabled =" isDisabled"
126- :title =" resolve(props.item. title) "
126+ :title =" title"
127127 v-bind =" item.componentProps"
128128 >
129129 {{ resolve(item.buttonLabel) || "配置" }}
137137 :show-alpha =" item.componentProps?.showAlpha ?? false"
138138 :modes =" item.componentProps?.modes ?? ['hex']"
139139 :disabled =" isDisabled"
140- :title =" resolve(props.item. title) "
140+ :title =" title"
141141 @complete =" handleAction"
142142 />
143143
@@ -195,38 +195,18 @@ const baseModelValue = computed({
195195 },
196196});
197197
198- // 基础禁用状态
199- const baseDisabled = computed (() => {
200- if (props .item .disabled === undefined ) return false ;
201- if (typeof props .item .disabled === " function" ) return props .item .disabled ();
202- return toValue (props .item .disabled );
203- });
204-
205198// 强制显示条件判断
206199const isForcedConditionMet = computed (() => {
207200 if (! props .item .forceIf ) return false ;
208- const condition = props .item .forceIf .condition ;
209- if (typeof condition === " function" ) {
210- return condition ();
211- }
212- return unref (condition );
213- });
214-
215- // 强制显示的值
216- const forcedValue = computed (() => {
217- if (! props .item .forceIf ) return undefined ;
218- const val = props .item .forceIf .forcedValue ;
219- if (typeof val === " function" ) {
220- return (val as any )();
221- }
222- return unref (val );
201+ return toValue (props .item .forceIf .condition );
223202});
224203
225204// 最终使用的 modelValue
226205const modelValue = computed ({
227206 get : () => {
228207 if (isForcedConditionMet .value ) {
229- return forcedValue .value ;
208+ const forcedValueRef = props .item .forceIf ! .forcedValue ;
209+ if (forcedValueRef !== undefined ) return toValue (forcedValueRef );
230210 }
231211 return baseModelValue .value ;
232212 },
@@ -239,10 +219,29 @@ const modelValue = computed({
239219 },
240220});
241221
242- // 最终使用的禁用状态
222+ // 禁用状态
243223const isDisabled = computed (() => {
244224 if (isForcedConditionMet .value ) return true ;
245- return baseDisabled .value ;
225+ if (props .item .disabled === undefined ) return false ;
226+ return toValue (props .item .disabled );
227+ });
228+
229+ // 描述内容
230+ const descriptionContent = computed (() => {
231+ if (isForcedConditionMet .value ) {
232+ const forcedDescriptionRef = props .item .forceIf ! .forcedDescription ;
233+ if (forcedDescriptionRef !== undefined ) return toValue (forcedDescriptionRef );
234+ }
235+ return toValue (props .item .description );
236+ });
237+
238+ // 鼠标悬停提示
239+ const title = computed (() => {
240+ if (isForcedConditionMet .value ) {
241+ const forcedTitleRef = props .item .forceIf ! .forcedTitle ;
242+ if (forcedTitleRef !== undefined ) return toValue (forcedTitleRef );
243+ }
244+ return toValue (props .item .title );
246245});
247246
248247// 解析子项
@@ -262,32 +261,21 @@ const isChildrenExpanded = computed(() => {
262261// 判断是否显示
263262const isShow = (childItem : SettingItem ) => {
264263 if (childItem .show === undefined ) return true ;
265- if (typeof childItem .show === " function" ) return childItem .show ();
266264 return toValue (childItem .show );
267265};
268266
269267// 判断额外按钮是否显示
270268const isExtraButtonShow = (action : any ) => {
271269 if (action .show === undefined ) return true ;
272- if (typeof action .show === " function" ) return action .show ();
273270 return toValue (action .show );
274271};
275272
276273// 规范化选项数据
277274const normalizedOptions = computed (() => {
278275 if (! props .item .options ) return [];
279- if (typeof props .item .options === " function" ) return props .item .options ();
280276 return toValue (props .item .options );
281277});
282278
283- // 解析描述内容
284- const descriptionContent = computed (() => {
285- if (isRef (props .item .description )) {
286- return props .item .description .value ;
287- }
288- return props .item .description ;
289- });
290-
291279// 获取属性值
292280const resolve = toValue ;
293281
0 commit comments