Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(tdesign-mobile-vue/image-viewer): 更新image-viewer api #291

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
39 changes: 37 additions & 2 deletions packages/scripts/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -60342,7 +60342,6 @@
{
"id": 2601,
"platform_framework": [
"8",
"16",
"32",
"64"
Expand Down Expand Up @@ -60373,7 +60372,6 @@
"support_default_value": 0,
"field_category_text": "Props",
"platform_framework_text": [
"Vue(Mobile)",
"React(Mobile)",
"Angular(Mobile)",
"Miniprogram"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不可以移除其他框架平台

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修复处理

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Miniprogram和mobile的api定义是要保持一致的,不用单独再定义mobile-vue的,如果Miniprogram不需要此api定义,再抽出来单独定义Miniprogram的

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Miniprogram和mobile的api定义是要保持一致的,不用单独再定义mobile-vue的,如果Miniprogram不需要此api定义,再抽出来单独定义Miniprogram的

mobile vue 端 ImageViewer 要先支持图片懒加载等功能,weijie 结合对应的 issues 和 pr 来看哇~

Tencent/tdesign-mobile-vue#1411
Tencent/tdesign-mobile-vue#1422

Expand Down Expand Up @@ -60423,6 +60421,43 @@
"Array"
]
},
{
"id": 1717132021,
"platform_framework": [
"8"
],
"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)"
],
"field_type_text": [
"Array"
]
},
{
"id": 2713,
"platform_framework": [
Expand Down
Loading