From c3a49a26e76debb395aa7e85381f731dd17edafd Mon Sep 17 00:00:00 2001 From: devin Date: Tue, 3 Jan 2023 21:44:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0link?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.js | 8 + packages/docs/button.md | 36 +---- packages/docs/select.md | 37 ++--- .../src/components/_shared/constant.ts | 1 + .../src/components/_shared/global.ts | 10 -- .../src/components/_shared/utils.ts | 14 +- .../src/components/button/OButton.vue | 9 ++ .../button/__demo__/BtnDisabled.vue | 5 +- .../opendesign/src/components/link/OLink.vue | 75 +++++---- .../components/link/__demo__/IndexLink.vue | 1 + .../src/components/link/__demo__/LinkDemo.vue | 31 +++- .../src/components/link/style/index.scss | 142 ++---------------- .../src/components/link/style/var.scss | 32 +--- .../src/components/select/OSelect.vue | 2 +- packages/portal/src/router.ts | 7 + 15 files changed, 149 insertions(+), 261 deletions(-) create mode 100644 packages/opendesign/src/components/_shared/constant.ts diff --git a/.eslintrc.js b/.eslintrc.js index 113afb5f..b4acfe57 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -67,9 +67,17 @@ module.exports = { normal: 'never', }, }], + // "vue/html-indent": ["error", type, { + // "attribute": 1, + // "baseIndent": 1, + // "closeBracket": 2, + // "alignAttributesVertically": true, + // "ignores": [] + // }], 'vue/singleline-html-element-content-newline': 'off', 'vue/html-closing-bracket-newline': 'off', + 'vue/multiline-html-element-content-newline': 'warn', // for ts // '@typescript-eslint/strict-boolean-expressions': 'warn', diff --git a/packages/docs/button.md b/packages/docs/button.md index 3ec6b396..f68d921f 100644 --- a/packages/docs/button.md +++ b/packages/docs/button.md @@ -1,33 +1,13 @@ # Button 按钮 -# props +## props -| name | type | 说明 | -| :---- | :--------- | :--- | -| type | ButtonType | 类型 | -| size | SizeT | 尺寸 | -| shape | ShapeT | 形状 | +| name | type | 默认值 | 说明 | +| :---- | :---------- | :-------- | :----------------------------------- | +| shape | ShapeT | 'normal' | 形状: large \| normal \| small | +| size | SizeT | 'normal' | 形状 normal \| round | +| type | ButtonTypeT | 'outline' | 形状 primary \|outline\| text \|link | -``` -enum ButtonType { - PRIMARY = 'primary', - OUTLINE = 'outline', - TEXT = 'text', - LINK = 'link', -} +## event -enum SizeT { - LARGE = 'large', - NORMAL = 'normal', - SMALL = 'small' -} - -enum ShapeT { - ROUND = 'round', - NORMAL = 'normal' -} -``` - -# event - -# expose +## expose diff --git a/packages/docs/select.md b/packages/docs/select.md index 842df15a..85703397 100644 --- a/packages/docs/select.md +++ b/packages/docs/select.md @@ -1,35 +1,22 @@ # Select 下拉选择器 -# props +## props -| name | type | 默认值 | 说明 | -| :----------- | :------- | :------------ | ------------------------------------------------------------- | -| model:value | Boolean | false | 开关状态 | -| shape | ShapeT | ShapeT.NORMAL | 形状 | -| size | SizeT | SizeT.NORMAL | 形状 | -| disabled | Boolean | false | 形状 | -| loading | Boolean | false | 加载状态 | -| beforeChange | Function | ()=>true | return Promise. resolve(true)继续切换,resolve(false)阻止切换 | +| name | type | 默认值 | 说明 | +| :----------- | :------- | :------- | ------------------------------------------------------------- | +| model:value | boolean | false | 开关状态 | +| shape | ShapeT | 'normal' | 形状: large \| normal \| small | +| size | SizeT | 'normal' | 形状 normal \| round | +| disabled | boolean | false | 形状 | +| loading | boolean | false | 加载状态 | +| beforeChange | function | ()=>true | return Promise. resolve(true)继续切换,resolve(false)阻止切换 | -``` -enum SizeT { - LARGE = 'large', - NORMAL = 'normal', - SMALL = 'small' -} - -enum ShapeT { - ROUND = 'round', - NORMAL = 'normal' -} -``` - -# event +## event | name | 参数 | 说明 | | :----- | :------------------------ | :------------- | | change | value: boolean; ev: Event | 选择切换后触发 | -# expose +## expose -# slot +## slot diff --git a/packages/opendesign/src/components/_shared/constant.ts b/packages/opendesign/src/components/_shared/constant.ts new file mode 100644 index 00000000..8f26d900 --- /dev/null +++ b/packages/opendesign/src/components/_shared/constant.ts @@ -0,0 +1 @@ +export const ProvideOptionKey = Symbol('option-provide'); diff --git a/packages/opendesign/src/components/_shared/global.ts b/packages/opendesign/src/components/_shared/global.ts index e5603c89..cca90c63 100644 --- a/packages/opendesign/src/components/_shared/global.ts +++ b/packages/opendesign/src/components/_shared/global.ts @@ -1,11 +1,6 @@ import { ref } from 'vue'; // 尺寸 -export enum Size { - LARGE = 'large', - NORMAL = 'normal', - SMALL = 'small' -} export type SizeT = 'large' | 'normal' | 'small' export const defaultSize = ref('normal'); @@ -15,10 +10,6 @@ export function initSize(type: SizeT) { } // 形状 -export enum Shape { - ROUND = 'round', - NORMAL = 'normal' -} export type ShapeT = 'round' | 'normal' export const defaultShape = ref('normal'); @@ -27,7 +18,6 @@ export function initShape(shape: ShapeT) { defaultShape.value = shape; } -export const OptionProvideKey = 'option-provide'; export interface OptionValueT { label: string; value: string | number; diff --git a/packages/opendesign/src/components/_shared/utils.ts b/packages/opendesign/src/components/_shared/utils.ts index 07591204..3e1e96c1 100644 --- a/packages/opendesign/src/components/_shared/utils.ts +++ b/packages/opendesign/src/components/_shared/utils.ts @@ -1,21 +1,21 @@ import { throttle as _throttle, debounce as _debounce } from 'lodash-es'; import type { ThrottleSettings, DebounceSettings } from 'lodash-es'; -export function isFunction(fn: any) { +export function isFunction(fn: unknown) { return typeof fn === 'function'; } // 防抖 -export function debounce any>(fn: T, wait?: number, ctx?: any | null, opts?: ThrottleSettings) { +export function debounce) => unknown>(fn: T, wait?: number, ctx?: unknown | null, opts?: ThrottleSettings) { return _debounce.apply(ctx, [fn, wait, opts]); } // 节流 -export function throttle any>(fn: T, wait?: number, ctx?: any | null, opts?: DebounceSettings) { +export function throttle) => unknown>(fn: T, wait?: number, ctx?: unknown | null, opts?: DebounceSettings) { return _throttle.apply(ctx, [fn, wait, opts]); } // 防抖 时间为一个一帧 -export function debounceRAF any>(fn: T) { +export function debounceRAF) => any>(fn: T) { let handle = 0; - const rlt = (...args: any[]) => { + const rlt = (...args: Array) => { if (handle) { cancelAnimationFrame(handle); } @@ -31,9 +31,9 @@ export function debounceRAF any>(fn: T) { return rlt; } // 节流 时间为一个一帧 -export function throttleRAF any>(fn: T) { +export function throttleRAF) => unknown>(fn: T) { let handle = 0; - const rlt = (...args: any[]) => { + const rlt = (...args: Array) => { if (handle) { return; } diff --git a/packages/opendesign/src/components/button/OButton.vue b/packages/opendesign/src/components/button/OButton.vue index e5e97e04..9e4d5334 100644 --- a/packages/opendesign/src/components/button/OButton.vue +++ b/packages/opendesign/src/components/button/OButton.vue @@ -4,8 +4,17 @@ import type { SizeT, ShapeT } from '../_shared/global'; import { ButtonTypeT } from './types'; interface ButtonPropT { + /** + * 按钮类型:'primary' | 'outline' | 'text' | 'link' + */ type?: ButtonTypeT; + /** + * 按钮尺寸:'primary' | 'outline' | 'text' | 'link' + */ size?: SizeT; + /** + * 按钮形状:'primary' | 'outline' | 'text' | 'link' + */ shape?: ShapeT; } const props = withDefaults(defineProps(), { diff --git a/packages/opendesign/src/components/button/__demo__/BtnDisabled.vue b/packages/opendesign/src/components/button/__demo__/BtnDisabled.vue index cd607a52..2239bec3 100644 --- a/packages/opendesign/src/components/button/__demo__/BtnDisabled.vue +++ b/packages/opendesign/src/components/button/__demo__/BtnDisabled.vue @@ -1,9 +1,12 @@