Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
MiniprogramTemplate
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
谢卓城
MiniprogramTemplate
Commits
9c045c36
Commit
9c045c36
authored
Dec 24, 2020
by
谢卓城
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增:压缩图片格式,components模板,完善:scss样式
parent
35a34acb
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
167 additions
and
54 deletions
+167
-54
README.md
README.md
+4
-4
gulpfile.js
gulpfile.js
+11
-10
app.scss
src/app.scss
+5
-2
model.png
src/images/index/model.png
+0
-0
index.js
src/pages/test/index.js
+0
-22
index.scss
src/pages/test/index.scss
+0
-6
index.wxml
src/pages/test/index.wxml
+0
-3
style.scss
src/scss/style.scss
+31
-0
variables.scss
src/scss/variables.scss
+64
-2
common.scss
src/styles/common.scss
+24
-5
index.js
src/template/components/index.js
+17
-0
index.json
src/template/components/index.json
+1
-0
index.scss
src/template/components/index.scss
+6
-0
index.wxml
src/template/components/index.wxml
+4
-0
No files found.
README.md
View file @
9c045c36
...
@@ -2,12 +2,12 @@
...
@@ -2,12 +2,12 @@
### 基于gulp构建的微信小程序工作流
### 基于gulp构建的微信小程序工作流
```
```
gulp newfile -p nmpage 创建名为nmpage的page文件
gulp new -p nmpage 创建名为nmpage的page文件
gulp newfile -s index -p nmpage 复制pages/index中的文件创建名称为nmpage的页面
gulp new -s index -p nmpage 复制pages/index中的文件创建名称为nmpage的页面
gulp new -c nmcomponent 创建名为nmcomponent的component文件
```
```
### TODO
### TODO
```
```
gulp newfile -t nmtpl 创建名为nmtpl的template文件
gulp new -t nmtpl 创建名为nmtpl的template文件
gulp newfile -c nmcomponent 创建名为nmcomponent的component文件
```
```
\ No newline at end of file
gulpfile.js
View file @
9c045c36
...
@@ -32,8 +32,8 @@ const sassFiles = [`${srcPath}/*.{scss, wxss}`];
...
@@ -32,8 +32,8 @@ const sassFiles = [`${srcPath}/*.{scss, wxss}`];
const
jsFiles
=
[
`
${
srcPath
}
/*.js`
,
`!
${
srcPath
}
/env/*.js`
];
const
jsFiles
=
[
`
${
srcPath
}
/*.js`
,
`!
${
srcPath
}
/env/*.js`
];
const
jsonFiles
=
[
`
${
srcPath
}
/*.json`
];
const
jsonFiles
=
[
`
${
srcPath
}
/*.json`
];
const
imageFiles
=
[
const
imageFiles
=
[
`
${
srcPath
}
/images/*.{png,jpg,gif,ico}`
,
`
${
srcPath
}
/images/*.{png,jp
eg,jp
g,gif,ico}`
,
`
${
srcPath
}
/images/**/*.{png,jpg,gif,ico}`
`
${
srcPath
}
/images/**/*.{png,jp
eg,jp
g,gif,ico}`
];
];
/* 清除dist目录 */
/* 清除dist目录 */
...
@@ -87,7 +87,7 @@ const wxss = () => {
...
@@ -87,7 +87,7 @@ const wxss = () => {
tap
(
file
=>
{
tap
(
file
=>
{
const
filePath
=
path
.
dirname
(
file
.
path
);
const
filePath
=
path
.
dirname
(
file
.
path
);
//console.log("filepath", filePath);
//console.log("filepath", filePath);
file
.
contents
=
new
Buffer
(
file
.
contents
=
Buffer
.
from
(
String
(
file
.
contents
).
replace
(
String
(
file
.
contents
).
replace
(
/@import
\s
+
[
'|"
](
.+
)[
'|"
]
;/g
,
/@import
\s
+
[
'|"
](
.+
)[
'|"
]
;/g
,
(
$1
,
$2
)
=>
{
(
$1
,
$2
)
=>
{
...
@@ -128,10 +128,10 @@ gulp.task(img);
...
@@ -128,10 +128,10 @@ gulp.task(img);
const
newfile
=
done
=>
{
const
newfile
=
done
=>
{
yargs
yargs
.
example
(
"gulp new
file
-p mypage"
,
"创建mypage的page目录"
)
.
example
(
"gulp new -p mypage"
,
"创建mypage的page目录"
)
.
example
(
"gulp new
file
-c mycomponent"
,
"创建mycomponent的component目录"
)
.
example
(
"gulp new -c mycomponent"
,
"创建mycomponent的component目录"
)
.
example
(
.
example
(
"gulp new
file
-s srcfile -p mypage"
,
"gulp new -s srcfile -p mypage"
,
"以srcfile为模版创建mypage的page目录"
"以srcfile为模版创建mypage的page目录"
)
)
.
option
({
.
option
({
...
@@ -192,13 +192,11 @@ const newfile = done => {
...
@@ -192,13 +192,11 @@ const newfile = done => {
?
`src/
${
source
}
/
${
type
}
/*`
?
`src/
${
source
}
/
${
type
}
/*`
:
`src/
${
type
}
/
${
source
}
/*`
;
:
`src/
${
type
}
/
${
source
}
/*`
;
console
.
log
(
"defaultPath "
+
`src/
${
type
}
/
${
name
}
`
,
defaultPath
);
return
gulp
.
src
(
defaultPath
).
pipe
(
gulp
.
dest
(
`src/
${
type
}
/
${
name
}
/`
));
return
gulp
.
src
(
defaultPath
).
pipe
(
gulp
.
dest
(
`src/
${
type
}
/
${
name
}
/`
));
};
};
gulp
.
task
(
newfile
);
gulp
.
task
(
"new"
,
newfile
);
gulp
.
task
(
"watch"
,
()
=>
{
gulp
.
task
(
"watch"
,
done
=>
{
const
watchSassFiles
=
[
const
watchSassFiles
=
[
...
sassFiles
,
...
sassFiles
,
...
DIRECTIMPORT
.
map
(
item
=>
`!
${
srcPath
}
/
${
item
}
/**/*`
)
...
DIRECTIMPORT
.
map
(
item
=>
`!
${
srcPath
}
/
${
item
}
/**/*`
)
...
@@ -208,6 +206,7 @@ gulp.task("watch", () => {
...
@@ -208,6 +206,7 @@ gulp.task("watch", () => {
gulp
.
watch
(
jsonFiles
,
json
);
gulp
.
watch
(
jsonFiles
,
json
);
gulp
.
watch
(
imageFiles
,
img
);
gulp
.
watch
(
imageFiles
,
img
);
gulp
.
watch
(
wxmlFiles
,
wxml
);
gulp
.
watch
(
wxmlFiles
,
wxml
);
done
();
});
});
gulp
.
task
(
gulp
.
task
(
...
@@ -217,6 +216,7 @@ gulp.task(
...
@@ -217,6 +216,7 @@ gulp.task(
gulp
.
parallel
(
"wxml"
,
"js"
,
"json"
,
"wxss"
,
"img"
,
"prodEnv"
)
gulp
.
parallel
(
"wxml"
,
"js"
,
"json"
,
"wxss"
,
"img"
,
"prodEnv"
)
)
)
);
);
gulp
.
task
(
gulp
.
task
(
"dev"
,
"dev"
,
gulp
.
series
(
gulp
.
series
(
...
@@ -225,6 +225,7 @@ gulp.task(
...
@@ -225,6 +225,7 @@ gulp.task(
"watch"
"watch"
)
)
);
);
gulp
.
task
(
gulp
.
task
(
"test"
,
"test"
,
gulp
.
series
(
gulp
.
series
(
...
...
src/app.scss
View file @
9c045c36
@import
'./styles/common.scss'
;
@import
'./styles/common.scss'
;
@import
'./scss/variables'
;
@import
'./scss/variables.scss'
;
@import
'./scss/style.scss'
;
.container
{
.container
{
width
:
100%
;
width
:
100%
;
height
:
100vh
;
height
:
100vh
;
color
:
$t
hemeColor
;
color
:
$t
c
;
}
}
\ No newline at end of file
images/index/model.png
→
src/
images/index/model.png
View file @
9c045c36
File moved
src/pages/test/index.js
deleted
100644 → 0
View file @
35a34acb
// pages/index.js
Page
({
/**
* 页面的初始数据
*/
data
:
{
content
:
"test"
},
/**
* 生命周期函数--监听页面加载
*/
onLoad
:
function
(
options
)
{
console
.
log
(
"onLoad"
);
},
/**
* 用户点击右上角分享
*/
onShareAppMessage
:
function
()
{
console
.
log
(
"onShareAppMessage"
);
}
});
src/pages/test/index.scss
deleted
100644 → 0
View file @
35a34acb
.container
{
width
:
100vw
;
.text
{
color
:
red
;
}
}
\ No newline at end of file
src/pages/test/index.wxml
deleted
100644 → 0
View file @
35a34acb
<view class='container'>
<text class="text">{{content}}</text>
</view>
\ No newline at end of file
src/scss/style.scss
0 → 100644
View file @
9c045c36
// copy changein -> common/scss/style
@import
'../scss/variables.scss'
;
.flex-1
{
flex
:
1
;
};
.flex-center
{
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
}
// text overflow
.text-ellipsis
{
display
:
inline-block
;
overflow
:
hidden
;
text-overflow
:
ellipsis
;
white-space
:
nowrap
;
}
// flex
.display-flex
{
display
:
flex
;
}
.flex-column
{
flex-direction
:
column
;
}
.flex-wrap
{
flex-wrap
:
wrap
;
}
\ No newline at end of file
src/scss/variables.scss
View file @
9c045c36
$themeColor
:
#8FBC8F
;
// copy changein -> common/scss/_variables
$base-font-size
:
26rpx
;
$font-sizes
:
(
xxs
:
0
.6923
,
//
18rpx
xs
:
0
.7692
,
//
20rpx
ssm
:
0
.8462
,
//
22rpx
sm
:
0
.9230
,
//
24rpx
md
:
1
,
//
26rpx
lg
:
1
.0769
,
//
28rpx
xl
:
1
.1538
,
//
30rpx
);
// spacing
// 0-5: 0
// .mt-1 => margin top .pb-2
$spacing-types
:
(
m
:
margin
,
p
:
padding
,
);
$spacing-directions
:
(
t
:
top
,
r
:
right
,
b
:
bottom
,
l
:
left
,
);
@each
$sizeKey
,
$size
in
$font-sizes
{
.fs-
#{
$sizeKey
}
{
font-size
:
$size
*
$base-font-size
;
}
}
// text align
@each
$var
in
(
left
,
center
,
right
)
{
.text-
#{
$var
}
{
text-align
:
$var
!
important
;
}
}
$flex-justify-content
:
(
$flex-justify-content
:
(
start
:
flex-start
,
start
:
flex-start
,
...
@@ -7,9 +56,22 @@ $flex-justify-content: (
...
@@ -7,9 +56,22 @@ $flex-justify-content: (
between
:
space-between
,
between
:
space-between
,
around
:
space-around
,
around
:
space-around
,
);
);
$flex-align-items
:
(
$flex-align-items
:
(
start
:
flex-start
,
start
:
flex-start
,
end
:
flex-end
,
end
:
flex-end
,
center
:
center
,
center
:
center
,
stretch
:
stretch
,
stretch
:
stretch
,
);
);
@each
$key
,
$value
in
$flex-justify-content
{
.flex-j-
#{
$key
}
{
justify-content
:
$value
;
}
}
@each
$key
,
$value
in
$flex-align-items
{
.flex-a-
#{
$key
}
{
align-items
:
$value
;
}
}
\ No newline at end of file
src/styles/common.scss
View file @
9c045c36
.flex-center
{
@import
'../scss/style.scss'
;
display
:
flex
;
align-items
:
center
;
$colors
:
(
justify-content
:
center
;
"themeColor"
:
#8FBC8F
,
);
$tc
:
map-get
(
$colors
,
'themeColor'
);
@mixin
width
(
$value
:
100%
)
{
width
:
$value
;
}
@mixin
height
(
$value
:
100%
)
{
height
:
$value
;
}
// width, height
.w-100
{
@include
width
();
}
.h-100
{
@include
height
();
}
}
src/template/components/index.js
0 → 100644
View file @
9c045c36
Component
({
properties
:
{
showDelect
:
Boolean
,
flexList
:
Array
,
title
:
String
// 简化的定义方式
},
data
:
{
content
:
"content"
},
methods
:
{
// 这里是一个自定义方法
tagAction
(
e
)
{
var
eventOption
=
{
content
:
e
.
currentTarget
.
dataset
.
text
};
// 触发事件的选项
this
.
triggerEvent
(
"tagClick"
,
eventOption
);
}
}
});
src/
pages/test
/index.json
→
src/
template/components
/index.json
View file @
9c045c36
{
{
"component"
:
true
,
"usingComponents"
:
{}
"usingComponents"
:
{}
}
}
\ No newline at end of file
src/template/components/index.scss
0 → 100644
View file @
9c045c36
.container
{
width
:
100vw
;
.text
{
color
:
red
;
}
}
\ No newline at end of file
src/template/components/index.wxml
0 → 100644
View file @
9c045c36
<!--template/components/index.wxml-->
<view class="container" hover-class="none" hover-stop-propagation="false">
<text class="flex-item" selectable="false" space="false" decode="false" bindtap="tagAction" data-text="{{content}}">{{content}}</text>
</view>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment