Skip to content

Commit

Permalink
resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
tiantiancheng committed Feb 17, 2025
2 parents 393dae2 + 884a816 commit 32dc8a6
Show file tree
Hide file tree
Showing 23 changed files with 2,918 additions and 113 deletions.
113 changes: 81 additions & 32 deletions docs/zh-CN/components/images.md

Large diffs are not rendered by default.

1,678 changes: 1,678 additions & 0 deletions docs/zh-CN/components/images.md.orig

Large diffs are not rendered by default.

100 changes: 100 additions & 0 deletions docs/zh-CN/components/slider.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
---
title: Slider 滑动条
description:
type: 0
group: ⚙ 组件
menuName: Tabs
icon:
---

主要用于移动端中支持左右滑动展示更多内容,在桌面端中更多内容展示在右侧

## 基本用法

```schema
{
"type": "page",
"body": {
"type": "service",
"api": "/api/mock2/sample?perPage=5",
"body": [
{
"type": "list",
"source": "$rows",
"listItem": {
"body": [
{
"type": "slider",
"body": [
{
"type": "container",
"body": {
"type": "tpl",
"tpl": "Engine: ${engine}"
}
}
],
"left": [
{
"type": "button",
"level": "primary",
"label": "详情",
"actionType": "dialog",
"dialog": {
"title": "查看详情",
"body": {
"type": "form",
"body": [
{
"label": "Engine",
"name": "engine",
"type": "static"
},
{
"name": "version",
"label": "Version",
"type": "static"
}
]
}
}
}
],
"right": [
{
"type": "button",
"level": "danger",
"label": "删除"
}
]
}
]
}
}
]
}
}
```

## 事件表

> 2.6.1 及以上版本
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,详细查看[事件动作](../../docs/concepts/event-action)

| 事件名称 | 事件参数 | 说明 |
| --------- | ---------------------------- | ------------------ |
| leftShow | `label: string` 鼠标事件对象 | 左侧内容出现时触发 |
| leftHide | `label: string` 鼠标事件对象 | 左侧内容隐藏时触发 |
| rightShow | `label: string` 鼠标事件对象 | 右侧内容出现时触发 |
| rightHide | `label: string` 鼠标事件对象 | 右侧内容隐藏时触发 |

## 属性表

| 属性名 | 类型 | 默认值 | 说明 |
| --------- | ----------------------------------------- | ---------- | ----------------------------------------- |
| type | `string` | `'slider'` | 指定为滑动条渲染器 |
| body | [SchemaNode](../../docs/types/schemanode) | | 容器主要内容 |
| right | [SchemaNode](../../docs/types/schemanode) | | 容器右侧内容,在 pc 下展示在右侧 |
| left | [SchemaNode](../../docs/types/schemanode) | | 容器左侧内容,在 pc 下展示在右侧 |
| bodyWidth | `string` | `'60%'` | pc 下 body 即移动端默认宽度占比,默认 60% |
8 changes: 8 additions & 0 deletions examples/components/Components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,14 @@ export const components = [
component: React.lazy(() =>
import('../../docs/zh-CN/components/shape.md').then(wrapDoc)
)
},

{
label: 'Slider 滑动条',
path: '/zh-CN/components/slider',
component: React.lazy(() =>
import('../../docs/zh-CN/components/slider.md').then(wrapDoc)
)
}
]
},
Expand Down
1 change: 1 addition & 0 deletions packages/amis-editor-core/scss/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,7 @@
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
}
}

Expand Down
8 changes: 7 additions & 1 deletion packages/amis-editor-core/src/component/ContainerWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ export class ContainerWrapper extends React.Component<ContainerWrapperProps> {
*/
@autobind
renderChild(region: string, node: Schema, props: any) {
const {render, $$editor, $$node} = this.props;
const {render, $$editor, $$node, $schema} = this.props;

if (
$$editor.regions?.find(item => item.key === region)?.hiddenOn?.($schema)
) {
return null;
}

const child = render(region, node, props);

Expand Down
5 changes: 5 additions & 0 deletions packages/amis-editor-core/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ export interface RegionConfig {
* 可以用来判断是否允许拖入当前节点。
*/
accept?: (json: any) => boolean;

/**
* 当前区域是否隐藏
*/
hiddenOn?: (schema: Schema) => boolean;
}

export interface VRendererConfig {
Expand Down
25 changes: 22 additions & 3 deletions packages/amis-editor/src/plugin/Images.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export class ImagesPlugin extends BasePlugin {
pluginIcon = 'images-plugin';
scaffold = {
type: 'images',
imageGallaryClassName: 'app-popover :AMISCSSWrapper'
imageGallaryClassName: 'app-popover :AMISCSSWrapper',
displayMode: 'thumb' // 默认缩略图模式
};
previewSchema = {
...this.scaffold,
Expand Down Expand Up @@ -126,6 +127,22 @@ export class ImagesPlugin extends BasePlugin {
}
]
},
{
type: 'select',
name: 'displayMode',
label: '图片集模式',
value: 'thumb',
options: [
{
label: '缩略图模式',
value: 'thumb'
},
{
label: '大图模式',
value: 'full'
}
]
},
getSchemaTpl('switch', {
name: 'enlargeAble',
label: '图片放大功能'
Expand Down Expand Up @@ -184,7 +201,8 @@ export class ImagesPlugin extends BasePlugin {
label: '铺满',
value: 'cover'
}
]
],
visibleOn: 'this.displayMode === "thumb"'
},

{
Expand All @@ -208,7 +226,8 @@ export class ImagesPlugin extends BasePlugin {
label: '16:9',
value: '16:9'
}
]
],
visibleOn: 'this.displayMode === "thumb"'
}
]
},
Expand Down
Loading

0 comments on commit 32dc8a6

Please sign in to comment.