Skip to content

Commit 9fdf288

Browse files
committed
init
0 parents  commit 9fdf288

Some content is hidden

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

43 files changed

+24063
-0
lines changed

.browserslistrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
> 5%
2+
Android >= 4.3

.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.DS_Store
2+
node_modules
3+
/dist
4+
/template
5+
*.sh
6+
7+
# local env files
8+
.env.local
9+
.env.*.local
10+
11+
# Log files
12+
npm-debug.log*
13+
yarn-debug.log*
14+
yarn-error.log*
15+
16+
# Editor directories and files
17+
.idea
18+
.vscode
19+
*.suo
20+
*.ntvs*
21+
*.njsproj
22+
*.sln
23+
*.sw?

gulpfile.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
const gulp = require('gulp'),
2+
sass = require('gulp-sass'),
3+
terser = require('gulp-terser'),
4+
rename = require('gulp-rename'),
5+
ts = require('gulp-typescript'),
6+
postcss = require('gulp-postcss'),
7+
cleanCSS = require('gulp-clean-css'),
8+
px2rpx = require('./px2rpx'),
9+
autoprefixer = require('autoprefixer');
10+
11+
const tsProject = ts.createProject('tsconfig.json');
12+
13+
const src = {
14+
scss: 'src/**/*.scss',
15+
ts: 'src/**/*.ts'
16+
}
17+
18+
gulp.task('build:scss', () => gulp.src(src.scss)
19+
.pipe(sass())
20+
.pipe(postcss([ autoprefixer() ]))
21+
.pipe(px2rpx())
22+
.pipe(cleanCSS())
23+
.pipe(rename(path => {
24+
path.extname = '.wxss'
25+
}))
26+
.pipe(gulp.dest('dist'))
27+
)
28+
29+
gulp.task('build:ts', () => gulp.src(src.ts)
30+
.pipe(tsProject())
31+
.pipe(rename(path => {
32+
path.extname = '.js'
33+
}))
34+
.pipe(terser())
35+
.pipe(gulp.dest('dist'))
36+
)
37+
38+
gulp.task('copy', () => gulp.src(['src/**/*', '!src/**/*.ts', '!src/**/*.scss']).pipe(gulp.dest('dist')))
39+
40+
gulp.task('watch', () => gulp.watch('src/**/*.*', gulp.series('build:scss', 'build:ts', 'copy')))
41+
42+
gulp.task('build', gulp.series('build:scss', 'build:ts', 'copy'))
43+
44+
gulp.task('default', done => {
45+
console.log(`
46+
commands:
47+
npm run start : show commands
48+
npm run dev : development mode
49+
npm run build : production mode
50+
`)
51+
done()
52+
})

package.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "demo",
3+
"version": "1.0.1",
4+
"scripts": {
5+
"show": "gulp",
6+
"start": "gulp watch",
7+
"build": "rm -rf dist && gulp build",
8+
"gen:page": "./autofile.sh",
9+
"gen:com": "./autofile.sh"
10+
},
11+
"devDependencies": {
12+
"typescript": "^3.3.3333"
13+
},
14+
"dependencies": {
15+
"autoprefixer": "^9.6.0",
16+
"gulp": "^4.0.2",
17+
"gulp-clean-css": "^4.2.0",
18+
"gulp-postcss": "^8.0.0",
19+
"gulp-rename": "^1.4.0",
20+
"gulp-sass": "^4.0.2",
21+
"gulp-terser": "^1.2.0",
22+
"gulp-typescript": "^5.0.1"
23+
}
24+
}

px2rpx.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
var through = require('through2');
2+
3+
// 常量
4+
const PLUGIN_NAME = 'gulp-px2rpx';
5+
6+
7+
function px2rpx(contents) {
8+
const rpxStr = (contents.toString()).replace(/(\s?\d+)px/g, '$1rpx')
9+
return Buffer.from(rpxStr);
10+
}
11+
12+
13+
function gulpPx2rpx() {
14+
15+
// 创建一个让每个文件通过的 stream 通道
16+
return through.obj(function(file, enc, cb) {
17+
if (file.isNull()) {
18+
// 返回空文件
19+
cb(null, file);
20+
}
21+
if (file.isBuffer()) {
22+
file.contents = px2rpx(file.contents)
23+
}
24+
if (file.isStream()) {
25+
throw new Error(PLUGIN_NAME, 'Not support stream!');
26+
}
27+
28+
cb(null, file);
29+
30+
});
31+
32+
};
33+
34+
// 暴露(export)插件主函数
35+
module.exports = gulpPx2rpx;

src/app.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"pages": [
3+
"pages/login/login",
4+
"pages/index/index",
5+
"pages/logs/logs"
6+
],
7+
"window": {
8+
"backgroundTextStyle": "light",
9+
"navigationBarBackgroundColor": "#fff",
10+
"navigationBarTitleText": "WeChat",
11+
"navigationBarTextStyle": "black"
12+
},
13+
"sitemapLocation": "sitemap.json"
14+
}

src/app.scss

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/**app.wxss**/
2+
// *{
3+
// margin:0;
4+
// padding: 0;
5+
// box-sizing: border-box;
6+
// font-style: normal;
7+
// font-weight: normal;
8+
// font-family: 'Avenir', Helvetica, Arial, sans-serif;
9+
// -webkit-font-smoothing: antialiased;
10+
// -moz-osx-font-smoothing: grayscale;
11+
// }
12+
13+
input, textarea, button, select {
14+
outline: none;
15+
-webkit-appearance:none;
16+
}
17+
// image,button,input {
18+
// border: none;
19+
// }
20+
button::after{
21+
display: none;
22+
}
23+
24+
.clearfix ::after{
25+
content: '';
26+
display: block;
27+
clear: both;
28+
}
29+
30+
.font600{
31+
font-weight: 600
32+
}
33+
34+
.o-btn {
35+
background:linear-gradient(135deg,rgba(255,40,81,1) 0%,rgba(247,115,104,1) 100%);
36+
border: none;
37+
border-radius:8px;
38+
height: 84px;
39+
width: 100%;
40+
margin: auto;
41+
color: #fff;
42+
font-size: 32px;
43+
display: flex;
44+
justify-content: center;
45+
align-items: center;
46+
47+
&.lg{
48+
width: 582px;
49+
}
50+
51+
&.line{
52+
color: #FE2F53;
53+
border: 1PX solid #FE2F53;
54+
background: #fff;
55+
}
56+
57+
&.disabled{
58+
color: #ccc;
59+
background: #eee;
60+
}
61+
}

src/app.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
//app.ts
2+
import { Http, IHttp } from './utils/http'
3+
4+
export interface IMyApp {
5+
userInfoReadyCallback?(res: wx.UserInfo): void
6+
globalData: {
7+
userInfo?: wx.UserInfo
8+
},
9+
$http: IHttp
10+
}
11+
12+
App<IMyApp>({
13+
onLaunch() {
14+
// 展示本地存储能力
15+
var logs: number[] = wx.getStorageSync('logs') || []
16+
logs.unshift(Date.now())
17+
wx.setStorageSync('logs', logs)
18+
19+
// 登录
20+
wx.login({
21+
success(_res) {
22+
// console.log(_res.code)
23+
// 发送 _res.code 到后台换取 openId, sessionKey, unionId
24+
}
25+
})
26+
// 获取用户信息
27+
wx.getSetting({
28+
success: (res) => {
29+
if (res.authSetting['scope.userInfo']) {
30+
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
31+
wx.getUserInfo({
32+
success: res => {
33+
// 可以将 res 发送给后台解码出 unionId
34+
this.globalData.userInfo = res.userInfo
35+
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
36+
// 所以此处加入 callback 以防止这种情况
37+
if (this.userInfoReadyCallback) {
38+
this.userInfoReadyCallback(res.userInfo)
39+
}
40+
}
41+
})
42+
}
43+
}
44+
})
45+
46+
console.log()
47+
},
48+
globalData: {
49+
},
50+
$http: new Http()
51+
})

src/components/button/button.json

Whitespace-only changes.

src/components/button/button.ts

Whitespace-only changes.

src/pages/home/home.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"usingComponents": {}
3+
}

src/pages/home/home.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/** this is home scss */
2+
.home{
3+
4+
}

src/pages/home/home.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//home.ts
2+
//获取应用实例
3+
import { IMyApp } from '@/app'
4+
5+
const app = getApp<IMyApp>()
6+
7+
Page({
8+
data: {
9+
// page data
10+
},
11+
//事件处理函数
12+
yourTap() {
13+
//
14+
},
15+
16+
// miniapp LifeCycle
17+
onLoad() {
18+
//
19+
},
20+
onShow() {
21+
//
22+
},
23+
onHide() {
24+
//
25+
},
26+
onUnload() {
27+
//
28+
}
29+
})

src/pages/home/home.wxml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<page>
2+
<view class="home">
3+
4+
</view>
5+
</page>

src/pages/index/index.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"usingComponents": {}
3+
}

src/pages/index/index.scss

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**index.scss**/
2+
.userinfo {
3+
display: flex;
4+
flex-direction: column;
5+
align-items: center;
6+
}
7+
8+
.userinfo-avatar {
9+
width: 128rpx;
10+
height: 128rpx;
11+
margin: 20rpx;
12+
border-radius: 50%;
13+
}
14+
15+
.userinfo-nickname {
16+
color: #aaa;
17+
}
18+
19+
.usermotto {
20+
margin-top: 200px;
21+
transition: all .3s;
22+
transform: translate3d(0,0,0,1);
23+
}

0 commit comments

Comments
 (0)