add card-container

This commit is contained in:
Timi
2026-10-12 16:17:14 +08:00
parent a20e051e8a
commit b09011251a
8 changed files with 132 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
# 项目概览
`timi-tdesign-mobile` 是 Vue 3 组件与前端通用能力依赖库,使用 TypeScript、Vite、Less、Axios、TDesign Mobile Vue。主要源码在 `src/components`、`src/api`、`src/assets`、`src/types`、`src/store`、`src/utils`,包入口为 `src/index.ts`。仓库也包含 `docs` 子项目。开发环境为 Windows,命令通过 PowerShell 执行。
@@ -0,0 +1,7 @@
# 风格与约定
- Vue 3 Composition API,优先 `<script setup>`;组件标签使用小写 kebab-case。
- TypeScript 优先明确类型并为公共 API 写 JSDoc;Promise 使用 async/await。
- Less 使用嵌套规则,属性尽量简写,优先 rem;属性按名称长度排序,类名简短。
- 文本文件使用 UTF-8;遵循仓库 `.eslintrc.js`。ESLint 9 当前使用旧式 `.eslintrc` 时,设置 `$env:ESLINT_USE_FLAT_CONFIG = 'false'` 后再运行。
- 不随意重命名公共类型,不无故增加依赖;不添加测试,除非用户明确要求。
+8
View File
@@ -0,0 +1,8 @@
# 常用命令(PowerShell)
- `pnpm dev`:启动 docs 开发服务(根脚本转发到 `docs`)。
- `pnpm build`:运行 `vue-tsc --noEmit` 并打包组件库。
- `pnpm run build:doc`:构建文档。
- `pnpm run preview:doc`:预览构建后的文档。
- ESLint 没有根脚本;旧式配置可用 `$env:ESLINT_USE_FLAT_CONFIG = 'false'; pnpm exec eslint <路径>`。
- 根 `package.json` 没有测试脚本。查看状态用 `git status --short`,文件搜索用 `rg` / `rg --files`。
+3
View File
@@ -0,0 +1,3 @@
# 完成任务时
先查看 `git status --short`,保留用户已有改动;遵循 `.eslintrc.js` 和 `AGENTS.md`。通常针对改动文件检查 ESLint 与 TypeScript 语法;与声明生成/打包相关的问题可运行 `pnpm build`。除非用户明确要求,不添加测试或运行测试。
+7
View File
@@ -0,0 +1,7 @@
import view from "./index.vue";
import { WebToolkit } from "timi-web";
export const CardContainer = WebToolkit.withInstall(view);
export default CardContainer;
export type { CardContainerProps } from "./type";
+91
View File
@@ -0,0 +1,91 @@
<template>
<div class="card-container">
<div class="card-title">
<h3 v-if="title || $slots.title" class="title">
<slot name="title">
<span v-text="title" />
</slot>
</h3>
<p v-if="description || $slots.description" class="description">
<slot name="description">
<span v-text="description" />
</slot>
</p>
</div>
<div v-if="$slots.default" class="content">
<slot />
</div>
<div v-if="tips || $slots.tips" class="tips">
<slot name="tips">
<span v-text="tips" />
</slot>
</div>
</div>
</template>
<script setup lang="ts">
defineProps({
title: String,
description: String,
tips: String
});
defineSlots<{
default?: () => unknown;
title?: () => unknown;
description?: () => unknown;
tips?: () => unknown;
}>();
defineOptions({
name: "CardContainer"
});
</script>
<style scoped lang="less">
.card-container {
margin: 0 1rem;
:deep(.t-cell-group--card) {
margin: 0;
}
.card-title {
.title {
margin: 0 .875rem;
}
.description {
color: var(--td-text-color-secondary, #52607a);
margin: .5rem .875rem;
font-size: .875rem;
}
}
.content {
overflow: hidden;
background: var(--td-bg-color-container, #fff);
border-radius: 1rem;
}
.tips {
color: var(--td-text-color-secondary, #52607a);
padding: .25rem 1rem;
font-size: .8125rem;
line-height: 1.5;
}
}
:global(html.theme-dark) {
.card-container {
background: rgba(15, 23, 42, .88);
box-shadow: 0 .75rem 2rem rgba(2, 6, 23, .32);
.tips {
color: #94a3b8;
background: rgba(148, 163, 184, .14);
}
}
}
</style>
+6
View File
@@ -0,0 +1,6 @@
/** CardContainer 组件属性。 */
export interface CardContainerProps {
title?: string;
description?: string;
tips?: string;
}
+7
View File
@@ -11,6 +11,7 @@ import NotifyEditor from "./notify-editor";
import NotifyView from "./notify-view"; import NotifyView from "./notify-view";
import BottomPopup from "./bottom-popup"; import BottomPopup from "./bottom-popup";
import Space from "./space"; import Space from "./space";
import CardContainer from "./card-container";
import { import {
AiChatComposer, AiChatComposer,
AiChatMessageList, AiChatMessageList,
@@ -31,6 +32,7 @@ export default [
NotifyView, NotifyView,
BottomPopup, BottomPopup,
Space, Space,
CardContainer,
AiChatComposer, AiChatComposer,
AiChatMessageList, AiChatMessageList,
AiChatPanel, AiChatPanel,
@@ -50,6 +52,7 @@ export {
NotifyView, NotifyView,
BottomPopup, BottomPopup,
Space, Space,
CardContainer,
AiChatComposer, AiChatComposer,
AiChatMessageList, AiChatMessageList,
AiChatPanel, AiChatPanel,
@@ -91,6 +94,10 @@ export type {
SpaceSlots SpaceSlots
} from "./space"; } from "./space";
export type {
CardContainerProps
} from "./card-container";
export type { export type {
PageTransitionBackground, PageTransitionBackground,
PageTransitionClass, PageTransitionClass,