icssoa 5 месяцев назад
Родитель
Сommit
185f5bf708

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
 	"name": "cool-unix",
-	"version": "8.0.27",
+	"version": "8.0.28",
 	"license": "MIT",
 	"scripts": {
 		"build-ui": "node ./uni_modules/cool-ui/scripts/generate-types.js",

+ 1 - 1
uni_modules/cool-ui/components/cl-checkbox/props.ts

@@ -12,7 +12,7 @@ export type ClCheckboxProps = {
 	pt?: ClCheckboxPassThrough;
 	modelValue?: any[] | boolean;
 	label?: string;
-	value: any;
+	value?: any;
 	disabled?: boolean;
 	activeIcon?: string;
 	inactiveIcon?: string;

+ 2 - 4
uni_modules/cool-ui/components/cl-page/props.ts

@@ -1,6 +1,4 @@
-import type { ClConfirmAction, ClConfirmOptions, ClToastOptions } from "../../types";
-import type { UiInstance } from "../../hooks";
-
-export type ClPageUiProps = {
+export type ClPageProps = {
 	className?: string;
+	backTop?: boolean;
 };

+ 2 - 2
uni_modules/cool-ui/components/cl-radio/props.ts

@@ -10,11 +10,11 @@ export type ClRadioPassThrough = {
 export type ClRadioProps = {
 	className?: string;
 	pt?: ClRadioPassThrough;
-	modelValue: any;
+	modelValue?: any;
 	activeIcon?: string;
 	inactiveIcon?: string;
 	showIcon?: boolean;
 	label?: string;
-	value: any;
+	value?: any;
 	disabled?: boolean;
 };

+ 1 - 8
uni_modules/cool-ui/index.d.ts

@@ -1,5 +1,4 @@
-import type { ClActionSheetItem, ClActionSheetOptions, PassThroughProps, Type, ClButtonType, Size, ClCalendarDateConfig, ClCalendarMode, ClListViewItem, ClFilterItemType, ClSelectOption, ClFormLabelPosition, ClFormRule, ClFormValidateError, ClInputType, ClListItem, Justify, ClListViewGroup, ClListViewVirtualItem, ClListViewRefresherStatus, ClConfirmAction, ClConfirmOptions, ClToastOptions, ClPopupDirection, ClQrcodeMode, ClSelectValue, ClSelectDateShortcut, ClTabsItem, ClTextType, ClTreeItem, ClTreeNodeInfo, ClUploadItem } from "./types";
-import { type UiInstance } from "./hooks";
+import type { ClActionSheetItem, ClActionSheetOptions, PassThroughProps, Type, ClButtonType, Size, ClCalendarDateConfig, ClCalendarMode, ClListViewItem, ClFilterItemType, ClSelectOption, ClFormLabelPosition, ClFormRule, ClFormValidateError, ClInputType, ClListItem, Justify, ClListViewGroup, ClListViewVirtualItem, ClListViewRefresherStatus, ClPopupDirection, ClQrcodeMode, ClSelectValue, ClSelectDateShortcut, ClTabsItem, ClTextType, ClToastOptions, ClTreeItem, ClTreeNodeInfo, ClUploadItem } from "./types";
 import { type QrcodeOptions } from "./draw";
 
 import type { ClActionSheetProps, ClActionSheetPassThrough } from "./components/cl-action-sheet/props";
@@ -9,7 +8,6 @@ import type { ClBadgeProps, ClBadgePassThrough } from "./components/cl-badge/pro
 import type { ClBannerProps, ClBannerPassThrough } from "./components/cl-banner/props";
 import type { ClButtonProps, ClButtonPassThrough } from "./components/cl-button/props";
 import type { ClCalendarProps, ClCalendarPassThrough } from "./components/cl-calendar/props";
-import type { ClCalendarPickerProps } from "./components/cl-calendar-picker/props";
 import type { ClCalendarSelectProps, ClCalendarSelectPassThrough } from "./components/cl-calendar-select/props";
 import type { ClCascaderProps, ClCascaderPassThrough } from "./components/cl-cascader/props";
 import type { ClCheckboxProps, ClCheckboxPassThrough } from "./components/cl-checkbox/props";
@@ -41,8 +39,6 @@ import type { ClLoadmoreProps, ClLoadmorePassThrough } from "./components/cl-loa
 import type { ClMarqueeProps, ClMarqueePassThrough } from "./components/cl-marquee/props";
 import type { ClNoticebarProps, ClNoticebarPassThrough } from "./components/cl-noticebar/props";
 import type { ClPageProps } from "./components/cl-page/props";
-import type { ClPageThemeProps } from "./components/cl-page-theme/props";
-import type { ClPageUiProps } from "./components/cl-page-ui/props";
 import type { ClPaginationProps, ClPaginationPassThrough } from "./components/cl-pagination/props";
 import type { ClSelectPickerViewProps } from "./components/cl-select-picker-view/props";
 import type { ClPopupProps, ClPopupPassThrough, ClPopupHeaderPassThrough } from "./components/cl-popup/props";
@@ -90,7 +86,6 @@ declare module "vue" {
 		"cl-banner": (typeof import('./components/cl-banner/cl-banner.uvue')['default']) & import('vue').DefineComponent<ClBannerProps>;
 		"cl-button": (typeof import('./components/cl-button/cl-button.uvue')['default']) & import('vue').DefineComponent<ClButtonProps>;
 		"cl-calendar": (typeof import('./components/cl-calendar/cl-calendar.uvue')['default']) & import('vue').DefineComponent<ClCalendarProps>;
-		"cl-calendar-picker": (typeof import('./components/cl-calendar-picker/cl-calendar-picker.uvue')['default']) & import('vue').DefineComponent<ClCalendarPickerProps>;
 		"cl-calendar-select": (typeof import('./components/cl-calendar-select/cl-calendar-select.uvue')['default']) & import('vue').DefineComponent<ClCalendarSelectProps>;
 		"cl-cascader": (typeof import('./components/cl-cascader/cl-cascader.uvue')['default']) & import('vue').DefineComponent<ClCascaderProps>;
 		"cl-checkbox": (typeof import('./components/cl-checkbox/cl-checkbox.uvue')['default']) & import('vue').DefineComponent<ClCheckboxProps>;
@@ -122,8 +117,6 @@ declare module "vue" {
 		"cl-marquee": (typeof import('./components/cl-marquee/cl-marquee.uvue')['default']) & import('vue').DefineComponent<ClMarqueeProps>;
 		"cl-noticebar": (typeof import('./components/cl-noticebar/cl-noticebar.uvue')['default']) & import('vue').DefineComponent<ClNoticebarProps>;
 		"cl-page": (typeof import('./components/cl-page/cl-page.uvue')['default']) & import('vue').DefineComponent<ClPageProps>;
-		"cl-page-theme": (typeof import('./components/cl-page-theme/cl-page-theme.uvue')['default']) & import('vue').DefineComponent<ClPageThemeProps>;
-		"cl-page-ui": (typeof import('./components/cl-page-ui/cl-page-ui.uvue')['default']) & import('vue').DefineComponent<ClPageUiProps>;
 		"cl-pagination": (typeof import('./components/cl-pagination/cl-pagination.uvue')['default']) & import('vue').DefineComponent<ClPaginationProps>;
 		"cl-select-picker-view": (typeof import('./components/cl-select-picker-view/cl-select-picker-view.uvue')['default']) & import('vue').DefineComponent<ClSelectPickerViewProps>;
 		"cl-popup": (typeof import('./components/cl-popup/cl-popup.uvue')['default']) & import('vue').DefineComponent<ClPopupProps>;

+ 11 - 17
uni_modules/cool-ui/scripts/generate-types.js

@@ -263,14 +263,12 @@ class UvueTypeParser {
 			return null;
 		}
 
+		// 默认所有 props 都是可选的(非必填),符合 Vue 的默认行为
 		const config = {
 			type: "any",
-			required: true
+			required: false
 		};
 
-		let hasDefault = false;
-		let hasRequired = false;
-
 		for (const prop of propValue.properties) {
 			if (!t.isObjectProperty(prop) || !t.isIdentifier(prop.key)) continue;
 
@@ -278,23 +276,12 @@ class UvueTypeParser {
 
 			if (key === "type") {
 				config.type = this.extractTypeFromValue(prop.value);
-			} else if (key === "default") {
-				hasDefault = true;
-				config.required = false;
 			} else if (key === "required" && t.isBooleanLiteral(prop.value)) {
-				hasRequired = true;
+				// 只有显式设置 required: true 时才设为必填
 				config.required = prop.value.value;
 			}
 		}
 
-		// 如果没有显式设置required且没有default,对于某些特殊类型可以设为可选
-		if (!hasRequired && !hasDefault) {
-			// 对于复杂的联合类型(比如openType),通常应该是可选的
-			if (config.type.includes("|") && config.type.split("|").length > 5) {
-				config.required = false;
-			}
-		}
-
 		return config;
 	}
 
@@ -775,6 +762,7 @@ class UvueTypeParser {
 
 	/**
 	 * 扫描指定目录下的所有uvue文件
+	 * 只扫描与父目录同名的主组件文件,忽略辅助组件
 	 */
 	scanUvueFiles(directory) {
 		const results = [];
@@ -791,7 +779,13 @@ class UvueTypeParser {
 				if (stat.isDirectory()) {
 					scanDir(fullPath);
 				} else if (item.endsWith(".uvue")) {
-					results.push(fullPath);
+					// 只包含与父目录同名的 .uvue 文件(主组件)
+					const parentDirName = path.basename(path.dirname(fullPath));
+					const fileNameWithoutExt = path.basename(item, ".uvue");
+					
+					if (parentDirName === fileNameWithoutExt) {
+						results.push(fullPath);
+					}
 				}
 			}
 		}