Skip to content

xtf-dialog ​

组件说明 ​

xtf-dialog 是对话框,用于承载确认、输入、选择和业务操作反馈。当前实现读取 actions 数据、由 show 控制显示、通过 update:show 等事件反馈交互。

  • 实际 Demo 路由:#/pages/components/xtf-dialog/index
  • Demo 源码

基础用法 ​

1. 最小可用 ​

提供能够直接看到或操作组件的最少业务内容。

vue
<template>
  <view class="doc-minimum">
    <XtfDialog title="账单详情" :show="true" message="账单将同步到共享账本" />
  </view>
</template>

<script setup lang="uts">
import XtfDialog from "@/uni_modules/xtf-linkuiunix/components/xtf-dialog/xtf-dialog.uvue"

</script>

<style>
.doc-minimum { display: flex; flex-direction: column; padding: 24rpx; }
</style>

2. 核心数据与主要事件 ​

使用组件真实数据入口,并记录当前源码声明的主要事件。

vue
<template>
  <view class="doc-core">
    <XtfDialog title="账单详情" :show="true" message="账单将同步到共享账本" :actions="fixture" @open="onPrimaryEvent" />
  </view>
</template>

<script setup lang="uts">
import XtfDialog from "@/uni_modules/xtf-linkuiunix/components/xtf-dialog/xtf-dialog.uvue"

const fixture = [{ label: '稍后处理', type: 'light', action: 'cancel' }, { label: '确认提交', theme: 'primary', action: 'confirm' }] as Array<any>
function onPrimaryEvent(payload: any): void { console.log("xtf-dialog:open", payload) }
</script>

<style>
.doc-core { display: flex; flex-direction: column; padding: 24rpx; }
</style>

3. 动态 show 状态 ​

运行时切换 show,观察组件对应状态变化。

vue
<template>
  <view class="doc-dynamic">
    <XtfDialog title="账单详情" message="账单将同步到共享账本" :show="state" />
    <button class="doc-action-button" @click="toggleState">切换 show</button>
    <text class="doc-state-text">show: {{ state }}</text>
  </view>
</template>

<script setup lang="uts">
import XtfDialog from "@/uni_modules/xtf-linkuiunix/components/xtf-dialog/xtf-dialog.uvue"

import { ref } from "vue"

const state = ref(true)
function toggleState(): void { state.value = !state.value; console.log("show", state.value) }
</script>

<style>
.doc-dynamic { display: flex; flex-direction: column; padding: 24rpx; }
.doc-action-button { margin-top: 16rpx; }
.doc-state-text { margin-top: 12rpx; color: #475569; font-size: 24rpx; }
</style>

4. 定制 title 插槽 ​

使用源码真实声明的 title slot 替换对应内容。

vue
<template>
  <view class="doc-slot">
    <XtfDialog title="账单详情" :show="true" message="账单将同步到共享账本">
      <template #title><text class="doc-content-text">自定义 title 内容</text></template>
    </XtfDialog>
  </view>
</template>

<script setup lang="uts">
import XtfDialog from "@/uni_modules/xtf-linkuiunix/components/xtf-dialog/xtf-dialog.uvue"

</script>

<style>
.doc-slot { display: flex; flex-direction: column; padding: 24rpx; }
.doc-content-text { color: #334155; font-size: 26rpx; }
</style>

5. 调用 open() ​

打开组件;签名为 open(options: UTSJSONObject = {}): void。

vue
<template>
  <view class="doc-method">
    <XtfDialog title="账单详情" :show="true" message="账单将同步到共享账本" ref="componentRef" />
    <button class="doc-action-button" @click="callMethod">打开组件</button>
  </view>
</template>

<script setup lang="uts">
import XtfDialog from "@/uni_modules/xtf-linkuiunix/components/xtf-dialog/xtf-dialog.uvue"

import { ref } from "vue"

const componentRef = ref<any>(null)
function callMethod(): void { componentRef.value?.open(); console.log("调用 open") }
</script>

<style>
.doc-method { display: flex; flex-direction: column; padding: 24rpx; }
.doc-action-button { margin-top: 16rpx; }
</style>

6. Manager 服务调用 ​

先挂载 service 宿主,再调用对应 manager 的实际显示 API。

vue
<template>
  <view class="doc-service">
    <XtfDialog title="账单详情" message="账单将同步到共享账本" service />
    <button class="doc-action-button" @click="openService">服务式调用</button>
  </view>
</template>

<script setup lang="uts">
import { dialogManager } from "@/uni_modules/xtf-linkuiunix/components/xtf-dialog/service.uts"
import XtfDialog from "@/uni_modules/xtf-linkuiunix/components/xtf-dialog/xtf-dialog.uvue"


function openService(): void { dialogManager.confirm({ title: '确认提交', message: '账单将同步到共享账本' }); console.log("dialogManager 已调用") }
</script>

<style>
.doc-service { display: flex; flex-direction: column; padding: 24rpx; }
.doc-action-button { margin-top: 16rpx; }
</style>

全部属性 ​

属性源码类型withDefaults 默认值实际行为 / 范围适用范围
servicebooleanfalse参与组件运行逻辑;源码在 9 处读取该值;消费位置:script 行 125、script 行 127、script 行 147、script 行 155需要控制显示、可用性或交互状态时设置。
showbooleanfalse参与组件运行逻辑;源码在 2 处读取该值;消费位置:service.uts 行 38、template 行 2需要控制显示、可用性或交互状态时设置。
titlestring""参与组件运行逻辑;源码在 2 处读取该值;消费位置:script 行 65、template 行 14需要提供业务文案或图标内容时设置。
subtitlestring""参与组件运行逻辑;源码在 2 处读取该值;消费位置:template 行 15需要提供业务文案或图标内容时设置。
messagestring""参与组件运行逻辑;源码在 2 处读取该值;消费位置:script 行 64需要提供业务文案或图标内容时设置。
contentstring""参与组件运行逻辑;源码在 1 处读取该值;消费位置:script 行 64需要覆盖组件默认业务值时设置。
descriptionstring""参与组件运行逻辑;源码在 2 处读取该值;消费位置:template 行 31需要提供业务文案或图标内容时设置。
typestring"default"参与组件运行逻辑;源码在 6 处读取该值;消费位置:script 行 49、script 行 50、script 行 52需要覆盖组件默认业务值时设置。
presetstring""参与组件运行逻辑;源码在 2 处读取该值;消费位置:script 行 48需要覆盖组件默认业务值时设置。
showCancelbooleantrue开关对应显示或交互行为;消费位置:script 行 72需要控制显示、可用性或交互状态时设置。
confirmTextstring""设置对应区域的显示文案;消费位置:script 行 73需要提供业务文案或图标内容时设置。
cancelTextstring""设置对应区域的显示文案;消费位置:script 行 74需要提供业务文案或图标内容时设置。
showCloseIconbooleanfalse设置对应区域的图标名称;消费位置:template 行 4需要控制显示、可用性或交互状态时设置。
actionsXtfDialogAction[]() => [] as XtfDialogAction[]参与组件运行逻辑;源码在 3 处读取该值;消费位置:template 行 37、template 行 38、template 行 39数据驱动或选项渲染场景。
optionsXtfDialogOption[]() => [] as XtfDialogOption[]参与组件运行逻辑;源码在 4 处读取该值;消费位置:script 行 66、script 行 89、script 行 91、template 行 21数据驱动或选项渲染场景。
optionValueXtfDialogValue""提供当前受控状态;是否回写以事件表为准;消费位置:script 行 34、script 行 43需要覆盖组件默认业务值时设置。
optionValuesXtfDialogValue[]() => [] as XtfDialogValue[]提供当前受控状态;是否回写以事件表为准;消费位置:script 行 35、script 行 44需要覆盖组件默认业务值时设置。
optionRequiredbooleanfalse参与组件运行逻辑;源码在 1 处读取该值;消费位置:script 行 83需要覆盖组件默认业务值时设置。
optionHelperstring""参与组件运行逻辑;源码在 2 处读取该值;消费位置:template 行 20需要覆盖组件默认业务值时设置。
overlaybooleantrue参与组件运行逻辑;源码在 1 处读取该值;消费位置:template 行 2需要控制显示、可用性或交互状态时设置。
overlayStylestring""覆盖或追加对应内部区域的样式对象;消费位置:template 行 2需要调整布局或视觉表现时设置。
closeOnClickOverlaybooleanfalse开关对应显示或交互行为;消费位置:template 行 2需要覆盖组件默认业务值时设置。
beforeClose(payload: UTSJSONObject) => boolean | Promise<boolean>null提供源码调用的业务回调,参数和返回值以类型列为准;消费位置:script 行 114需要接入业务守卫、转换或过滤逻辑时设置。
loadingbooleanfalse参与组件运行逻辑;源码在 3 处读取该值;消费位置:script 行 41、template 行 38、template 行 39需要控制显示、可用性或交互状态时设置。
confirmLoadingbooleanfalse参与组件运行逻辑;源码在 3 处读取该值;消费位置:script 行 41、template 行 38、template 行 39需要覆盖组件默认业务值时设置。
cancelLoadingbooleanfalse参与组件运行逻辑;源码在 3 处读取该值;消费位置:script 行 41、template 行 38、template 行 39需要覆盖组件默认业务值时设置。
themestring"primary"参与组件运行逻辑;源码在 2 处读取该值;消费位置:script 行 62、script 行 63需要调整布局或视觉表现时设置。
iconstring""参与组件运行逻辑;源码在 2 处读取该值;消费位置:script 行 61需要提供业务文案或图标内容时设置。
iconThemestring""参与组件运行逻辑;源码在 2 处读取该值;消费位置:script 行 62需要覆盖组件默认业务值时设置。
iconColorstring""设置对应区域的颜色;消费位置:template 行 10需要调整布局或视觉表现时设置。
avatarstring""参与组件运行逻辑;源码在 3 处读取该值;消费位置:template 行 7、template 行 8需要覆盖组件默认业务值时设置。
alignstring""参与组件运行逻辑;源码在 1 处读取该值;消费位置:script 行 71需要调整布局或视觉表现时设置。
widthnumber620参与组件运行逻辑;源码在 1 处读取该值;消费位置:script 行 76需要覆盖组件默认业务值时设置。
radiusnumber24参与组件运行逻辑;源码在 1 处读取该值;消费位置:script 行 81需要覆盖组件默认业务值时设置。
buttonDirectionstring"horizontal"参与组件运行逻辑;源码在 2 处读取该值;消费位置:script 行 80、script 行 100需要覆盖组件默认业务值时设置。
footerNotestring""参与组件运行逻辑;源码在 2 处读取该值;消费位置:template 行 35需要覆盖组件默认业务值时设置。
customClassstring""参与组件运行逻辑;源码在 1 处读取该值;消费位置:script 行 79需要调整布局或视觉表现时设置。
customStyleUTSJSONObject() => ({} as UTSJSONObject)参与组件运行逻辑;源码在 1 处读取该值;消费位置:script 行 81需要调整布局或视觉表现时设置。
titleStyleUTSJSONObject() => ({} as UTSJSONObject)覆盖或追加对应内部区域的样式对象;消费位置:template 行 13需要调整布局或视觉表现时设置。
bodyStyleUTSJSONObject() => ({} as UTSJSONObject)覆盖或追加对应内部区域的样式对象;消费位置:template 行 17需要调整布局或视觉表现时设置。
fullscreenbooleanfalse参与组件运行逻辑;源码在 4 处读取该值;消费位置:script 行 76、script 行 79、script 行 81、script 行 82需要覆盖组件默认业务值时设置。
showInputbooleanfalse开关对应显示或交互行为;消费位置:script 行 67需要控制显示、可用性或交互状态时设置。
inputValuestring""提供当前受控状态;是否回写以事件表为准;消费位置:script 行 36、script 行 45需要覆盖组件默认业务值时设置。
inputTypestring"text"参与组件运行逻辑;源码在 1 处读取该值;消费位置:script 行 68需要覆盖组件默认业务值时设置。
inputPlaceholderstring""参与组件运行逻辑;源码在 2 处读取该值;消费位置:script 行 69需要提供业务文案或图标内容时设置。
inputLabelstring""参与组件运行逻辑;源码在 1 处读取该值;消费位置:template 行 30需要提供业务文案或图标内容时设置。
inputRowsnumber4参与组件运行逻辑;源码在 1 处读取该值;消费位置:template 行 30需要覆盖组件默认业务值时设置。
inputMaxlengthnumber140参与组件运行逻辑;源码在 1 处读取该值;消费位置:template 行 30需要覆盖组件默认业务值时设置。
inputRequiredbooleanfalse参与组件运行逻辑;源码在 2 处读取该值;消费位置:script 行 83、template 行 30需要覆盖组件默认业务值时设置。
inputAutoFocusbooleanfalse参与组件运行逻辑;源码在 1 处读取该值;消费位置:template 行 30需要覆盖组件默认业务值时设置。

XtfDialogAction 数据结构 ​

字段源码类型字段语义
labelstring显示文字
themestring源码声明的业务扩展字段;当前实现未提供更具体语义。
typestring类型标识
actionstring业务动作标识
disabledboolean是否禁止该项交互
loadingboolean该项是否显示加载状态
keepOpenboolean操作后是否保持浮层打开

XtfDialogOption 数据结构 ​

字段源码类型字段语义
keystring稳定渲染标识
valueXtfDialogValue业务值
labelstring显示文字
namestring名称或兼容显示字段
descriptionstring补充说明
descstring简短说明
dangerboolean是否使用危险语义
disabledboolean是否禁止该项交互
keepOpenboolean操作后是否保持浮层打开

事件 ​

事件名称源码触发边界回调参数参数说明
update:showhandlePopupShow 内触发(script 行 125);参数表达式:value;前置 guard:!current()
open 内触发(script 行 155);参数表达式:true;前置 guard:!captureRequest()()
(...args: any[])表中参数表达式来自当前源码直接调用点;禁用、守卫失败或未进入该函数分支时不会触发。
update:inputValueupdateInputValue 内触发(script 行 127);参数表达式:innerInputValue.value;前置 guard:busy.value、!current()(...args: any[])表中参数表达式来自当前源码直接调用点;禁用、守卫失败或未进入该函数分支时不会触发。
update:optionValueselectOption 内触发(script 行 145);参数表达式:value;前置 guard:busy.value || option.disabled == true || (closePending != null && closePending())、!current()、!current()(...args: any[])表中参数表达式来自当前源码直接调用点;禁用、守卫失败或未进入该函数分支时不会触发。
update:optionValuesselectOption 内触发(script 行 141);参数表达式:values.slice();前置 guard:busy.value || option.disabled == true || (closePending != null && closePending())、!current()(...args: any[])表中参数表达式来自当前源码直接调用点;禁用、守卫失败或未进入该函数分支时不会触发。
open模板行 2 透传子组件事件;参数表达式:无回调参数(...args: any[])表中参数表达式来自当前源码直接调用点;禁用、守卫失败或未进入该函数分支时不会触发。
opened模板行 2 透传子组件事件;参数表达式:无回调参数(...args: any[])表中参数表达式来自当前源码直接调用点;禁用、守卫失败或未进入该函数分支时不会触发。
closehandlePopupClose 内触发(script 行 126);参数表达式:payload(...args: any[])表中参数表达式来自当前源码直接调用点;禁用、守卫失败或未进入该函数分支时不会触发。
closed模板行 2 透传子组件事件;参数表达式:无回调参数(...args: any[])表中参数表达式来自当前源码直接调用点;禁用、守卫失败或未进入该函数分支时不会触发。
click-overlay模板行 2 透传子组件事件;参数表达式:无回调参数(...args: any[])表中参数表达式来自当前源码直接调用点;禁用、守卫失败或未进入该函数分支时不会触发。
blocked-closefinish 内触发(script 行 108);参数表达式:payload;前置 guard:!current() || busy.value、!allowed
handlePopupBlockedClose 内触发(script 行 124);参数表达式:dialogPayload(payload["source"] == null ? "popup" : payload["source"].toString())
(...args: any[])表中参数表达式来自当前源码直接调用点;禁用、守卫失败或未进入该函数分支时不会触发。
input-changeupdateInputValue 内触发(script 行 127);参数表达式:{ value: innerInputValue.value, type: resolvedType(), preset: resolvedPreset() } as UTSJSONObject;前置 guard:busy.value、!current()、!current()(...args: any[])表中参数表达式来自当前源码直接调用点;禁用、守卫失败或未进入该函数分支时不会触发。
cancelsetup 内触发(script 行 152);参数表达式:无回调参数;前置 guard:!current()(...args: any[])表中参数表达式来自当前源码直接调用点;禁用、守卫失败或未进入该函数分支时不会触发。
confirmsetup 内触发(script 行 153);参数表达式:无回调参数;前置 guard:!current()(...args: any[])表中参数表达式来自当前源码直接调用点;禁用、守卫失败或未进入该函数分支时不会触发。
cancel-detailsetup 内触发(script 行 152);参数表达式:payload(...args: any[])表中参数表达式来自当前源码直接调用点;禁用、守卫失败或未进入该函数分支时不会触发。
confirm-detailsetup 内触发(script 行 153);参数表达式:payload(...args: any[])表中参数表达式来自当前源码直接调用点;禁用、守卫失败或未进入该函数分支时不会触发。
actionselectOption 内触发(script 行 150);参数表达式:payload;前置 guard:!current()、!current()、!current()
handleAction 内触发(script 行 154);参数表达式:payload;前置 guard:action.action == "cancel"、action.action == "confirm"、!current()
(...args: any[])表中参数表达式来自当前源码直接调用点;禁用、守卫失败或未进入该函数分支时不会触发。
option-selectselectOption 内触发(script 行 149);参数表达式:payload;前置 guard:!current()、!current()、!current()(...args: any[])表中参数表达式来自当前源码直接调用点;禁用、守卫失败或未进入该函数分支时不会触发。

插槽 ​

插槽Scope 参数实际渲染位置
title无 scope 参数仅在模板对应 <slot> 渲染位置生效。
default无 scope 参数仅在模板对应 <slot> 渲染位置生效。
footer无 scope 参数仅在模板对应 <slot> 渲染位置生效。

方法 ​

实例方法 ​

方法签名 / 返回值调用边界
openopen(options: UTSJSONObject = {}): void打开组件;通过组件 ref 调用,参数和返回值按签名处理。
closeclose(): void请求关闭组件;通过组件 ref 调用,参数和返回值按签名处理。
confirmconfirm(): void提交当前草稿;通过组件 ref 调用,参数和返回值按签名处理。
cancelcancel(): void撤销当前草稿;通过组件 ref 调用,参数和返回值按签名处理。

公开状态 ​

状态类型 / 包装读取边界
--当前组件没有公开状态。

Manager 宿主与导入 ​

  • 宿主:在页面中挂载 <XtfDialog service />。
  • 导入:import { dialogManager } from "@/uni_modules/xtf-linkuiunix/components/xtf-dialog/service.uts"。
  • 调用:基础用法中的 Manager 示例调用真实显示 API,而不是只读取 getState()。
  • 返回:manager 返回当前状态快照或通知项,不是等待用户操作的 Promise;用户结果继续监听宿主事件。
  • 服务式 Dialog 按请求隔离:beforeClose 等异步守卫未结束时再次 show/confirm,或在 confirm-detail、cancel-detail、action、输入/选项事件中重入新请求,旧请求的后续关闭与状态写回不会作用到新请求。update 修改当前请求,show 才创建新请求;内部请求标识不是业务 API。

主题说明 ​

  • var(--xtf-color-border):组件样式实际读取的主题变量,可在 xtf-config-provider 作用域或主题 class 下覆盖。
  • var(--xtf-color-danger):组件样式实际读取的主题变量,可在 xtf-config-provider 作用域或主题 class 下覆盖。
  • var(--xtf-color-primary):组件样式实际读取的主题变量,可在 xtf-config-provider 作用域或主题 class 下覆盖。
  • var(--xtf-color-surface):组件样式实际读取的主题变量,可在 xtf-config-provider 作用域或主题 class 下覆盖。
  • var(--xtf-dialog-soft):组件样式实际读取的主题变量,可在 xtf-config-provider 作用域或主题 class 下覆盖。

平台与实现边界 ​

  • 基线为 HBuilderX 5.26+ 与 uni-app x;当前报告已验证 Web Chromium 的对应 Demo,不据此承诺 Safari、小程序或 App 原生端等价。
  • Android、iOS、HarmonyOS、Vapor 原生路径、触摸手势、字体、Canvas、安全区和系统权限能力,只有源码或完整性报告明确覆盖的部分才可视为已验证。
  • 本文按当前源码生成,不补入旧版 xtf-linkui 存在但迁移版未实现的 props、事件、slot 或方法。
  • 详细公共边界见 平台与实现边界,逐项运行证据见项目根目录 COMPONENT_COMPLETENESS.md。

MIT Licensed