Skip to content

Commit 1c04222

Browse files
committed
feat: leaferApp
1 parent cec2574 commit 1c04222

File tree

5 files changed

+4875
-4011
lines changed

5 files changed

+4875
-4011
lines changed

docs/.vitepress/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default defineConfig({
2020
text: '应用组件',
2121
items: [
2222
{
23-
text: 'App',
23+
text: 'LeaferApp',
2424
link: '/guide/components/app/app',
2525
},
2626
{

docs/guide/components/app/app.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<script setup lang="ts">
2+
import code from './leaferApp.vue?raw'
3+
</script>
4+
15
# lfApp 应用
26
>
37
> 用于创建应用的根组件,子组件只能为[lfLeafer](leafer.md),详情查看[APP](https://www.leaferjs.com/ui/guide/display/App.html)
@@ -15,3 +19,4 @@ import { lfApp, lfLeafer } from 'leafer-vue'
1519
</lfApp>
1620
</template>
1721
```
22+
<Repl :code="code" />
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<script setup lang="ts">
2+
import { LeaferApp } from 'leafer-vue'
3+
import { ref } from 'vue'
4+
5+
const rotation = ref(0)
6+
function animate() {
7+
rotation.value += 1
8+
requestAnimationFrame(animate)
9+
}
10+
animate()
11+
12+
const fill = ref('#32cd79')
13+
function changeColor() {
14+
fill.value = `#${Math.floor(Math.random() * 0xFFFFFF).toString(16)}`
15+
}
16+
</script>
17+
18+
<template>
19+
<LeaferApp :width="650" :height="340">
20+
<Leafer @tap="changeColor">
21+
<template
22+
v-for="row in 33"
23+
:key="row"
24+
>
25+
<Rect
26+
v-for="col in 17"
27+
:key="col"
28+
:rotation="rotation"
29+
:x="(row - 1) * 20" :y="(col - 1) * 20"
30+
:width="15" :height="15"
31+
:fill="fill"
32+
:draggable="true"
33+
@tap="changeColor"
34+
/>
35+
</template>
36+
</Leafer>
37+
</LeaferApp>
38+
</template>

packages/vue3/types/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import type { IRectInputData } from '@leafer-ui/interface'
1+
import type { ILeaferConfig, IRectInputData } from '@leafer-ui/interface'
22
import type { LeaferVueComponent } from './LeaferVueComponent'
33

44
interface LeaferVueComponents {
5+
LeaferApp: LeaferVueComponent<ILeaferConfig>
56
Rect: LeaferVueComponent<IRectInputData>
67
}
78

0 commit comments

Comments
 (0)