diff --git a/example/docs/zh-CN/components/fullscreen.md b/example/docs/zh-CN/components/fullscreen.md new file mode 100644 index 00000000..25cfc5f0 --- /dev/null +++ b/example/docs/zh-CN/components/fullscreen.md @@ -0,0 +1,228 @@ +::: anchor +::: + +::: title 基本介绍 +::: + +::: describe 将某一区域的内容全屏展示。 +::: + +::: title 浏览器全屏 +::: + +::: demo 使用 `lay-fullscreen` 标签包裹触发全屏事件的按钮 + + + + 进入全屏 + 退出 + 切换: {{isFullscreen ? "退出" : "进入全屏"}} + + + + + +::: + +::: title 局部区域全屏 +::: + +::: demo 使用 `target` 属性指定需要局部全屏的元素, 组件必须用 `div` 包裹, 因为不是所有元素都能向浏览器请求全屏 + + + + + 进入全屏 + 退出 + 切换: {{isFullscreen ? "退出" : "进入全屏"}} + + + + + + + +::: + +::: title 浏览器窗口内全屏 +::: + +::: demo 使用 `target` 属性指定需要局部全屏的元素, 并设置`immersive`属性为 `false`,可使 `target` 在浏览器窗口内全屏 + + + + + 进入全屏 + 退出 + 切换: {{isFullscreen ? "退出" : "进入全屏"}} + + + + + + + +::: + +::: title 铺满特定容器 +::: + +::: demo 使用 `target` 属性指定需要局部全屏的元素, 并设置`immersive = false`, `position="absolute"`,可使 `target` 在特定容器内全屏 + + + + + + 进入全屏 + 退出 + 切换: {{isFullscreen ? "退出" : "进入全屏"}} + + + + + + + + +::: + +:::title fullscreen 属性 +::: + +:::table +| 属性 | 描述 | 类型 | 默认值 | 可选值 | +| --------- | ----------------------------------------- | ------------- | ------ | ------------------- | +| target | 可选,要全屏显示的元素 | `HTMLElement` | `html` | - | +| immersive | 可选,全屏模式,`false`时浏览器窗口内全屏 | `boolean` | true | `true` `false` | +| position | 可选,浏览器窗口内全屏定位模式 | `string` | - | `absolute` `fixed` | +| zIndex | 可选,全屏层级 | `string` | - | - | +::: + +:::title fullscreen 事件 +::: + +:::table +| 事件 | 描述 | 参数 | +|------ |----------|-----------| +| fullscreenchange | 全屏更改事件回调 | isFullscreen 是否全屏 | +::: + +:::title fullscreen 插槽 +::: + +:::table +| 插槽 | 描述 | 参数 | +|------ |----------|-----------| +| default | 默认插槽 | - | +::: + +:::title fullscreen 插槽属性 +::: + +:::table +| 属性 | 描述 | 类型 | 参数 | +| --------- | --------------| ------------- | ------ | +| enter | 进入全屏 | Function | 可选,HTMLElement | +| exit | 退出全屏 | Function | 可选,HTMLElement /| Document | +| toggle | 进入/退出全屏 | Function | - | +| isFullscreen | 是否全屏 | boolean | - | +::: diff --git a/example/src/router/zh-CN.ts b/example/src/router/zh-CN.ts index c0b24bcd..26c47e35 100644 --- a/example/src/router/zh-CN.ts +++ b/example/src/router/zh-CN.ts @@ -335,11 +335,17 @@ const zhCN = [ path: "/zh-CN/components/exception", component: () => import("../../docs/zh-CN/components/exception.md"), meta: { title: "异常" }, - }, { + }, + { path: "/zh-CN/components/result", component: () => import("../../docs/zh-CN/components/result.md"), meta: { title: "结果" }, }, + { + path: "/zh-CN/components/fullscreen", + component: () => import("../../docs/zh-CN/components/fullscreen.md"), + meta: { title: "结果" }, + }, ], } ], diff --git a/example/src/view/utils/menus.ts b/example/src/view/utils/menus.ts index eed2b3de..9d42817e 100644 --- a/example/src/view/utils/menus.ts +++ b/example/src/view/utils/menus.ts @@ -27,6 +27,12 @@ const menus = [ subTitle: "animation", path: "/zh-CN/components/animation", }, + { + id: 101, + title: "全屏", + subTitle: "fullscreen", + path: "/zh-CN/components/fullscreen", + }, ], }, { @@ -308,7 +314,7 @@ const menus = [ title: "异常", subTitle: "exception", path: "/zh-CN/components/exception", - }, + }, { id: 100, title: "结果", diff --git a/src/component/fullscreen/index.less b/src/component/fullscreen/index.less new file mode 100644 index 00000000..170d4df6 --- /dev/null +++ b/src/component/fullscreen/index.less @@ -0,0 +1,9 @@ +.layui-fullscreen { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 10; + overflow: auto; +} diff --git a/src/component/fullscreen/index.ts b/src/component/fullscreen/index.ts new file mode 100644 index 00000000..5511c18f --- /dev/null +++ b/src/component/fullscreen/index.ts @@ -0,0 +1,8 @@ +import type { App } from "vue"; +import Component from "./index.vue"; + +Component.install = (app: App) => { + app.component(Component.name, Component); +}; + +export default Component; diff --git a/src/component/fullscreen/index.vue b/src/component/fullscreen/index.vue new file mode 100644 index 00000000..e101c07b --- /dev/null +++ b/src/component/fullscreen/index.vue @@ -0,0 +1,229 @@ + + + + + + + diff --git a/src/index.ts b/src/index.ts index 1b4f93ad..e8ce2831 100644 --- a/src/index.ts +++ b/src/index.ts @@ -76,6 +76,7 @@ import LaySplitPanel from "./component/splitPanel/index"; import LaySplitPanelItem from "./component/splitPanelItem/index"; import LayException from "./component/exception/index"; import LayResult from "./component/result/index"; +import LayFullscreen from "./component/fullscreen/index"; import LayConfigProvider from "./provider"; const components: Record = { @@ -149,6 +150,7 @@ const components: Record = { LaySubMenu, LayException, LayResult, + LayFullscreen, LayConfigProvider, }; @@ -231,6 +233,7 @@ export { LaySubMenu, LayException, LayResult, + LayFullscreen, LayConfigProvider, };