diff --git a/.lintstagedrc.mjs b/.lintstagedrc.mjs index 94b0192a..2a5a5a1a 100644 --- a/.lintstagedrc.mjs +++ b/.lintstagedrc.mjs @@ -15,6 +15,6 @@ export default { ], 'package.json': ['prettier --cache --write'], '{!(package)*.json,*.code-snippets,.!(browserslist)*rc}': [ - 'prettier --cache --write--parser json', + 'prettier --cache --write --parser json', ], }; diff --git a/.node-version b/.node-version index 48b14e6b..ee5c2446 100644 --- a/.node-version +++ b/.node-version @@ -1 +1 @@ -20.14.0 +22.1.0 diff --git a/.vscode/settings.json b/.vscode/settings.json index 8b76b276..46d853ff 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -14,7 +14,7 @@ "editor.tabSize": 2, "editor.detectIndentation": false, "editor.cursorBlinking": "expand", - "editor.largeFileOptimizations": false, + "editor.largeFileOptimizations": true, "editor.accessibilitySupport": "off", "editor.cursorSmoothCaretAnimation": "on", "editor.guides.bracketPairs": "active", @@ -91,6 +91,7 @@ "**/bower_components": true, "**/.turbo": true, "**/.idea": true, + "**/.vitepress": true, "**/tmp": true, "**/.git": true, "**/.svn": true, @@ -112,6 +113,8 @@ "**/yarn.lock": true }, + "typescript.tsserver.exclude": ["**/node_modules", "**/dist", "**/.turbo"], + // search "search.searchEditor.singleClickBehaviour": "peekDefinition", "search.followSymlinks": false, diff --git a/internal/vite-config/src/typing.ts b/internal/vite-config/src/typing.ts index 31683cc7..f730bdb9 100644 --- a/internal/vite-config/src/typing.ts +++ b/internal/vite-config/src/typing.ts @@ -3,149 +3,328 @@ import type { ConfigEnv, PluginOption, UserConfig } from 'vite'; import type { PluginOptions } from 'vite-plugin-dts'; import type { Options as PwaPluginOptions } from 'vite-plugin-pwa'; +/** + * ImportMap 配置接口 + * @description 用于配置模块导入映射,支持自定义导入路径和范围 + * @example + * ```typescript + * { + * imports: { + * 'vue': 'https://unpkg.com/vue@3.2.47/dist/vue.esm-browser.js' + * }, + * scopes: { + * 'https://site.com/': { + * 'vue': 'https://unpkg.com/vue@3.2.47/dist/vue.esm-browser.js' + * } + * } + * } + * ``` + */ interface IImportMap { + /** 模块导入映射 */ imports?: Record; + /** 作用域特定的导入映射 */ scopes?: { [scope: string]: Record; }; } + +/** + * 打印插件配置选项 + * @description 用于配置控制台打印信息 + */ interface PrintPluginOptions { /** - * 打印的数据 + * 打印的数据映射 + * @description 键值对形式的数据,将在控制台打印 + * @example + * ```typescript + * { + * 'App Version': '1.0.0', + * 'Build Time': '2024-01-01' + * } + * ``` */ infoMap?: Record; } +/** + * Nitro Mock 插件配置选项 + * @description 用于配置 Nitro Mock 服务器的行为 + */ interface NitroMockPluginOptions { /** - * mock server 包名 + * Mock 服务器包名 + * @default '@vbenjs/nitro-mock' */ mockServerPackage?: string; /** - * mock 服务端口 + * Mock 服务端口 + * @default 3000 */ port?: number; /** - * mock 日志是否打印 + * 是否打印 Mock 日志 + * @default false */ verbose?: boolean; } +/** + * 归档插件配置选项 + * @description 用于配置构建产物的压缩归档 + */ interface ArchiverPluginOptions { /** * 输出文件名 - * @default dist + * @default 'dist' */ name?: string; /** * 输出目录 - * @default . + * @default '.' */ outputDir?: string; } /** - * importmap 插件配置 + * ImportMap 插件配置 + * @description 用于配置模块的 CDN 导入 */ interface ImportmapPluginOptions { /** * CDN 供应商 - * @default jspm.io + * @default 'jspm.io' + * @description 支持 esm.sh 和 jspm.io 两种 CDN 供应商 */ defaultProvider?: 'esm.sh' | 'jspm.io'; - /** importmap 配置 */ + /** + * ImportMap 配置数组 + * @description 配置需要从 CDN 导入的包 + * @example + * ```typescript + * [ + * { name: 'vue' }, + * { name: 'pinia', range: '^2.0.0' } + * ] + * ``` + */ importmap?: Array<{ name: string; range?: string }>; - /** 手动配置importmap */ + /** + * 手动配置 ImportMap + * @description 自定义 ImportMap 配置 + */ inputMap?: IImportMap; } /** - * 用于判断是否需要加载插件 + * 条件插件配置 + * @description 用于根据条件动态加载插件 */ interface ConditionPlugin { - // 判断条件 + /** + * 判断条件 + * @description 当条件为 true 时加载插件 + */ condition?: boolean; - // 插件对象 + /** + * 插件对象 + * @description 返回插件数组或 Promise + */ plugins: () => PluginOption[] | PromiseLike; } +/** + * 通用插件配置选项 + * @description 所有插件共用的基础配置 + */ interface CommonPluginOptions { - /** 是否开启devtools */ + /** + * 是否开启开发工具 + * @default false + */ devtools?: boolean; - /** 环境变量 */ + /** + * 环境变量 + * @description 自定义环境变量 + */ env?: Record; - /** 是否注入metadata */ + /** + * 是否注入元数据 + * @default true + */ injectMetadata?: boolean; - /** 是否构建模式 */ + /** + * 是否为构建模式 + * @default false + */ isBuild?: boolean; - /** 构建模式 */ + /** + * 构建模式 + * @default 'development' + */ mode?: string; - /** 开启依赖分析 */ + /** + * 是否开启依赖分析 + * @default false + * @description 使用 rollup-plugin-visualizer 分析依赖 + */ visualizer?: boolean | PluginVisualizerOptions; } +/** + * 应用插件配置选项 + * @description 用于配置应用构建时的插件选项 + */ interface ApplicationPluginOptions extends CommonPluginOptions { - /** 开启后,会在打包dist同级生成dist.zip */ + /** + * 是否开启压缩归档 + * @default false + * @description 开启后会在打包目录生成 zip 文件 + */ archiver?: boolean; - /** 压缩归档插件配置 */ + /** + * 压缩归档插件配置 + * @description 配置压缩归档的行为 + */ archiverPluginOptions?: ArchiverPluginOptions; - /** 开启 gzip|brotli 压缩 */ + /** + * 是否开启压缩 + * @default false + * @description 支持 gzip 和 brotli 压缩 + */ compress?: boolean; - /** 压缩类型 */ + /** + * 压缩类型 + * @default ['gzip'] + * @description 可选的压缩类型 + */ compressTypes?: ('brotli' | 'gzip')[]; - /** 在构建的时候抽离配置文件 */ + /** + * 是否抽离配置文件 + * @default false + * @description 在构建时抽离配置文件 + */ extraAppConfig?: boolean; - /** 是否开启html插件 */ + /** + * 是否开启 HTML 插件 + * @default true + */ html?: boolean; - /** 是否开启i18n */ + /** + * 是否开启国际化 + * @default false + */ i18n?: boolean; - /** 是否开启 importmap CDN */ + /** + * 是否开启 ImportMap CDN + * @default false + */ importmap?: boolean; - /** importmap 插件配置 */ + /** + * ImportMap 插件配置 + */ importmapOptions?: ImportmapPluginOptions; - /** 是否注入app loading */ + /** + * 是否注入应用加载动画 + * @default true + */ injectAppLoading?: boolean; - /** 是否注入全局scss */ + /** + * 是否注入全局 SCSS + * @default true + */ injectGlobalScss?: boolean; - /** 是否注入版权信息 */ + /** + * 是否注入版权信息 + * @default true + */ license?: boolean; - /** 是否开启nitro mock */ + /** + * 是否开启 Nitro Mock + * @default false + */ nitroMock?: boolean; - /** nitro mock 插件配置 */ + /** + * Nitro Mock 插件配置 + */ nitroMockOptions?: NitroMockPluginOptions; - /** 开启控制台自定义打印 */ + /** + * 是否开启控制台打印 + * @default false + */ print?: boolean; - /** 打印插件配置 */ + /** + * 打印插件配置 + */ printInfoMap?: PrintPluginOptions['infoMap']; - /** 是否开启pwa */ + /** + * 是否开启 PWA + * @default false + */ pwa?: boolean; - /** pwa 插件配置 */ + /** + * PWA 插件配置 + */ pwaOptions?: Partial; - /** 是否开启vxe-table懒加载 */ + /** + * 是否开启 VXE Table 懒加载 + * @default false + */ vxeTableLazyImport?: boolean; } +/** + * 库插件配置选项 + * @description 用于配置库构建时的插件选项 + */ interface LibraryPluginOptions extends CommonPluginOptions { - /** 开启 dts 输出 */ + /** + * 是否开启 DTS 输出 + * @default true + * @description 生成 TypeScript 类型声明文件 + */ dts?: boolean | PluginOptions; } +/** + * 应用配置选项类型 + */ type ApplicationOptions = ApplicationPluginOptions; +/** + * 库配置选项类型 + */ type LibraryOptions = LibraryPluginOptions; +/** + * 应用配置定义函数类型 + * @description 用于定义应用构建配置 + */ type DefineApplicationOptions = (config?: ConfigEnv) => Promise<{ + /** 应用插件配置 */ application?: ApplicationOptions; + /** Vite 配置 */ vite?: UserConfig; }>; +/** + * 库配置定义函数类型 + * @description 用于定义库构建配置 + */ type DefineLibraryOptions = (config?: ConfigEnv) => Promise<{ + /** 库插件配置 */ library?: LibraryOptions; + /** Vite 配置 */ vite?: UserConfig; }>; +/** + * 配置定义类型 + * @description 应用或库的配置定义 + */ type DefineConfig = DefineApplicationOptions | DefineLibraryOptions; export type { diff --git a/package.json b/package.json index 452dd503..d6d46cbd 100644 --- a/package.json +++ b/package.json @@ -99,7 +99,7 @@ "node": ">=20.10.0", "pnpm": ">=9.12.0" }, - "packageManager": "pnpm@9.15.9", + "packageManager": "pnpm@10.10.0", "pnpm": { "peerDependencyRules": { "allowedVersions": { diff --git a/packages/@core/ui-kit/form-ui/src/form-render/expandable.ts b/packages/@core/ui-kit/form-ui/src/form-render/expandable.ts index a7b8ef41..9383064c 100644 --- a/packages/@core/ui-kit/form-ui/src/form-render/expandable.ts +++ b/packages/@core/ui-kit/form-ui/src/form-render/expandable.ts @@ -2,13 +2,18 @@ import type { FormRenderProps } from '../types'; import { computed, nextTick, onMounted, ref, useTemplateRef, watch } from 'vue'; -import { breakpointsTailwind, useBreakpoints } from '@vueuse/core'; +import { + breakpointsTailwind, + useBreakpoints, + useElementVisibility, +} from '@vueuse/core'; /** * 动态计算行数 */ export function useExpandable(props: FormRenderProps) { const wrapperRef = useTemplateRef('wrapperRef'); + const isVisible = useElementVisibility(wrapperRef); const rowMapping = ref>({}); // 是否已经计算过一次 const isCalculated = ref(false); @@ -31,6 +36,7 @@ export function useExpandable(props: FormRenderProps) { () => props.showCollapseButton, () => breakpoints.active().value, () => props.schema?.length, + () => isVisible.value, ], async ([val]) => { if (val) { diff --git a/packages/@core/ui-kit/popup-ui/src/drawer/drawer.vue b/packages/@core/ui-kit/popup-ui/src/drawer/drawer.vue index 7a28dddd..25069979 100644 --- a/packages/@core/ui-kit/popup-ui/src/drawer/drawer.vue +++ b/packages/@core/ui-kit/popup-ui/src/drawer/drawer.vue @@ -82,17 +82,17 @@ const { zIndex, } = usePriorityValues(props, state); -watch( - () => showLoading.value, - (v) => { - if (v && wrapperRef.value) { - wrapperRef.value.scrollTo({ - // behavior: 'smooth', - top: 0, - }); - } - }, -); +// watch( +// () => showLoading.value, +// (v) => { +// if (v && wrapperRef.value) { +// wrapperRef.value.scrollTo({ +// // behavior: 'smooth', +// top: 0, +// }); +// } +// }, +// ); function interactOutside(e: Event) { if (!closeOnClickModal.value || submitting.value) { @@ -266,19 +266,13 @@ const getForceMount = computed(() => { ref="wrapperRef" :class=" cn('relative flex-1 overflow-y-auto p-3', contentClass, { - 'overflow-hidden': showLoading, + 'pointer-events-none': showLoading || submitting, }) " > - - - + - - +