Skip to content

Commit 1786c3c

Browse files
committed
feat(fe): add base demo
1 parent d5b3722 commit 1786c3c

175 files changed

Lines changed: 5204 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

fe/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ package-lock.json
99
pnpm-lock.yaml
1010
coverage
1111
example/*
12+
!example/base
1213
!example/subpackages
1314
!example/weui
1415
!example/vant

fe/example/base/app.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
App({
2+
onLaunch(options) {
3+
console.log("app onLaunch===this.globalData=", this.globalData)
4+
// 修改 globalData 以测试
5+
this.globalData = 'I am modified global data'
6+
},
7+
onShow(options) {
8+
console.log("app onShow===this.globalData=", this.globalData) // 这里不应该是undefined
9+
10+
},
11+
onHide() {
12+
console.log("app onHide===this.globalData=", this.globalData)
13+
},
14+
onError(msg) {
15+
console.log(msg)
16+
},
17+
globalData: 'I am global data'
18+
})

fe/example/base/app.json

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{
2+
"pages": [
3+
"pages/index",
4+
"pages/scroll-view/index",
5+
"pages/input/index",
6+
"pages/image/index",
7+
"pages/icon/index",
8+
"pages/button/index",
9+
"pages/switch/index",
10+
"pages/radio/index",
11+
"pages/checkbox/index",
12+
"pages/slider/index",
13+
"pages/form/index",
14+
"pages/textarea/index",
15+
"pages/progress/index",
16+
"pages/navigator/index/index",
17+
"pages/navigator/navigate/navigate",
18+
"pages/navigator/redirect/redirect",
19+
"pages/cover-view/index",
20+
"pages/movable-view/index",
21+
"pages/picker/index",
22+
"pages/picker-view/index",
23+
"pages/swiper/index",
24+
"pages/rich-text/index",
25+
"pages/custom-component/index",
26+
"pages/events/index",
27+
"pages/mark/index",
28+
"pages/intersection-observer/index",
29+
"pages/api/index",
30+
"pages/project-mixed/pages/home/index",
31+
"pages/project-mixed/pages/detail/index",
32+
"pages/package/index",
33+
"pages/data-observer/index",
34+
"pages/behaviors/index",
35+
"pages/animation/index",
36+
"pages/custom-class/index"
37+
],
38+
"subPackages": [
39+
{
40+
"root": "subPackageA",
41+
"pages": [
42+
"pages/index"
43+
]
44+
},
45+
{
46+
"root": "subPackageB",
47+
"pages": []
48+
},
49+
{
50+
"root": "commonPackage",
51+
"pages": []
52+
}
53+
],
54+
"window": {
55+
"backgroundTextStyle": "light",
56+
"navigationBarBackgroundColor": "#fff",
57+
"navigationBarTitleText": "WeChat",
58+
"navigationBarTextStyle": "black"
59+
},
60+
"permission": {
61+
"scope.userLocation": {
62+
"desc": "你的位置信息将用于小程序位置接口的效果展示"
63+
}
64+
},
65+
"requiredPrivateInfos": [
66+
"onLocationChange",
67+
"startLocationUpdate",
68+
"chooseLocation",
69+
"getLocation"
70+
]
71+
}

fe/example/base/app.wxss

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
.green{
2+
color: #09BB07;
3+
}
4+
.red{
5+
color: #F76260;
6+
}
7+
.blue{
8+
color: #10AEFF;
9+
}
10+
.yellow{
11+
color: #FFBE00;
12+
}
13+
.gray{
14+
color: #C9C9C9;
15+
}
16+
17+
.strong{
18+
font-weight: bold;
19+
}
20+
21+
.bc_green{
22+
background-color: #09BB07;
23+
}
24+
.bc_red{
25+
background-color: #F76260;
26+
}
27+
.bc_blue{
28+
background-color: #10AEFF;
29+
}
30+
.bc_yellow{
31+
background-color: #FFBE00;
32+
}
33+
.bc_gray{
34+
background-color: #C9C9C9;
35+
}
36+
37+
.tc{
38+
text-align: center;
39+
}
40+
41+
checkbox, radio{
42+
margin-right: 5px;
43+
}
44+
45+
.btn-area{
46+
padding: 0 15px;
47+
}
48+
.btn-area button{
49+
margin-top: 10px;
50+
margin-bottom: 10px;
51+
}
52+
53+
.page {
54+
min-height: 100%;
55+
flex: 1;
56+
background-color: #FBF9FE;
57+
font-size: 16px;
58+
font-family: -apple-system-font,Helvetica Neue,Helvetica,sans-serif;
59+
overflow: hidden;
60+
}
61+
.page__hd{
62+
padding: 40px;
63+
}
64+
.page__title{
65+
display: block;
66+
font-size: 20px;
67+
}
68+
.page__desc{
69+
margin-top: 5px;
70+
font-size: 14px;
71+
color: #888888;
72+
}
73+
74+
.section{
75+
margin-bottom: 40px;
76+
}
77+
.section_gap{
78+
padding: 0 15px;
79+
}
80+
.section__title{
81+
margin-bottom: 8px;
82+
padding-left: 15px;
83+
padding-right: 15px;
84+
}
85+
.section_gap .section__title{
86+
padding-left: 0;
87+
padding-right: 0;
88+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Component({
2+
options: {
3+
styleIsolation: 'isolated'
4+
},
5+
lifetimes: {
6+
attached() {
7+
this.triggerEvent('attached')
8+
}
9+
},
10+
methods: {
11+
clicked() {
12+
this.triggerEvent('clicked')
13+
}
14+
}
15+
})
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"component": true,
3+
"usingComponents": {}
4+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<view class="button" hover-class="hover" bindtap="clicked">
2+
<slot></slot>
3+
</view>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.button {
2+
width: 200px;
3+
height: 50px;
4+
line-height: 50px;
5+
text-align: center;
6+
background-color: #07c160;
7+
color: white;
8+
border-radius: 4px;
9+
}
10+
.button.hover {
11+
background-color: #06a754;
12+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
getPackageName: () => 'common'
3+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
Page({
2+
data: {
3+
animation: null
4+
},
5+
onReady: function () {
6+
this.animation = wx.createAnimation()
7+
},
8+
rotate: function () {
9+
this.animation.rotate(Math.random() * 720 - 360).step()
10+
this.setData({ animation: this.animation.export() })
11+
},
12+
scale: function () {
13+
this.animation.scale(Math.random() * 2).step()
14+
this.setData({ animation: this.animation.export() })
15+
},
16+
translate: function () {
17+
this.animation.translate(Math.random() * 100 - 50, Math.random() * 100 - 50).step()
18+
this.setData({ animation: this.animation.export() })
19+
},
20+
skew: function () {
21+
this.animation.skew(Math.random() * 90, Math.random() * 90).step()
22+
this.setData({ animation: this.animation.export() })
23+
},
24+
rotateAndScale: function () {
25+
this.animation.rotate(Math.random() * 720 - 360)
26+
.scale(Math.random() * 2)
27+
.step()
28+
this.setData({ animation: this.animation.export() })
29+
},
30+
rotateThenScale: function () {
31+
this.animation.rotate(Math.random() * 720 - 360).step()
32+
.scale(Math.random() * 2).step()
33+
this.setData({ animation: this.animation.export() })
34+
},
35+
all: function () {
36+
this.animation.rotate(Math.random() * 720 - 360)
37+
.scale(Math.random() * 2)
38+
.translate(Math.random() * 100 - 50, Math.random() * 100 - 50)
39+
.skew(Math.random() * 90, Math.random() * 90)
40+
.step()
41+
this.setData({ animation: this.animation.export() })
42+
},
43+
allInQueue: function () {
44+
this.animation.rotate(Math.random() * 720 - 360).step()
45+
.scale(Math.random() * 2).step()
46+
.translate(Math.random() * 100 - 50, Math.random() * 100 - 50).step()
47+
.skew(Math.random() * 90, Math.random() * 90).step()
48+
this.setData({ animation: this.animation.export() })
49+
},
50+
reset: function () {
51+
this.animation.rotate(0, 0)
52+
.scale(1)
53+
.translate(0, 0)
54+
.skew(0, 0)
55+
.step({ duration: 0 })
56+
this.setData({ animation: this.animation.export() })
57+
}
58+
})

0 commit comments

Comments
 (0)