diff --git a/devui/panel/index.ts b/devui/panel/index.ts
index f0d6cb2ca750c1684cb5dd1f13b15a419092bee0..56eaba1e71bd0c1e7dc24f381a7b83273a9979e5 100644
--- a/devui/panel/index.ts
+++ b/devui/panel/index.ts
@@ -16,7 +16,7 @@ export { Panel }
export default {
title: 'Panel 面板',
category: '通用',
- status: '50%',
+ status: '100%',
install(app: App): void {
app.use(Panel as any)
}
diff --git a/devui/panel/src/panel.tsx b/devui/panel/src/panel.tsx
index 079a1de08567f717f11ddc4c298bf88778c3104c..741ebcf5505daf1891589d19f5a3e2fb699edf77 100644
--- a/devui/panel/src/panel.tsx
+++ b/devui/panel/src/panel.tsx
@@ -11,8 +11,10 @@ export default defineComponent({
provide('showAnimation', props.showAnimation);
provide('hasLeftPadding', props.hasLeftPadding);
const isCollapsed = ref(props.isCollapsed);
-
const bodyEl = ref();
+ const onToggle = ()=> {
+ props.toggle?.(Store.getByKey(`isCollapsed[${timeStamp}]`))
+ };
onMounted(() => {
if(bodyEl.value) {
@@ -21,26 +23,16 @@ export default defineComponent({
dom.style.height = `${dom.offsetHeight}px`;
}
})
+
const timeStamp = new Date().getTime().toString();
Store.setData(`isCollapsed[${timeStamp}]`, isCollapsed.value);
-
return () => {
return (
-
+
{ctx.slots.default()}
)
}
},
- render(){
- const {props,$slots} = this;
- return () => {
- return (
-
- {$slots.default()}
-
- )
- }
- }
})
\ No newline at end of file
diff --git a/devui/panel/src/store/store.ts b/devui/panel/src/store/store.ts
index 9e989228ed0d54f186a4510973c0623f22baf390..d274bff2952b6bc4275d10671f49b9720e47f8a0 100644
--- a/devui/panel/src/store/store.ts
+++ b/devui/panel/src/store/store.ts
@@ -4,6 +4,9 @@ import {ref,reactive} from 'vue';
export const option = reactive({})
class Store {
+ public static getByKey(timeStamp){
+ return option[timeStamp];
+ }
public static state() {
return option;
}
diff --git a/docs/components/panel/index.md b/docs/components/panel/index.md
index e25db70736cc3e564d85cac064fa98294077f713..aeae65aa903bc4c77ce54acea91ece39eb5b3da9 100644
--- a/docs/components/panel/index.md
+++ b/docs/components/panel/index.md
@@ -18,10 +18,10 @@
This is body
-
+
Panel has no left padding
-
+
This is body
@@ -32,15 +32,107 @@
This is footer
+
```
:::
+### 多种类型
-|参数| 类型| 默认| 说明|
-|:-:|:-:|:-:|:-:|
-|type| PanelType| 'default'| 可选,面板的类型|
-|cssClass| string| --| 可选,自定义 class 名|
-|isCollapsed| boolean| false| 可选,是否展开|
-|hasLeftPadding| boolean| true| 可选,是否显示左侧填充|
-|showAnimation| boolean| true| 可选,是否展示动画|
-|beforeToggle| Function\|Promise\|Observable| --| 可选,面板折叠状态改变前的回调函数,返回 boolean 类型,返回 false 可以阻止面板改变折叠状态 根据条件阻止折叠|
\ No newline at end of file
+面板类型分为default、primary、success,danger、warning、info。
+
+:::demo
+```vue
+
+
+ Panel with Primary Type
+ This is body
+
+
+
+ Panel with Success Type
+ This is body
+
+
+
+ Panel with Warning Type
+ This is body
+
+
+
+ Panel with danger Type
+ This is body
+
+
+```
+:::
+
+### 阻止折叠
+
+某种情况下,我们需要阻止面板收起。Panel提供了这项API,我们可以使用beforeToggle来阻止面板的收起
+
+根据条件判断,当panel展开时,点击阻止折叠按钮,将无法折叠panel。当panel折叠时不影响操作。
+
+:::demo
+```vue
+
+
+
+ Panel with foldable
+
+
+ This is body
+
+
+
+
+ {{ panelToggle ? '阻止折叠' : '允许折叠' }}
+
+
+
+```
+:::
+
+### API
+
+|参数| 类型| 默认| 说明|
+|:-:|:-:|:-:|:-:|
+|type| PanelType| 'default'| 可选,面板的类型|
+|cssClass| string| -- | 可选,自定义 class 名|
+|isCollapsed| boolean| false | 可选,是否展开|
+|hasLeftPadding| boolean| true | 可选,是否显示左侧填充|
+|showAnimation| boolean| true | 可选,是否展示动画|
+|beforeToggle| Function\|Promise\|Observable| -- | 可选,面板折叠状态改变前的回调函数,返回 boolean 类型,返回 false 可以阻止面板改变折叠状态 根据条件阻止折叠|
+|toggle| Function| -- | 可选,面板当前状态的回调函数,返回boolean类型,返回 false 代表面板被收起,返回 true 代表面板展开
\ No newline at end of file