Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d22aeea560 | ||
|
|
9d2faf3440 | ||
|
|
88e83415b6 | ||
|
|
46c000c76c | ||
|
|
68e44caaa4 | ||
|
|
b7a4de49c4 | ||
|
|
75d34d5078 | ||
|
|
86da3d44d8 | ||
|
|
71fca76412 | ||
|
|
3f4c98fbf3 | ||
|
|
7349bb3429 | ||
|
|
0796e73ab1 | ||
|
|
2556fc26ff | ||
|
|
bdaee75b81 | ||
|
|
a50f134b25 | ||
|
|
f8140bb70b | ||
|
|
0a23f0e3b9 | ||
|
|
f709a8faed | ||
|
|
dd303e1781 | ||
|
|
bed8b65092 | ||
|
|
214263f78f | ||
|
|
87d0c5cd33 |
@@ -72,8 +72,8 @@ jobs:
|
|||||||
- name: Ensure version not published
|
- name: Ensure version not published
|
||||||
if: ${{ steps.version.outputs.publish == 'true' }}
|
if: ${{ steps.version.outputs.publish == 'true' }}
|
||||||
run: |
|
run: |
|
||||||
if npm view "timi-tdesign-mobile@${{ steps.version.outputs.version }}" version > /dev/null 2>&1; then
|
if npm view "@timi/tdesign-mobile@${{ steps.version.outputs.version }}" version > /dev/null 2>&1; then
|
||||||
echo "FAIL: timi-tdesign-mobile@${{ steps.version.outputs.version }} 已存在于 nexus,请提升 package.json 版本"
|
echo "FAIL: @timi/tdesign-mobile@${{ steps.version.outputs.version }} 已存在于 nexus,请提升 package.json 版本"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "OK: 版本未占用"
|
echo "OK: 版本未占用"
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
# timi-tdesign-mobile
|
# @timi/tdesign-mobile
|
||||||
|
|
||||||
Vue 3 移动端通用组件库,依赖 `timi-web` 提供基础组件和编辑器能力。
|
Vue 3 移动端通用组件库,依赖 `@timi/web` 提供基础组件和编辑器能力。
|
||||||
|
|
||||||
本包不依赖 `timi-web-api`。业务项目可以只安装本包使用通用组件;需要业务接口、领域类型或用户状态时,再单独安装 `timi-web-api`。
|
本包不绑定业务 API 包。业务项目可以只安装本包使用通用组件;业务接口、领域类型和用户状态由应用层自行提供。
|
||||||
|
|
||||||
## 文章和通知组件
|
## 文章和通知组件
|
||||||
|
|
||||||
`ArticleEditor`、`ArticleView`、`NotifyEditor`、`NotifyView` 只约束对象的最小字段。`Article`、`Attachment` 和 `NotifyDetail` 支持携带业务自定义字段,不要求对象来自 `timi-web-api`。
|
`ArticleEditor`、`ArticleView`、`NotifyEditor`、`NotifyView` 只约束对象的最小字段。`Article`、`Attachment` 和 `NotifyDetail` 支持携带业务自定义字段,不要求对象来自特定 API 包。
|
||||||
|
|
||||||
上传和附件地址由业务项目通过回调注入:
|
上传和附件地址由业务项目通过回调注入:
|
||||||
|
|
||||||
|
|||||||
Vendored
+3
@@ -22,8 +22,10 @@ declare module 'vue' {
|
|||||||
BottomPopup: typeof import('./src/components/bottom-popup/index.vue')['default']
|
BottomPopup: typeof import('./src/components/bottom-popup/index.vue')['default']
|
||||||
CardContainer: typeof import('./src/components/card-container/index.vue')['default']
|
CardContainer: typeof import('./src/components/card-container/index.vue')['default']
|
||||||
CodeEditor: typeof import('./src/components/code-editor/index.vue')['default']
|
CodeEditor: typeof import('./src/components/code-editor/index.vue')['default']
|
||||||
|
DropdownFilter: typeof import('./src/components/dropdown-filter/index.vue')['default']
|
||||||
DurationPicker: typeof import('./src/components/duration-picker/index.vue')['default']
|
DurationPicker: typeof import('./src/components/duration-picker/index.vue')['default']
|
||||||
EditorSearch: typeof import('./src/components/editor-search/index.vue')['default']
|
EditorSearch: typeof import('./src/components/editor-search/index.vue')['default']
|
||||||
|
Item: typeof import('./src/components/timeline/item.vue')['default']
|
||||||
MasterDetail: typeof import('./src/components/master-detail/index.vue')['default']
|
MasterDetail: typeof import('./src/components/master-detail/index.vue')['default']
|
||||||
MasterDetailPage: typeof import('./src/components/master-detail-page/index.vue')['default']
|
MasterDetailPage: typeof import('./src/components/master-detail-page/index.vue')['default']
|
||||||
NotifyEditor: typeof import('./src/components/notify-editor/index.vue')['default']
|
NotifyEditor: typeof import('./src/components/notify-editor/index.vue')['default']
|
||||||
@@ -44,6 +46,7 @@ declare module 'vue' {
|
|||||||
TIcon: typeof import('tdesign-mobile-vue')['Icon']
|
TIcon: typeof import('tdesign-mobile-vue')['Icon']
|
||||||
TImage: typeof import('tdesign-mobile-vue')['Image']
|
TImage: typeof import('tdesign-mobile-vue')['Image']
|
||||||
TImageViewer: typeof import('tdesign-mobile-vue')['ImageViewer']
|
TImageViewer: typeof import('tdesign-mobile-vue')['ImageViewer']
|
||||||
|
Timeline: typeof import('./src/components/timeline/index.vue')['default']
|
||||||
TInput: typeof import('tdesign-mobile-vue')['Input']
|
TInput: typeof import('tdesign-mobile-vue')['Input']
|
||||||
TiptapCodeBlockButton: typeof import('./src/components/tiptap-editor/TiptapCodeBlockButton.vue')['default']
|
TiptapCodeBlockButton: typeof import('./src/components/tiptap-editor/TiptapCodeBlockButton.vue')['default']
|
||||||
TiptapEditor: typeof import('./src/components/tiptap-editor/index.vue')['default']
|
TiptapEditor: typeof import('./src/components/tiptap-editor/index.vue')['default']
|
||||||
|
|||||||
@@ -35,6 +35,14 @@ export interface ComponentMeta {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const COMPONENT_LIST: ComponentMeta[] = [
|
export const COMPONENT_LIST: ComponentMeta[] = [
|
||||||
|
{
|
||||||
|
name: "TTimeline",
|
||||||
|
title: "Timeline 时间轴",
|
||||||
|
description: "按时间顺序展示事件。",
|
||||||
|
category: "布局组件",
|
||||||
|
entry: "src/components/timeline/index.vue",
|
||||||
|
slug: "timeline"
|
||||||
|
},
|
||||||
// ---------- 布局组件 ----------
|
// ---------- 布局组件 ----------
|
||||||
{
|
{
|
||||||
name: "PageTransition",
|
name: "PageTransition",
|
||||||
@@ -85,6 +93,13 @@ export const COMPONENT_LIST: ComponentMeta[] = [
|
|||||||
category: "布局组件",
|
category: "布局组件",
|
||||||
entry: "src/components/master-detail-page/index.vue"
|
entry: "src/components/master-detail-page/index.vue"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "DropdownFilter",
|
||||||
|
title: "DropdownFilter 筛选栏",
|
||||||
|
description: "列表页顶部的搜索框与下拉筛选,取值和事件统一收口。",
|
||||||
|
category: "布局组件",
|
||||||
|
entry: "src/components/dropdown-filter/index.vue"
|
||||||
|
},
|
||||||
|
|
||||||
// ---------- 编辑器组件 ----------
|
// ---------- 编辑器组件 ----------
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -209,6 +209,13 @@ onUnmounted(() => {
|
|||||||
// 文档预览里的过渡组件就是用来验证转场的,因此在预览范围内恢复原定时长。
|
// 文档预览里的过渡组件就是用来验证转场的,因此在预览范围内恢复原定时长。
|
||||||
@media (prefers-reduced-motion: reduce) {
|
@media (prefers-reduced-motion: reduce) {
|
||||||
.tui-demo {
|
.tui-demo {
|
||||||
|
// 语音输入的呼吸边框是交互反馈的一部分,预览中恢复动画
|
||||||
|
:deep(.composer.voice-active .form::after) {
|
||||||
|
animation-delay: 0s !important;
|
||||||
|
animation-duration: 1.6s !important;
|
||||||
|
animation-iteration-count: infinite !important;
|
||||||
|
}
|
||||||
|
|
||||||
:deep(.page-transition .push-left-enter-active) {
|
:deep(.page-transition .push-left-enter-active) {
|
||||||
transition-duration: 520ms, 200ms !important;
|
transition-duration: 520ms, 200ms !important;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,18 +10,97 @@ demo-preview=../demos/ai-chat-composer/basic.vue
|
|||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
## 语音输入
|
||||||
|
|
||||||
|
开启 `voice-enabled` 后,输入框为空时右侧发送按钮会变成语音按钮(图标 `voice-wave`,文案「语音」)。点击后输入区切换为「按住说话」,右侧按钮变为键盘按钮(图标 `keyboard-1`,文案「输入」);点击键盘按钮回到文本输入。组件只负责手势与状态展示,识别能力由业务侧接入。
|
||||||
|
|
||||||
|
:::preview 语音输入 || 点击语音按钮进入按住说话,识别文本实时显示在整个控件上方;松手发送,移出按住按钮后松开取消;示例接入浏览器 Web Speech API,不支持时可勾选「模拟识别」
|
||||||
|
|
||||||
|
demo-preview=../demos/ai-chat-composer/voice.vue
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
### 交互约定
|
||||||
|
|
||||||
|
- 输入框有内容时右侧仍是发送按钮;只有内容为空且 `voiceState` 为 `idle` 时才显示语音入口
|
||||||
|
- 点击语音按钮进入语音模式,输入区替换为「按住说话」按钮;按住立即触发 `voice-start`,没有长按等待
|
||||||
|
- 按住期间整个输入卡片显示主题色呼吸边框,识别文本实时浮在整个输入卡片上方,最多两行
|
||||||
|
- 按住时按钮文案使用 `voiceSendHint`,默认「松开发送」;指针移出按住按钮后改用 `voiceCancelHint`,默认「松开取消」
|
||||||
|
- 松手时指针仍在按住按钮内:触发 `voice-stop`,由业务侧停止识别、取最终结果并发送
|
||||||
|
- 松手时指针已移出按住按钮:触发 `voice-cancel`,业务侧应中断识别并丢弃本次结果
|
||||||
|
- 指针被系统取消时同样触发 `voice-cancel`
|
||||||
|
- 语音模式右侧固定为键盘按钮(图标 `keyboard-1`,文案「输入」),识别中和按住时禁用;点击回到文本输入
|
||||||
|
- 文本输入与按住说话共用同一输入区高度,切换模式时组件不跳动;文本域按内容换行,最少 3 行、最多 6 行,超出后在文本域内滚动
|
||||||
|
- `voiceEnabled` 默认关闭,需要显式开启
|
||||||
|
|
||||||
|
`voiceState` 由业务侧驱动:
|
||||||
|
|
||||||
|
| 状态 | 含义 |
|
||||||
|
| --- | --- |
|
||||||
|
| `idle` | 未在识别,可以切换模式或按住说话 |
|
||||||
|
| `listening` | 正在聆听,实时回写 `voiceText`,组件显示在整个控件上方 |
|
||||||
|
| `processing` | 已松手,等待最终识别结果 |
|
||||||
|
|
||||||
|
识别完成或失败后回到 `idle`。组件不会自动发送;正常松手由业务侧在 `voice-stop` 后自行处理。想换文案时用 `voiceHoldText`、`voiceSendHint`、`voiceCancelHint`、`voiceListeningText`、`voiceProcessingText`。
|
||||||
|
|
||||||
|
### 组件边界与兼容性
|
||||||
|
|
||||||
|
`AiChatComposer` 不包含 ASR,也不依赖 Web Speech API。`voice-start`、`voice-stop`、`voice-cancel` 只表达手势,录音、识别和失败降级全部由调用方决定。上面的 demo 使用 Web Speech API 只是演示适配器,可以整体换成服务端流式识别或原生桥接。
|
||||||
|
|
||||||
|
Web Speech API 的实际兼容性(2026-11):
|
||||||
|
|
||||||
|
| 平台 | 情况 |
|
||||||
|
| --- | --- |
|
||||||
|
| Windows / macOS Chrome、Edge | 可用;Chromium 系通常依赖厂商在线语音服务,国内网络或离线可能报 `network` |
|
||||||
|
| macOS Safari 14.1+ | 可用(`webkitSpeechRecognition`),需要启用 Siri / 听写 |
|
||||||
|
| iOS Safari 14.5+ | 可用,需要启用 Siri;`continuous` 从 Safari 17 起才完整,之前停顿后容易提前结束 |
|
||||||
|
| Android Chrome | 可用,但 `continuous = true` 无效,停顿会结束识别;通常依赖 Google 语音服务,国内网络可能不可用 |
|
||||||
|
| Android 厂商浏览器 / 微信 / App WebView | 多数不支持或没有可用的语音服务 |
|
||||||
|
| Firefox 桌面 160+ | 有实现,但生态较新,建议实测;Firefox Android 不支持 |
|
||||||
|
| SafariViewController / iOS App 内嵌页 | Web Speech API 不可用或不可靠,改用原生桥接 |
|
||||||
|
|
||||||
|
Web Speech API 还需要 HTTPS(localhost 除外)和麦克风授权;音频会交给浏览器厂商的服务,隐私敏感或企业内网场景不建议使用。组件在 `pointerdown` 时立即触发 `voice-start`,iOS 上应在这个事件里同步调用 `SpeechRecognition.start()`;等异步连接建立后再启动容易被用户手势策略拒绝。
|
||||||
|
|
||||||
|
生产环境建议把识别放到服务端流式 ASR(WebSocket)或原生语音插件。业务侧只需要按组件契约驱动状态:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const voiceState = ref<"idle" | "listening" | "processing">("idle");
|
||||||
|
const voiceText = ref("");
|
||||||
|
|
||||||
|
function onVoiceStart() {
|
||||||
|
voiceState.value = "listening";
|
||||||
|
// 开始录音或连接 ASR;中间结果持续写入 voiceText
|
||||||
|
}
|
||||||
|
|
||||||
|
function onVoiceStop() {
|
||||||
|
voiceState.value = "processing";
|
||||||
|
// 停止录音,等待最终结果;拿到结果后发送
|
||||||
|
}
|
||||||
|
|
||||||
|
function onVoiceCancel() {
|
||||||
|
voiceState.value = "idle";
|
||||||
|
voiceText.value = "";
|
||||||
|
// 中断录音或识别,丢弃本次结果
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
`voiceText` 只在按住说话区上方展示,不回写 `v-model`;语音结果由业务侧在 `voice-stop` 后取出并发送。识别不可用时退回文字输入,不要阻塞发送。
|
||||||
|
|
||||||
## 何时使用
|
## 何时使用
|
||||||
|
|
||||||
需要单独摆放输入框时使用。多数情况下直接用 [AiChatPanel](/components/ai-chat-panel) 更省事。
|
需要单独摆放输入框时使用。多数情况下直接用 [AiChatPanel](/components/ai-chat-panel) 更省事。
|
||||||
|
|
||||||
## 输入区与操作按钮
|
## 输入区与操作按钮
|
||||||
|
|
||||||
文本域占满整行并随内容自动增高。下一行左侧是新开会话(`chat-add`)和添加附件(`file-add`),右侧根据状态显示纯文本发送或停止按钮。
|
文本域占满整行并随内容自动增高。下一行左侧是新开会话(`chat-add`)和添加附件(`file-add`),右侧根据状态显示语音、键盘、发送或停止按钮。
|
||||||
|
|
||||||
| 状态 | 按钮 |
|
| 状态 | 按钮 |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| 空闲且未禁用 | 新开会话、添加附件、发送(`sendText`) |
|
| 空闲、输入框为空且启用 `voiceEnabled` | 语音(`voice-wave`),点击进入语音模式 |
|
||||||
| `isGenerating` 为真 | 停止(`stopText`,危险色) |
|
| 语音模式且未在识别 | 键盘(`keyboard-1`),点击回到文本输入 |
|
||||||
|
| 语音模式正在识别或处理 | 键盘按钮禁用 |
|
||||||
|
| 文本模式且有内容 | 发送(`sendText`) |
|
||||||
|
| `isGenerating` 为真 | 停止(`stopText`,危险色),优先于语音模式 |
|
||||||
| 有 `lastError` 且 `canRetry` | 错误条 + 重试(`retryText`) |
|
| 有 `lastError` 且 `canRetry` | 错误条 + 重试(`retryText`) |
|
||||||
|
|
||||||
生成中或 `disabled` 为真时输入框不可编辑,新开会话、添加附件和 `send` 事件不会触发。
|
生成中或 `disabled` 为真时输入框不可编辑,新开会话、添加附件和 `send` 事件不会触发。
|
||||||
@@ -33,12 +112,15 @@ demo-preview=../demos/ai-chat-composer/basic.vue
|
|||||||
- `retry`:点错误条上的重试
|
- `retry`:点错误条上的重试
|
||||||
- `new-conversation`:清空输入框并请求业务侧开始一个新会话
|
- `new-conversation`:清空输入框并请求业务侧开始一个新会话
|
||||||
- `add-attachment`:请求业务侧添加附件
|
- `add-attachment`:请求业务侧添加附件
|
||||||
|
- `voice-start`:按住「按住说话」按钮时立即触发,可以开始录音或启动识别
|
||||||
|
- `voice-stop`:松手且不在取消区,可以停止识别并取最终结果
|
||||||
|
- `voice-cancel`:松手时指针已移出按住按钮,或指针被系统取消;业务侧应中断识别并丢弃本次结果
|
||||||
|
|
||||||
输入框内容用 `v-model` 绑定,`maxLength` 默认 2000。
|
输入框内容用 `v-model` 绑定,`maxLength` 默认 2000。语音识别结果只通过 `voiceText` 展示,不写入 `v-model`。
|
||||||
|
|
||||||
## 自定义插槽
|
## 自定义插槽
|
||||||
|
|
||||||
`send`、`stop`、`error` 三个插槽可以替换对应区域的渲染,都带作用域参数(`disabled`、`onSend`、`onStop`、`error`、`canRetry`)。
|
`send`、`stop`、`error` 三个插槽可以替换对应区域的渲染,都带作用域参数(`disabled`、`onSend`、`onStop`、`error`、`canRetry`)。`send` 插槽只用于文本发送;语音入口和键盘切换按钮由组件内置。
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ async function onChangeTab(value: string) {
|
|||||||
|
|
||||||
`AppShell` 只负责导航形态与容器尺寸,不接管路由。`v-model` 与 `change` 都只是把点击结果交回业务,跳不跳、跳去哪里由业务决定。
|
`AppShell` 只负责导航形态与容器尺寸,不接管路由。`v-model` 与 `change` 都只是把点击结果交回业务,跳不跳、跳去哪里由业务决定。
|
||||||
|
|
||||||
|
点击未禁用的左侧导航项时,`rail-click` 会传出该项的值,包括已激活的导航项。该事件表示点击,不受 `before-change` 控制;切换是否被允许仍由 `before-change` 和 `change` 决定。
|
||||||
|
|
||||||
## 平板布局
|
## 平板布局
|
||||||
|
|
||||||
`tablet` 默认 `true`——引入 `AppShell` 就意味着要手机和平板两端。真有项目只需要容器能力、暂不响应式,传 `:tablet="false"` 即可退回纯手机布局。
|
`tablet` 默认 `true`——引入 `AppShell` 就意味着要手机和平板两端。真有项目只需要容器能力、暂不响应式,传 `:tablet="false"` 即可退回纯手机布局。
|
||||||
|
|||||||
@@ -0,0 +1,121 @@
|
|||||||
|
# DropdownFilter 筛选栏
|
||||||
|
|
||||||
|
列表页顶部的「搜索框 + 下拉筛选」。结构、取值和事件统一收在组件里,
|
||||||
|
数据从哪来、什么时候发请求、怎么同步到 URL,仍归业务。
|
||||||
|
|
||||||
|
外观不写在组件里,而是由 `page-layout.less` 的 `.tui-filters` 提供——
|
||||||
|
手写同样结构(`.tui-filters` 包住 `.t-input` 和 `.menus`)会得到同一套样式,
|
||||||
|
从旧项目搬过来的筛选栏只需要换一个根类名。
|
||||||
|
|
||||||
|
## 基础用法
|
||||||
|
|
||||||
|
:::preview 搜索 + 下拉筛选 || 输入关键词、切换品类或状态,观察筛选栏与列表的联动
|
||||||
|
|
||||||
|
demo-preview=../demos/dropdown-filter/basic.vue
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
```vue
|
||||||
|
<dropdown-filter
|
||||||
|
v-model="keyword"
|
||||||
|
:filters="filters"
|
||||||
|
placeholder="搜索产品名称或编码"
|
||||||
|
@filter-change="handleFilterChange"
|
||||||
|
>
|
||||||
|
<template #suffix-icon>
|
||||||
|
<t-button size="extra-small" theme="primary" variant="outline" content="选择" />
|
||||||
|
</template>
|
||||||
|
</dropdown-filter>
|
||||||
|
```
|
||||||
|
|
||||||
|
`filters` 的每一项对应一个 `t-dropdown-item`,`label` 由业务算好——
|
||||||
|
组件不会根据 `value` 反查选项文本:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const filters = computed<DropdownFilterItem[]>(() => [
|
||||||
|
{
|
||||||
|
key: "category",
|
||||||
|
label: categoryOptions.find(item => item.value === category.value)?.label || "全部品类",
|
||||||
|
value: category.value,
|
||||||
|
options: categoryOptions
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
```
|
||||||
|
|
||||||
|
## 一个事件管全部筛选
|
||||||
|
|
||||||
|
`filter-change` 同时承载搜索框和下拉项,业务只接一个口:
|
||||||
|
|
||||||
|
| 来源 | `key` | 说明 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| 搜索框 | `keyword` | 固定值,值已转成字符串 |
|
||||||
|
| 下拉项 | 配置里的 `key` | 值原样来自 TDesign DropdownItem |
|
||||||
|
|
||||||
|
`v-model` 照常可用,用来读搜索框内容;只接 `filter-change` 也能跑通。
|
||||||
|
|
||||||
|
```ts
|
||||||
|
function handleFilterChange(change: DropdownFilterChange): void {
|
||||||
|
if (change.key === "keyword") {
|
||||||
|
// 这里做防抖,组件不管节流
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 其余 key 直接写回对应的 ref,再重新拉数据
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
搜索框每次输入都会触发事件,防抖放在业务侧——不同页面的输入成本差别很大,
|
||||||
|
组件里定一个固定间隔只会在某些页面上变成累赘。
|
||||||
|
|
||||||
|
## 放进列表页骨架
|
||||||
|
|
||||||
|
筛选栏要贴在内容区顶部、滚上去被毛玻璃盖住,需要页面骨架配合:
|
||||||
|
|
||||||
|
- 页面根节点:`tui-page-layout` + `tui-navbar`
|
||||||
|
- 内容区(`MasterDetailPage` 自带,或者手写 `main`):追加 `list`
|
||||||
|
- 滚动容器:`t-pull-down-refresh` 加 `pull-refresh`
|
||||||
|
- 筛选栏:`DropdownFilter`,或者手写 `.tui-filters`
|
||||||
|
|
||||||
|
```vue
|
||||||
|
<div class="tui-page-layout tui-navbar">
|
||||||
|
<t-navbar fixed title="库存流水" left-arrow @left-click="$router.back()" />
|
||||||
|
<master-detail-page class="list" :split="isWide" :selected="!!selectedId">
|
||||||
|
<template #master>
|
||||||
|
<t-pull-down-refresh class="pull-refresh" v-model="isRefreshing" @refresh="reload">
|
||||||
|
<dropdown-filter v-model="keyword" :filters="filters" @filter-change="handleFilterChange" />
|
||||||
|
<t-cell-group theme="card">
|
||||||
|
<!-- 列表 -->
|
||||||
|
</t-cell-group>
|
||||||
|
</t-pull-down-refresh>
|
||||||
|
</template>
|
||||||
|
</master-detail-page>
|
||||||
|
</div>
|
||||||
|
```
|
||||||
|
|
||||||
|
这三层各管一件事,缺一层都会露馅:
|
||||||
|
|
||||||
|
| 位置 | 类名 | 作用 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| 内容区 | `list` | 清掉内容区自己的上下内边距,间距改由滚动容器承担 |
|
||||||
|
| 滚动容器 | `pull-refresh` | 接管滚动,撑满剩余高度,底部让出安全区 |
|
||||||
|
| 筛选栏 | `tui-filters` | 吸顶、毛玻璃、搜索框与菜单连成一块 |
|
||||||
|
|
||||||
|
### 菜单展开时筛选栏被滚走
|
||||||
|
|
||||||
|
TDesign 展开下拉菜单时会往 `.t-pull-down-refresh__track` 写 `overflow: hidden`,
|
||||||
|
track 一旦成为滚动容器,`sticky` 就失效。骨架里已经处理了两条路:
|
||||||
|
|
||||||
|
- 浏览器支持 `:has()`:滚动容器里出现 `.tui-filters` 就自动放开 `overflow`
|
||||||
|
- 不支持,或者筛选栏被别的元素包了一层:给滚动容器加 `has-dropdown-filter`
|
||||||
|
|
||||||
|
```vue
|
||||||
|
<t-pull-down-refresh class="pull-refresh has-dropdown-filter" v-model="isRefreshing" @refresh="reload">
|
||||||
|
```
|
||||||
|
|
||||||
|
## 深色模式
|
||||||
|
|
||||||
|
筛选栏只用 TDesign 语义变量(`--td-bg-color-container`、`--td-component-border`),
|
||||||
|
深色主题下由 TDesign 的变量切换接管,不需要额外写一套。
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
<api-table name="DropdownFilter" />
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# 组件总览
|
# 组件总览
|
||||||
|
|
||||||
共 21 个组件,分为布局、编辑器、交互与 AI 对话四类。
|
共 22 个组件,分为布局、编辑器、交互与 AI 对话四类。
|
||||||
|
|
||||||
## 布局组件
|
## 布局组件
|
||||||
|
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
| [MasterDetail](/components/master-detail) | 宽屏下列表与详情并排,窄屏只渲染列表。 |
|
| [MasterDetail](/components/master-detail) | 宽屏下列表与详情并排,窄屏只渲染列表。 |
|
||||||
| [PaneTransition](/components/pane-transition) | 与路由无关的左右推入效果,用于栏位内部的视图切换。 |
|
| [PaneTransition](/components/pane-transition) | 与路由无关的左右推入效果,用于栏位内部的视图切换。 |
|
||||||
| [MasterDetailPage](/components/master-detail-page) | 把列表页骨架、主从分栏与栏内过渡打包成一个组件,列表页不再手写 master-detail。 |
|
| [MasterDetailPage](/components/master-detail-page) | 把列表页骨架、主从分栏与栏内过渡打包成一个组件,列表页不再手写 master-detail。 |
|
||||||
|
| [DropdownFilter](/components/dropdown-filter) | 列表页顶部的搜索框与下拉筛选,取值和事件统一收口。 |
|
||||||
|
|
||||||
## 编辑器组件
|
## 编辑器组件
|
||||||
|
|
||||||
|
|||||||
@@ -74,6 +74,30 @@ demo-preview=../demos/master-detail-page/sub.vue
|
|||||||
第三层只在分栏形态下成立:`split` 为 false 时 `sub` 被忽略,
|
第三层只在分栏形态下成立:`split` 为 false 时 `sub` 被忽略,
|
||||||
子页要走整页路由,由详情页自己判断(`usePane().openSub()` 会返回 false)。
|
子页要走整页路由,由详情页自己判断(`usePane().openSub()` 会返回 false)。
|
||||||
|
|
||||||
|
### 列表要留着的时候:`sub-mode="cover"`
|
||||||
|
|
||||||
|
上面那种是「同一条记录继续往下钻」,列表可以不要了。但如果从详情跳进的是**另一个模块**
|
||||||
|
的页面,用户还得对着列表核对,`shift` 把列表推走就错了。
|
||||||
|
|
||||||
|
传 `sub-mode="cover"`:主栏不动、子页直接盖住详情栏,详情原地保活(返回时滚动位置和状态都在)。
|
||||||
|
|
||||||
|
```vue
|
||||||
|
<master-detail-page :split="isWide" :selected="!!selectedId" :sub="!!subView" sub-mode="cover">
|
||||||
|
<template #master><!-- 资金流水列表 --></template>
|
||||||
|
<template #detail><fund-record-detail :record-id="selectedId" /></template>
|
||||||
|
<template #sub><sales-order-detail :order-id="orderPane.orderId" /></template>
|
||||||
|
</master-detail-page>
|
||||||
|
```
|
||||||
|
|
||||||
|
| 状态 | 主栏 | 右栏 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| 选中 | 列表 | 详情 |
|
||||||
|
| `sub` 为 true | 列表(不动) | 子页 |
|
||||||
|
|
||||||
|
两种模式共用同一套 `sub` / `subView` 状态,层级、历史和 `pane.close()` 的行为完全一致,
|
||||||
|
只影响布局。子页里再换一层(订单详情 → 取消订单)仍然是给 `#sub` 里的内容换 `:key`,
|
||||||
|
外层 `PaneTransition` 自动接上。
|
||||||
|
|
||||||
### 谁来决定子页
|
### 谁来决定子页
|
||||||
|
|
||||||
详情页发起,列表页编排:
|
详情页发起,列表页编排:
|
||||||
@@ -100,6 +124,18 @@ const { selectedId, subView } = useMasterDetailPane({
|
|||||||
子页里的返回调 `usePane().close()`,会关掉最上面一层;`pane.close(true)` 表示
|
子页里的返回调 `usePane().close()`,会关掉最上面一层;`pane.close(true)` 表示
|
||||||
子页里改过数据,回到详情时宿主会重新拉一次。
|
子页里改过数据,回到详情时宿主会重新拉一次。
|
||||||
|
|
||||||
|
宿主需要给子页标识补前缀(例如标明"叠在哪一单上")时,用 `providePane` 在页面最外层
|
||||||
|
换一套派生上下文,别在中间塞容器组件——那会切断栏内骨架的直系选择器:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const { selectedId, subView, openSub, close } = useMasterDetailPane({ … });
|
||||||
|
|
||||||
|
providePane({
|
||||||
|
close: saved => close(saved),
|
||||||
|
openSub: view => openSub(buildView(orderPane.value.orderId, view))
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
子页内部不要再套一层 `MasterDetailPage` 分栏——右栏本来就不宽,
|
子页内部不要再套一层 `MasterDetailPage` 分栏——右栏本来就不宽,
|
||||||
需要列表就用单栏形态(`split` 传 false)。
|
需要列表就用单栏形态(`split` 传 false)。
|
||||||
|
|
||||||
|
|||||||
@@ -244,6 +244,55 @@ function openSub(view: string): boolean {
|
|||||||
|
|
||||||
用 `useMasterDetailPane` 的话这些它都包了,把 `:sub="!!subView"` 接上即可。
|
用 `useMasterDetailPane` 的话这些它都包了,把 `:sub="!!subView"` 接上即可。
|
||||||
|
|
||||||
|
### 第三层的两种呈现
|
||||||
|
|
||||||
|
同样是第三层,用户要不要继续看列表,决定了完全不同的排布:
|
||||||
|
|
||||||
|
| `sub-mode` | 主栏 | 右栏 | 用在什么场景 |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| `shift`(默认) | 详情 | 子页 | 同一条记录继续往下钻,列表已经不用看了 |
|
||||||
|
| `cover` | 列表(不动) | 子页 | 从详情跳进**另一个模块**的页面,列表要一直在眼前 |
|
||||||
|
|
||||||
|
`cover` 的典型例子:资金流水列表 → 某条流水的详情 → 点「交易订单详情」。
|
||||||
|
这时订单是另一个模块的整页,但用户还在按资金流水核对,列表必须留着。
|
||||||
|
`shift` 会把列表整列推走,正好相反。
|
||||||
|
|
||||||
|
```vue
|
||||||
|
<master-detail :split="isWide" :detail-empty="!selectedId" :sub="!!subView" sub-mode="cover">
|
||||||
|
<template #master><!-- 资金流水列表 --></template>
|
||||||
|
<template #detail>
|
||||||
|
<fund-record-detail :record-id="selectedId" />
|
||||||
|
</template>
|
||||||
|
<template #sub>
|
||||||
|
<sales-order-detail :order-id="orderPane.orderId" />
|
||||||
|
</template>
|
||||||
|
</master-detail>
|
||||||
|
```
|
||||||
|
|
||||||
|
`cover` 下详情不参与位移,只原地淡出——**保活**,返回时滚动位置和内部表单状态都还在,
|
||||||
|
不会像 `v-if` 重建那样重新拉一次接口。
|
||||||
|
|
||||||
|
两种模式共用同一套 `sub` / `subView` 状态,只是布局不同:层级、历史和 `pane.close()` 的行为完全一致。
|
||||||
|
|
||||||
|
### 右栏里的页面怎么带上前缀
|
||||||
|
|
||||||
|
子页标识由内容页发起(`pane.openSub("payment")`),但宿主可能需要在前面补上"叠在哪一条上",
|
||||||
|
例如 `sales-order:<订单 id>:payment`。别在中间塞一层容器组件去改写——容器会切断
|
||||||
|
`.detail > .tui-page-layout` / `.sub > .tui-page-layout` 这些直系选择器,栏内导航栏会退回 `fixed`
|
||||||
|
飘到视口顶上。用 `providePane` 在页面最外层换一套派生上下文:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const { selectedId, subView, openSub, close } = useMasterDetailPane({ … });
|
||||||
|
|
||||||
|
providePane({
|
||||||
|
close: saved => close(saved),
|
||||||
|
// 订单页发的是 `payment`,补上订单 id 后宿主的 #sub 才知道渲染谁
|
||||||
|
openSub: view => openSub(isOrderView(view) ? view : buildView(orderId, view))
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
它只在当前组件的后代里生效,并会遮蔽上层的同一套上下文,所以 `close` 要原样转发。
|
||||||
|
|
||||||
### 切换动画
|
### 切换动画
|
||||||
|
|
||||||
右栏换视图没有路由变化,所以不能用 `PageTransition`,改用 `PaneTransition`(只做效果,不绑定路由):
|
右栏换视图没有路由变化,所以不能用 `PageTransition`,改用 `PaneTransition`(只做效果,不绑定路由):
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
# Timeline 时间轴
|
||||||
|
|
||||||
|
按时间顺序展示事件,使用 `Timeline` 和 `TimelineItem` 组合。
|
||||||
|
|
||||||
|
:::preview 基础用法
|
||||||
|
|
||||||
|
demo-preview=../demos/timeline/basic.vue
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
容器支持 `layout`(`vertical`、`horizontal`)和 `reverse`。节点支持 `label`、`content`、`dot-color`,以及默认、`label`、`content`、`dot` 插槽。点击节点触发 `click`,参数包含事件 `e` 和节点属性 `item`。
|
||||||
|
|
||||||
|
这是基础实现,暂不支持 PC 端的全部属性和布局。
|
||||||
|
|
||||||
|
## 样式变量
|
||||||
|
|
||||||
|
可在时间轴或其祖先元素上覆盖以下 CSS 变量。圆点颜色使用节点的 `dot-color` 属性设置。
|
||||||
|
|
||||||
|
| 变量 | 默认值 | 说明 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `--t-timeline-dot-size` | `.5rem` | 圆点宽高 |
|
||||||
|
| `--t-timeline-dot-border-width` | `2px` | 圆点边框宽度 |
|
||||||
|
| `--t-timeline-dot-background` | `var(--td-bg-color-container, #fff)` | 圆点背景 |
|
||||||
|
| `--t-timeline-line-width` | `2px` | 连接线粗细 |
|
||||||
|
| `--t-timeline-line-color` | `var(--td-component-border, #ddd)` | 连接线颜色 |
|
||||||
|
| `--t-timeline-line-gap` | `.25rem` | 连接线与圆点的间隙 |
|
||||||
|
| `--t-timeline-item-gap` | `1rem` | 纵向节点底部间距 |
|
||||||
|
| `--t-timeline-content-offset` | `1rem` | 纵向内容左侧偏移 |
|
||||||
|
| `--t-timeline-horizontal-offset` | `1.5rem` | 横向内容顶部偏移 |
|
||||||
|
| `--t-timeline-horizontal-gap` | `.75rem` | 横向节点右侧间距 |
|
||||||
|
| `--t-timeline-label-color` | `var(--td-text-color-secondary, #777)` | 时间标签颜色 |
|
||||||
|
|
||||||
|
```css
|
||||||
|
.my-timeline {
|
||||||
|
--t-timeline-dot-size: .625rem;
|
||||||
|
--t-timeline-line-color: #aaa;
|
||||||
|
--t-timeline-item-gap: 1.5rem;
|
||||||
|
}
|
||||||
|
```
|
||||||
@@ -0,0 +1,353 @@
|
|||||||
|
<template>
|
||||||
|
<div class="demo">
|
||||||
|
<p
|
||||||
|
class="voice-placeholder"
|
||||||
|
:class="{ hidden: voiceState !== 'idle' }"
|
||||||
|
v-text="'点击语音按钮,按住下方按钮说话;移出按钮后松开取消'"
|
||||||
|
/>
|
||||||
|
<ai-chat-composer
|
||||||
|
v-model="draft"
|
||||||
|
:is-generating="generating"
|
||||||
|
voice-enabled
|
||||||
|
:voice-state="voiceState"
|
||||||
|
:voice-text="voiceText"
|
||||||
|
@send="sendMessage"
|
||||||
|
@voice-start="onVoiceStart"
|
||||||
|
@voice-stop="onVoiceStop"
|
||||||
|
@voice-cancel="onVoiceCancel"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div class="bar">
|
||||||
|
<label class="mock">
|
||||||
|
<input v-model="mockEnabled" type="checkbox" />
|
||||||
|
<span v-text="'模拟识别'" />
|
||||||
|
</label>
|
||||||
|
<span class="hint" v-text="hint" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ol class="log">
|
||||||
|
<li v-for="(item, index) in log" :key="index" v-text="item" />
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, onBeforeUnmount, onMounted, ref } from "vue";
|
||||||
|
import { AiChatComposer } from "timi-tdesign-mobile";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注意:下面的 Web Speech API 只是文档演示用的适配器,不属于 AiChatComposer。
|
||||||
|
* 组件本身不包含 ASR;换成服务端流式识别或原生桥接时,只需回写 voiceState / voiceText。
|
||||||
|
*/
|
||||||
|
|
||||||
|
type VoiceState = "idle" | "listening" | "processing";
|
||||||
|
|
||||||
|
/** Web Speech API 的主入口不在 lib.dom 里,这里只声明演示用到的部分。 */
|
||||||
|
interface SpeechRecognitionLike {
|
||||||
|
lang: string;
|
||||||
|
continuous: boolean;
|
||||||
|
interimResults: boolean;
|
||||||
|
onresult: ((event: SpeechResultEvent) => void) | null;
|
||||||
|
onerror: ((event: SpeechErrorEvent) => void) | null;
|
||||||
|
onend: (() => void) | null;
|
||||||
|
start: () => void;
|
||||||
|
stop: () => void;
|
||||||
|
abort: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SpeechResultEvent {
|
||||||
|
resultIndex: number;
|
||||||
|
results: ArrayLike<{ isFinal: boolean; 0: { transcript: string } }>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SpeechErrorEvent {
|
||||||
|
error: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
type SpeechRecognitionConstructor = new () => SpeechRecognitionLike;
|
||||||
|
|
||||||
|
/** 模拟识别逐段吐出的文本,用来预览不说话也能看到的完整交互。 */
|
||||||
|
const MOCK_STEPS = [
|
||||||
|
"帮我",
|
||||||
|
"帮我整理一下",
|
||||||
|
"帮我整理一下上周的订单数据",
|
||||||
|
"帮我整理一下上周的订单数据,并总结三条结论"
|
||||||
|
];
|
||||||
|
|
||||||
|
const draft = ref("");
|
||||||
|
const generating = ref(false);
|
||||||
|
const log = ref<string[]>([]);
|
||||||
|
const supported = ref(false);
|
||||||
|
const mockEnabled = ref(false);
|
||||||
|
const voiceState = ref<VoiceState>("idle");
|
||||||
|
const voiceText = ref("");
|
||||||
|
|
||||||
|
let recognition: SpeechRecognitionLike | undefined;
|
||||||
|
let finalText = "";
|
||||||
|
let mockStepTimer: number | undefined;
|
||||||
|
let mockFinishTimer: number | undefined;
|
||||||
|
|
||||||
|
const hint = computed(() => {
|
||||||
|
if (mockEnabled.value) {
|
||||||
|
return "模拟模式:按住按钮说话,松手发送;移出按钮后松开取消。";
|
||||||
|
}
|
||||||
|
if (!supported.value) {
|
||||||
|
return "当前浏览器不支持语音识别,已切换为模拟。";
|
||||||
|
}
|
||||||
|
return "按住按钮说话,识别文本显示在整个控件上方;松手发送,移出按钮后松开取消。";
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 获取浏览器实现;Chrome 与 Edge 需要 webkit 前缀。 */
|
||||||
|
function getSpeechRecognition(): SpeechRecognitionConstructor | undefined {
|
||||||
|
if (typeof window === "undefined") {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
const speechWindow = window as Window & {
|
||||||
|
SpeechRecognition?: SpeechRecognitionConstructor;
|
||||||
|
webkitSpeechRecognition?: SpeechRecognitionConstructor;
|
||||||
|
};
|
||||||
|
return speechWindow.SpeechRecognition ?? speechWindow.webkitSpeechRecognition;
|
||||||
|
}
|
||||||
|
|
||||||
|
function push(message: string): void {
|
||||||
|
log.value = [`${new Date().toLocaleTimeString()} ${message}`, ...log.value].slice(0, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 所有发送入口共用:录音结果与手动输入都走这里。 */
|
||||||
|
function sendMessage(message: string): void {
|
||||||
|
const content = message.trim();
|
||||||
|
if (!content) {
|
||||||
|
push("没有识别到内容,请再试一次");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
draft.value = "";
|
||||||
|
generating.value = true;
|
||||||
|
push(`send("${content}")`);
|
||||||
|
setTimeout(() => {
|
||||||
|
generating.value = false;
|
||||||
|
push("生成结束");
|
||||||
|
}, 1500);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onVoiceStart(): void {
|
||||||
|
voiceText.value = "";
|
||||||
|
finalText = "";
|
||||||
|
if (mockEnabled.value || !supported.value) {
|
||||||
|
startMock();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const SpeechRecognition = getSpeechRecognition();
|
||||||
|
if (!SpeechRecognition) {
|
||||||
|
startMock();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const instance = new SpeechRecognition();
|
||||||
|
instance.lang = "zh-CN";
|
||||||
|
instance.continuous = true;
|
||||||
|
instance.interimResults = true;
|
||||||
|
instance.onresult = handleResult;
|
||||||
|
instance.onerror = handleError;
|
||||||
|
instance.onend = handleEnd;
|
||||||
|
instance.start();
|
||||||
|
recognition = instance;
|
||||||
|
voiceState.value = "listening";
|
||||||
|
} catch {
|
||||||
|
push("语音识别启动失败,已切换模拟识别");
|
||||||
|
startMock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onVoiceStop(): void {
|
||||||
|
stopVoice();
|
||||||
|
}
|
||||||
|
|
||||||
|
function stopVoice(): void {
|
||||||
|
if (voiceState.value !== "listening") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (mockStepTimer !== undefined) {
|
||||||
|
stopMock();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!recognition) {
|
||||||
|
finishVoice();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
voiceState.value = "processing";
|
||||||
|
try {
|
||||||
|
recognition.stop();
|
||||||
|
} catch {
|
||||||
|
finishVoice();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onVoiceCancel(): void {
|
||||||
|
push("已取消语音输入");
|
||||||
|
draft.value = "";
|
||||||
|
resetVoice();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 实时拼接最终结果与临时结果,组件在按住说话区上方展示。 */
|
||||||
|
function handleResult(event: SpeechResultEvent): void {
|
||||||
|
let interim = "";
|
||||||
|
for (let index = event.resultIndex; index < event.results.length; index += 1) {
|
||||||
|
const result = event.results[index];
|
||||||
|
const transcript = result[0]?.transcript ?? "";
|
||||||
|
if (result.isFinal) {
|
||||||
|
finalText += transcript;
|
||||||
|
} else {
|
||||||
|
interim += transcript;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
voiceText.value = (finalText + interim).trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleError(event: SpeechErrorEvent): void {
|
||||||
|
if (event.error === "aborted") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const messages: Record<string, string> = {
|
||||||
|
"not-allowed": "麦克风权限被拒绝,可勾选「模拟识别」再试",
|
||||||
|
"service-not-allowed": "当前环境不允许语音识别,可勾选「模拟识别」再试",
|
||||||
|
"audio-capture": "没有找到可用的麦克风",
|
||||||
|
network: "语音服务不可用,可勾选「模拟识别」再试",
|
||||||
|
"no-speech": "没有听到声音,请再试一次"
|
||||||
|
};
|
||||||
|
push(messages[event.error] ?? `语音识别失败:${event.error}`);
|
||||||
|
draft.value = "";
|
||||||
|
resetVoice();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleEnd(): void {
|
||||||
|
recognition = undefined;
|
||||||
|
voiceState.value = "processing";
|
||||||
|
finishVoice();
|
||||||
|
}
|
||||||
|
|
||||||
|
function finishVoice(): void {
|
||||||
|
const message = voiceText.value.trim();
|
||||||
|
resetVoice();
|
||||||
|
sendMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
function startMock(): void {
|
||||||
|
voiceState.value = "listening";
|
||||||
|
voiceText.value = MOCK_STEPS[0];
|
||||||
|
let step = 1;
|
||||||
|
mockStepTimer = window.setInterval(() => {
|
||||||
|
voiceText.value = MOCK_STEPS[Math.min(step, MOCK_STEPS.length - 1)];
|
||||||
|
step += 1;
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
function stopMock(): void {
|
||||||
|
if (mockStepTimer !== undefined) {
|
||||||
|
window.clearInterval(mockStepTimer);
|
||||||
|
mockStepTimer = undefined;
|
||||||
|
}
|
||||||
|
voiceState.value = "processing";
|
||||||
|
mockFinishTimer = window.setTimeout(() => {
|
||||||
|
mockFinishTimer = undefined;
|
||||||
|
finishVoice();
|
||||||
|
}, 600);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 释放识别实例与定时器;abort 用于取消,正常结束则只解绑回调。 */
|
||||||
|
function resetVoice(): void {
|
||||||
|
if (recognition) {
|
||||||
|
const instance = recognition;
|
||||||
|
recognition = undefined;
|
||||||
|
instance.onresult = null;
|
||||||
|
instance.onerror = null;
|
||||||
|
instance.onend = null;
|
||||||
|
try {
|
||||||
|
instance.abort();
|
||||||
|
} catch {
|
||||||
|
// 实例可能已自行结束,忽略
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mockStepTimer !== undefined) {
|
||||||
|
window.clearInterval(mockStepTimer);
|
||||||
|
mockStepTimer = undefined;
|
||||||
|
}
|
||||||
|
if (mockFinishTimer !== undefined) {
|
||||||
|
window.clearTimeout(mockFinishTimer);
|
||||||
|
mockFinishTimer = undefined;
|
||||||
|
}
|
||||||
|
voiceState.value = "idle";
|
||||||
|
voiceText.value = "";
|
||||||
|
finalText = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
supported.value = Boolean(getSpeechRecognition());
|
||||||
|
mockEnabled.value = !supported.value;
|
||||||
|
});
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
resetVoice();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
.demo {
|
||||||
|
.voice-placeholder {
|
||||||
|
display: flex;
|
||||||
|
height: 5.5rem;
|
||||||
|
margin: 0 0 .5rem;
|
||||||
|
color: var(--vp-c-text-3);
|
||||||
|
font-size: .75rem;
|
||||||
|
border: 1px dashed var(--vp-c-divider);
|
||||||
|
border-radius: 1rem;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
|
||||||
|
&.hidden {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.bar {
|
||||||
|
display: flex;
|
||||||
|
gap: .5rem;
|
||||||
|
align-items: center;
|
||||||
|
margin-top: .75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mock {
|
||||||
|
gap: .25rem;
|
||||||
|
flex: none;
|
||||||
|
display: inline-flex;
|
||||||
|
font-size: .75rem;
|
||||||
|
cursor: pointer;
|
||||||
|
color: var(--vp-c-text-2);
|
||||||
|
white-space: nowrap;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
input {
|
||||||
|
cursor: pointer;
|
||||||
|
accent-color: var(--vp-c-brand-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.hint {
|
||||||
|
font-size: .75rem;
|
||||||
|
line-height: 1.4;
|
||||||
|
color: var(--vp-c-text-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.log {
|
||||||
|
margin: .75rem 0 0;
|
||||||
|
padding-left: 1.25rem;
|
||||||
|
font-size: .75rem;
|
||||||
|
font-family: monospace;
|
||||||
|
color: var(--vp-c-text-2);
|
||||||
|
|
||||||
|
li {
|
||||||
|
margin-bottom: .25rem;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,152 @@
|
|||||||
|
<template>
|
||||||
|
<div class="demo">
|
||||||
|
<div class="stage">
|
||||||
|
<div class="tui-page-content list">
|
||||||
|
<t-pull-down-refresh class="pull-refresh" :value="false">
|
||||||
|
<dropdown-filter
|
||||||
|
v-model="keyword"
|
||||||
|
:filters="filters"
|
||||||
|
placeholder="搜索产品名称或编码"
|
||||||
|
@filter-change="handleFilterChange"
|
||||||
|
>
|
||||||
|
<template #suffix-icon>
|
||||||
|
<t-button size="extra-small" theme="primary" variant="outline" content="选择" />
|
||||||
|
</template>
|
||||||
|
</dropdown-filter>
|
||||||
|
<div class="list-body">
|
||||||
|
<t-cell-group v-if="visibleList.length" theme="card">
|
||||||
|
<t-cell
|
||||||
|
v-for="item in visibleList"
|
||||||
|
:key="item.id"
|
||||||
|
:title="item.name"
|
||||||
|
:description="item.code"
|
||||||
|
:note="item.status === 'on' ? '在售' : '停售'"
|
||||||
|
/>
|
||||||
|
</t-cell-group>
|
||||||
|
<p v-else class="empty" v-text="'没有匹配的产品'" />
|
||||||
|
</div>
|
||||||
|
</t-pull-down-refresh>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p class="log">
|
||||||
|
<span v-text="'最近一次 filter-change:'" />
|
||||||
|
<code v-text="lastChange" />
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, ref } from "vue";
|
||||||
|
import {
|
||||||
|
DropdownFilter,
|
||||||
|
type DropdownFilterChange,
|
||||||
|
type DropdownFilterItem,
|
||||||
|
type DropdownFilterOption
|
||||||
|
} from "timi-tdesign-mobile";
|
||||||
|
|
||||||
|
const keyword = ref("");
|
||||||
|
const category = ref("all");
|
||||||
|
const status = ref("all");
|
||||||
|
const lastChange = ref("—");
|
||||||
|
|
||||||
|
const productList = [
|
||||||
|
{ id: "p1", name: "氨基酸洁面慕斯", code: "P-1001", category: "cleanser", status: "on" },
|
||||||
|
{ id: "p2", name: "玻尿酸精华液", code: "P-1002", category: "serum", status: "on" },
|
||||||
|
{ id: "p3", name: "烟酰胺原液", code: "P-1003", category: "serum", status: "off" },
|
||||||
|
{ id: "p4", name: "舒缓修护面霜", code: "P-1004", category: "cream", status: "on" },
|
||||||
|
{ id: "p5", name: "清透防晒乳", code: "P-1005", category: "cream", status: "off" },
|
||||||
|
{ id: "p6", name: "氨基酸洗发水", code: "P-1006", category: "body", status: "on" }
|
||||||
|
];
|
||||||
|
|
||||||
|
const categoryOptions: DropdownFilterOption[] = [
|
||||||
|
{ label: "全部品类", value: "all" },
|
||||||
|
{ label: "洁面", value: "cleanser" },
|
||||||
|
{ label: "精华", value: "serum" },
|
||||||
|
{ label: "面霜", value: "cream" },
|
||||||
|
{ label: "身体护理", value: "body" }
|
||||||
|
];
|
||||||
|
|
||||||
|
const statusOptions: DropdownFilterOption[] = [
|
||||||
|
{ label: "全部状态", value: "all" },
|
||||||
|
{ label: "在售", value: "on" },
|
||||||
|
{ label: "停售", value: "off" }
|
||||||
|
];
|
||||||
|
|
||||||
|
const filters = computed<DropdownFilterItem[]>(() => [
|
||||||
|
{
|
||||||
|
key: "category",
|
||||||
|
label: categoryOptions.find(item => item.value === category.value)?.label || "全部品类",
|
||||||
|
value: category.value,
|
||||||
|
options: categoryOptions
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "status",
|
||||||
|
label: statusOptions.find(item => item.value === status.value)?.label || "全部状态",
|
||||||
|
value: status.value,
|
||||||
|
options: statusOptions
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
|
const visibleList = computed(() => {
|
||||||
|
const text = keyword.value.trim().toLowerCase();
|
||||||
|
return productList.filter(item => {
|
||||||
|
const matchedText = !text || `${item.name}${item.code}`.toLowerCase().includes(text);
|
||||||
|
const matchedCategory = category.value === "all" || item.category === category.value;
|
||||||
|
const matchedStatus = status.value === "all" || item.status === status.value;
|
||||||
|
return matchedText && matchedCategory && matchedStatus;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function handleFilterChange(change: DropdownFilterChange): void {
|
||||||
|
lastChange.value = `${change.key} = ${String(change.value)}`;
|
||||||
|
if (change.key === "category") {
|
||||||
|
category.value = String(change.value);
|
||||||
|
}
|
||||||
|
if (change.key === "status") {
|
||||||
|
status.value = String(change.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
.demo {
|
||||||
|
.stage {
|
||||||
|
height: 20rem;
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: .75rem;
|
||||||
|
background: var(--vp-c-bg-alt);
|
||||||
|
|
||||||
|
.tui-page-content {
|
||||||
|
padding-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pull-refresh {
|
||||||
|
padding-top: 1rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-body {
|
||||||
|
margin: 0 1rem 1rem;
|
||||||
|
|
||||||
|
.empty {
|
||||||
|
margin: 0;
|
||||||
|
padding: 2rem 0;
|
||||||
|
font-size: .8125rem;
|
||||||
|
text-align: center;
|
||||||
|
color: var(--vp-c-text-3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.log {
|
||||||
|
margin: .75rem 0 0;
|
||||||
|
font-size: .8125rem;
|
||||||
|
color: var(--vp-c-text-3);
|
||||||
|
|
||||||
|
code {
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--vp-c-brand-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<template>
|
||||||
|
<t-timeline>
|
||||||
|
<t-timeline-item label="2026-11-11" content="提交订单" />
|
||||||
|
<t-timeline-item label="2026-11-12" dot-color="warning">正在配送</t-timeline-item>
|
||||||
|
<t-timeline-item label="2026-11-13" dot-color="default">等待签收</t-timeline-item>
|
||||||
|
</t-timeline>
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { Timeline as TTimeline, TimelineItem as TTimelineItem } from "timi-tdesign-mobile";
|
||||||
|
</script>
|
||||||
+1
-1
@@ -10,7 +10,7 @@
|
|||||||
"preview": "vitepress preview ."
|
"preview": "vitepress preview ."
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"tdesign-mobile-vue": "^1.17.1",
|
"tdesign-mobile-vue": "^1.17.2",
|
||||||
"timi-web": "^1.0.2",
|
"timi-web": "^1.0.2",
|
||||||
"vue": "^3.5.26",
|
"vue": "^3.5.26",
|
||||||
"vue-router": "^4.5.0"
|
"vue-router": "^4.5.0"
|
||||||
|
|||||||
Generated
+23
-16
@@ -9,8 +9,8 @@ importers:
|
|||||||
.:
|
.:
|
||||||
dependencies:
|
dependencies:
|
||||||
tdesign-mobile-vue:
|
tdesign-mobile-vue:
|
||||||
specifier: ^1.17.1
|
specifier: ^1.17.2
|
||||||
version: 1.17.1(vue@3.5.43(typescript@5.9.3))
|
version: 1.17.2(vue@3.5.43(typescript@5.9.3))
|
||||||
timi-web:
|
timi-web:
|
||||||
specifier: ^1.0.2
|
specifier: ^1.0.2
|
||||||
version: 1.0.2(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.9.3)(vue@3.5.43(typescript@5.9.3))
|
version: 1.0.2(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.9.3)(vue@3.5.43(typescript@5.9.3))
|
||||||
@@ -26,7 +26,7 @@ importers:
|
|||||||
version: 25.9.8
|
version: 25.9.8
|
||||||
'@vitepress-demo-preview/plugin':
|
'@vitepress-demo-preview/plugin':
|
||||||
specifier: ^1.4.1
|
specifier: ^1.4.1
|
||||||
version: 1.4.1(markdown-it-container@3.0.0)(vitepress@1.6.4(@algolia/client-search@5.59.0)(@types/node@25.9.8)(less@4.9.1)(postcss@8.5.28)(search-insights@2.17.3)(terser@5.51.2)(typescript@5.9.3))(vue@3.5.43(typescript@5.9.3))
|
version: 1.4.1(markdown-it-container@3.0.0)(vitepress@1.6.4(@algolia/client-search@5.59.0)(@types/node@25.9.8)(less@4.9.1)(postcss@8.5.28)(search-insights@2.17.3)(sortablejs@1.15.7)(terser@5.51.2)(typescript@5.9.3))(vue@3.5.43(typescript@5.9.3))
|
||||||
less:
|
less:
|
||||||
specifier: ^4.5.1
|
specifier: ^4.5.1
|
||||||
version: 4.9.1
|
version: 4.9.1
|
||||||
@@ -41,7 +41,7 @@ importers:
|
|||||||
version: 21.1.0(@vueuse/core@12.8.2(typescript@5.9.3))(esbuild@0.21.5)(rollup@4.63.4)(vite@5.4.21(@types/node@25.9.8)(less@4.9.1)(terser@5.51.2))
|
version: 21.1.0(@vueuse/core@12.8.2(typescript@5.9.3))(esbuild@0.21.5)(rollup@4.63.4)(vite@5.4.21(@types/node@25.9.8)(less@4.9.1)(terser@5.51.2))
|
||||||
vitepress:
|
vitepress:
|
||||||
specifier: ^1.6.4
|
specifier: ^1.6.4
|
||||||
version: 1.6.4(@algolia/client-search@5.59.0)(@types/node@25.9.8)(less@4.9.1)(postcss@8.5.28)(search-insights@2.17.3)(terser@5.51.2)(typescript@5.9.3)
|
version: 1.6.4(@algolia/client-search@5.59.0)(@types/node@25.9.8)(less@4.9.1)(postcss@8.5.28)(search-insights@2.17.3)(sortablejs@1.15.7)(terser@5.51.2)(typescript@5.9.3)
|
||||||
vue-docgen-api:
|
vue-docgen-api:
|
||||||
specifier: ^4.79.2
|
specifier: ^4.79.2
|
||||||
version: 4.79.2(vue@3.5.43(typescript@5.9.3))
|
version: 4.79.2(vue@3.5.43(typescript@5.9.3))
|
||||||
@@ -1648,6 +1648,9 @@ packages:
|
|||||||
shiki@2.5.0:
|
shiki@2.5.0:
|
||||||
resolution: {integrity: sha512-mI//trrsaiCIPsja5CNfsyNOqgAZUb6VpJA+340toL42UpzQlXpwRV9nch69X6gaUxrr9kaOOa6e3y3uAkGFxQ==}
|
resolution: {integrity: sha512-mI//trrsaiCIPsja5CNfsyNOqgAZUb6VpJA+340toL42UpzQlXpwRV9nch69X6gaUxrr9kaOOa6e3y3uAkGFxQ==}
|
||||||
|
|
||||||
|
sortablejs@1.15.7:
|
||||||
|
resolution: {integrity: sha512-Kk8wLQPlS+yi1ZEf48a4+fzHa4yxjC30M/Sr2AnQu+f/MPwvvX9XjZ6OWejiz8crBsLwSq8GHqaxaET7u6ux0A==}
|
||||||
|
|
||||||
source-map-js@1.2.1:
|
source-map-js@1.2.1:
|
||||||
resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}
|
resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}
|
||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
@@ -1693,13 +1696,13 @@ packages:
|
|||||||
tabbable@6.5.0:
|
tabbable@6.5.0:
|
||||||
resolution: {integrity: sha512-wieBHXygIm7OyQOu5hQlkk62/WyCFYGlWg7L6/ZCUZwx0o398Zkn4pVmMyfYhfMG8kGrj/Krt8eIk6UKC6VzwA==}
|
resolution: {integrity: sha512-wieBHXygIm7OyQOu5hQlkk62/WyCFYGlWg7L6/ZCUZwx0o398Zkn4pVmMyfYhfMG8kGrj/Krt8eIk6UKC6VzwA==}
|
||||||
|
|
||||||
tdesign-icons-vue-next@0.4.11:
|
tdesign-icons-vue-next@0.4.12:
|
||||||
resolution: {integrity: sha512-lBkRUy8bdb6lQLFOOkSb1LPdl4CmZRewrc8SOUlmWkDD/DG3BTsSd/ZQ4Z767pPSlypyvxwSwcJgRv6+zjubAQ==}
|
resolution: {integrity: sha512-isuKOIBdOdQCCeWDiOfvdZSucXa0KC6wLBy2YvNLpRZhVxL7SjDVTulCncehzt4JFzi81LI0+dCVohw6GbfjPA==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
vue: ^3.0.0
|
vue: ^3.0.0
|
||||||
|
|
||||||
tdesign-mobile-vue@1.17.1:
|
tdesign-mobile-vue@1.17.2:
|
||||||
resolution: {integrity: sha512-gCmhaNCc2xhSkbITHiXnE/UGs6GHLe9LTE7T26ELOENC5Cqpa+j4KYU9wz6uqFV+Ro10RkG3DFikYHnq0gNN0A==}
|
resolution: {integrity: sha512-/MH+eNnySvMlEMwIlG0sMPOuwUuhWyOHn6HdS79ct9/+ZP+gCDzGH/usgcahZHM1l0ulY2NTlUp32opimlSZkQ==}
|
||||||
engines: {node: '>=18.0.0'}
|
engines: {node: '>=18.0.0'}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
vue: ^3.2.6
|
vue: ^3.2.6
|
||||||
@@ -2710,12 +2713,12 @@ snapshots:
|
|||||||
vite: 5.4.21(@types/node@25.9.8)(less@4.9.1)(terser@5.51.2)
|
vite: 5.4.21(@types/node@25.9.8)(less@4.9.1)(terser@5.51.2)
|
||||||
vue: 3.5.43(typescript@5.9.3)
|
vue: 3.5.43(typescript@5.9.3)
|
||||||
|
|
||||||
'@vitepress-demo-preview/plugin@1.4.1(markdown-it-container@3.0.0)(vitepress@1.6.4(@algolia/client-search@5.59.0)(@types/node@25.9.8)(less@4.9.1)(postcss@8.5.28)(search-insights@2.17.3)(terser@5.51.2)(typescript@5.9.3))(vue@3.5.43(typescript@5.9.3))':
|
'@vitepress-demo-preview/plugin@1.4.1(markdown-it-container@3.0.0)(vitepress@1.6.4(@algolia/client-search@5.59.0)(@types/node@25.9.8)(less@4.9.1)(postcss@8.5.28)(search-insights@2.17.3)(sortablejs@1.15.7)(terser@5.51.2)(typescript@5.9.3))(vue@3.5.43(typescript@5.9.3))':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@flypeng/tool': 5.7.5
|
'@flypeng/tool': 5.7.5
|
||||||
markdown-it: 14.3.2
|
markdown-it: 14.3.2
|
||||||
markdown-it-container: 3.0.0
|
markdown-it-container: 3.0.0
|
||||||
vitepress: 1.6.4(@algolia/client-search@5.59.0)(@types/node@25.9.8)(less@4.9.1)(postcss@8.5.28)(search-insights@2.17.3)(terser@5.51.2)(typescript@5.9.3)
|
vitepress: 1.6.4(@algolia/client-search@5.59.0)(@types/node@25.9.8)(less@4.9.1)(postcss@8.5.28)(search-insights@2.17.3)(sortablejs@1.15.7)(terser@5.51.2)(typescript@5.9.3)
|
||||||
vue: 3.5.43(typescript@5.9.3)
|
vue: 3.5.43(typescript@5.9.3)
|
||||||
|
|
||||||
'@vue/compiler-core@3.5.43':
|
'@vue/compiler-core@3.5.43':
|
||||||
@@ -2811,13 +2814,14 @@ snapshots:
|
|||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- typescript
|
- typescript
|
||||||
|
|
||||||
'@vueuse/integrations@12.8.2(focus-trap@7.8.0)(typescript@5.9.3)':
|
'@vueuse/integrations@12.8.2(focus-trap@7.8.0)(sortablejs@1.15.7)(typescript@5.9.3)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@vueuse/core': 12.8.2(typescript@5.9.3)
|
'@vueuse/core': 12.8.2(typescript@5.9.3)
|
||||||
'@vueuse/shared': 12.8.2(typescript@5.9.3)
|
'@vueuse/shared': 12.8.2(typescript@5.9.3)
|
||||||
vue: 3.5.43(typescript@5.9.3)
|
vue: 3.5.43(typescript@5.9.3)
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
focus-trap: 7.8.0
|
focus-trap: 7.8.0
|
||||||
|
sortablejs: 1.15.7
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- typescript
|
- typescript
|
||||||
|
|
||||||
@@ -3656,6 +3660,8 @@ snapshots:
|
|||||||
'@shikijs/vscode-textmate': 10.0.2
|
'@shikijs/vscode-textmate': 10.0.2
|
||||||
'@types/hast': 3.0.5
|
'@types/hast': 3.0.5
|
||||||
|
|
||||||
|
sortablejs@1.15.7: {}
|
||||||
|
|
||||||
source-map-js@1.2.1: {}
|
source-map-js@1.2.1: {}
|
||||||
|
|
||||||
source-map-support@0.5.21:
|
source-map-support@0.5.21:
|
||||||
@@ -3697,19 +3703,20 @@ snapshots:
|
|||||||
|
|
||||||
tabbable@6.5.0: {}
|
tabbable@6.5.0: {}
|
||||||
|
|
||||||
tdesign-icons-vue-next@0.4.11(vue@3.5.43(typescript@5.9.3)):
|
tdesign-icons-vue-next@0.4.12(vue@3.5.43(typescript@5.9.3)):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/runtime': 7.29.7
|
'@babel/runtime': 7.29.7
|
||||||
vue: 3.5.43(typescript@5.9.3)
|
vue: 3.5.43(typescript@5.9.3)
|
||||||
|
|
||||||
tdesign-mobile-vue@1.17.1(vue@3.5.43(typescript@5.9.3)):
|
tdesign-mobile-vue@1.17.2(vue@3.5.43(typescript@5.9.3)):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/runtime': 7.29.7
|
'@babel/runtime': 7.29.7
|
||||||
'@use-gesture/vanilla': 10.3.1
|
'@use-gesture/vanilla': 10.3.1
|
||||||
'@vueuse/core': 10.7.0(vue@3.5.43(typescript@5.9.3))
|
'@vueuse/core': 10.7.0(vue@3.5.43(typescript@5.9.3))
|
||||||
dayjs: 1.11.23
|
dayjs: 1.11.23
|
||||||
lodash-es: 4.18.1
|
lodash-es: 4.18.1
|
||||||
tdesign-icons-vue-next: 0.4.11(vue@3.5.43(typescript@5.9.3))
|
sortablejs: 1.15.7
|
||||||
|
tdesign-icons-vue-next: 0.4.12(vue@3.5.43(typescript@5.9.3))
|
||||||
tinycolor2: 1.6.0
|
tinycolor2: 1.6.0
|
||||||
validator: 13.15.35
|
validator: 13.15.35
|
||||||
vue: 3.5.43(typescript@5.9.3)
|
vue: 3.5.43(typescript@5.9.3)
|
||||||
@@ -3897,7 +3904,7 @@ snapshots:
|
|||||||
less: 4.9.1
|
less: 4.9.1
|
||||||
terser: 5.51.2
|
terser: 5.51.2
|
||||||
|
|
||||||
vitepress@1.6.4(@algolia/client-search@5.59.0)(@types/node@25.9.8)(less@4.9.1)(postcss@8.5.28)(search-insights@2.17.3)(terser@5.51.2)(typescript@5.9.3):
|
vitepress@1.6.4(@algolia/client-search@5.59.0)(@types/node@25.9.8)(less@4.9.1)(postcss@8.5.28)(search-insights@2.17.3)(sortablejs@1.15.7)(terser@5.51.2)(typescript@5.9.3):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@docsearch/css': 3.8.2
|
'@docsearch/css': 3.8.2
|
||||||
'@docsearch/js': 3.8.2(@algolia/client-search@5.59.0)(search-insights@2.17.3)
|
'@docsearch/js': 3.8.2(@algolia/client-search@5.59.0)(search-insights@2.17.3)
|
||||||
@@ -3910,7 +3917,7 @@ snapshots:
|
|||||||
'@vue/devtools-api': 7.7.10
|
'@vue/devtools-api': 7.7.10
|
||||||
'@vue/shared': 3.5.43
|
'@vue/shared': 3.5.43
|
||||||
'@vueuse/core': 12.8.2(typescript@5.9.3)
|
'@vueuse/core': 12.8.2(typescript@5.9.3)
|
||||||
'@vueuse/integrations': 12.8.2(focus-trap@7.8.0)(typescript@5.9.3)
|
'@vueuse/integrations': 12.8.2(focus-trap@7.8.0)(sortablejs@1.15.7)(typescript@5.9.3)
|
||||||
focus-trap: 7.8.0
|
focus-trap: 7.8.0
|
||||||
mark.js: 8.11.1
|
mark.js: 8.11.1
|
||||||
minisearch: 7.2.0
|
minisearch: 7.2.0
|
||||||
|
|||||||
+27
-8
@@ -1,11 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "timi-tdesign-mobile",
|
"name": "@timi/tdesign-mobile",
|
||||||
"main": "./dist/timi-tdesign-mobile.umd.js",
|
"type": "module",
|
||||||
|
"main": "./dist/index.js",
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
"module": "./dist/timi-tdesign-mobile.mjs",
|
"module": "./dist/index.js",
|
||||||
"style": "./dist/timi-tdesign-mobile.css",
|
"style": "./dist/timi-tdesign-mobile.css",
|
||||||
|
"sideEffects": [
|
||||||
|
"**/*.css"
|
||||||
|
],
|
||||||
"private": false,
|
"private": false,
|
||||||
"version": "1.1.0",
|
"version": "2.1.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "pnpm run -C docs dev",
|
"dev": "pnpm run -C docs dev",
|
||||||
@@ -25,8 +29,23 @@
|
|||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
"types": "./dist/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
"import": "./dist/timi-tdesign-mobile.mjs",
|
"import": "./dist/index.js"
|
||||||
"require": "./dist/timi-tdesign-mobile.umd.js"
|
},
|
||||||
|
"./components": {
|
||||||
|
"types": "./dist/components/index.d.ts",
|
||||||
|
"import": "./dist/components/index.js"
|
||||||
|
},
|
||||||
|
"./components/*": {
|
||||||
|
"types": "./dist/components/*/index.d.ts",
|
||||||
|
"import": "./dist/components/*/index.js"
|
||||||
|
},
|
||||||
|
"./directives": {
|
||||||
|
"types": "./dist/directives/index.d.ts",
|
||||||
|
"import": "./dist/directives/index.js"
|
||||||
|
},
|
||||||
|
"./utils/message": {
|
||||||
|
"types": "./dist/utils/message.d.ts",
|
||||||
|
"import": "./dist/utils/message.js"
|
||||||
},
|
},
|
||||||
"./style.css": "./dist/timi-tdesign-mobile.css",
|
"./style.css": "./dist/timi-tdesign-mobile.css",
|
||||||
"./src/*": "./src/*"
|
"./src/*": "./src/*"
|
||||||
@@ -35,8 +54,8 @@
|
|||||||
"node": ">=20.0.0"
|
"node": ">=20.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"tdesign-mobile-vue": "^1.17.1",
|
"tdesign-mobile-vue": "^1.17.2",
|
||||||
"timi-web": "^1.0.2"
|
"@timi/web": "^2.0.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"vue": "^3.5.0",
|
"vue": "^3.5.0",
|
||||||
|
|||||||
Generated
+65
-58
@@ -8,12 +8,12 @@ importers:
|
|||||||
|
|
||||||
.:
|
.:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
'@timi/web':
|
||||||
|
specifier: ^2.0.0
|
||||||
|
version: 2.0.0(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.8.3)(vue@3.5.26(typescript@5.8.3))
|
||||||
tdesign-mobile-vue:
|
tdesign-mobile-vue:
|
||||||
specifier: ^1.17.1
|
specifier: ^1.17.2
|
||||||
version: 1.17.1(vue@3.5.26(typescript@5.8.3))
|
version: 1.17.2(vue@3.5.26(typescript@5.8.3))
|
||||||
timi-web:
|
|
||||||
specifier: ^1.0.2
|
|
||||||
version: 1.0.2(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.8.3)(vue@3.5.26(typescript@5.8.3))
|
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@types/node':
|
'@types/node':
|
||||||
specifier: ^22.13.5
|
specifier: ^22.13.5
|
||||||
@@ -1152,6 +1152,14 @@ packages:
|
|||||||
'@soda/get-current-script@1.0.2':
|
'@soda/get-current-script@1.0.2':
|
||||||
resolution: {integrity: sha512-T7VNNlYVM1SgQ+VsMYhnDkcGmWhQdL0bDyGm5TlQ3GBXnJscEClUUOKduWTmm2zCnvNLC1hc3JpuXjs/nFOc5w==}
|
resolution: {integrity: sha512-T7VNNlYVM1SgQ+VsMYhnDkcGmWhQdL0bDyGm5TlQ3GBXnJscEClUUOKduWTmm2zCnvNLC1hc3JpuXjs/nFOc5w==}
|
||||||
|
|
||||||
|
'@timi/ts@1.0.0':
|
||||||
|
resolution: {integrity: sha512-0NFi1+CnonZTcf73IeDdcd5Qoqnt/EdESI448wHfdbd5mk6gRqJNzb82z03SHOCJlIOiLUPvBgctAVLbB58V1A==}
|
||||||
|
engines: {node: '>=20.0.0'}
|
||||||
|
|
||||||
|
'@timi/web@2.0.0':
|
||||||
|
resolution: {integrity: sha512-Qp/jvLpRbmPCK6jO70cHuefHdw8qw4l90GjPRFpo0ZB8CpIYmwcqHffcDS61p59z1GqsDP6BGT1kEPHDGxDsGg==}
|
||||||
|
engines: {node: '>=20.0.0'}
|
||||||
|
|
||||||
'@tiptap/core@3.33.0':
|
'@tiptap/core@3.33.0':
|
||||||
resolution: {integrity: sha512-sZjBCwK9+h0kbc/CZvkepX6RTJ2jOfeWY1aId9O3YnG0CAiOs/4DbqFmpcmv5BQAGPA6gC96gqdafa/9Dpg0tw==}
|
resolution: {integrity: sha512-sZjBCwK9+h0kbc/CZvkepX6RTJ2jOfeWY1aId9O3YnG0CAiOs/4DbqFmpcmv5BQAGPA6gC96gqdafa/9Dpg0tw==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@@ -3271,6 +3279,7 @@ packages:
|
|||||||
image-size@0.5.5:
|
image-size@0.5.5:
|
||||||
resolution: {integrity: sha512-6TDAlDPZxUFCv+fuOkIoXT/V/f3Qbq8e37p+YOiYrUv3v9cc3/6x78VdfPgFVaB9dZYeLUfKgHRebpkm/oP2VQ==}
|
resolution: {integrity: sha512-6TDAlDPZxUFCv+fuOkIoXT/V/f3Qbq8e37p+YOiYrUv3v9cc3/6x78VdfPgFVaB9dZYeLUfKgHRebpkm/oP2VQ==}
|
||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
|
deprecated: Please migrate to image-size@2.x
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
import-fresh@3.3.1:
|
import-fresh@3.3.1:
|
||||||
@@ -4675,6 +4684,9 @@ packages:
|
|||||||
sockjs@0.3.24:
|
sockjs@0.3.24:
|
||||||
resolution: {integrity: sha512-GJgLTZ7vYb/JtPSSZ10hsOYIvEYsjbNU+zPdIHcUaWVNUEPivzxku31865sSSud0Da0W4lEeOPlmw93zLQchuQ==}
|
resolution: {integrity: sha512-GJgLTZ7vYb/JtPSSZ10hsOYIvEYsjbNU+zPdIHcUaWVNUEPivzxku31865sSSud0Da0W4lEeOPlmw93zLQchuQ==}
|
||||||
|
|
||||||
|
sortablejs@1.15.7:
|
||||||
|
resolution: {integrity: sha512-Kk8wLQPlS+yi1ZEf48a4+fzHa4yxjC30M/Sr2AnQu+f/MPwvvX9XjZ6OWejiz8crBsLwSq8GHqaxaET7u6ux0A==}
|
||||||
|
|
||||||
source-map-js@1.2.1:
|
source-map-js@1.2.1:
|
||||||
resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}
|
resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}
|
||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
@@ -4817,13 +4829,13 @@ packages:
|
|||||||
resolution: {integrity: sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==}
|
resolution: {integrity: sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==}
|
||||||
engines: {node: '>=6'}
|
engines: {node: '>=6'}
|
||||||
|
|
||||||
tdesign-icons-vue-next@0.4.11:
|
tdesign-icons-vue-next@0.4.12:
|
||||||
resolution: {integrity: sha512-lBkRUy8bdb6lQLFOOkSb1LPdl4CmZRewrc8SOUlmWkDD/DG3BTsSd/ZQ4Z767pPSlypyvxwSwcJgRv6+zjubAQ==}
|
resolution: {integrity: sha512-isuKOIBdOdQCCeWDiOfvdZSucXa0KC6wLBy2YvNLpRZhVxL7SjDVTulCncehzt4JFzi81LI0+dCVohw6GbfjPA==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
vue: ^3.0.0
|
vue: ^3.0.0
|
||||||
|
|
||||||
tdesign-mobile-vue@1.17.1:
|
tdesign-mobile-vue@1.17.2:
|
||||||
resolution: {integrity: sha512-gCmhaNCc2xhSkbITHiXnE/UGs6GHLe9LTE7T26ELOENC5Cqpa+j4KYU9wz6uqFV+Ro10RkG3DFikYHnq0gNN0A==}
|
resolution: {integrity: sha512-/MH+eNnySvMlEMwIlG0sMPOuwUuhWyOHn6HdS79ct9/+ZP+gCDzGH/usgcahZHM1l0ulY2NTlUp32opimlSZkQ==}
|
||||||
engines: {node: '>=18.0.0'}
|
engines: {node: '>=18.0.0'}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
vue: ^3.2.6
|
vue: ^3.2.6
|
||||||
@@ -4865,14 +4877,6 @@ packages:
|
|||||||
thunky@1.1.0:
|
thunky@1.1.0:
|
||||||
resolution: {integrity: sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA==}
|
resolution: {integrity: sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA==}
|
||||||
|
|
||||||
timi-ts@1.0.0:
|
|
||||||
resolution: {integrity: sha512-MR9LJGH4/UEgzzrc1yVdxypTcoQRASt8xns2z5xNyoXr2e0kdXv8sjnuRshp3uZnOCU/pSks1LeLi9OvC2U/7g==}
|
|
||||||
engines: {node: '>=20.0.0'}
|
|
||||||
|
|
||||||
timi-web@1.0.2:
|
|
||||||
resolution: {integrity: sha512-CXyWEeGTjrExnrAwstdWPc3qK5Lfyp7ipD8p7+WYcm4mcnJOS48k6SkVnrAIADAImeJAr/1e5JEV8wk+8AcvxQ==}
|
|
||||||
engines: {node: '>=20.0.0'}
|
|
||||||
|
|
||||||
tinycolor2@1.6.0:
|
tinycolor2@1.6.0:
|
||||||
resolution: {integrity: sha512-XPaBkWQJdsf3pLKJV9p4qN/S+fm2Oj8AIPo1BTUhg5oxkvm9+SVEGFdhyOz7tTdUTfvxMiAs4sp6/eZO2Ew+pw==}
|
resolution: {integrity: sha512-XPaBkWQJdsf3pLKJV9p4qN/S+fm2Oj8AIPo1BTUhg5oxkvm9+SVEGFdhyOz7tTdUTfvxMiAs4sp6/eZO2Ew+pw==}
|
||||||
|
|
||||||
@@ -6556,6 +6560,44 @@ snapshots:
|
|||||||
|
|
||||||
'@soda/get-current-script@1.0.2': {}
|
'@soda/get-current-script@1.0.2': {}
|
||||||
|
|
||||||
|
'@timi/ts@1.0.0': {}
|
||||||
|
|
||||||
|
'@timi/web@2.0.0(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.8.3)(vue@3.5.26(typescript@5.8.3))':
|
||||||
|
dependencies:
|
||||||
|
'@marsio/vue-split-pane': 1.0.0(typescript@5.8.3)
|
||||||
|
'@timi/ts': 1.0.0
|
||||||
|
'@tiptap/extension-code-block': 3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0)
|
||||||
|
'@tiptap/extension-color': 3.33.0(@tiptap/extension-text-style@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0)))
|
||||||
|
'@tiptap/extension-image': 3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))
|
||||||
|
'@tiptap/extension-link': 3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0)
|
||||||
|
'@tiptap/extension-placeholder': 3.33.0(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))
|
||||||
|
'@tiptap/extension-subscript': 3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0)
|
||||||
|
'@tiptap/extension-superscript': 3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0)
|
||||||
|
'@tiptap/extension-table': 3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0)
|
||||||
|
'@tiptap/extension-table-cell': 3.33.0(@tiptap/extension-table@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))
|
||||||
|
'@tiptap/extension-table-header': 3.33.0(@tiptap/extension-table@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))
|
||||||
|
'@tiptap/extension-table-row': 3.33.0(@tiptap/extension-table@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))
|
||||||
|
'@tiptap/extension-text-align': 3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))
|
||||||
|
'@tiptap/extension-text-style': 3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))
|
||||||
|
'@tiptap/extension-underline': 3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))
|
||||||
|
'@tiptap/pm': 3.33.0
|
||||||
|
'@tiptap/starter-kit': 3.33.0
|
||||||
|
'@tiptap/vue-3': 3.33.0(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0)(vue@3.5.26(typescript@5.8.3))
|
||||||
|
less: 4.5.1
|
||||||
|
marked: 17.0.6
|
||||||
|
marked-gfm-heading-id: 4.1.4(marked@17.0.6)
|
||||||
|
marked-highlight: 2.2.4(marked@17.0.6)
|
||||||
|
marked-mangle: 1.1.14(marked@17.0.6)
|
||||||
|
prismjs: 1.30.0
|
||||||
|
terser: 5.46.0
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- '@floating-ui/dom'
|
||||||
|
- '@tiptap/core'
|
||||||
|
- '@tiptap/extensions'
|
||||||
|
- supports-color
|
||||||
|
- typescript
|
||||||
|
- vue
|
||||||
|
|
||||||
'@tiptap/core@3.33.0(@tiptap/pm@3.33.0)':
|
'@tiptap/core@3.33.0(@tiptap/pm@3.33.0)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@tiptap/pm': 3.33.0
|
'@tiptap/pm': 3.33.0
|
||||||
@@ -10443,6 +10485,8 @@ snapshots:
|
|||||||
uuid: 8.3.2
|
uuid: 8.3.2
|
||||||
websocket-driver: 0.7.4
|
websocket-driver: 0.7.4
|
||||||
|
|
||||||
|
sortablejs@1.15.7: {}
|
||||||
|
|
||||||
source-map-js@1.2.1: {}
|
source-map-js@1.2.1: {}
|
||||||
|
|
||||||
source-map-support@0.5.21:
|
source-map-support@0.5.21:
|
||||||
@@ -10585,19 +10629,20 @@ snapshots:
|
|||||||
|
|
||||||
tapable@2.2.1: {}
|
tapable@2.2.1: {}
|
||||||
|
|
||||||
tdesign-icons-vue-next@0.4.11(vue@3.5.26(typescript@5.8.3)):
|
tdesign-icons-vue-next@0.4.12(vue@3.5.26(typescript@5.8.3)):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/runtime': 7.26.9
|
'@babel/runtime': 7.26.9
|
||||||
vue: 3.5.26(typescript@5.8.3)
|
vue: 3.5.26(typescript@5.8.3)
|
||||||
|
|
||||||
tdesign-mobile-vue@1.17.1(vue@3.5.26(typescript@5.8.3)):
|
tdesign-mobile-vue@1.17.2(vue@3.5.26(typescript@5.8.3)):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/runtime': 7.26.9
|
'@babel/runtime': 7.26.9
|
||||||
'@use-gesture/vanilla': 10.3.1
|
'@use-gesture/vanilla': 10.3.1
|
||||||
'@vueuse/core': 10.7.0(vue@3.5.26(typescript@5.8.3))
|
'@vueuse/core': 10.7.0(vue@3.5.26(typescript@5.8.3))
|
||||||
dayjs: 1.11.13
|
dayjs: 1.11.13
|
||||||
lodash-es: 4.17.21
|
lodash-es: 4.17.21
|
||||||
tdesign-icons-vue-next: 0.4.11(vue@3.5.26(typescript@5.8.3))
|
sortablejs: 1.15.7
|
||||||
|
tdesign-icons-vue-next: 0.4.12(vue@3.5.26(typescript@5.8.3))
|
||||||
tinycolor2: 1.6.0
|
tinycolor2: 1.6.0
|
||||||
validator: 13.12.0
|
validator: 13.12.0
|
||||||
vue: 3.5.26(typescript@5.8.3)
|
vue: 3.5.26(typescript@5.8.3)
|
||||||
@@ -10639,44 +10684,6 @@ snapshots:
|
|||||||
|
|
||||||
thunky@1.1.0: {}
|
thunky@1.1.0: {}
|
||||||
|
|
||||||
timi-ts@1.0.0: {}
|
|
||||||
|
|
||||||
timi-web@1.0.2(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))(typescript@5.8.3)(vue@3.5.26(typescript@5.8.3)):
|
|
||||||
dependencies:
|
|
||||||
'@marsio/vue-split-pane': 1.0.0(typescript@5.8.3)
|
|
||||||
'@tiptap/extension-code-block': 3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0)
|
|
||||||
'@tiptap/extension-color': 3.33.0(@tiptap/extension-text-style@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0)))
|
|
||||||
'@tiptap/extension-image': 3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))
|
|
||||||
'@tiptap/extension-link': 3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0)
|
|
||||||
'@tiptap/extension-placeholder': 3.33.0(@tiptap/extensions@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))
|
|
||||||
'@tiptap/extension-subscript': 3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0)
|
|
||||||
'@tiptap/extension-superscript': 3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0)
|
|
||||||
'@tiptap/extension-table': 3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0)
|
|
||||||
'@tiptap/extension-table-cell': 3.33.0(@tiptap/extension-table@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))
|
|
||||||
'@tiptap/extension-table-header': 3.33.0(@tiptap/extension-table@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))
|
|
||||||
'@tiptap/extension-table-row': 3.33.0(@tiptap/extension-table@3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0))
|
|
||||||
'@tiptap/extension-text-align': 3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))
|
|
||||||
'@tiptap/extension-text-style': 3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))
|
|
||||||
'@tiptap/extension-underline': 3.33.0(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))
|
|
||||||
'@tiptap/pm': 3.33.0
|
|
||||||
'@tiptap/starter-kit': 3.33.0
|
|
||||||
'@tiptap/vue-3': 3.33.0(@floating-ui/dom@1.8.0)(@tiptap/core@3.33.0(@tiptap/pm@3.33.0))(@tiptap/pm@3.33.0)(vue@3.5.26(typescript@5.8.3))
|
|
||||||
less: 4.5.1
|
|
||||||
marked: 17.0.6
|
|
||||||
marked-gfm-heading-id: 4.1.4(marked@17.0.6)
|
|
||||||
marked-highlight: 2.2.4(marked@17.0.6)
|
|
||||||
marked-mangle: 1.1.14(marked@17.0.6)
|
|
||||||
prismjs: 1.30.0
|
|
||||||
terser: 5.46.0
|
|
||||||
timi-ts: 1.0.0
|
|
||||||
transitivePeerDependencies:
|
|
||||||
- '@floating-ui/dom'
|
|
||||||
- '@tiptap/core'
|
|
||||||
- '@tiptap/extensions'
|
|
||||||
- supports-color
|
|
||||||
- typescript
|
|
||||||
- vue
|
|
||||||
|
|
||||||
tinycolor2@1.6.0: {}
|
tinycolor2@1.6.0: {}
|
||||||
|
|
||||||
tinyglobby@0.2.12:
|
tinyglobby@0.2.12:
|
||||||
|
|||||||
@@ -6,6 +6,19 @@
|
|||||||
*/
|
*/
|
||||||
:root {
|
:root {
|
||||||
--tui-split-duration: 320ms;
|
--tui-split-duration: 320ms;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 安全区统一入口,四个方向都从这里取。
|
||||||
|
*
|
||||||
|
* --safe-area-inset-* 由 Capacitor 原生层按 WindowInsets 注入:Android WebView
|
||||||
|
* 不实现 env(safe-area-inset-*),恒返回 0,只有原生注入的变量才是真实值。
|
||||||
|
* iOS / 浏览器没有这套变量,回退到 env()。
|
||||||
|
* 使用方要自己接管安全区时,覆盖这几个 --tui-safe-* 即可。
|
||||||
|
*/
|
||||||
|
--tui-safe-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
|
||||||
|
--tui-safe-right: var(--safe-area-inset-right, env(safe-area-inset-right, 0px));
|
||||||
|
--tui-safe-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
|
||||||
|
--tui-safe-left: var(--safe-area-inset-left, env(safe-area-inset-left, 0px));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -18,6 +31,11 @@
|
|||||||
*
|
*
|
||||||
* .tui-page-content 使用绝对定位铺满上级容器,因此上级必须是
|
* .tui-page-content 使用绝对定位铺满上级容器,因此上级必须是
|
||||||
* PageTransition 渲染出的定位容器,不要在普通 div 中直接使用。
|
* PageTransition 渲染出的定位容器,不要在普通 div 中直接使用。
|
||||||
|
*
|
||||||
|
* 顶部安全区从 --tui-safe-top 取(定义在 :root,Capacitor 注入优先、env() 兜底)。
|
||||||
|
* 这个取值能成立的前提是窗口真的 edge-to-edge:Android 15+ 由系统强制,
|
||||||
|
* Android 15 以下需要在 MainActivity 里调 WindowCompat.setDecorFitsSystemWindows(false)。
|
||||||
|
* 窗口没全屏却按全屏补安全区,顶部就会多出一条状态栏高度的空白。
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,13 +50,70 @@
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
padding-top: var(--tui-detail-empty-inset, calc(var(--safe-area-inset-top, env(safe-area-inset-top, 0px)) + 48px));
|
padding-top: var(--tui-detail-empty-inset, calc(var(--tui-safe-top, 0px) + 48px));
|
||||||
// 必须有不透明背景:切换视图时它和旧内容同时在场,
|
// 必须有不透明背景:切换视图时它和旧内容同时在场,
|
||||||
// 透明的话提示文字会浮在还在滑出的页面上,看起来像重影。
|
// 透明的话提示文字会浮在还在滑出的页面上,看起来像重影。
|
||||||
background: var(--tui-detail-empty-background, var(--td-bg-color-page));
|
background: var(--tui-detail-empty-background, var(--td-bg-color-page));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表页顶部的筛选栏:搜索框 + 下拉菜单贴在内容区顶部,展开的菜单和搜索框连成一块。
|
||||||
|
*
|
||||||
|
* 由 `DropdownFilter` 使用,也接受手写结构——只要根节点挂上这个类,
|
||||||
|
* 内部的 `.t-input` / `.menus` 就按同一套样式渲染。`z-index` 让整条栏浮在列表之上,
|
||||||
|
* 毛玻璃背景用 `::after` 单独一层,往下渐隐,内容滚过去才有层次感。
|
||||||
|
*/
|
||||||
|
.tui-filters {
|
||||||
|
top: -1rem;
|
||||||
|
margin: -1rem 0 0;
|
||||||
|
padding: 1rem 1rem 0;
|
||||||
|
z-index: 10;
|
||||||
|
position: sticky;
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
mask: linear-gradient(to top, transparent 0%, #000 60%);
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
content: "";
|
||||||
|
z-index: -1;
|
||||||
|
position: absolute;
|
||||||
|
backdrop-filter: blur(var(--tui-backdrop-blur, 10px));
|
||||||
|
-webkit-mask: linear-gradient(to top, transparent 0%, #000 60%);
|
||||||
|
-webkit-backdrop-filter: blur(var(--tui-backdrop-blur, 10px));
|
||||||
|
}
|
||||||
|
|
||||||
|
.t-input {
|
||||||
|
--td-button-border-radius: 99rem;
|
||||||
|
|
||||||
|
border: 1px solid var(--td-component-border);
|
||||||
|
height: 2.25rem;
|
||||||
|
padding: .25rem .25rem .25rem .75rem;
|
||||||
|
z-index: 2;
|
||||||
|
position: relative;
|
||||||
|
border-radius: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tabs {
|
||||||
|
--td-tab-item-height: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menus {
|
||||||
|
--td-spacer-1: 6px;
|
||||||
|
|
||||||
|
width: 100%;
|
||||||
|
border: 1px solid rgba(148, 163, 184, .18);
|
||||||
|
z-index: 1;
|
||||||
|
overflow: hidden;
|
||||||
|
margin-top: -1rem;
|
||||||
|
border-top: none;
|
||||||
|
padding-top: .8rem;
|
||||||
|
border-radius: 0 0 1rem 1rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.tui-page-layout {
|
.tui-page-layout {
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
@@ -54,8 +129,8 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding-top: calc(var(--safe-area-inset-top, env(safe-area-inset-top, 0px)) + 48px + 1rem);
|
padding-top: calc(var(--tui-safe-top, 0px) + 48px + 1rem);
|
||||||
padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
|
padding-bottom: calc(var(--tui-safe-bottom, 0px) + 1rem);
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
&.scroll {
|
&.scroll {
|
||||||
@@ -72,11 +147,53 @@
|
|||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表页的滚动容器。
|
||||||
|
*
|
||||||
|
* 内容区自己不滚动(`tui-page-content` 默认 `overflow: hidden`),
|
||||||
|
* 列表页把滚动权交给这个容器:外层只分配高度,`t-pull-down-refresh` 负责滚。
|
||||||
|
* track 撑满高度并纵向排列,空态才能垂直居中。
|
||||||
|
*/
|
||||||
|
.pull-refresh {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
overflow-x: hidden;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding-bottom: calc(var(--tui-safe-bottom, 0px) + 1rem);
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
|
||||||
|
.t-pull-down-refresh__track {
|
||||||
|
gap: 1rem;
|
||||||
|
display: flex;
|
||||||
|
min-height: 100%;
|
||||||
|
height: auto;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 筛选菜单展开时 TDesign 会给 track 写 `overflow: hidden`,
|
||||||
|
* 那会让 track 变成 sticky 的滚动容器,筛选栏跟着整条滚走。
|
||||||
|
* 有 `:has()` 时自动识别,没有时由 `.has-dropdown-filter` 兜底。
|
||||||
|
*/
|
||||||
|
@supports selector(:has(*)) {
|
||||||
|
&:has(.tui-filters) .t-pull-down-refresh__track {
|
||||||
|
overflow: visible !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.has-dropdown-filter {
|
||||||
|
|
||||||
|
.t-pull-down-refresh__track {
|
||||||
|
overflow: visible !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.tui-navbar {
|
&.tui-navbar {
|
||||||
--tui-nav-height: calc(var(--safe-area-inset-top, env(safe-area-inset-top, 0px)) + 48px);
|
--tui-nav-height: calc(var(--tui-safe-top, 0px) + 48px);
|
||||||
--td-navbar-padding-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
|
--td-navbar-padding-top: var(--tui-safe-top, 0px);
|
||||||
|
|
||||||
.t-navbar__content,
|
.t-navbar__content,
|
||||||
.t-navbar__placeholder {
|
.t-navbar__placeholder {
|
||||||
@@ -101,6 +218,20 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表页的顶部间距必须落在真正的滚动容器上,内容才能穿进导航栏的毛玻璃层。
|
||||||
|
* 分栏形态下内容区不滚动、滚动的是主栏里的列表容器,间距的落点一样,
|
||||||
|
* 所以两种形态共用这一条。
|
||||||
|
*/
|
||||||
|
&.tui-navbar .tui-page-content.list {
|
||||||
|
padding-top: 0;
|
||||||
|
padding-bottom: 0;
|
||||||
|
|
||||||
|
.pull-refresh {
|
||||||
|
padding-top: calc(var(--tui-nav-height) + 1rem);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -110,7 +241,7 @@
|
|||||||
.tui-app-shell.is-rail {
|
.tui-app-shell.is-rail {
|
||||||
|
|
||||||
.rail {
|
.rail {
|
||||||
padding-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
|
padding-top: var(--tui-safe-top, 0px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.t-navbar--fixed .t-navbar__content {
|
.t-navbar--fixed .t-navbar__content {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="composer">
|
<div class="composer" :class="{ 'voice-active': voicePressing }">
|
||||||
<div v-if="props.lastError" class="error-bar">
|
<div v-if="props.lastError" class="error-bar">
|
||||||
<slot name="error" :error="props.lastError" :can-retry="props.canRetry">
|
<slot name="error" :error="props.lastError" :can-retry="props.canRetry">
|
||||||
<span class="error-text" v-text="props.lastError" />
|
<span class="error-text" v-text="props.lastError" />
|
||||||
@@ -13,14 +13,39 @@
|
|||||||
</slot>
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
<t-form class="form glass-white" @submit="submitMessage">
|
<t-form class="form glass-white" @submit="submitMessage">
|
||||||
|
<div v-if="voiceMode && (voiceTranscript || voiceTranscriptHint)" class="voice-transcript" aria-live="polite">
|
||||||
|
<div class="voice-wave" aria-hidden="true">
|
||||||
|
<span v-for="index in 5" :key="index" :style="`--i: ${index}`" />
|
||||||
|
</div>
|
||||||
|
<p v-if="voiceTranscript" class="voice-text" v-text="voiceTranscript" />
|
||||||
|
<p v-else class="voice-placeholder" v-text="voiceTranscriptHint" />
|
||||||
|
</div>
|
||||||
|
<div class="input-wrap">
|
||||||
<t-textarea
|
<t-textarea
|
||||||
|
ref="textareaRef"
|
||||||
v-model="draft"
|
v-model="draft"
|
||||||
class="input"
|
class="input"
|
||||||
:autosize="{ minRows: 3, maxRows: 6 }"
|
:class="{ 'voice-input-hidden': voiceMode }"
|
||||||
:disabled="props.isGenerating || props.disabled"
|
:autosize="{ minRows: 2, maxRows: 6 }"
|
||||||
|
:disabled="voiceMode || props.isGenerating || props.disabled"
|
||||||
:maxlength="props.maxLength"
|
:maxlength="props.maxLength"
|
||||||
:placeholder="props.placeholder"
|
:placeholder="props.placeholder"
|
||||||
|
:aria-hidden="voiceMode"
|
||||||
/>
|
/>
|
||||||
|
<button
|
||||||
|
v-if="voiceMode"
|
||||||
|
ref="holdRef"
|
||||||
|
class="voice-hold"
|
||||||
|
:class="{ active: voicePressing, cancel: willCancel }"
|
||||||
|
type="button"
|
||||||
|
:disabled="props.disabled || props.isGenerating"
|
||||||
|
@pointerdown="handleVoicePointerDown"
|
||||||
|
@contextmenu.prevent
|
||||||
|
>
|
||||||
|
<t-icon name="voice-wave" size="small" />
|
||||||
|
<span v-text="voiceHoldLabel" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<div class="tools">
|
<div class="tools">
|
||||||
<t-button
|
<t-button
|
||||||
@@ -61,13 +86,49 @@
|
|||||||
<t-button
|
<t-button
|
||||||
class="send"
|
class="send"
|
||||||
type="button"
|
type="button"
|
||||||
size="extra-small"
|
size="small"
|
||||||
theme="danger"
|
theme="danger"
|
||||||
:disabled="props.disabled"
|
:disabled="props.disabled"
|
||||||
:content="props.stopText"
|
:content="props.stopText"
|
||||||
@click="emit('stop')"
|
@click="emit('stop')"
|
||||||
/>
|
>
|
||||||
|
<template #icon>
|
||||||
|
<t-icon name="stop" />
|
||||||
|
</template>
|
||||||
|
</t-button>
|
||||||
</slot>
|
</slot>
|
||||||
|
<template v-else-if="props.voiceEnabled && voiceMode">
|
||||||
|
<t-button
|
||||||
|
class="send voice-toggle"
|
||||||
|
type="button"
|
||||||
|
size="small"
|
||||||
|
theme="primary"
|
||||||
|
aria-label="切换到键盘输入"
|
||||||
|
:disabled="props.disabled || voicePressing || props.voiceState !== 'idle'"
|
||||||
|
content="输入"
|
||||||
|
@click="exitVoiceMode"
|
||||||
|
>
|
||||||
|
<template #icon>
|
||||||
|
<t-icon name="keyboard-1" />
|
||||||
|
</template>
|
||||||
|
</t-button>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="props.voiceEnabled && !draft.trim()">
|
||||||
|
<t-button
|
||||||
|
class="send voice-toggle"
|
||||||
|
type="button"
|
||||||
|
size="small"
|
||||||
|
theme="primary"
|
||||||
|
aria-label="语音输入"
|
||||||
|
:disabled="props.disabled || props.voiceState !== 'idle'"
|
||||||
|
content="语音"
|
||||||
|
@click="enterVoiceMode"
|
||||||
|
>
|
||||||
|
<template #icon>
|
||||||
|
<t-icon name="voice-wave" />
|
||||||
|
</template>
|
||||||
|
</t-button>
|
||||||
|
</template>
|
||||||
<slot
|
<slot
|
||||||
v-else
|
v-else
|
||||||
name="send"
|
name="send"
|
||||||
@@ -77,11 +138,15 @@
|
|||||||
<t-button
|
<t-button
|
||||||
class="send"
|
class="send"
|
||||||
type="submit"
|
type="submit"
|
||||||
size="extra-small"
|
size="small"
|
||||||
theme="primary"
|
theme="primary"
|
||||||
:disabled="props.disabled"
|
:disabled="props.disabled"
|
||||||
:content="props.sendText"
|
:content="props.sendText"
|
||||||
/>
|
>
|
||||||
|
<template #icon>
|
||||||
|
<t-icon name="send-1" />
|
||||||
|
</template>
|
||||||
|
</t-button>
|
||||||
</slot>
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
</t-form>
|
</t-form>
|
||||||
@@ -89,6 +154,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { computed, nextTick, onBeforeUnmount, ref, useTemplateRef, watch } from "vue";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "AiChatComposer"
|
name: "AiChatComposer"
|
||||||
});
|
});
|
||||||
@@ -103,6 +170,22 @@ export interface Props {
|
|||||||
stopText?: string;
|
stopText?: string;
|
||||||
retryText?: string;
|
retryText?: string;
|
||||||
maxLength?: number;
|
maxLength?: number;
|
||||||
|
/** 是否启用语音输入 */
|
||||||
|
voiceEnabled?: boolean;
|
||||||
|
/** 语音识别状态,由业务侧驱动 */
|
||||||
|
voiceState?: "idle" | "listening" | "processing";
|
||||||
|
/** 语音中间结果 */
|
||||||
|
voiceText?: string;
|
||||||
|
/** 按住说话提示 */
|
||||||
|
voiceHoldText?: string;
|
||||||
|
/** 按住时的提示 */
|
||||||
|
voiceSendHint?: string;
|
||||||
|
/** 移出按住按钮时的提示 */
|
||||||
|
voiceCancelHint?: string;
|
||||||
|
/** 正在聆听提示 */
|
||||||
|
voiceListeningText?: string;
|
||||||
|
/** 正在识别提示 */
|
||||||
|
voiceProcessingText?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
@@ -113,7 +196,15 @@ const props = withDefaults(defineProps<Props>(), {
|
|||||||
sendText: "发送",
|
sendText: "发送",
|
||||||
stopText: "停止",
|
stopText: "停止",
|
||||||
retryText: "重试",
|
retryText: "重试",
|
||||||
maxLength: 2000
|
maxLength: 2000,
|
||||||
|
voiceEnabled: false,
|
||||||
|
voiceState: "idle",
|
||||||
|
voiceText: "",
|
||||||
|
voiceHoldText: "按住 说话",
|
||||||
|
voiceSendHint: "松开 发送",
|
||||||
|
voiceCancelHint: "松开 取消",
|
||||||
|
voiceListeningText: "正在听你说…",
|
||||||
|
voiceProcessingText: "正在识别…"
|
||||||
});
|
});
|
||||||
|
|
||||||
const draft = defineModel<string>({ required: true });
|
const draft = defineModel<string>({ required: true });
|
||||||
@@ -123,8 +214,59 @@ const emit = defineEmits<{
|
|||||||
retry: [];
|
retry: [];
|
||||||
"new-conversation": [];
|
"new-conversation": [];
|
||||||
"add-attachment": [];
|
"add-attachment": [];
|
||||||
|
"voice-start": [];
|
||||||
|
"voice-stop": [];
|
||||||
|
"voice-cancel": [];
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const textareaRef = useTemplateRef<{ focus: () => void }>("textareaRef");
|
||||||
|
const holdRef = useTemplateRef<HTMLElement>("holdRef");
|
||||||
|
const voiceMode = ref(false);
|
||||||
|
const voicePressing = ref(false);
|
||||||
|
const willCancel = ref(false);
|
||||||
|
let voicePointerId: number | undefined;
|
||||||
|
|
||||||
|
const voiceTranscript = computed(() => props.voiceText.trim());
|
||||||
|
|
||||||
|
const voiceHoldLabel = computed(() => {
|
||||||
|
if (willCancel.value) {
|
||||||
|
return props.voiceCancelHint;
|
||||||
|
}
|
||||||
|
if (props.voiceState === "processing") {
|
||||||
|
return props.voiceProcessingText;
|
||||||
|
}
|
||||||
|
if (voicePressing.value) {
|
||||||
|
return props.voiceSendHint;
|
||||||
|
}
|
||||||
|
if (props.voiceState === "listening") {
|
||||||
|
return props.voiceListeningText;
|
||||||
|
}
|
||||||
|
return props.voiceHoldText;
|
||||||
|
});
|
||||||
|
|
||||||
|
const voiceTranscriptHint = computed(() => {
|
||||||
|
if (voiceTranscript.value) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if (props.voiceState === "processing") {
|
||||||
|
return props.voiceProcessingText;
|
||||||
|
}
|
||||||
|
if (voicePressing.value || props.voiceState === "listening") {
|
||||||
|
return props.voiceListeningText;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(() => props.voiceEnabled, (enabled) => {
|
||||||
|
if (enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (voicePressing.value) {
|
||||||
|
cancelVoice();
|
||||||
|
}
|
||||||
|
voiceMode.value = false;
|
||||||
|
});
|
||||||
|
|
||||||
function startNewConversation(): void {
|
function startNewConversation(): void {
|
||||||
if (props.disabled || props.isGenerating) {
|
if (props.disabled || props.isGenerating) {
|
||||||
return;
|
return;
|
||||||
@@ -151,6 +293,96 @@ function submitMessage(): void {
|
|||||||
draft.value = "";
|
draft.value = "";
|
||||||
emit("send", message);
|
emit("send", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function enterVoiceMode(): void {
|
||||||
|
if (!props.voiceEnabled || props.disabled || props.isGenerating || props.voiceState !== "idle" || draft.value.trim()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
voiceMode.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function exitVoiceMode(): void {
|
||||||
|
if (voicePressing.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
voiceMode.value = false;
|
||||||
|
nextTick(() => textareaRef.value?.focus());
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleVoicePointerDown(event: PointerEvent): void {
|
||||||
|
if (!props.voiceEnabled || !voiceMode.value || props.disabled || props.isGenerating || props.voiceState !== "idle" || voicePressing.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
voicePressing.value = true;
|
||||||
|
willCancel.value = false;
|
||||||
|
voicePointerId = event.pointerId;
|
||||||
|
event.preventDefault();
|
||||||
|
// 监听 window,手指移出按钮后仍能收到移动、释放和取消
|
||||||
|
window.addEventListener("pointermove", handleVoicePointerMove);
|
||||||
|
window.addEventListener("pointerup", handleVoicePointerUp);
|
||||||
|
window.addEventListener("pointercancel", handleVoicePointerCancel);
|
||||||
|
navigator.vibrate?.(15);
|
||||||
|
emit("voice-start");
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleVoicePointerMove(event: PointerEvent): void {
|
||||||
|
if (!voicePressing.value || event.pointerId !== voicePointerId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
willCancel.value = !isPointInsideHold(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
function isPointInsideHold(event: PointerEvent): boolean {
|
||||||
|
const element = holdRef.value;
|
||||||
|
if (!element) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const rect = element.getBoundingClientRect();
|
||||||
|
return event.clientX >= rect.left
|
||||||
|
&& event.clientX <= rect.right
|
||||||
|
&& event.clientY >= rect.top
|
||||||
|
&& event.clientY <= rect.bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleVoicePointerUp(event: PointerEvent): void {
|
||||||
|
if (!voicePressing.value || event.pointerId !== voicePointerId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!isPointInsideHold(event)) {
|
||||||
|
cancelVoice();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
resetVoicePress();
|
||||||
|
emit("voice-stop");
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleVoicePointerCancel(event: PointerEvent): void {
|
||||||
|
if (!voicePressing.value || event.pointerId !== voicePointerId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cancelVoice();
|
||||||
|
}
|
||||||
|
|
||||||
|
function cancelVoice(): void {
|
||||||
|
resetVoicePress();
|
||||||
|
emit("voice-cancel");
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetVoicePress(): void {
|
||||||
|
window.removeEventListener("pointermove", handleVoicePointerMove);
|
||||||
|
window.removeEventListener("pointerup", handleVoicePointerUp);
|
||||||
|
window.removeEventListener("pointercancel", handleVoicePointerCancel);
|
||||||
|
voicePressing.value = false;
|
||||||
|
willCancel.value = false;
|
||||||
|
voicePointerId = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
if (voicePressing.value) {
|
||||||
|
emit("voice-cancel");
|
||||||
|
}
|
||||||
|
resetVoicePress();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
@@ -188,22 +420,139 @@ function submitMessage(): void {
|
|||||||
margin: .5rem 0 0;
|
margin: .5rem 0 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: .5rem;
|
padding: .5rem;
|
||||||
|
position: relative;
|
||||||
box-shadow: 0 .5rem 1.5rem rgba(15, 23, 42, .12);
|
box-shadow: 0 .5rem 1.5rem rgba(15, 23, 42, .12);
|
||||||
|
transition: border-color .2s, box-shadow .2s;
|
||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
border-radius: 1.25rem;
|
border-radius: 1.25rem;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
|
.input-wrap {
|
||||||
|
gap: .375rem;
|
||||||
|
display: flex;
|
||||||
|
position: relative;
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
.input {
|
.input {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 0 .25rem;
|
padding: 0 .25rem;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
|
|
||||||
|
&.voice-input-hidden {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.voice-transcript {
|
||||||
|
left: 50%;
|
||||||
|
gap: .5rem;
|
||||||
|
width: 100%;
|
||||||
|
z-index: 3;
|
||||||
|
display: flex;
|
||||||
|
padding: .5rem .75rem;
|
||||||
|
position: absolute;
|
||||||
|
box-sizing: border-box;
|
||||||
|
bottom: calc(100% + .5rem);
|
||||||
|
align-items: center;
|
||||||
|
pointer-events: none;
|
||||||
|
border: 1px solid var(--td-brand-color);
|
||||||
|
background: var(--td-bg-color-container);
|
||||||
|
box-shadow: 0 .5rem 1.5rem rgba(15, 23, 42, .16);
|
||||||
|
animation: voice-transcript-in .16s ease-out;
|
||||||
|
border-radius: 1rem;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.voice-wave {
|
||||||
|
gap: .1875rem;
|
||||||
|
height: 1rem;
|
||||||
|
display: flex;
|
||||||
|
flex: none;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
span {
|
||||||
|
width: .125rem;
|
||||||
|
height: 100%;
|
||||||
|
border-radius: .125rem;
|
||||||
|
background: var(--td-brand-color);
|
||||||
|
animation: voice-wave .9s ease-in-out infinite;
|
||||||
|
animation-delay: calc(var(--i) * .1s);
|
||||||
|
transform: scaleY(.3);
|
||||||
|
transform-origin: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.voice-text,
|
||||||
|
.voice-placeholder {
|
||||||
|
margin: 0;
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
.voice-text {
|
||||||
|
display: -webkit-box;
|
||||||
|
overflow: hidden;
|
||||||
|
color: var(--td-text-color-primary);
|
||||||
|
font-size: .875rem;
|
||||||
|
line-height: 1.4;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
-webkit-line-clamp: 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.voice-placeholder {
|
||||||
|
overflow: hidden;
|
||||||
|
color: var(--td-text-color-placeholder);
|
||||||
|
font-size: .75rem;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.voice-hold {
|
||||||
|
inset: 0;
|
||||||
|
gap: .375rem;
|
||||||
|
z-index: 1;
|
||||||
|
display: flex;
|
||||||
|
padding: 0 .75rem;
|
||||||
|
position: absolute;
|
||||||
|
color: var(--td-brand-color);
|
||||||
|
font-size: .875rem;
|
||||||
|
font-weight: 500;
|
||||||
|
transition: color .15s, border-color .15s;
|
||||||
|
border: 0;
|
||||||
|
border-bottom: 1px solid var(--td-component-border);
|
||||||
|
background: transparent;
|
||||||
|
border-radius: 0;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
touch-action: none;
|
||||||
|
user-select: none;
|
||||||
|
-webkit-tap-highlight-color: transparent;
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
color: var(--td-brand-color);
|
||||||
|
border-bottom-color: var(--td-brand-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
&.cancel {
|
||||||
|
color: var(--td-error-color);
|
||||||
|
border-bottom-color: var(--td-error-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
&:disabled {
|
||||||
|
opacity: .55;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.actions {
|
.actions {
|
||||||
--td-button-border-radius: .75rem;
|
--td-button-border-radius: 1rem;
|
||||||
|
|
||||||
gap: .5rem;
|
gap: .5rem;
|
||||||
|
min-height: 2rem;
|
||||||
margin-top: .375rem;
|
margin-top: .375rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -214,12 +563,60 @@ function submitMessage(): void {
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.send {
|
&.voice-active .form {
|
||||||
padding: 0 1rem;
|
border-color: var(--td-brand-color);
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
content: "";
|
||||||
|
inset: -.125rem;
|
||||||
|
border: 1px solid var(--td-brand-color);
|
||||||
|
position: absolute;
|
||||||
|
animation: voice-breathe 1s ease-in-out 0s infinite;
|
||||||
|
will-change: transform, opacity;
|
||||||
|
border-radius: inherit;
|
||||||
|
pointer-events: none;
|
||||||
|
transform-origin: center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@keyframes voice-breathe {
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
opacity: .6;
|
||||||
|
transform: scaleX(1) scaleY(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
50% {
|
||||||
|
opacity: .2;
|
||||||
|
transform: scaleX(1.02) scaleY(1.08);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes voice-wave {
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
opacity: .5;
|
||||||
|
transform: scaleY(.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
50% {
|
||||||
|
opacity: 1;
|
||||||
|
transform: scaleY(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes voice-transcript-in {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:global(html.theme-dark) {
|
:global(html.theme-dark) {
|
||||||
|
|||||||
@@ -84,7 +84,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { nextTick, useTemplateRef } from "vue";
|
import { nextTick, useTemplateRef } from "vue";
|
||||||
import { MarkdownView } from "timi-web";
|
import { MarkdownView } from "@timi/web/components/markdown-view";
|
||||||
import AiChatThinking from "./AiChatThinking.vue";
|
import AiChatThinking from "./AiChatThinking.vue";
|
||||||
import type {
|
import type {
|
||||||
AiChatMessage,
|
AiChatMessage,
|
||||||
@@ -173,7 +173,7 @@ defineExpose({
|
|||||||
flex: none;
|
flex: none;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: var(--ai-msg-padding-top, .5rem) 1rem calc(var(--ai-chat-bottom-area-height, 4.5rem) + 1.5rem + env(safe-area-inset-bottom, 0px));
|
padding: var(--ai-msg-padding-top, .5rem) 1rem calc(var(--ai-chat-bottom-area-height, 4.5rem) + 1.5rem + var(--tui-safe-bottom, 0px));
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ defineExpose({
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
.bottom-area {
|
.bottom-area {
|
||||||
inset: auto 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
|
inset: auto 1rem calc(1rem + var(--tui-safe-bottom, 0px));
|
||||||
width: auto;
|
width: auto;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { WebToolkit } from "timi-web";
|
import { WebToolkit } from "@timi/web/utils";
|
||||||
import AiChatComposerView from "./AiChatComposer.vue";
|
import AiChatComposerView from "./AiChatComposer.vue";
|
||||||
import AiChatMessageListView from "./AiChatMessageList.vue";
|
import AiChatMessageListView from "./AiChatMessageList.vue";
|
||||||
import AiChatPanelView from "./AiChatPanel.vue";
|
import AiChatPanelView from "./AiChatPanel.vue";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import view from "./index.vue";
|
import view from "./index.vue";
|
||||||
import { WebToolkit } from "timi-web";
|
import { WebToolkit } from "@timi/web/utils";
|
||||||
|
|
||||||
export const AppShell = WebToolkit.withInstall(view);
|
export const AppShell = WebToolkit.withInstall(view);
|
||||||
export default AppShell;
|
export default AppShell;
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ const props = withDefaults(defineProps<AppShellProps>(), {
|
|||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
"update:modelValue": [value: AppShellValue];
|
"update:modelValue": [value: AppShellValue];
|
||||||
"change": [value: AppShellValue];
|
"change": [value: AppShellValue];
|
||||||
|
"rail-click": [value: AppShellValue];
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
defineSlots<{
|
defineSlots<{
|
||||||
@@ -164,6 +165,7 @@ function onSelect(item: AppShellItem): void {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit("rail-click", item.value);
|
||||||
void requestChange(item.value);
|
void requestChange(item.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,7 +211,7 @@ function onTabChange(value: AppShellValue): void {
|
|||||||
position: relative;
|
position: relative;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
padding-left: env(safe-area-inset-left, 0);
|
padding-left: var(--tui-safe-left, 0);
|
||||||
border-right: 1px solid var(--td-component-border);
|
border-right: 1px solid var(--td-component-border);
|
||||||
background: var(--tui-rail-background, var(--td-bg-color-container));
|
background: var(--tui-rail-background, var(--td-bg-color-container));
|
||||||
|
|
||||||
@@ -260,7 +262,7 @@ function onTabChange(value: AppShellValue): void {
|
|||||||
|
|
||||||
.rail-extra {
|
.rail-extra {
|
||||||
margin-top: auto;
|
margin-top: auto;
|
||||||
padding-bottom: calc(.75rem + env(safe-area-inset-bottom, 0));
|
padding-bottom: calc(.75rem + var(--tui-safe-bottom, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,7 +272,7 @@ function onTabChange(value: AppShellValue): void {
|
|||||||
|
|
||||||
flex: none;
|
flex: none;
|
||||||
border-top: 1px solid var(--td-component-border);
|
border-top: 1px solid var(--td-component-border);
|
||||||
padding-bottom: env(safe-area-inset-bottom, 0);
|
padding-bottom: var(--tui-safe-bottom, 0);
|
||||||
background: var(--tui-tabbar-background, var(--td-bg-color-container));
|
background: var(--tui-tabbar-background, var(--td-bg-color-container));
|
||||||
|
|
||||||
:deep(.t-tab-bar-item) {
|
:deep(.t-tab-bar-item) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
TEMP_FILE_ID_ATTR,
|
TEMP_FILE_ID_ATTR,
|
||||||
isLocalMediaId,
|
isLocalMediaId,
|
||||||
normalizeContent
|
normalizeContent
|
||||||
} from "timi-web/editor";
|
} from "@timi/web/editor";
|
||||||
import type { ArticleContentType, Attachment } from "./types";
|
import type { ArticleContentType, Attachment } from "./types";
|
||||||
|
|
||||||
/** 文章内容中附件和临时文件的标识前缀。 */
|
/** 文章内容中附件和临时文件的标识前缀。 */
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import view from "./index.vue";
|
import view from "./index.vue";
|
||||||
import { WebToolkit } from "timi-web";
|
import { WebToolkit } from "@timi/web/utils";
|
||||||
import type { Article } from "./types";
|
import type { Article } from "./types";
|
||||||
|
|
||||||
export type {
|
export type {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { Article, ArticleContentType, Attachment, UploadResult } from "./types";
|
import type { Article, ArticleContentType, Attachment, UploadResult } from "./types";
|
||||||
import { MarkdownEditor } from "timi-web";
|
import { MarkdownEditor } from "@timi/web/components/markdown-editor";
|
||||||
import { TiptapEditor } from "../tiptap-editor";
|
import { TiptapEditor } from "../tiptap-editor";
|
||||||
import type { TiptapEditorExpose } from "../tiptap-editor";
|
import type { TiptapEditorExpose } from "../tiptap-editor";
|
||||||
import {
|
import {
|
||||||
@@ -41,7 +41,7 @@ import {
|
|||||||
ATTACHMENT_ID_ATTR,
|
ATTACHMENT_ID_ATTR,
|
||||||
TEMP_FILE_ID_ATTR,
|
TEMP_FILE_ID_ATTR,
|
||||||
normalizeContent
|
normalizeContent
|
||||||
} from "timi-web/editor";
|
} from "@timi/web/editor";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "ArticleEditor"
|
name: "ArticleEditor"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { UploadResult as EditorUploadResult } from "timi-web/editor";
|
import type { UploadResult as EditorUploadResult } from "@timi/web/editor";
|
||||||
|
|
||||||
/** 文章编辑器支持的正文类型。 */
|
/** 文章编辑器支持的正文类型。 */
|
||||||
export type ArticleContentType = "TEXT" | "MARKDOWN" | "TIP_TAP";
|
export type ArticleContentType = "TEXT" | "MARKDOWN" | "TIP_TAP";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import view from "./index.vue";
|
import view from "./index.vue";
|
||||||
import { WebToolkit } from "timi-web";
|
import { WebToolkit } from "@timi/web/utils";
|
||||||
|
|
||||||
export const ArticleView = WebToolkit.withInstall(view);
|
export const ArticleView = WebToolkit.withInstall(view);
|
||||||
export default ArticleView;
|
export default ArticleView;
|
||||||
|
|||||||
@@ -14,14 +14,14 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { Article, Attachment } from "../article-editor/types";
|
import type { Article, Attachment } from "../article-editor/types";
|
||||||
import { MarkdownView } from "timi-web";
|
import { MarkdownView } from "@timi/web/components/markdown-view";
|
||||||
import { TiptapView } from "../tiptap-view";
|
import { TiptapView } from "../tiptap-view";
|
||||||
import {
|
import {
|
||||||
getAttachmentIdFromSrc,
|
getAttachmentIdFromSrc,
|
||||||
normalizeArticleContentType,
|
normalizeArticleContentType,
|
||||||
normalizeRawArticleContent
|
normalizeRawArticleContent
|
||||||
} from "../article-editor/content";
|
} from "../article-editor/content";
|
||||||
import { ATTACHMENT_ID_ATTR, normalizeContent } from "timi-web/editor";
|
import { ATTACHMENT_ID_ATTR, normalizeContent } from "@timi/web/editor";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "ArticleView"
|
name: "ArticleView"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import view from "./index.vue";
|
import view from "./index.vue";
|
||||||
import { WebToolkit } from "timi-web";
|
import { WebToolkit } from "@timi/web/utils";
|
||||||
|
|
||||||
export type {
|
export type {
|
||||||
AttachmentSelectorItem,
|
AttachmentSelectorItem,
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ import type {
|
|||||||
AttachmentSelectorViewerItem
|
AttachmentSelectorViewerItem
|
||||||
} from "./types";
|
} from "./types";
|
||||||
import { getMediaKind, getMediaPreviewURL } from "./utils";
|
import { getMediaKind, getMediaPreviewURL } from "./utils";
|
||||||
import { CenterTips } from "timi-web";
|
import { CenterTips } from "@timi/web/components/center-tips";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "AttachmentSelector",
|
name: "AttachmentSelector",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import view from "./index.vue";
|
import view from "./index.vue";
|
||||||
import { WebToolkit } from "timi-web";
|
import { WebToolkit } from "@timi/web/utils";
|
||||||
|
|
||||||
export const BottomPopup = WebToolkit.withInstall(view);
|
export const BottomPopup = WebToolkit.withInstall(view);
|
||||||
export default BottomPopup;
|
export default BottomPopup;
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ defineSlots<BottomPopupSlots>();
|
|||||||
|
|
||||||
.body {
|
.body {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
padding: 0 0 env(safe-area-inset-bottom, 0);
|
padding: 0 0 var(--tui-safe-bottom, 0);
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import view from "./index.vue";
|
import view from "./index.vue";
|
||||||
import { WebToolkit } from "timi-web";
|
import { WebToolkit } from "@timi/web/utils";
|
||||||
|
|
||||||
export const CardContainer = WebToolkit.withInstall(view);
|
export const CardContainer = WebToolkit.withInstall(view);
|
||||||
export default CardContainer;
|
export default CardContainer;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import view from "./index.vue";
|
import view from "./index.vue";
|
||||||
import { WebToolkit } from "timi-web";
|
import { WebToolkit } from "@timi/web/utils";
|
||||||
import "./style.less";
|
import "./style.less";
|
||||||
|
|
||||||
export type CodeEditorScrollState = {
|
export type CodeEditorScrollState = {
|
||||||
|
|||||||
@@ -65,8 +65,8 @@ import {
|
|||||||
replaceMatchText,
|
replaceMatchText,
|
||||||
type TextSearchMatch,
|
type TextSearchMatch,
|
||||||
type TextSearchOptions
|
type TextSearchOptions
|
||||||
} from "timi-web/editor";
|
} from "@timi/web/editor";
|
||||||
import { highlightCode, resolveCodeEditorKeydown, resolvePrismLanguage } from "timi-web/editor";
|
import { highlightCode, resolveCodeEditorKeydown, resolvePrismLanguage } from "@timi/web/editor";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "CodeEditor"
|
name: "CodeEditor"
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import view from "./index.vue";
|
||||||
|
import { WebToolkit } from "@timi/web/utils";
|
||||||
|
|
||||||
|
export const DropdownFilter = WebToolkit.withInstall(view);
|
||||||
|
export default DropdownFilter;
|
||||||
|
|
||||||
|
export type {
|
||||||
|
DropdownFilterChange,
|
||||||
|
DropdownFilterItem,
|
||||||
|
DropdownFilterOption,
|
||||||
|
DropdownFilterProps
|
||||||
|
} from "./type";
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
<template>
|
||||||
|
<div class="tui-filters dropdown-filter">
|
||||||
|
<t-input
|
||||||
|
:model-value="props.modelValue"
|
||||||
|
class="search-input"
|
||||||
|
type="search"
|
||||||
|
borderless
|
||||||
|
clearable
|
||||||
|
:placeholder="props.placeholder"
|
||||||
|
@update:model-value="handleKeywordChange"
|
||||||
|
>
|
||||||
|
<template v-if="$slots['suffix-icon']" #suffix-icon>
|
||||||
|
<slot name="suffix-icon" />
|
||||||
|
</template>
|
||||||
|
</t-input>
|
||||||
|
<configured-dropdown-menu
|
||||||
|
:filters="props.filters"
|
||||||
|
:menu-props="props.menuProps"
|
||||||
|
@filter-change="handleDropdownChange"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { defineComponent, h, type PropType } from "vue";
|
||||||
|
import { DropdownItem, DropdownMenu } from "tdesign-mobile-vue";
|
||||||
|
import type { DropdownMenuProps, DropdownValue } from "tdesign-mobile-vue";
|
||||||
|
import type { DropdownFilterChange, DropdownFilterItem, DropdownFilterProps } from "./type";
|
||||||
|
|
||||||
|
defineOptions({ name: "DropdownFilter" });
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<DropdownFilterProps>(), {
|
||||||
|
modelValue: "",
|
||||||
|
placeholder: "搜索"
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
"update:modelValue": [value: string];
|
||||||
|
"filter-change": [change: DropdownFilterChange];
|
||||||
|
}>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TDesign 的 DropdownMenu 只收直接子节点里的 TDropdownItem——它在内部遍历
|
||||||
|
* `slots.default()` 并比对组件名。模板里写 `v-for` 会被编译成一个 Fragment,
|
||||||
|
* 比对失败,整条菜单就是空的;渲染函数手动铺平的数组才是它要的形状。
|
||||||
|
*/
|
||||||
|
const ConfiguredDropdownMenu = defineComponent({
|
||||||
|
name: "ConfiguredDropdownMenu",
|
||||||
|
props: {
|
||||||
|
filters: {
|
||||||
|
type: Array as PropType<DropdownFilterItem[]>,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
menuProps: {
|
||||||
|
type: Object as PropType<DropdownMenuProps & { class?: string }>,
|
||||||
|
default: undefined
|
||||||
|
}
|
||||||
|
},
|
||||||
|
emits: ["filter-change"],
|
||||||
|
setup(menu, { emit: emitMenu }) {
|
||||||
|
return () => h(DropdownMenu, {
|
||||||
|
...menu.menuProps,
|
||||||
|
class: ["menus", menu.menuProps?.class]
|
||||||
|
}, {
|
||||||
|
default: () => menu.filters.map(filter => h(DropdownItem, {
|
||||||
|
key: filter.key,
|
||||||
|
modelValue: filter.value,
|
||||||
|
label: filter.label,
|
||||||
|
options: filter.options,
|
||||||
|
multiple: filter.multiple,
|
||||||
|
optionsColumns: filter.optionsColumns,
|
||||||
|
disabled: filter.disabled,
|
||||||
|
onChange: (value: DropdownValue) => emitMenu("filter-change", { key: filter.key, value })
|
||||||
|
}))
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 搜索框的变化同时算一次筛选变化,业务只接 `filter-change` 也能跑通;
|
||||||
|
* key 固定为 `keyword`,免得每个页面再自己起一套约定。
|
||||||
|
*/
|
||||||
|
function handleKeywordChange(value: string | number): void {
|
||||||
|
const keyword = String(value ?? "");
|
||||||
|
emit("update:modelValue", keyword);
|
||||||
|
emit("filter-change", { key: "keyword", value: keyword });
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDropdownChange(change: DropdownFilterChange): void {
|
||||||
|
emit("filter-change", change);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
import type { DropdownMenuProps, DropdownValue } from "tdesign-mobile-vue";
|
||||||
|
|
||||||
|
/** 下拉筛选里的一个选项。 */
|
||||||
|
export interface DropdownFilterOption {
|
||||||
|
/** 选项文本。 */
|
||||||
|
label: string;
|
||||||
|
/** 选项值,原样交给 TDesign DropdownItem。 */
|
||||||
|
value: DropdownValue;
|
||||||
|
/** 是否禁用。 */
|
||||||
|
disabled?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 一个筛选项的完整配置。 */
|
||||||
|
export interface DropdownFilterItem {
|
||||||
|
/** 筛选项标识,随 `filter-change` 一起抛出。 */
|
||||||
|
key: string;
|
||||||
|
/** 当前值对应的展示文本,由业务算好。 */
|
||||||
|
label: string;
|
||||||
|
/** 当前值,配合 `v-model` 由业务侧回填。 */
|
||||||
|
value: DropdownValue;
|
||||||
|
/** 可选项。 */
|
||||||
|
options: DropdownFilterOption[];
|
||||||
|
/** 是否多选。 */
|
||||||
|
multiple?: boolean;
|
||||||
|
/** 选项列数。 */
|
||||||
|
optionsColumns?: string | number;
|
||||||
|
/** 是否禁用。 */
|
||||||
|
disabled?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** `filter-change` 的事件参数。 */
|
||||||
|
export interface DropdownFilterChange {
|
||||||
|
/** 触发变化的筛选项标识;搜索框固定为 `keyword`。 */
|
||||||
|
key: string;
|
||||||
|
/** 变化后的值。 */
|
||||||
|
value: DropdownValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** DropdownFilter 的 props。 */
|
||||||
|
export interface DropdownFilterProps {
|
||||||
|
/** 搜索框内容,配合 `v-model` 使用。 */
|
||||||
|
modelValue?: string;
|
||||||
|
/** 搜索框占位文本,默认「搜索」。 */
|
||||||
|
placeholder?: string;
|
||||||
|
/** 下拉筛选项,按数组顺序渲染。 */
|
||||||
|
filters: DropdownFilterItem[];
|
||||||
|
/** 透传给 TDesign DropdownMenu 的属性。 */
|
||||||
|
menuProps?: DropdownMenuProps;
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import view from "./index.vue";
|
import view from "./index.vue";
|
||||||
import { WebToolkit } from "timi-web";
|
import { WebToolkit } from "@timi/web/utils";
|
||||||
|
|
||||||
export const DurationPicker = WebToolkit.withInstall(view);
|
export const DurationPicker = WebToolkit.withInstall(view);
|
||||||
export default DurationPicker;
|
export default DurationPicker;
|
||||||
|
|||||||
+16
-1
@@ -16,7 +16,9 @@ import NotifyView from "./notify-view";
|
|||||||
import BottomPopup from "./bottom-popup";
|
import BottomPopup from "./bottom-popup";
|
||||||
import AttachmentSelector from "./attachment-selector";
|
import AttachmentSelector from "./attachment-selector";
|
||||||
import Space from "./space";
|
import Space from "./space";
|
||||||
|
import { Timeline, TimelineItem } from "./timeline";
|
||||||
import CardContainer from "./card-container";
|
import CardContainer from "./card-container";
|
||||||
|
import DropdownFilter from "./dropdown-filter";
|
||||||
import {
|
import {
|
||||||
AiChatComposer,
|
AiChatComposer,
|
||||||
AiChatMessageList,
|
AiChatMessageList,
|
||||||
@@ -42,7 +44,10 @@ export default [
|
|||||||
BottomPopup,
|
BottomPopup,
|
||||||
AttachmentSelector,
|
AttachmentSelector,
|
||||||
Space,
|
Space,
|
||||||
|
Timeline,
|
||||||
|
TimelineItem,
|
||||||
CardContainer,
|
CardContainer,
|
||||||
|
DropdownFilter,
|
||||||
AiChatComposer,
|
AiChatComposer,
|
||||||
AiChatMessageList,
|
AiChatMessageList,
|
||||||
AiChatPanel,
|
AiChatPanel,
|
||||||
@@ -67,7 +72,10 @@ export {
|
|||||||
BottomPopup,
|
BottomPopup,
|
||||||
AttachmentSelector,
|
AttachmentSelector,
|
||||||
Space,
|
Space,
|
||||||
|
Timeline,
|
||||||
|
TimelineItem,
|
||||||
CardContainer,
|
CardContainer,
|
||||||
|
DropdownFilter,
|
||||||
AiChatComposer,
|
AiChatComposer,
|
||||||
AiChatMessageList,
|
AiChatMessageList,
|
||||||
AiChatPanel,
|
AiChatPanel,
|
||||||
@@ -75,7 +83,7 @@ export {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export { createLayoutContext, provideLayout, useLayout } from "./app-shell";
|
export { createLayoutContext, provideLayout, useLayout } from "./app-shell";
|
||||||
export { useExpandToMaster, useMasterDetail, useMasterDetailPane, usePane } from "../composables/use-master-detail";
|
export { useExpandToMaster, useMasterDetail, useMasterDetailPane, usePane, providePane } from "../composables/use-master-detail";
|
||||||
export type { ExpandToMasterOptions, PaneContext, PaneDirection, UseMasterDetailOptions, UseMasterDetailPaneOptions, UseMasterDetailPaneReturn, UseMasterDetailReturn } from "../composables/use-master-detail";
|
export type { ExpandToMasterOptions, PaneContext, PaneDirection, UseMasterDetailOptions, UseMasterDetailPaneOptions, UseMasterDetailPaneReturn, UseMasterDetailReturn } from "../composables/use-master-detail";
|
||||||
|
|
||||||
export type {
|
export type {
|
||||||
@@ -129,6 +137,13 @@ export type {
|
|||||||
CardContainerProps
|
CardContainerProps
|
||||||
} from "./card-container";
|
} from "./card-container";
|
||||||
|
|
||||||
|
export type {
|
||||||
|
DropdownFilterChange,
|
||||||
|
DropdownFilterItem,
|
||||||
|
DropdownFilterOption,
|
||||||
|
DropdownFilterProps
|
||||||
|
} from "./dropdown-filter";
|
||||||
|
|
||||||
export type {
|
export type {
|
||||||
AttachmentSelectorItem,
|
AttachmentSelectorItem,
|
||||||
AttachmentSelectorProps,
|
AttachmentSelectorProps,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import view from "./index.vue";
|
import view from "./index.vue";
|
||||||
import { WebToolkit } from "timi-web";
|
import { WebToolkit } from "@timi/web/utils";
|
||||||
|
|
||||||
export const MasterDetailPage = WebToolkit.withInstall(view);
|
export const MasterDetailPage = WebToolkit.withInstall(view);
|
||||||
export default MasterDetailPage;
|
export default MasterDetailPage;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
:top-inset="topInset"
|
:top-inset="topInset"
|
||||||
:detail-empty="!selected"
|
:detail-empty="!selected"
|
||||||
:sub="sub"
|
:sub="sub"
|
||||||
|
:sub-mode="subMode"
|
||||||
>
|
>
|
||||||
<template #master>
|
<template #master>
|
||||||
<div class="tui-master-wrap">
|
<div class="tui-master-wrap">
|
||||||
@@ -54,7 +55,8 @@ const props = withDefaults(defineProps<MasterDetailPageProps>(), {
|
|||||||
direction: "forward",
|
direction: "forward",
|
||||||
masterWidth: 380,
|
masterWidth: 380,
|
||||||
topInset: "",
|
topInset: "",
|
||||||
sub: false
|
sub: false,
|
||||||
|
subMode: "shift"
|
||||||
});
|
});
|
||||||
|
|
||||||
defineSlots<{
|
defineSlots<{
|
||||||
|
|||||||
@@ -19,9 +19,16 @@ export interface MasterDetailPageProps {
|
|||||||
/**
|
/**
|
||||||
* 是否进入第三层:主栏换成详情内容,右栏显示 `#sub` 槽。
|
* 是否进入第三层:主栏换成详情内容,右栏显示 `#sub` 槽。
|
||||||
*
|
*
|
||||||
* 三层依次是:列表 → 详情 → 子页。进入时列表整列滑出左侧、详情退到主栏,
|
* 三层依次是:列表 → 详情 → 子页。只有分栏形态下有效,
|
||||||
* 返回时反向还原成「列表 + 详情」。只有分栏形态下有效,
|
|
||||||
* 窄屏请让子页走整页路由(`usePane().openSub()` 会返回 false)。
|
* 窄屏请让子页走整页路由(`usePane().openSub()` 会返回 false)。
|
||||||
*/
|
*/
|
||||||
sub?: boolean;
|
sub?: boolean;
|
||||||
|
/**
|
||||||
|
* 第三层的呈现方式,默认 `shift`。
|
||||||
|
*
|
||||||
|
* - `shift`:列表整列滑出、详情退到主栏,适合同一条记录继续往下钻;
|
||||||
|
* - `cover`:主栏不动、子页盖住详情栏,适合从详情跳进另一个模块的页面,
|
||||||
|
* 列表要一直留在眼前(详情原地保活,返回时滚动位置和状态都在)。
|
||||||
|
*/
|
||||||
|
subMode?: "shift" | "cover";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import view from "./index.vue";
|
import view from "./index.vue";
|
||||||
import { WebToolkit } from "timi-web";
|
import { WebToolkit } from "@timi/web/utils";
|
||||||
|
|
||||||
export const MasterDetail = WebToolkit.withInstall(view);
|
export const MasterDetail = WebToolkit.withInstall(view);
|
||||||
export default MasterDetail;
|
export default MasterDetail;
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
:class="{
|
:class="{
|
||||||
split: isSplit,
|
split: isSplit,
|
||||||
'is-collapsed': isSplit && detailEmpty,
|
'is-collapsed': isSplit && detailEmpty,
|
||||||
'has-sub': isSplit && showSub
|
'has-sub': isSplit && showSub,
|
||||||
|
'is-sub-cover': isSplit && showSub && subMode === 'cover'
|
||||||
}"
|
}"
|
||||||
:style="rootStyle"
|
:style="rootStyle"
|
||||||
>
|
>
|
||||||
@@ -30,7 +31,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, type StyleValue } from "vue";
|
import { computed, type StyleValue } from "vue";
|
||||||
import { CenterTips } from "timi-web";
|
import { CenterTips } from "@timi/web/components/center-tips";
|
||||||
import { useLayout } from "../../composables/use-layout";
|
import { useLayout } from "../../composables/use-layout";
|
||||||
import type { MasterDetailProps } from "./type";
|
import type { MasterDetailProps } from "./type";
|
||||||
|
|
||||||
@@ -44,7 +45,8 @@ const props = withDefaults(defineProps<MasterDetailProps>(), {
|
|||||||
emptyText: "",
|
emptyText: "",
|
||||||
topInset: "",
|
topInset: "",
|
||||||
detailEmpty: false,
|
detailEmpty: false,
|
||||||
sub: false
|
sub: false,
|
||||||
|
subMode: "shift"
|
||||||
});
|
});
|
||||||
|
|
||||||
defineSlots<{
|
defineSlots<{
|
||||||
@@ -126,7 +128,17 @@ const rootStyle = computed<StyleValue>(() => ({
|
|||||||
-webkit-overflow-scrolling: touch;
|
-webkit-overflow-scrolling: touch;
|
||||||
// 时长和曲线都来自 page-layout.less 的变量,列表页导航栏用同一组,
|
// 时长和曲线都来自 page-layout.less 的变量,列表页导航栏用同一组,
|
||||||
// 两边必须同拍,否则列表跳、导航滑。
|
// 两边必须同拍,否则列表跳、导航滑。
|
||||||
transition: left @duration @easing, right @duration @easing, opacity .12s ease-out;
|
transition:
|
||||||
|
left @duration @easing,
|
||||||
|
right @duration @easing,
|
||||||
|
border-color .2s linear,
|
||||||
|
opacity .12s ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 常驻一条透明分隔线:谁在左谁负责显示,换人的时候不改变盒宽
|
||||||
|
.master,
|
||||||
|
.detail {
|
||||||
|
border-right: 1px solid transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 未选中:主栏占满,另外两层收在右侧边界外
|
// 未选中:主栏占满,另外两层收在右侧边界外
|
||||||
@@ -167,7 +179,7 @@ const rootStyle = computed<StyleValue>(() => ({
|
|||||||
|
|
||||||
.master {
|
.master {
|
||||||
right: calc(100% - var(--tui-master-width));
|
right: calc(100% - var(--tui-master-width));
|
||||||
border-right: 1px solid var(--td-component-border, rgba(0, 0, 0, .08));
|
border-right-color: var(--td-component-border, rgba(0, 0, 0, .08));
|
||||||
}
|
}
|
||||||
|
|
||||||
.detail,
|
.detail,
|
||||||
@@ -188,10 +200,6 @@ const rootStyle = computed<StyleValue>(() => ({
|
|||||||
*/
|
*/
|
||||||
&.is-collapsed {
|
&.is-collapsed {
|
||||||
|
|
||||||
.master {
|
|
||||||
border-right-color: transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
.detail,
|
.detail,
|
||||||
.sub {
|
.sub {
|
||||||
overflow-y: hidden;
|
overflow-y: hidden;
|
||||||
@@ -207,14 +215,46 @@ const rootStyle = computed<StyleValue>(() => ({
|
|||||||
*/
|
*/
|
||||||
&.has-sub {
|
&.has-sub {
|
||||||
|
|
||||||
|
// 分隔线跟着换人:列表在视口外,主栏与右栏之间改由详情画
|
||||||
.master {
|
.master {
|
||||||
left: calc(-1 * var(--tui-master-width));
|
left: calc(-1 * var(--tui-master-width));
|
||||||
right: 100%;
|
right: 100%;
|
||||||
|
border-right-color: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
.detail {
|
.detail {
|
||||||
left: 0;
|
left: 0;
|
||||||
right: calc(100% - var(--tui-master-width));
|
right: calc(100% - var(--tui-master-width));
|
||||||
|
border-right-color: var(--td-component-border, rgba(0, 0, 0, .08));
|
||||||
|
}
|
||||||
|
|
||||||
|
.sub {
|
||||||
|
left: var(--tui-master-width);
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 第三层的 cover 形态:右栏换人,主栏不动。
|
||||||
|
*
|
||||||
|
* shift 是"整条轨道左移",用户已经不看列表了;cover 针对的相反——
|
||||||
|
* 从详情跳进别的模块,列表本身要一直留在眼前。
|
||||||
|
* 详情不参与位移,只原地淡出(保活,返回时滚动位置和内部状态都还在),
|
||||||
|
* 子页像换班一样滑进右栏。
|
||||||
|
*/
|
||||||
|
&.has-sub.is-sub-cover {
|
||||||
|
|
||||||
|
.master {
|
||||||
|
left: 0;
|
||||||
|
right: calc(100% - var(--tui-master-width));
|
||||||
|
border-right-color: var(--td-component-border, rgba(0, 0, 0, .08));
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail {
|
||||||
|
left: var(--tui-master-width);
|
||||||
|
right: 0;
|
||||||
|
opacity: 0;
|
||||||
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sub {
|
.sub {
|
||||||
|
|||||||
@@ -31,4 +31,15 @@ export interface MasterDetailProps {
|
|||||||
* 只有分栏形态下有效,窄屏请让子页走整页路由。
|
* 只有分栏形态下有效,窄屏请让子页走整页路由。
|
||||||
*/
|
*/
|
||||||
sub?: boolean;
|
sub?: boolean;
|
||||||
|
/**
|
||||||
|
* 第三层的呈现方式,默认 `shift`。
|
||||||
|
*
|
||||||
|
* - `shift`:整条轨道左移,列表滑出、详情退到主栏。适合同一条记录继续往下钻,
|
||||||
|
* 用户已经不需要再看列表了。
|
||||||
|
* - `cover`:主栏不动,子页直接盖住详情栏(详情原地保活,返回时滚动位置和内部状态都在)。
|
||||||
|
* 适合从详情跳进**另一个模块**的页面——列表本身是用户要一直看的东西。
|
||||||
|
*
|
||||||
|
* 两种方式共用同一套 `sub` / `subView` 状态,切换只影响布局,不影响层级和历史的处理。
|
||||||
|
*/
|
||||||
|
subMode?: "shift" | "cover";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import view from "./index.vue";
|
import view from "./index.vue";
|
||||||
import { WebToolkit } from "timi-web";
|
import { WebToolkit } from "@timi/web/utils";
|
||||||
import type { NotifyDetail } from "./types";
|
import type { NotifyDetail } from "./types";
|
||||||
|
|
||||||
export type { NotifyContentType, NotifyDetail } from "./types";
|
export type { NotifyContentType, NotifyDetail } from "./types";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import view from "./index.vue";
|
import view from "./index.vue";
|
||||||
import { WebToolkit } from "timi-web";
|
import { WebToolkit } from "@timi/web/utils";
|
||||||
|
|
||||||
export const NotifyView = WebToolkit.withInstall(view);
|
export const NotifyView = WebToolkit.withInstall(view);
|
||||||
export default NotifyView;
|
export default NotifyView;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import view from "./index.vue";
|
import view from "./index.vue";
|
||||||
import { WebToolkit } from "timi-web";
|
import { WebToolkit } from "@timi/web/utils";
|
||||||
|
|
||||||
export type {
|
export type {
|
||||||
PageTransitionBackground,
|
PageTransitionBackground,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import view from "./index.vue";
|
import view from "./index.vue";
|
||||||
import { WebToolkit } from "timi-web";
|
import { WebToolkit } from "@timi/web/utils";
|
||||||
|
|
||||||
export const PaneTransition = WebToolkit.withInstall(view);
|
export const PaneTransition = WebToolkit.withInstall(view);
|
||||||
export default PaneTransition;
|
export default PaneTransition;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import view from "./index.vue";
|
import view from "./index.vue";
|
||||||
import { WebToolkit } from "timi-web";
|
import { WebToolkit } from "@timi/web/utils";
|
||||||
|
|
||||||
export const RootLayout = WebToolkit.withInstall(view);
|
export const RootLayout = WebToolkit.withInstall(view);
|
||||||
export default RootLayout;
|
export default RootLayout;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { Copyright } from "timi-web";
|
import { Copyright } from "@timi/web/components/copyright";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "RootLayout"
|
name: "RootLayout"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import view from "./index.vue";
|
import view from "./index.vue";
|
||||||
import { WebToolkit } from "timi-web";
|
import { WebToolkit } from "@timi/web/utils";
|
||||||
|
|
||||||
export type {
|
export type {
|
||||||
SpaceAlign,
|
SpaceAlign,
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import { WebToolkit } from "@timi/web/utils";
|
||||||
|
import timeline from "./index.vue";
|
||||||
|
import item from "./item.vue";
|
||||||
|
|
||||||
|
export const Timeline = WebToolkit.withInstall(timeline);
|
||||||
|
export const TimelineItem = WebToolkit.withInstall(item);
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
<template>
|
||||||
|
<div class="t-timeline" :class="{ horizontal: layout === 'horizontal', reverse }">
|
||||||
|
<slot />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
defineOptions({ name: "TTimeline" });
|
||||||
|
withDefaults(defineProps<{ layout?: "vertical" | "horizontal"; reverse?: boolean }>(), {
|
||||||
|
layout: "vertical",
|
||||||
|
reverse: false
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<style lang="less">
|
||||||
|
.t-timeline {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
&.reverse {
|
||||||
|
flex-direction: column-reverse;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.horizontal {
|
||||||
|
flex-direction: row;
|
||||||
|
|
||||||
|
&.reverse {
|
||||||
|
flex-direction: row-reverse;
|
||||||
|
}
|
||||||
|
|
||||||
|
.t-timeline-item {
|
||||||
|
flex: 1;
|
||||||
|
padding: var(--t-timeline-horizontal-offset, 1.5rem) var(--t-timeline-horizontal-gap, .75rem) 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.t-timeline-item::before {
|
||||||
|
top: calc((var(--t-timeline-dot-size, .5rem) - var(--t-timeline-line-width, 2px)) / 2);
|
||||||
|
left: calc(var(--t-timeline-dot-size, .5rem) + var(--t-timeline-line-gap, .25rem));
|
||||||
|
width: calc(100% - var(--t-timeline-dot-size, .5rem) - var(--t-timeline-line-gap, .25rem) - var(--t-timeline-line-gap, .25rem));
|
||||||
|
height: var(--t-timeline-line-width, 2px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.t-timeline-item .dot {
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.t-timeline-item {
|
||||||
|
position: relative;
|
||||||
|
padding: 0 0 var(--t-timeline-item-gap, 1rem) var(--t-timeline-content-offset, 1rem);
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
position: absolute;
|
||||||
|
top: calc(1lh / 2 + var(--t-timeline-dot-size, .5rem) / 2 + var(--t-timeline-line-gap, .25rem));
|
||||||
|
bottom: calc(var(--t-timeline-dot-size, .5rem) / 2 + var(--t-timeline-line-gap, .25rem) - 1lh / 2);
|
||||||
|
left: calc((var(--t-timeline-dot-size, .5rem) - var(--t-timeline-line-width, 2px)) / 2);
|
||||||
|
width: var(--t-timeline-line-width, 2px);
|
||||||
|
content: "";
|
||||||
|
background: var(--t-timeline-line-color, var(--td-component-border, #ddd));
|
||||||
|
}
|
||||||
|
|
||||||
|
&:last-child::before {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.reverse .t-timeline-item:last-child::before {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.reverse .t-timeline-item:first-child::before {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
<template>
|
||||||
|
<div class="t-timeline-item" @click="onClick">
|
||||||
|
<span class="dot" :style="{ color: color }">
|
||||||
|
<slot name="dot" />
|
||||||
|
</span>
|
||||||
|
<div v-if="label || $slots.label" class="label">
|
||||||
|
<slot name="label">
|
||||||
|
<span v-text="label" />
|
||||||
|
</slot>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<slot name="content">
|
||||||
|
<slot>
|
||||||
|
<span v-text="content" />
|
||||||
|
</slot>
|
||||||
|
</slot>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from "vue";
|
||||||
|
|
||||||
|
defineOptions({ name: "TTimelineItem" });
|
||||||
|
const props = withDefaults(defineProps<{
|
||||||
|
label?: string;
|
||||||
|
content?: string;
|
||||||
|
dotColor?: string
|
||||||
|
}>(), { dotColor: "primary" });
|
||||||
|
const emit = defineEmits<{ click: [context: { e: MouseEvent; item: typeof props }] }>();
|
||||||
|
const colors: Record<string, string> = {
|
||||||
|
primary: "var(--td-brand-color, #0052d9)",
|
||||||
|
warning: "#ed7b2f",
|
||||||
|
error: "#d54941",
|
||||||
|
default: "#bbb"
|
||||||
|
};
|
||||||
|
const color = computed(() => colors[props.dotColor] ?? props.dotColor);
|
||||||
|
|
||||||
|
function onClick(e: MouseEvent): void {
|
||||||
|
emit("click", { e, item: props });
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style lang="less" scoped>
|
||||||
|
.dot {
|
||||||
|
position: absolute;
|
||||||
|
top: calc((1lh - var(--t-timeline-dot-size, .5rem)) / 2);
|
||||||
|
left: 0;
|
||||||
|
width: var(--t-timeline-dot-size, .5rem);
|
||||||
|
height: var(--t-timeline-dot-size, .5rem);
|
||||||
|
border: var(--t-timeline-dot-border-width, 2px) solid currentColor;
|
||||||
|
box-sizing: border-box;
|
||||||
|
background: var(--t-timeline-dot-background, var(--td-bg-color-container, #fff));
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label {
|
||||||
|
color: var(--t-timeline-label-color, var(--td-text-color-secondary, #777));
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -21,8 +21,8 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { PickerValue } from "tdesign-mobile-vue";
|
import type { PickerValue } from "tdesign-mobile-vue";
|
||||||
import { supportedCodeLanguages } from "timi-web/editor";
|
import { supportedCodeLanguages } from "@timi/web/editor";
|
||||||
import type { TiptapEditorInstance } from "timi-web/editor";
|
import type { TiptapEditorInstance } from "@timi/web/editor";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "TiptapCodeBlockButton"
|
name: "TiptapCodeBlockButton"
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { showPlatformMessage } from "../message";
|
import { showPlatformMessage } from "../message";
|
||||||
import type { TiptapEditorInstance } from "timi-web/editor";
|
import type { TiptapEditorInstance } from "@timi/web/editor";
|
||||||
import BottomPopup from "../bottom-popup/index.vue";
|
import BottomPopup from "../bottom-popup/index.vue";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
@@ -142,7 +142,7 @@ async function onConfirm() {
|
|||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.popup {
|
.popup {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0 1rem calc(1rem + env(safe-area-inset-bottom));
|
padding: 0 1rem calc(1rem + var(--tui-safe-bottom, 0px));
|
||||||
background: var(--td-bg-color-container);
|
background: var(--td-bg-color-container);
|
||||||
|
|
||||||
.field {
|
.field {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { TiptapEditorInstance } from "timi-web/editor";
|
import type { TiptapEditorInstance } from "@timi/web/editor";
|
||||||
import BottomPopup from "../bottom-popup/index.vue";
|
import BottomPopup from "../bottom-popup/index.vue";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
@@ -101,7 +101,7 @@ function onConfirm() {
|
|||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.link-form {
|
.link-form {
|
||||||
gap: .75rem;
|
gap: .75rem;
|
||||||
padding: 0 1rem calc(1rem + env(safe-area-inset-bottom));
|
padding: 0 1rem calc(1rem + var(--tui-safe-bottom, 0px));
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,7 +90,7 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { showPlatformMessage } from "../message";
|
import { showPlatformMessage } from "../message";
|
||||||
import type { TiptapEditorInstance, UploadResult } from "timi-web/editor";
|
import type { TiptapEditorInstance, UploadResult } from "@timi/web/editor";
|
||||||
import BottomPopup from "../bottom-popup/index.vue";
|
import BottomPopup from "../bottom-popup/index.vue";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
@@ -231,7 +231,7 @@ async function onConfirm() {
|
|||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.popup {
|
.popup {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0 1rem calc(1rem + env(safe-area-inset-bottom));
|
padding: 0 1rem calc(1rem + var(--tui-safe-bottom, 0px));
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
background: var(--td-bg-color-container);
|
background: var(--td-bg-color-container);
|
||||||
|
|
||||||
|
|||||||
@@ -61,8 +61,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { TABLE_PICKER_SIZE } from "timi-web/editor";
|
import { TABLE_PICKER_SIZE } from "@timi/web/editor";
|
||||||
import type { TiptapEditorInstance } from "timi-web/editor";
|
import type { TiptapEditorInstance } from "@timi/web/editor";
|
||||||
import BottomPopup from "../bottom-popup/index.vue";
|
import BottomPopup from "../bottom-popup/index.vue";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
@@ -136,7 +136,7 @@ watch(() => props.active, (active) => {
|
|||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.table-picker {
|
.table-picker {
|
||||||
padding: 0 1rem calc(1rem + env(safe-area-inset-bottom));
|
padding: 0 1rem calc(1rem + var(--tui-safe-bottom, 0px));
|
||||||
display: flex;
|
display: flex;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
background: var(--td-bg-color-container, #fff);
|
background: var(--td-bg-color-container, #fff);
|
||||||
|
|||||||
@@ -151,8 +151,8 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { ColorObject } from "tdesign-mobile-vue";
|
import type { ColorObject } from "tdesign-mobile-vue";
|
||||||
import type { AlignType, UploadResult, TiptapEditorInstance } from "timi-web/editor";
|
import type { AlignType, UploadResult, TiptapEditorInstance } from "@timi/web/editor";
|
||||||
import { headingMeta } from "timi-web/editor";
|
import { headingMeta } from "@timi/web/editor";
|
||||||
import TiptapCodeBlockButton from "./TiptapCodeBlockButton.vue";
|
import TiptapCodeBlockButton from "./TiptapCodeBlockButton.vue";
|
||||||
import TiptapIframeButton from "./TiptapIframeButton.vue";
|
import TiptapIframeButton from "./TiptapIframeButton.vue";
|
||||||
import TiptapLinkButton from "./TiptapLinkButton.vue";
|
import TiptapLinkButton from "./TiptapLinkButton.vue";
|
||||||
@@ -520,7 +520,7 @@ function confirmColor() {
|
|||||||
|
|
||||||
.heading-picker {
|
.heading-picker {
|
||||||
width: min(22rem, calc(100vw - 2rem));
|
width: min(22rem, calc(100vw - 2rem));
|
||||||
padding: .5rem .75rem calc(.5rem + env(safe-area-inset-bottom));
|
padding: .5rem .75rem calc(.5rem + var(--tui-safe-bottom, 0px));
|
||||||
}
|
}
|
||||||
|
|
||||||
.color-picker-popup {
|
.color-picker-popup {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import view from "./index.vue";
|
import view from "./index.vue";
|
||||||
import { WebToolkit } from "timi-web";
|
import { WebToolkit } from "@timi/web/utils";
|
||||||
import type { TiptapEditorInstance } from "timi-web/editor";
|
import type { TiptapEditorInstance } from "@timi/web/editor";
|
||||||
|
|
||||||
export * from "timi-web/editor";
|
export * from "@timi/web/editor";
|
||||||
export type TiptapEditorExpose = {
|
export type TiptapEditorExpose = {
|
||||||
submit: () => Promise<string>;
|
submit: () => Promise<string>;
|
||||||
getPendingMediaCount: () => number;
|
getPendingMediaCount: () => number;
|
||||||
|
|||||||
@@ -58,18 +58,18 @@ import {
|
|||||||
buildSearchRegex,
|
buildSearchRegex,
|
||||||
replaceMatchText,
|
replaceMatchText,
|
||||||
type TextSearchOptions
|
type TextSearchOptions
|
||||||
} from "timi-web/editor";
|
} from "@timi/web/editor";
|
||||||
import { Toolkit } from "timi-web";
|
import { Toolkit } from "@timi/web/utils";
|
||||||
import type { PendingMediaItem, UploadMediaType, UploadResult } from "timi-web/editor";
|
import type { PendingMediaItem, UploadMediaType, UploadResult } from "@timi/web/editor";
|
||||||
import TiptapToolbar from "./TiptapToolbar.vue";
|
import TiptapToolbar from "./TiptapToolbar.vue";
|
||||||
import { useTiptapEditor } from "timi-web/editor";
|
import { useTiptapEditor } from "@timi/web/editor";
|
||||||
import {
|
import {
|
||||||
ATTACHMENT_ID_ATTR,
|
ATTACHMENT_ID_ATTR,
|
||||||
LOCAL_MEDIA_ID_PREFIX,
|
LOCAL_MEDIA_ID_PREFIX,
|
||||||
TEMP_FILE_ID_ATTR,
|
TEMP_FILE_ID_ATTR,
|
||||||
isLocalMediaId,
|
isLocalMediaId,
|
||||||
normalizeContent
|
normalizeContent
|
||||||
} from "timi-web/editor";
|
} from "@timi/web/editor";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "TiptapEditor"
|
name: "TiptapEditor"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import view from "./index.vue";
|
import view from "./index.vue";
|
||||||
import { WebToolkit } from "timi-web";
|
import { WebToolkit } from "@timi/web/utils";
|
||||||
|
|
||||||
export const TiptapView = WebToolkit.withInstall(view);
|
export const TiptapView = WebToolkit.withInstall(view);
|
||||||
export default TiptapView;
|
export default TiptapView;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { normalizeContent, useTiptapView } from "timi-web/editor";
|
import { normalizeContent, useTiptapView } from "@timi/web/editor";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "TiptapView"
|
name: "TiptapView"
|
||||||
|
|||||||
@@ -86,6 +86,24 @@ export function usePane(): PaneContext | null {
|
|||||||
return inject(PANE_KEY, null);
|
return inject(PANE_KEY, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 把一套栏内上下文提供给后代。
|
||||||
|
*
|
||||||
|
* 用在"页面要改写子页标识"的场合:列表页在最外层 provide 一套派生上下文,
|
||||||
|
* 右栏里的页面调 `openSub()` 时标识先经过它,不必在中间塞一层容器组件。
|
||||||
|
*
|
||||||
|
* 不要用容器组件代替它:栏内页面的骨架样式(导航栏退化成栏内头部、内容区铺满)
|
||||||
|
* 挂在 `.detail > .tui-page-layout` 这类直系选择器上,多包一层就全落空。
|
||||||
|
*
|
||||||
|
* 注意 provide 只在当前组件的后代里生效,且会遮蔽上层的同一套上下文,
|
||||||
|
* 所以派生时要把 `close` / `openSub` 转发给宿主,别自己重写一套。
|
||||||
|
*
|
||||||
|
* @param context 派生出来的上下文,通常转发 `usePane()` 拿到的宿主上下文
|
||||||
|
*/
|
||||||
|
export function providePane(context: PaneContext): void {
|
||||||
|
provide(PANE_KEY, context);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主从布局的选中态管理。
|
* 主从布局的选中态管理。
|
||||||
*
|
*
|
||||||
@@ -99,7 +117,7 @@ export function useMasterDetail(options: UseMasterDetailOptions = {}): UseMaster
|
|||||||
const isWide = layout.isWide;
|
const isWide = layout.isWide;
|
||||||
|
|
||||||
// 右栏里的页面通过 usePane().close() 把控制权交回来
|
// 右栏里的页面通过 usePane().close() 把控制权交回来
|
||||||
provide(PANE_KEY, {
|
providePane({
|
||||||
close: (saved = false) => options.onClose?.(saved),
|
close: (saved = false) => options.onClose?.(saved),
|
||||||
openSub: view => options.onOpenSub?.(view) ?? false
|
openSub: view => options.onOpenSub?.(view) ?? false
|
||||||
});
|
});
|
||||||
@@ -226,6 +244,13 @@ export interface UseMasterDetailPaneReturn {
|
|||||||
openSub: (view: string) => boolean;
|
openSub: (view: string) => boolean;
|
||||||
/** 关闭子页面,回到详情层。 */
|
/** 关闭子页面,回到详情层。 */
|
||||||
closeSub: () => void;
|
closeSub: () => void;
|
||||||
|
/**
|
||||||
|
* 关闭右栏最上面一层:有子页先关子页,其次关编辑,最后关详情。
|
||||||
|
*
|
||||||
|
* 和 `usePane().close()` 是同一套逻辑,给"页面要派生一套栏内上下文"时转发用
|
||||||
|
* (见 `providePane`)。
|
||||||
|
*/
|
||||||
|
close: (saved?: boolean) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -313,7 +338,11 @@ export function useMasterDetailPane(options: UseMasterDetailPaneOptions): UseMas
|
|||||||
? options.edit(id)
|
? options.edit(id)
|
||||||
: options.detail(id)),
|
: options.detail(id)),
|
||||||
onOpenSub: requestSub,
|
onOpenSub: requestSub,
|
||||||
onClose: saved => {
|
onClose: saved => closePane(saved)
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 关闭右栏最上面一层;页面派生上下文时原样转发这一个。 */
|
||||||
|
function closePane(saved = false): void {
|
||||||
if (popPane(saved)) {
|
if (popPane(saved)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -340,7 +369,6 @@ export function useMasterDetailPane(options: UseMasterDetailPaneOptions): UseMas
|
|||||||
// 关闭详情:右滑出,回到空栏
|
// 关闭详情:右滑出,回到空栏
|
||||||
selectedId.value = "";
|
selectedId.value = "";
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
function openDetail(id: string): void {
|
function openDetail(id: string): void {
|
||||||
// 正在编辑时直接点列表里另一项:栈顶是编辑层,就地改成新客户的详情的话,
|
// 正在编辑时直接点列表里另一项:栈顶是编辑层,就地改成新客户的详情的话,
|
||||||
@@ -494,7 +522,8 @@ export function useMasterDetailPane(options: UseMasterDetailPaneOptions): UseMas
|
|||||||
openDetail,
|
openDetail,
|
||||||
openEdit,
|
openEdit,
|
||||||
openSub: requestSub,
|
openSub: requestSub,
|
||||||
closeSub
|
closeSub,
|
||||||
|
close: closePane
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import "./assets/style/tdesign-custom.less";
|
|||||||
import "./assets/style/entrance-transition.less";
|
import "./assets/style/entrance-transition.less";
|
||||||
import "./assets/style/page-layout.less";
|
import "./assets/style/page-layout.less";
|
||||||
import "./components/tiptap-content.less";
|
import "./components/tiptap-content.less";
|
||||||
import "timi-web/style.css";
|
|
||||||
|
|
||||||
export * from "./components";
|
export * from "./components";
|
||||||
export * from "./directives";
|
export * from "./directives";
|
||||||
|
|||||||
+52
-17
@@ -1,3 +1,4 @@
|
|||||||
|
import { existsSync, readdirSync, statSync } from "fs";
|
||||||
import { resolve } from "path";
|
import { resolve } from "path";
|
||||||
import { Alias, defineConfig } from "vite";
|
import { Alias, defineConfig } from "vite";
|
||||||
import vue from "@vitejs/plugin-vue";
|
import vue from "@vitejs/plugin-vue";
|
||||||
@@ -8,11 +9,44 @@ import dts from "vite-plugin-dts";
|
|||||||
|
|
||||||
const alias: Alias[] = [
|
const alias: Alias[] = [
|
||||||
{
|
{
|
||||||
find: /^timi-tdesign-mobile(\/(es|lib))?$/,
|
find: /^@timi\/tdesign-mobile(\/(es|lib))?$/,
|
||||||
replacement: resolve(__dirname, "./src/index.ts")
|
replacement: resolve(__dirname, "./src/index.ts")
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递归收集组件入口,组件目录下存在 index.ts 时即视为一个可独立导出的组件
|
||||||
|
*/
|
||||||
|
function collectComponentEntries(
|
||||||
|
dir: string,
|
||||||
|
prefix: string,
|
||||||
|
entries: Record<string, string>
|
||||||
|
) {
|
||||||
|
for (const name of readdirSync(dir)) {
|
||||||
|
const fullPath = resolve(dir, name);
|
||||||
|
if (!statSync(fullPath).isDirectory()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const entry = resolve(fullPath, "index.ts");
|
||||||
|
if (existsSync(entry)) {
|
||||||
|
entries[`${prefix}/${name}/index`] = entry;
|
||||||
|
}
|
||||||
|
collectComponentEntries(fullPath, `${prefix}/${name}`, entries);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const entries: Record<string, string> = {
|
||||||
|
index: resolve(__dirname, "./src/index.ts"),
|
||||||
|
"components/index": resolve(__dirname, "./src/components/index.ts"),
|
||||||
|
"directives/index": resolve(__dirname, "./src/directives/index.ts"),
|
||||||
|
"utils/message": resolve(__dirname, "./src/utils/message.ts")
|
||||||
|
};
|
||||||
|
collectComponentEntries(
|
||||||
|
resolve(__dirname, "./src/components"),
|
||||||
|
"components",
|
||||||
|
entries
|
||||||
|
);
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
server: {
|
server: {
|
||||||
port: 3004,
|
port: 3004,
|
||||||
@@ -24,33 +58,34 @@ export default defineConfig({
|
|||||||
build: {
|
build: {
|
||||||
outDir: "dist",
|
outDir: "dist",
|
||||||
lib: {
|
lib: {
|
||||||
entry: resolve(__dirname, "./src/index.ts"),
|
entry: entries,
|
||||||
name: "TimiTDesignMobile",
|
formats: ["es"],
|
||||||
fileName: "timi-tdesign-mobile"
|
fileName: (_format, entryName) => `${entryName}.js`,
|
||||||
|
cssFileName: "timi-tdesign-mobile"
|
||||||
},
|
},
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
external: [
|
external: (id) =>
|
||||||
"vue",
|
id === "vue" ||
|
||||||
"vue-router",
|
id === "vue-router" ||
|
||||||
"timi-web",
|
id === "@timi/web" ||
|
||||||
"tdesign-mobile-vue"
|
id.startsWith("@timi/web/") ||
|
||||||
],
|
id === "tdesign-mobile-vue" ||
|
||||||
|
id.startsWith("tdesign-mobile-vue/"),
|
||||||
output: {
|
output: {
|
||||||
globals: {
|
chunkFileNames: "chunks/[name]-[hash].js"
|
||||||
vue: "Vue",
|
|
||||||
"timi-web": "TimiWeb"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
minify: "terser"
|
cssCodeSplit: false,
|
||||||
|
minify: "terser",
|
||||||
|
target: "es2017"
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
vue({
|
vue({
|
||||||
include: [/\.vue$/, /\.md$/]
|
include: [/\.vue$/, /\.md$/]
|
||||||
}),
|
}),
|
||||||
dts({
|
dts({
|
||||||
pathsToAliases: false,
|
entryRoot: "src",
|
||||||
aliasesExclude: [/^timi-web\/editor$/]
|
pathsToAliases: false
|
||||||
}),
|
}),
|
||||||
AutoImport({
|
AutoImport({
|
||||||
imports: [
|
imports: [
|
||||||
|
|||||||
Reference in New Issue
Block a user