Skip to content

Commit d06b097

Browse files
committed
feat: add learn page
1 parent 0823223 commit d06b097

File tree

18 files changed

+470
-91
lines changed

18 files changed

+470
-91
lines changed

miniprogram/app.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
"pages/my/index",
66
"pages/myStarred/index",
77
"pages/changelog/index",
8-
"pages/changelog/detail"
8+
"pages/changelog/detail",
9+
"pages/learn/index",
10+
"pages/learn/detail"
911
],
1012
"window": {
1113
"backgroundColor": "#f6f6f6",

miniprogram/app.less

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,67 @@ page {
88
height: 100%;
99
box-sizing: border-box;
1010
}
11+
12+
.list {
13+
padding-left: 10rpx;
14+
15+
.item {
16+
position: relative;
17+
line-height: 40rpx;
18+
padding-left: 28rpx;
19+
20+
&:before {
21+
content: '';
22+
position: absolute;
23+
top: 15rpx;
24+
left: 0;
25+
display: block;
26+
width: 12rpx;
27+
height: 12rpx;
28+
border-radius: 50%;
29+
border: 4rpx solid #555;
30+
box-sizing: border-box;
31+
}
32+
33+
+ .item {
34+
margin-top: 16rpx;
35+
}
36+
}
37+
38+
&--inner {
39+
margin: 24rpx 0;
40+
}
41+
}
42+
43+
.text {
44+
45+
&--bold {
46+
font-weight: bolder;
47+
}
48+
49+
&--code {
50+
background: #e6eefb;
51+
color: #0052d9;
52+
padding: 0 4px;
53+
border-radius: 4px;
54+
}
55+
56+
&--image {
57+
font-family: 't';
58+
color: #333;
59+
text-decoration: underline;
60+
61+
&::before {
62+
content: '\E074';
63+
}
64+
}
65+
66+
&--link {
67+
font-family: 't';
68+
text-decoration: underline;
69+
70+
&:before {
71+
content: '\E07C';
72+
}
73+
}
74+
}

miniprogram/pages/detail/index.less

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -61,37 +61,6 @@
6161
margin: 8rpx;
6262
}
6363

64-
.list {
65-
padding-left: 10rpx;
66-
67-
.item {
68-
position: relative;
69-
line-height: 40rpx;
70-
padding-left: 28rpx;
71-
72-
&:before {
73-
content: '';
74-
position: absolute;
75-
top: 15rpx;
76-
left: 0;
77-
display: block;
78-
width: 12rpx;
79-
height: 12rpx;
80-
border-radius: 50%;
81-
border: 4rpx solid #555;
82-
box-sizing: border-box;
83-
}
84-
85-
+ .item {
86-
margin-top: 16rpx;
87-
}
88-
}
89-
90-
&--inner {
91-
margin: 24rpx 0;
92-
}
93-
}
94-
9564
.button {
9665
display: inline-flex;
9766
align-items: center;
@@ -190,36 +159,3 @@
190159
color: #0052d9;
191160
}
192161
}
193-
194-
.text {
195-
196-
&--bold {
197-
font-weight: bolder;
198-
}
199-
200-
&--code {
201-
background: #e6eefb;
202-
color: #0052d9;
203-
padding: 0 4px;
204-
border-radius: 4px;
205-
}
206-
207-
&--image {
208-
font-family: 't';
209-
color: #333;
210-
text-decoration: underline;
211-
212-
&::before {
213-
content: '\E074';
214-
}
215-
}
216-
217-
&--link {
218-
font-family: 't';
219-
text-decoration: underline;
220-
221-
&:before {
222-
content: '\E07C';
223-
}
224-
}
225-
}

miniprogram/pages/detail/index.wxml

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<import src="/templates/hyperText.wxml" />
2+
13
<view class="container">
24
<view class="title">{{title}}</view>
35

@@ -94,27 +96,6 @@
9496
</t-button-group>
9597
</view>
9698

97-
<template name="hyper-text">
98-
<text wx:if="{{_.getType(tokens) == 'string'}}">{{tokens}}</text>
99-
<block wx:elif="{{_.getType(tokens) == 'array'}}">
100-
<block wx:for="{{tokens}}" wx:key="index">
101-
<template is="super-text" data="{{ item }}"></template>
102-
</block>
103-
</block>
104-
<block wx:else>
105-
<template is="super-text" data="{{ item: tokens }}"></template>
106-
</block>
107-
</template>
108-
109-
<template name="super-text">
110-
<text wx:if="{{_.getType(item) == 'string'}}">{{item}}</text>
111-
<text wx:elif="{{item.type == 'strong' || item.type == 'em'}}" class="text--bold"> {{item.text}} </text>
112-
<text wx:elif="{{item.type == 'codespan'}}" class="text--code">{{item.text}}</text>
113-
<text wx:elif="{{item.type == 'image'}}" bind:tap="handlePreview" data-src="{{item.href}}" class="text--image"> {{item.text}}</text>
114-
<text wx:elif="{{item.type == 'link'}}" bind:tap="handleLink" data-src="{{item.href}}" class="text--link"> {{item.text}}</text>
115-
<text wx:else>{{item.text}}</text>
116-
</template>
117-
11899
<wxs module="_">
119100
module.exports.getTime = function(str) {
120101
if (typeof str != 'string') {

miniprogram/pages/index/index.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ Page({
1010
text: '首页',
1111
value: 'home',
1212
icon: 'home'
13+
},{
14+
text: '学习',
15+
value: 'learn',
16+
icon: 'laptop'
1317
}, {
1418
text: '个人中心',
1519
value: 'my',
@@ -47,11 +51,9 @@ Page({
4751
handleTabbarChange({ detail }) {
4852
const { value } = detail;
4953

50-
if (value == 'my') {
51-
wx.redirectTo({
52-
url: '../my/index'
53-
})
54-
}
54+
wx.redirectTo({
55+
url: `../${value}/index`
56+
})
5557
},
5658

5759
onShareAppMessage() {

miniprogram/pages/learn/data.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

miniprogram/pages/learn/detail.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
const info = require('./data.js').default
2+
3+
Page({
4+
5+
/**
6+
* 页面的初始数据
7+
*/
8+
data: {
9+
info: []
10+
},
11+
12+
/**
13+
* 生命周期函数--监听页面加载
14+
*/
15+
onLoad: function (options) {
16+
const { index = 0 } = options;
17+
const target = info[index];
18+
19+
this.setData({
20+
info: target.content
21+
})
22+
wx.setNavigationBarTitle({
23+
title: target.title
24+
})
25+
},
26+
27+
/**
28+
* 生命周期函数--监听页面初次渲染完成
29+
*/
30+
onReady: function () {
31+
32+
},
33+
34+
/**
35+
* 生命周期函数--监听页面显示
36+
*/
37+
onShow: function () {
38+
39+
},
40+
41+
/**
42+
* 生命周期函数--监听页面隐藏
43+
*/
44+
onHide: function () {
45+
46+
},
47+
48+
/**
49+
* 生命周期函数--监听页面卸载
50+
*/
51+
onUnload: function () {
52+
53+
},
54+
55+
/**
56+
* 页面相关事件处理函数--监听用户下拉动作
57+
*/
58+
onPullDownRefresh: function () {
59+
60+
},
61+
62+
/**
63+
* 页面上拉触底事件的处理函数
64+
*/
65+
onReachBottom: function () {
66+
67+
},
68+
69+
/**
70+
* 用户点击右上角分享
71+
*/
72+
onShareAppMessage: function () {
73+
74+
}
75+
})
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"usingComponents": {}
3+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
page {
2+
background-color: #fff;
3+
}
4+
5+
.container {
6+
padding: 24rpx;
7+
}
8+
9+
.h1, .h2, .h3, .h4 {
10+
font-weight: bold;
11+
margin-bottom: 12rpx;
12+
}
13+
14+
.h1 {
15+
font-size: 38rpx;
16+
}
17+
18+
.h2 {
19+
font-size: 36rpx;
20+
}
21+
22+
.h3 {
23+
font-size: 32rpx;
24+
}
25+
26+
.h4 {
27+
font-size: 30rpx;
28+
}
29+
30+
.list {
31+
margin-bottom: 24rpx;
32+
font-size: 28rpx;
33+
line-height: 36rpx;
34+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
<import src="/templates/hyperText.wxml" />
3+
4+
<view class="container">
5+
<block wx:for="{{info}}" wx:key="index" wx:for-item="section">
6+
<view wx:if="{{section.type == 'heading'}}" class="h{{section.depth}}">{{section.text}}</view>
7+
<view wx:elif="{{section.type == 'list'}}" class="list">
8+
<block wx:for="{{section.items}}" wx:key="index">
9+
<view class="item">
10+
<template is="hyper-text" data="{{ tokens: item }}"></template>
11+
</view>
12+
</block>
13+
</view>
14+
<view wx:else>{{section.text}}</view>
15+
</block>
16+
</view>

0 commit comments

Comments
 (0)