This repository has been archived by the owner on Mar 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 支持buildMiniComponent,以webpack方式构建小程序自定义组件
- Loading branch information
sydeEvans
committed
Jul 27, 2021
1 parent
90fddc4
commit e5ed805
Showing
62 changed files
with
9,948 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
dist/ | ||
yarn-error.log | ||
yarn.lock | ||
.tea | ||
.vscode | ||
.DS_Store | ||
!src/node_modules | ||
build/ | ||
miniapptools_dist/ | ||
|
||
alipay/components | ||
wechat/components |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
page { | ||
background: #f7f7f7; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
App({ | ||
onLaunch(options) { | ||
// 第一次打开 | ||
// options.query == {number:1} | ||
console.info('App onLaunch'); | ||
}, | ||
onShow(options) { | ||
// 从后台被 scheme 重新打开 | ||
// options.query == {number:1} | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"pages": [ | ||
"pages/index/index" | ||
], | ||
"window": { | ||
"defaultTitle": "My App" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"exclude": [ | ||
"dist/**/*" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* required by usingComponents */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
<view> | ||
this is a blank page | ||
<greet name="greet1"></greet> | ||
<greet2 name="greet2"></greet2> | ||
</view> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Page({ | ||
onLoad(query) { | ||
// 页面加载 | ||
console.info(`Page onLoad with query: ${JSON.stringify(query)}`); | ||
}, | ||
onReady() { | ||
// 页面加载完成 | ||
}, | ||
onShow() { | ||
// 页面显示 | ||
}, | ||
onHide() { | ||
// 页面隐藏 | ||
}, | ||
onUnload() { | ||
// 页面被关闭 | ||
}, | ||
onTitleClick() { | ||
// 标题被点击 | ||
}, | ||
onPullDownRefresh() { | ||
// 页面被下拉 | ||
}, | ||
onReachBottom() { | ||
// 页面被拉到底部 | ||
}, | ||
onShareAppMessage() { | ||
// 返回自定义分享信息 | ||
return { | ||
title: 'My App', | ||
desc: 'My App description', | ||
path: 'pages/index/index', | ||
}; | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"usingComponents": { | ||
"greet": "/components/greet/index", | ||
"greet2": "/components/greet2/index" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const { buildMiniComponent } = require('@remax/cli'); | ||
|
||
const buildMap = [ | ||
{ | ||
target: 'ali', | ||
output: 'alipay/components', | ||
rootDir: 'src', | ||
pxToRpx: true, | ||
input: { | ||
greet: 'greet/index', | ||
greet2: 'greet2/index', | ||
}, | ||
}, | ||
{ | ||
target: 'wechat', | ||
output: 'wechat/components', | ||
rootDir: 'src', | ||
pxToRpx: true, | ||
input: { | ||
greet: 'greet/index', | ||
}, | ||
}, | ||
]; | ||
|
||
buildMap.forEach(it => { | ||
buildMiniComponent({ | ||
cwd: process.cwd(), | ||
...it, | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "e2e-mini", | ||
"private": true, | ||
"version": "1.0.0", | ||
"scripts": { | ||
"build": "node build.js" | ||
}, | ||
"dependencies": { | ||
"mini-antui": "^0.4.34", | ||
"react": "^16.8.6", | ||
"remax": "*" | ||
}, | ||
"workspaces": { | ||
"nohoist": [ | ||
"mini-antui", | ||
"react" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import * as React from 'react'; | ||
import { View } from 'remax/one'; | ||
|
||
console.log('greeting1'); | ||
export default ({ name }) => { | ||
return ( | ||
<View id="greeting"> | ||
<View>Hello {name}</View> | ||
</View> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import * as React from 'react'; | ||
import { View } from 'remax/one'; | ||
import Badge from 'mini-antui/es/badge'; | ||
|
||
console.log('greeting2'); | ||
export default ({ name }) => { | ||
return ( | ||
<View id="greeting"> | ||
<View>Hello {name}</View> | ||
<Badge> | ||
<View slot="inner">Remax</View> | ||
</Badge> | ||
</View> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// app.js | ||
App({ | ||
onLaunch() { | ||
// 展示本地存储能力 | ||
const logs = wx.getStorageSync('logs') || []; | ||
logs.unshift(Date.now()); | ||
wx.setStorageSync('logs', logs); | ||
|
||
// 登录 | ||
wx.login({ | ||
success: res => { | ||
// 发送 res.code 到后台换取 openId, sessionKey, unionId | ||
}, | ||
}); | ||
}, | ||
globalData: { | ||
userInfo: null, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"pages":[ | ||
"pages/index/index" | ||
], | ||
"window":{ | ||
"backgroundTextStyle":"light", | ||
"navigationBarBackgroundColor": "#fff", | ||
"navigationBarTitleText": "Weixin", | ||
"navigationBarTextStyle":"black" | ||
}, | ||
"style": "v2", | ||
"sitemapLocation": "sitemap.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/**app.wxss**/ | ||
.container { | ||
height: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: space-between; | ||
padding: 200rpx 0; | ||
box-sizing: border-box; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// index.js | ||
// 获取应用实例 | ||
const app = getApp(); | ||
|
||
Page({ | ||
data: { | ||
motto: 'Hello World', | ||
userInfo: {}, | ||
hasUserInfo: false, | ||
canIUse: wx.canIUse('button.open-type.getUserInfo'), | ||
canIUseGetUserProfile: false, | ||
canIUseOpenData: wx.canIUse('open-data.type.userAvatarUrl') && wx.canIUse('open-data.type.userNickName'), // 如需尝试获取用户信息可改为false | ||
}, | ||
// 事件处理函数 | ||
bindViewTap() { | ||
wx.navigateTo({ | ||
url: '../logs/logs', | ||
}); | ||
}, | ||
onLoad() { | ||
if (wx.getUserProfile) { | ||
this.setData({ | ||
canIUseGetUserProfile: true, | ||
}); | ||
} | ||
}, | ||
getUserProfile(e) { | ||
// 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗 | ||
wx.getUserProfile({ | ||
desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写 | ||
success: res => { | ||
console.log(res); | ||
this.setData({ | ||
userInfo: res.userInfo, | ||
hasUserInfo: true, | ||
}); | ||
}, | ||
}); | ||
}, | ||
getUserInfo(e) { | ||
// 不推荐使用getUserInfo获取用户信息,预计自2021年4月13日起,getUserInfo将不再弹出弹窗,并直接返回匿名的用户个人信息 | ||
console.log(e); | ||
this.setData({ | ||
userInfo: e.detail.userInfo, | ||
hasUserInfo: true, | ||
}); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"usingComponents": { | ||
"greet": "/components/greet/index" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<!--index.wxml--> | ||
<view class="container"> | ||
hello remax | ||
<greet name="hello"/> | ||
</view> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/**index.wxss**/ | ||
.userinfo { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
color: #aaa; | ||
} | ||
|
||
.userinfo-avatar { | ||
overflow: hidden; | ||
width: 128rpx; | ||
height: 128rpx; | ||
margin: 20rpx; | ||
border-radius: 50%; | ||
} | ||
|
||
.usermotto { | ||
margin-top: 200px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
{ | ||
"description": "项目配置文件", | ||
"packOptions": { | ||
"ignore": [] | ||
}, | ||
"setting": { | ||
"bundle": false, | ||
"userConfirmedBundleSwitch": false, | ||
"urlCheck": true, | ||
"scopeDataCheck": false, | ||
"coverView": true, | ||
"es6": true, | ||
"postcss": true, | ||
"compileHotReLoad": false, | ||
"lazyloadPlaceholderEnable": false, | ||
"preloadBackgroundData": false, | ||
"minified": true, | ||
"autoAudits": false, | ||
"newFeature": false, | ||
"uglifyFileName": false, | ||
"uploadWithSourceMap": true, | ||
"useIsolateContext": true, | ||
"nodeModules": false, | ||
"enhance": true, | ||
"useMultiFrameRuntime": true, | ||
"useApiHook": true, | ||
"useApiHostProcess": true, | ||
"showShadowRootInWxmlPanel": true, | ||
"packNpmManually": false, | ||
"enableEngineNative": false, | ||
"packNpmRelationList": [], | ||
"minifyWXSS": true, | ||
"showES6CompileOption": false | ||
}, | ||
"compileType": "miniprogram", | ||
"libVersion": "2.18.1", | ||
"appid": "wx4f97573c7eadf58f", | ||
"projectname": "wechat", | ||
"debugOptions": { | ||
"hidedInDevtools": [] | ||
}, | ||
"scripts": {}, | ||
"staticServerOptions": { | ||
"baseURL": "", | ||
"servePath": "" | ||
}, | ||
"isGameTourist": false, | ||
"condition": { | ||
"search": { | ||
"list": [] | ||
}, | ||
"conversation": { | ||
"list": [] | ||
}, | ||
"game": { | ||
"list": [] | ||
}, | ||
"plugin": { | ||
"list": [] | ||
}, | ||
"gamePlugin": { | ||
"list": [] | ||
}, | ||
"miniprogram": { | ||
"list": [] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", | ||
"rules": [{ | ||
"action": "allow", | ||
"page": "*" | ||
}] | ||
} |
Oops, something went wrong.