From 34e352b25cb06e434fd702c37c4c701aa9a394c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B1=E7=9C=A0=E5=84=80=E5=BC=8F?= <854085467@qq.com> Date: Mon, 27 Jun 2022 17:04:24 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D(layer):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package/document-layer/index.html | 2 +- package/document-layer/{ => src}/App.vue | 0 .../document-layer/src/components/LayCode.vue | 40 +- .../document-layer/src/document/zh-CN/demo.md | 406 ++++++++++++++++ .../document-layer/src/document/zh-CN/help.md | 0 .../src/document/zh-CN/index.md | 439 ------------------ .../document-layer/{ => src}/entry-client.ts | 0 .../document-layer/{ => src}/entry-server.ts | 0 package/document-layer/src/layouts/Layout.vue | 25 +- package/document-layer/{ => src}/main.ts | 16 +- package/document-layer/src/router/zh-CN.ts | 15 +- package/document-layer/tsconfig.json | 19 + package/layer/src/component/index.vue | 11 +- 13 files changed, 478 insertions(+), 495 deletions(-) rename package/document-layer/{ => src}/App.vue (100%) create mode 100644 package/document-layer/src/document/zh-CN/demo.md create mode 100644 package/document-layer/src/document/zh-CN/help.md rename package/document-layer/{ => src}/entry-client.ts (100%) rename package/document-layer/{ => src}/entry-server.ts (100%) rename package/document-layer/{ => src}/main.ts (56%) create mode 100644 package/document-layer/tsconfig.json diff --git a/package/document-layer/index.html b/package/document-layer/index.html index e544e5fc..6c0fc6f3 100644 --- a/package/document-layer/index.html +++ b/package/document-layer/index.html @@ -21,6 +21,6 @@
- + diff --git a/package/document-layer/App.vue b/package/document-layer/src/App.vue similarity index 100% rename from package/document-layer/App.vue rename to package/document-layer/src/App.vue diff --git a/package/document-layer/src/components/LayCode.vue b/package/document-layer/src/components/LayCode.vue index 5ae046c0..1d55a410 100644 --- a/package/document-layer/src/components/LayCode.vue +++ b/package/document-layer/src/components/LayCode.vue @@ -1,49 +1,19 @@ diff --git a/package/document-layer/src/document/zh-CN/demo.md b/package/document-layer/src/document/zh-CN/demo.md new file mode 100644 index 00000000..44a2c243 --- /dev/null +++ b/package/document-layer/src/document/zh-CN/demo.md @@ -0,0 +1,406 @@ +
+ 消息 +
+ +::: demo 通过 layer.msg(content, options) 创建消息窗, 第一个参数`msg`为消息内容, 第二参数`options`为可选配置, 常用于配置`time`超时时间等。 + + + + + +::: + +
+ 确认 +
+ +::: demo 通过 layer.confirm(msg, options) 创建确认框, 第一个参数`msg`为文本消息, 第二个参数`options`为选项配置, 你可以使用`options`的`btn`属性定义操作。 + + + + + +::: + +
+ 加载 +
+ +::: demo 通过 layer.load(type, options) 创建加载层, 第一个参数`type`为加载动画样式, 第二个参数`options`为可选配置, 常用于设置`time`加载时长`shade`遮盖层等。 + + + + + +::: + +
+ 模态 +
+ +::: demo 通过 layer.open(option) 创建模态窗, 目前支持`iframe` `page`等类型, 你可以使用`options`选项开启`Resize` `Offset`等更多特性。 + + + + + +::: + +
+ 抽屉 +
+ +::: demo 通过 layer.drawer(options) 创建抽屉层, `options`选项配置, 抽屉本质上是一个特殊的模态窗, 你可以使用`offset`选项来设置方向。 + + + +::: + +
+ 图片 +
+ +::: demo 通过 layer.photos(options) 创建图片预览弹层, 参数`options`主要传入预览的图片链接。 + + + + + +::: + +
+ 销毁 +
+ +::: demo 我们提供 layer.close(id) 与 layer.closeAll() 函数实现弹出层的主动销毁。 + + + + +::: + +
+ 通讯 +
+ +::: demo 👉 查看 [Children1.vue](https://gitee.com/layui-vue/layer-vue/blob/master/example/src/components/Children1.vue), 通过 h() 函数的第二个参数向 Children1.vue 传递响应式变量。 + + + + + +::: + +::: demo 👉 查看 [Children2.vue](https://gitee.com/layui-vue/layer-vue/blob/master/example/src/components/Children2.vue), 通过 h() 函数的第二个参数声明 onXxx() 形式的函数完成 Children2.vue 的事件监听。 + + + + + +::: diff --git a/package/document-layer/src/document/zh-CN/help.md b/package/document-layer/src/document/zh-CN/help.md new file mode 100644 index 00000000..e69de29b diff --git a/package/document-layer/src/document/zh-CN/index.md b/package/document-layer/src/document/zh-CN/index.md index 34612f2c..60f2eb79 100644 --- a/package/document-layer/src/document/zh-CN/index.md +++ b/package/document-layer/src/document/zh-CN/index.md @@ -69,445 +69,6 @@ const changeVisible = () => { } ``` - -
- 消息 -
- -::: demo 通过 layer.msg(content, options) 创建消息窗, 第一个参数`msg`为消息内容, 第二参数`options`为可选配置, 常用于配置`time`超时时间等。 - - - - - -::: - -
- 加载 -
- -::: demo 通过 layer.load(type, options) 创建加载层, 第一个参数`type`为加载动画样式, 第二个参数`options`为可选配置, 常用于设置`time`加载时长`shade`遮盖层等。 - - - - - -::: - -
- 模态 -
- -::: demo 通过 layer.open(option) 创建模态窗, 目前支持`iframe` `page`等类型, 你可以使用`options`选项开启`Resize` `Offset`等更多特性。 - - - - - -::: - -
- 询问 -
- -::: demo 通过 layer.confirm(msg, options) 创建确认框, 第一个参数`msg`为文本消息, 第二个参数`options`为选项配置, 你可以使用`options`的`btn`属性定义操作。 - - - - - -::: - -
- 抽屉 -
- -::: demo 通过 layer.drawer(options) 创建抽屉层, `options`选项配置, 抽屉本质上是一个特殊的模态窗, 你可以使用`offset`选项来设置方向。 - - - -::: - -
- 图片层 -
- -::: demo 通过 layer.photos(options) 创建图片预览弹层, 参数`options`主要传入预览的图片链接。 - - - - - -::: - - -
- 通讯 -
- -::: demo 👉 查看 [Children1.vue](https://gitee.com/layui-vue/layer-vue/blob/master/example/src/components/Children1.vue), 通过 h() 函数的第二个参数向 Children1.vue 传递响应式变量。 - - - - - -::: - -::: demo 👉 查看 [Children2.vue](https://gitee.com/layui-vue/layer-vue/blob/master/example/src/components/Children2.vue), 通过 h() 函数的第二个参数声明 onXxx() 形式的函数完成 Children2.vue 的事件监听。 - - - - - -::: - -
- 销毁 -
- -::: demo 我们提供 layer.close(id) 与 layer.closeAll() 函数实现弹出层的主动销毁。 - - - - -::: - -
- 组件 -
- -::: demo 我们提供了一些核心函数来创建弹出层, 但在一些复杂的应用场景中, `lay-layer`是一个更好的选择。 - - - - - -::: -
选项
diff --git a/package/document-layer/entry-client.ts b/package/document-layer/src/entry-client.ts similarity index 100% rename from package/document-layer/entry-client.ts rename to package/document-layer/src/entry-client.ts diff --git a/package/document-layer/entry-server.ts b/package/document-layer/src/entry-server.ts similarity index 100% rename from package/document-layer/entry-server.ts rename to package/document-layer/src/entry-server.ts diff --git a/package/document-layer/src/layouts/Layout.vue b/package/document-layer/src/layouts/Layout.vue index 1818d392..4a8567a6 100644 --- a/package/document-layer/src/layouts/Layout.vue +++ b/package/document-layer/src/layouts/Layout.vue @@ -1,5 +1,6 @@ diff --git a/package/document-layer/main.ts b/package/document-layer/src/main.ts similarity index 56% rename from package/document-layer/main.ts rename to package/document-layer/src/main.ts index 9ffa044e..e4ab404d 100644 --- a/package/document-layer/main.ts +++ b/package/document-layer/src/main.ts @@ -1,12 +1,13 @@ import Layout from "./App.vue"; import { App, createApp as _createApp } from "vue"; -import { createRouter } from "./src/router/index"; +import { createRouter } from "./router/index"; import { Router } from "vue-router"; -import LayCode from "./src/components/LayCode.vue"; -import Children1 from "./src/components/Children1.vue"; -import Children2 from "./src/components/Children2.vue"; -import layer from "../layer/src/index"; -import "./src/assets/css/index.css"; +import LayCode from "./components/LayCode.vue"; +import Children1 from "./components/Children1.vue"; +import Children2 from "./components/Children2.vue"; +import layui from "../../component/src/index"; +import layer from "../../layer/src/index"; +import "./assets/css/index.css"; export function createApp(): { app: App; @@ -16,6 +17,7 @@ export function createApp(): { const router = createRouter(); app + .use(layui) .use(layer) .use(router) .component("LayCode", LayCode) @@ -23,4 +25,4 @@ export function createApp(): { .component("Children2", Children2); return { app, router }; -} +} \ No newline at end of file diff --git a/package/document-layer/src/router/zh-CN.ts b/package/document-layer/src/router/zh-CN.ts index 32a20ff3..8882f63a 100644 --- a/package/document-layer/src/router/zh-CN.ts +++ b/package/document-layer/src/router/zh-CN.ts @@ -10,11 +10,20 @@ const zhCN = [ { path: "/zh-CN/index", component: () => import("../document/zh-CN/index.md"), - - meta: { title: "指南" }, + meta: { title: "入门" }, + }, + { + path: "/zh-CN/demo", + component: () => import("../document/zh-CN/demo.md"), + meta: { title: "示例" }, + }, + { + path: "/zh-CN/help", + component: () => import("../document/zh-CN/help.md"), + meta: { title: "帮助" }, }, ], }, ]; -export default zhCN; +export default zhCN; \ No newline at end of file diff --git a/package/document-layer/tsconfig.json b/package/document-layer/tsconfig.json new file mode 100644 index 00000000..f7c932aa --- /dev/null +++ b/package/document-layer/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "module": "esnext", + "target": "es2015", + "moduleResolution": "Node", + "strict": true, + "allowJs": true, + "resolveJsonModule": true, + "declaration": true, + "emitDeclarationOnly": true, + "esModuleInterop": true, + "declarationDir": "types", + "jsx": "preserve", + "lib": ["ESNext","DOM"] + }, + "include": ["src/**/*","shims-vue.d.ts"], + "exclude": ["node_modules"] +} \ No newline at end of file diff --git a/package/layer/src/component/index.vue b/package/layer/src/component/index.vue index e7e8cae2..33153753 100644 --- a/package/layer/src/component/index.vue +++ b/package/layer/src/component/index.vue @@ -159,25 +159,22 @@ const _l: Ref = ref(offset.value[1]); *

*/ const firstOpenDelayCalculation = function () { - nextTick(async () => { + nextTick( async () => { area.value = getArea(layero.value); if (type == 4) { area.value = calculateDrawerArea(props.offset, props.area); } if (type == 5) { // @ts-ignore - area.value = await calculatePhotosArea( - props.imgList[props.startIndex].src, - props - ); + area.value = await calculatePhotosArea(props.imgList[props.startIndex].src, props); } offset.value = calculateOffset(props.offset, area.value, props.type); w.value = area.value[0]; h.value = area.value[1]; - t.value = offset.value[0]; - l.value = offset.value[1]; _w.value = area.value[0]; _l.value = area.value[1]; + t.value = offset.value[0]; + l.value = offset.value[1]; _t.value = offset.value[0]; _l.value = offset.value[1]; supportMove();