Skip to content

Commit bed8aca

Browse files
author
Vace
committed
refactor: 使用最新的开发规范重构小程序
1 parent 5cbb8c8 commit bed8aca

Some content is hidden

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

58 files changed

+1091
-8619
lines changed

Diff for: README.md

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
# wechatapp-news-reader
2-
微信小程序 —— 新闻阅读器
2+
微信小程序 —— 新闻阅读器(示例)
33

44
## 说明
55

6-
1.数据部分API来源于[《中安新闻客户端》](http://www.anhuinews.com/)
7-
2.富文本解析[wxParse](https://github.com/icindy/wxParse)
8-
9-
10-
6+
- 所有数据均为模拟的假数据,见 `mock` 文件夹
7+
- 富文本解析使用 [mp-html](https://github.com/jin-yufeng/mp-html)
118

129
## 界面截图
1310

Diff for: app.js

+1-26
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,2 @@
11
//app.js
2-
const utils = require('./utils/util.js')
3-
4-
App({
5-
onLaunch: function() {
6-
7-
},
8-
9-
getUserInfo(){
10-
return new utils.Promise((resolve,reject) => {
11-
if(this.globalData.userInfo){
12-
resolve(this.globalData.userInfo)
13-
}
14-
return utils.getUserInfo().then(res => {
15-
resolve(this.globalData.userInfo = res.userInfo)
16-
})
17-
})
18-
},
19-
globalData:{
20-
userInfo:null,
21-
categoryChanged:true
22-
},
23-
24-
cacheSubscibe:[],
25-
26-
utils
27-
})
2+
App({})

Diff for: app.json

+49-44
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,51 @@
11
{
2-
"pages": [
3-
"pages/news/index",
4-
"pages/news/detail",
5-
"pages/news/manage",
6-
"pages/subscibe/index",
7-
"pages/subscibe/article",
8-
"pages/found/index",
9-
10-
"pages/user/index"
11-
],
12-
"window": {
13-
"backgroundTextStyle": "light",
14-
"navigationBarBackgroundColor": "#fff",
15-
"navigationBarTitleText": "News Reader",
16-
"navigationBarTextStyle": "black"
17-
},
18-
"tabBar": {
19-
"color": "#333",
20-
"selectedColor": "#d81e06",
21-
"borderStyle": "white",
22-
"backgroundColor": "#ffffff",
23-
"list": [{
24-
"pagePath": "pages/news/index",
25-
"iconPath": "image/icon-news.png",
26-
"selectedIconPath": "image/icon-news-a.png",
27-
"text": "新闻"
28-
}, {
29-
"pagePath": "pages/subscibe/index",
30-
"iconPath": "image/icon-sub.png",
31-
"selectedIconPath": "image/icon-sub-a.png",
32-
"text": "订阅"
33-
}, {
34-
"pagePath": "pages/found/index",
35-
"iconPath": "image/icon-like.png",
36-
"selectedIconPath": "image/icon-like-a.png",
37-
"text": "发现"
38-
}, {
39-
"pagePath": "pages/user/index",
40-
"iconPath": "image/icon-user.png",
41-
"selectedIconPath": "image/icon-user-a.png",
42-
"text": "我的"
43-
}]
44-
},
45-
"debug":true
2+
"pages": [
3+
"pages/news/index",
4+
"pages/news/detail",
5+
"pages/news/manage",
6+
"pages/subscibe/index",
7+
"pages/subscibe/article",
8+
"pages/found/index",
9+
"pages/user/index"
10+
],
11+
"window": {
12+
"backgroundTextStyle": "light",
13+
"navigationBarBackgroundColor": "#fff",
14+
"navigationBarTitleText": "News Reader",
15+
"navigationBarTextStyle": "black"
16+
},
17+
"tabBar": {
18+
"color": "#333",
19+
"selectedColor": "#d81e06",
20+
"borderStyle": "white",
21+
"backgroundColor": "#ffffff",
22+
"list": [
23+
{
24+
"pagePath": "pages/news/index",
25+
"iconPath": "image/icon-news.png",
26+
"selectedIconPath": "image/icon-news-a.png",
27+
"text": "新闻"
28+
},
29+
{
30+
"pagePath": "pages/subscibe/index",
31+
"iconPath": "image/icon-sub.png",
32+
"selectedIconPath": "image/icon-sub-a.png",
33+
"text": "订阅"
34+
},
35+
{
36+
"pagePath": "pages/found/index",
37+
"iconPath": "image/icon-like.png",
38+
"selectedIconPath": "image/icon-like-a.png",
39+
"text": "发现"
40+
},
41+
{
42+
"pagePath": "pages/user/index",
43+
"iconPath": "image/icon-user.png",
44+
"selectedIconPath": "image/icon-user-a.png",
45+
"text": "我的"
46+
}
47+
]
48+
},
49+
"debug": true,
50+
"sitemapLocation": "sitemap.json"
4651
}

Diff for: app.wxss

+10-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
@import "./utils/wxParse/wxParse.wxss";
2-
3-
41
/**app.wxss**/
52
.page {
63
min-height: 100%;
@@ -26,34 +23,32 @@
2623
}
2724
.article__item{
2825
display: flex;
29-
padding: 30rpx;
26+
padding: 30rpx 20rpx;
3027
align-items: center;
3128
border-bottom: 1rpx solid #eee;
3229
position: relative;
33-
padding-bottom: 40rpx;
30+
padding-bottom: 20rpx;
3431
}
3532
.article__thumb{
36-
width:4.2rem;
37-
height: 3rem;
38-
margin-right: 0.6rem;
33+
width: 160rpx;
34+
height: 140rpx;
35+
margin-right: 20rpx;
3936
}
4037
.article__image{
41-
width:4.2rem;
42-
height: 3rem;
38+
width:160rpx;
39+
height: 140rpx;
4340
}
4441
.article__info{
4542
flex: 1;
46-
width: 100%;
47-
overflow: hidden;
4843
}
4944
.article__title{
5045
font-weight: 400;
5146
font-size: 26rpx;
5247
text-overflow: ellipsis;
53-
white-space:nowrap;
5448
display: block;
5549
width: 100%;
5650
margin-bottom: 20rpx;
51+
overflow: hidden;
5752
}
5853
/* 支持多行 */
5954
.article__title__large{
@@ -76,13 +71,13 @@
7671
}
7772
.article__ad{
7873
width: 100%;
79-
height: 4rem;
74+
height: 240rpx;
8075
border-radius: 10rpx;
8176
}
8277

8378
.article__remark{
8479
bottom: 0;
85-
width: 20rem;
80+
width: 750rpx;
8681
display: block;
8782
font-size: 28rpx;
8883
}

Diff for: components/mp-html/index.js

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: components/mp-html/index.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"component":true,"usingComponents":{"node":"./node/node"}}

Diff for: components/mp-html/index.wxml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<view class="_root {{selectable?'_select':''}}" style="{{containerStyle}}"><slot wx:if="{{!nodes[0]}}"/><node id="_root" childs="{{nodes}}" opts="{{[lazyLoad,loadingImg,errorImg,showImgMenu,selectable]}}" catchadd="_add"/></view>

Diff for: components/mp-html/index.wxss

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
._root{padding:1px 0;overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch}._select{-webkit-user-select:text;user-select:text}

Diff for: components/mp-html/node/node.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: components/mp-html/node/node.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"component":true,"usingComponents":{"node":"./node"}}

Diff for: components/mp-html/node/node.wxml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<wxs module="isInline">var e={abbr:!0,b:!0,big:!0,code:!0,del:!0,em:!0,i:!0,ins:!0,label:!0,q:!0,small:!0,span:!0,strong:!0,sub:!0,sup:!0};module.exports=function(n,i){return e[n]||-1!==(i||"").indexOf("inline")};</wxs><template name="el"><block wx:if="{{n.name==='img'}}"><image wx:if="{{(opts[1]&&!ctrl[i])||ctrl[i]<0}}" class="_img" style="{{n.attrs.style}}" src="{{ctrl[i]<0?opts[2]:opts[1]}}" mode="widthFix"/><image id="{{n.attrs.id}}" class="_img {{n.attrs.class}}" style="{{ctrl[i]===-1?'display:none;':''}}width:{{ctrl[i]||1}}px;height:1px;{{n.attrs.style}}" src="{{n.attrs.src}}" mode="{{!n.h?'widthFix':(!n.w?'heightFix':'')}}" lazy-load="{{opts[0]}}" webp="{{n.webp}}" show-menu-by-longpress="{{opts[3]&&!n.attrs.ignore}}" data-i="{{i}}" bindload="imgLoad" binderror="mediaError" catchtap="imgTap" bindlongpress="noop"/></block><text wx:elif="{{n.text}}" user-select="{{opts[4]}}" decode>{{n.text}}</text><text wx:elif="{{n.name==='br'}}">\n</text><view wx:elif="{{n.name==='a'}}" id="{{n.attrs.id}}" class="{{n.attrs.href?'_a ':''}}{{n.attrs.class}}" hover-class="_hover" style="display:inline;{{n.attrs.style}}" data-i="{{i}}" catchtap="linkTap"><node childs="{{n.children}}" opts="{{opts}}" style="display:inherit"/></view><video wx:elif="{{n.name==='video'}}" id="{{n.attrs.id}}" class="{{n.attrs.class}}" style="{{n.attrs.style}}" autoplay="{{n.attrs.autoplay}}" controls="{{n.attrs.controls}}" loop="{{n.attrs.loop}}" muted="{{n.attrs.muted}}" object-fit="{{n.attrs['object-fit']}}" poster="{{n.attrs.poster}}" src="{{n.src[ctrl[i]||0]}}" data-i="{{i}}" bindplay="play" binderror="mediaError"/><audio wx:elif="{{n.name==='audio'}}" id="{{n.attrs.id}}" class="{{n.attrs.class}}" style="{{n.attrs.style}}" author="{{n.attrs.author}}" controls="{{n.attrs.controls}}" loop="{{n.attrs.loop}}" name="{{n.attrs.name}}" poster="{{n.attrs.poster}}" src="{{n.src[ctrl[i]||0]}}" data-i="{{i}}" bindplay="play" binderror="mediaError"/><rich-text wx:else id="{{n.attrs.id}}" style="{{n.f}}" user-select="{{opts[4]}}" nodes="{{[n]}}"/></template><block wx:for="{{childs}}" wx:for-item="n1" wx:for-index="i1" wx:key="i1"><template wx:if="{{!n1.c&&(!n1.children||n1.name==='a'||!isInline(n1.name,n1.attrs.style))}}" is="el" data="{{n:n1,i:''+i1,opts:opts,ctrl:ctrl}}"/><view wx:else id="{{n1.attrs.id}}" class="_{{n1.name}} {{n1.attrs.class}}" style="{{n1.attrs.style}}"><block wx:for="{{n1.children}}" wx:for-item="n2" wx:for-index="i2" wx:key="i2"><template wx:if="{{!n2.c&&(!n2.children||n2.name==='a'||!isInline(n2.name,n2.attrs.style))}}" is="el" data="{{n:n2,i:i1+'_'+i2,opts:opts,ctrl:ctrl}}"/><view wx:else id="{{n2.attrs.id}}" class="_{{n2.name}} {{n2.attrs.class}}" style="{{n2.attrs.style}}"><block wx:for="{{n2.children}}" wx:for-item="n3" wx:for-index="i3" wx:key="i3"><template wx:if="{{!n3.c&&(!n3.children||n3.name==='a'||!isInline(n3.name,n3.attrs.style))}}" is="el" data="{{n:n3,i:i1+'_'+i2+'_'+i3,opts:opts,ctrl:ctrl}}"/><view wx:else id="{{n3.attrs.id}}" class="_{{n3.name}} {{n3.attrs.class}}" style="{{n3.attrs.style}}"><block wx:for="{{n3.children}}" wx:for-item="n4" wx:for-index="i4" wx:key="i4"><template wx:if="{{!n4.c&&(!n4.children||n4.name==='a'||!isInline(n4.name,n4.attrs.style))}}" is="el" data="{{n:n4,i:i1+'_'+i2+'_'+i3+'_'+i4,opts:opts,ctrl:ctrl}}"/><view wx:else id="{{n4.attrs.id}}" class="_{{n4.name}} {{n4.attrs.class}}" style="{{n4.attrs.style}}"><block wx:for="{{n4.children}}" wx:for-item="n5" wx:for-index="i5" wx:key="i5"><template wx:if="{{!n5.c&&(!n5.children||n5.name==='a'||!isInline(n5.name,n5.attrs.style))}}" is="el" data="{{n:n5,i:i1+'_'+i2+'_'+i3+'_'+i4+'_'+i5,opts:opts,ctrl:ctrl}}"/><node wx:else id="{{n5.attrs.id}}" class="_{{n5.name}} {{n5.attrs.class}}" style="{{n5.attrs.style}}" childs="{{n5.children}}" opts="{{opts}}"/></block></view></block></view></block></view></block></view></block>

Diff for: components/mp-html/node/node.wxss

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
._a{padding:1.5px 0 1.5px 0;color:#366092;word-break:break-all}._hover{text-decoration:underline;opacity:.7}._img{max-width:100%;-webkit-touch-callout:none}._b,._strong{font-weight:700}._code{font-family:monospace}._del{text-decoration:line-through}._em,._i{font-style:italic}._h1{font-size:2em}._h2{font-size:1.5em}._h3{font-size:1.17em}._h5{font-size:.83em}._h6{font-size:.67em}._h1,._h2,._h3,._h4,._h5,._h6{display:block;font-weight:700}._ins{text-decoration:underline}._li{display:list-item}._ol{list-style-type:decimal}._ol,._ul{display:block;padding-left:40px;margin:1em 0}._q::before{content:'"'}._q::after{content:'"'}._sub{font-size:smaller;vertical-align:sub}._sup{font-size:smaller;vertical-align:super}._tbody,._tfoot,._thead{display:table-row-group}._tr{display:table-row}._td,._th{display:table-cell;vertical-align:middle}._th{font-weight:700;text-align:center}._ul{list-style-type:disc}._ul ._ul{margin:0;list-style-type:circle}._ul ._ul ._ul{list-style-type:square}._abbr,._b,._code,._del,._em,._i,._ins,._label,._q,._span,._strong,._sub,._sup{display:inline}._blockquote,._div,._p{display:block}

Diff for: components/mp-html/parser.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: coverHttps.php

-81
This file was deleted.

Diff for: image/default-avatar.png

9.38 KB
Loading

Diff for: mock/api-banners.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"code": 0,
3+
"message": "请求成功",
4+
"data": [{
5+
"id": 6039141,
6+
"image": "http:\/\/resource.anhuiyun.anhuinews.com\/ahtt\/P0202205\/P020220526\/P020220526250538268778.jpg",
7+
"title": "引江济淮9月底将实现试通水"
8+
}, {
9+
"id": 6039076,
10+
"image": "http:\/\/resource.anhuiyun.anhuinews.com\/ahtt\/P0202205\/P020220526\/P020220526223385377533.png",
11+
"title": "山村“秘境”迎客来"
12+
}, {
13+
"id": 6039036,
14+
"image": "http:\/\/resource.anhuiyun.anhuinews.com\/ahtt\/P0202205\/P020220526\/P020220526181243378775.jpg",
15+
"title": "安徽宿松:小麦喜丰收 插秧不误时"
16+
}, {
17+
"id": 6039038,
18+
"image": "http:\/\/resource.anhuiyun.anhuinews.com\/ahtt\/P0202205\/P020220526\/P020220526178546100780.jpg",
19+
"title": "安徽美术馆正式开放 高清大图先睹为快"
20+
}, {
21+
"id": 6011225,
22+
"image": "http:\/\/resource.anhuiyun.anhuinews.com\/ahtt\/P0202205\/P020220513\/P020220513177264367300.jpg",
23+
"title": "5.2亿!福彩快乐8大派奖"
24+
}]
25+
}

0 commit comments

Comments
 (0)