Skip to content

Commit

Permalink
refactor(tdesign-mobile-vue/image-viewer): 更新image-viewer api (#291)
Browse files Browse the repository at this point in the history
* refactor(tdesign-mobile-vue/image-viewer): 更新image-viewer api

* fix: 修复mobile vue image-viewer单独属性设置问题

* chore: json to db

* feat: update platform_framework

---------

Co-authored-by: 黎伟杰 <674416404@qq.com>
  • Loading branch information
aaronmhl and liweijie0812 authored Jul 22, 2024
1 parent 448efd2 commit c4c1fd3
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 8 deletions.
Binary file modified db/TDesign.db
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ name | type | default | description | required
-- | -- | -- | -- | --
closeBtn | Boolean / Slot / Function | true | Typescript:`boolean \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
deleteBtn | Boolean / Slot / Function | false | Typescript:`boolean \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
images | Array | [] | Typescript:`Array<string>` | N
images | Array | [] | Typescript:`Array<string \| {url: string; align: 'start' \| 'center' \| 'end'; }>` | N
index | Number | - | `v-model:index` is supported | N
defaultIndex | Number | - | uncontrolled property | N
maxZoom | Number | 3 | Typescript:`Number` | N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
-- | -- | -- | -- | --
closeBtn | Boolean / Slot / Function | true | 是否展示关闭按钮,值为 `true` 显示默认关闭按钮;值为 `false` 则不显示关闭按钮;也可以完全自定义关闭按钮。TS 类型:`boolean \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
deleteBtn | Boolean / Slot / Function | false | 是否显示删除操作,前提需要开启页码。TS 类型:`boolean \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-mobile-vue/blob/develop/src/common.ts) | N
images | Array | [] | 图片数组。TS 类型:`Array<string>` | N
images | Array | [] | 图片数组。TS 类型:`Array<string \| {url: string; align: 'start' \| 'center' \| 'end'; }>` | N
index | Number | - | 当前预览图片所在的下标。支持语法糖 `v-model:index` | N
defaultIndex | Number | - | 当前预览图片所在的下标。非受控属性 | N
maxZoom | Number | 3 | 【开发中】最大放大比例。TS 类型:`Number` | N
Expand Down
59 changes: 59 additions & 0 deletions packages/products/tdesign-mobile-vue/src/image-viewer/props.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/* eslint-disable */

/**
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* */

import { TdImageViewerProps } from './type';
import { PropType } from 'vue';

export default {
/** 是否展示关闭按钮,值为 `true` 显示默认关闭按钮;值为 `false` 则不显示关闭按钮;也可以完全自定义关闭按钮 */
closeBtn: {
type: [Boolean, Function] as PropType<TdImageViewerProps['closeBtn']>,
default: true,
},
/** 是否显示删除操作,前提需要开启页码 */
deleteBtn: {
type: [Boolean, Function] as PropType<TdImageViewerProps['deleteBtn']>,
default: false,
},
/** 图片数组 */
images: {
type: Array as PropType<TdImageViewerProps['images']>,
default: (): TdImageViewerProps['images'] => [],
},
/** 当前预览图片所在的下标 */
index: {
type: Number,
default: undefined,
},
/** 当前预览图片所在的下标,非受控属性 */
defaultIndex: {
type: Number,
},
/** 【开发中】最大放大比例 */
maxZoom: {
type: Number,
default: 3,
},
/** 是否显示页码 */
showIndex: Boolean,
/** 隐藏/显示预览 */
visible: {
type: Boolean,
default: undefined,
},
modelValue: {
type: Boolean,
default: undefined,
},
/** 隐藏/显示预览,非受控属性 */
defaultVisible: Boolean,
/** 关闭时触发 */
onClose: Function as PropType<TdImageViewerProps['onClose']>,
/** 点击删除操作按钮时触发 */
onDelete: Function as PropType<TdImageViewerProps['onDelete']>,
/** 预览图片切换时触发,`context.prev` 切换到上一张图片,`context.next` 切换到下一张图片 */
onIndexChange: Function as PropType<TdImageViewerProps['onIndexChange']>,
};
70 changes: 70 additions & 0 deletions packages/products/tdesign-mobile-vue/src/image-viewer/type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/* eslint-disable */

/**
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* */

import { TNode } from '../common';

export interface TdImageViewerProps {
/**
* 是否展示关闭按钮,值为 `true` 显示默认关闭按钮;值为 `false` 则不显示关闭按钮;也可以完全自定义关闭按钮
* @default true
*/
closeBtn?: boolean | TNode;
/**
* 是否显示删除操作,前提需要开启页码
* @default false
*/
deleteBtn?: boolean | TNode;
/**
* 图片数组
* @default []
*/
images?: Array<string | { url: string; align: 'start' | 'center' | 'end' }>;
/**
* 当前预览图片所在的下标
*/
index?: number;
/**
* 当前预览图片所在的下标,非受控属性
*/
defaultIndex?: number;
/**
* 【开发中】最大放大比例
* @default 3
*/
maxZoom?: Number;
/**
* 是否显示页码
* @default false
*/
showIndex?: boolean;
/**
* 隐藏/显示预览
* @default false
*/
visible?: boolean;
/**
* 隐藏/显示预览,非受控属性
* @default false
*/
defaultVisible?: boolean;
/**
* 隐藏/显示预览
* @default false
*/
modelValue?: boolean;
/**
* 关闭时触发
*/
onClose?: (context: { trigger: 'overlay' | 'close-btn'; visible: Boolean; index: Number }) => void;
/**
* 点击删除操作按钮时触发
*/
onDelete?: (index: Number) => void;
/**
* 预览图片切换时触发,`context.prev` 切换到上一张图片,`context.next` 切换到下一张图片
*/
onIndexChange?: (index: number, context: { trigger: 'prev' | 'next' }) => void;
}
47 changes: 41 additions & 6 deletions packages/scripts/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -60580,9 +60580,6 @@
{
"id": 2601,
"platform_framework": [
"8",
"16",
"32",
"64"
],
"component": "ImageViewer",
Expand Down Expand Up @@ -60611,9 +60608,6 @@
"support_default_value": 0,
"field_category_text": "Props",
"platform_framework_text": [
"Vue(Mobile)",
"React(Mobile)",
"Angular(Mobile)",
"Miniprogram"
],
"field_type_text": [
Expand Down Expand Up @@ -60661,6 +60655,47 @@
"Array"
]
},
{
"id": 1717132021,
"platform_framework": [
"8",
"16",
"32"
],
"component": "ImageViewer",
"field_category": 1,
"field_name": "images",
"field_type": [
"16"
],
"field_default_value": "[]",
"field_enum": "",
"field_desc_zh": "图片数组",
"field_desc_en": null,
"field_required": 0,
"event_input": "",
"create_time": "2024-05-31 05:07:01",
"update_time": "2024-05-31 05:07:01",
"event_output": null,
"custom_field_type": "Array<string | {url: string; align: 'start' | 'center' | 'end'; }>",
"syntactic_sugar": null,
"readonly": 1,
"html_attribute": 0,
"trigger_elements": "",
"deprecated": 0,
"version": "",
"test_description": null,
"support_default_value": 0,
"field_category_text": "Props",
"platform_framework_text": [
"Vue(Mobile)",
"React(Mobile)",
"Angular(Mobile)"
],
"field_type_text": [
"Array"
]
},
{
"id": 2713,
"platform_framework": [
Expand Down

0 comments on commit c4c1fd3

Please sign in to comment.