Browse Source

pages

master
1549469775 4 years ago
parent
commit
6b1fe48077
  1. 23
      gulpfile.js/index.js
  2. 8
      package-lock.json
  3. 3
      package.json
  4. 2
      src/common/__common.less
  5. 57
      src/common/__less/common.less
  6. 0
      src/common/__less/meida.less
  7. 48
      src/common/reset.css
  8. 21
      src/common/style.less
  9. 159
      src/css/index/index.less
  10. 33
      src/html/index.pug
  11. 6
      test.js

23
gulpfile.js/index.js

@ -11,8 +11,8 @@ const browserSync = require('browser-sync').create();
const reload = browserSync.reload;
let srcPath = "src"
// let distPath = "node_modules/.gcache"
let distPath = "dist"
let distPath = "node_modules/.gcache"
// let distPath = "dist"
/**
* 删除输出文件夹目录
@ -23,18 +23,21 @@ function remove() {
function removeStatic() {
return del(['dist/static/**/*']);
}
const exculde = `!${srcPath}/**/__*/**`
// 处理公共库
function common() {
let commonJS = src([`${srcPath}/common/**/*.js`,`!${srcPath}/**/__*`]).pipe(rename({suffix: "._cn",dirname: 'js'}))
let commonCSS = src([`${srcPath}/common/**/*.css`,`!${srcPath}/**/__*`]).pipe(rename({suffix: "._cn",dirname: 'css'}))
let commonLess = src([`${srcPath}/common/**/*.less`,`!${srcPath}/**/__*`]) .pipe(less()).pipe(rename({suffix: "._cn",dirname: 'css', extname: ".css" }))
let commonJS = src([`${srcPath}/common/**/*.js`,exculde]).pipe(rename({suffix: "._cn",dirname: 'js'}))
let commonCSS = src([`${srcPath}/common/**/*.css`,exculde]).pipe(rename({suffix: "._cn",dirname: 'css'}))
let commonLess = src([`${srcPath}/common/**/*.less`,exculde]) .pipe(less()).pipe(rename({suffix: "._cn",dirname: 'css', extname: ".css" }))
return es.merge(commonJS, commonCSS, commonLess).pipe(dest(`${distPath}`))
}
// 处理页面资源
function page(name="index") {
let pageJS = src([`${srcPath}/js/${name}/**/*`,`!src/**/__*`]).pipe(rename({suffix: `._${name}`,dirname: 'js'}))
let pageLess = src([`${srcPath}/css/${name}/**/*.less`,`!${srcPath}/**/__*`]) .pipe(less()).pipe(rename({suffix: "._cn",dirname: 'css', extname: ".css" }))
let pageCSS = src([`${srcPath}/css/${name}/**/*`,`!${srcPath}/**/__*`]).pipe(rename({suffix: `._${name}`,dirname: 'css'}))
let pageJS = src([`${srcPath}/js/${name}/**/*`,exculde]).pipe(rename({suffix: `._${name}`,dirname: 'js'}))
let pageLess = src([`${srcPath}/css/${name}/**/*.less`,exculde]) .pipe(less()).pipe(rename({suffix: `._${name}`,dirname: 'css', extname: ".css" }))
let pageCSS = src([`${srcPath}/css/${name}/**/*.css`,exculde]).pipe(rename({suffix: `._${name}`,dirname: 'css'}))
return es.merge(pageJS, pageCSS, pageLess).pipe(dest(`${distPath}`))
}
// 处理页面资源的包装函数
@ -45,7 +48,7 @@ function asset(name="index") {
}
// 静态资源
function static() {
return src(`${srcPath}/static/**/*`).pipe(dest(`${distPath}/static`))
return src([`${srcPath}/static/**/*`,exculde]).pipe(dest(`${distPath}/static`))
}
// 处理页面
function pageFn(name="index") {
@ -54,7 +57,7 @@ function pageFn(name="index") {
const jsFiles = src(`${distPath}/js/**/*._${name}.js`, {read: false})
const cssCNFiles = src(`${distPath}/css/**/*._cn.css`, {read: false})
const cssFiles = src(`${distPath}/css/**/*._${name}.css`, {read: false})
return src([`${srcPath}/html/${name}.pug`,`!${srcPath}/**/__*`]).pipe(pug()).pipe(inject(es.merge(
return src([`${srcPath}/html/${name}.pug`,exculde]).pipe(pug()).pipe(inject(es.merge(
jsCNiles,
cssCNFiles,
cssFiles,

8
package-lock.json

@ -2574,7 +2574,7 @@
},
"fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"resolved": "https://registry.npm.taobao.org/fs.realpath/download/fs.realpath-1.0.0.tgz",
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
},
"fsevents": {
@ -2644,8 +2644,8 @@
},
"glob": {
"version": "7.1.7",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz",
"integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==",
"resolved": "https://registry.nlark.com/glob/download/glob-7.1.7.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fglob%2Fdownload%2Fglob-7.1.7.tgz",
"integrity": "sha1-Oxk+kjPwHULQs/eClLvutBj5SpA=",
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
@ -3226,7 +3226,7 @@
},
"inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"resolved": "https://registry.npm.taobao.org/inflight/download/inflight-1.0.6.tgz",
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
"requires": {
"once": "^1.3.0",

3
package.json

@ -4,6 +4,8 @@
"description": "",
"main": "index.js",
"scripts": {
"dev": "gulp watch",
"build": "gulp",
"test": "cypress open"
},
"keywords": [],
@ -18,6 +20,7 @@
"dependencies": {
"del": "^6.0.0",
"event-stream": "^4.0.1",
"glob": "^7.1.7",
"gulp-less": "^5.0.0",
"gulp-pug": "^5.0.0",
"gulp-rename": "^2.0.0"

2
src/common/__common.less

@ -1,2 +0,0 @@
@import (reference) "./__meida.less";
@red: red;

57
src/common/__less/common.less

@ -0,0 +1,57 @@
@import (reference) "./meida.less";
.hairline(@content) {
&::after {
content: " ";
box-sizing: border-box;
pointer-events: none;
border: 0 solid #ebedf0;
position: absolute;
top: -50%;
right: -50%;
bottom: -50%;
left: -50%;
-webkit-transform: scale(0.5);
transform: scale(0.5);
@content();
}
}
.hairline--all() {
.hairline({
border-width: 1px;
});
}
.hairline {
.hairline--all();
}
.ellipsis(@lines: 1) when (@lines = 1){
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.ellipsis{
.ellipsis()
}
.over-ellipsis{
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
overflow: hidden;
text-overflow: ellipsis;
word-break: break-all;
}
.clearfix {
&:after {
clear: both;
content: '.';
display: block;
height: 0;
line-height: 0;
overflow: hidden;
}
*height: 1%;
}

0
src/common/__meida.less → src/common/__less/meida.less

48
src/common/reset.css

@ -0,0 +1,48 @@
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}

21
src/common/style.less

@ -1,5 +1,20 @@
@import (reference) "./__common.less";
@import "./__less/common.less";
.@{red}-w{
color: @red;
html, body{
background-color: #43b244;
color: #fffef8;
height: 100%;
margin: 0;
padding: 0;
}
body{
font: 12px/1.5 Tahoma,Helvetica,Arial,'宋体',sans-serif;
}
.container{
margin: 0 auto;
width: 960px;
}

159
src/css/index/index.less

@ -1,10 +1,157 @@
@red: green;
.@{red}{
color: @red;
/**
* 用户头像
**/
.userProfile{
display: flex;
align-items: center;
height: 100px;
width: 300px;
font-size: 2.0833em;
line-height: 1.3;
.head{
width: 100px;
height: 100%;
position: relative;
text-align: center;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
.avatar{
width: 100%;
height: 100%;
position: absolute;
border-radius: 50%;
overflow: hidden;
left: 0;
right: 0;
bottom: 0;
top: 0;
transition: transform .6s linear, left .6s linear;
}
&:hover .avatar{
transform: rotate(-360deg);
left: -105%;
}
}
.text{
flex: 1;
width: 0;
margin-left: 10px;
.userName{
font-size: 1em;
}
.userDesc{
margin-top: 4px;
font-size: .7em;
}
}
}
.container{
margin: 0 auto;
width: 1200px;
/**
* 用户头像End
**/
.mb{
margin-bottom: 20px;
}
header{
position: sticky;
top: 0;
z-index: 999;
font-size: 1.333em;
background-color: #fffef870;
border-bottom-left-radius: 6px;
border-bottom-right-radius: 6px;
margin-bottom: 15px;
padding: 0 30px;
height: 35px;
line-height: 35px;
.item{
cursor: pointer;
padding: 0 10px;
&:hover{
background-color: #fffef870;
}
}
.menulist{
li{
float: left;
}
}
.oplist{
li{
float: right;
}
}
}
.panel{
// background-color: #fffef870;
border-radius: 6px;
padding: 8px;
text-align: center;
position: relative;
h1{
font-size: 2.9116em;
}
.author{
font-size: 1.0833em;
}
.content{
text-align: left;
font-size: 1.6667em;
margin-top: 15px;
line-height: 1.2;
word-break: break-all;
}
.float{
cursor: pointer;
font-size: 1.1667em;
position: absolute;
right: 100%;
top: 200px;
background-color: #fffef870;
border-top-left-radius: 6px;
border-bottom-left-radius: 6px;
width: 45px;
word-break: break-all;
padding: 4px 6px;
&:hover{
animation: bounce .4s;
}
}
}
@keyframes bounce {
0%{
transform: scale(1);
}
50%{
transform: scale(1.2);
}
100%{
transform: scale(1);
}
}
.line{
height: 15px;
width: 200px;
margin: 0 auto;
cursor: pointer;
&:hover{
height: 15px;
&::after{
height: 15px;
}
}
&::after{
content: "";
height: 5px;
display: block;
border-radius: 6px;
background-color: #fffef870;
transition: height .4s ease;
}
}

33
src/html/index.pug

@ -4,7 +4,34 @@ extends __layout/layout.pug
block title
- var title = "哈哈"
block content
.container
p 不错了
- var avatarURL = "https://cdn.pixabay.com/photo/2021/06/22/14/55/girl-6356393_960_720.jpg"
- var content = `先帝创业未半而中道崩殂,今天下三分,益州疲弊,此诚危急存亡之秋也。然侍卫之臣不懈于内,忠志之士忘身于外者,盖追先帝之殊遇,欲报之于陛下也。诚宜开张圣听,以光先帝遗德,恢弘志士之气,不宜妄自菲薄,引喻失义,以塞忠谏之路也。
- 宫中府中,俱为一体;陟罚臧否,不宜异同。若有作奸犯科及为忠善者,宜付有司论其刑赏,以昭陛下平明之理,不宜偏私,使内外异法也。
- 侍中、侍郎郭攸之、费祎、董允等,此皆良实,志虑忠纯,是以先帝简拔以遗陛下。愚以为宫中之事,事无大小,悉以咨之,然后施行,必能裨补阙漏,有所广益。
- 将军向宠,性行淑均,晓畅军事,试用于昔日,先帝称之曰能,是以众议举宠为督。愚以为营中之事,悉以咨之,必能使行阵和睦,优劣得所。
- 亲贤臣,远小人,此先汉所以兴隆也;亲小人,远贤臣,此后汉所以倾颓也。先帝在时,每与臣论此事,未尝不叹息痛恨于桓、灵也。侍中、尚书、长史、参军,此悉贞良死节之臣,愿陛下亲之信之,则汉室之隆,可计日而待也。
- 臣本布衣,躬耕于南阳,苟全性命于乱世,不求闻达于诸侯。先帝不以臣卑鄙,猥自枉屈,三顾臣于草庐之中,咨臣以当世之事,由是感激,遂许先帝以驱驰。后值倾覆,受任于败军之际,奉命于危难之间,尔来二十有一年矣。
- 先帝知臣谨慎,故临崩寄臣以大事也。受命以来,夙夜忧叹,恐托付不效,以伤先帝之明;故五月渡泸,深入不毛。今南方已定,兵甲已足,当奖率三军,北定中原,庶竭驽钝,攘除奸凶,兴复汉室,还于旧都。此臣所以报先帝`
.container.page
header.clearfix.mb
ul.menulist
li.item 首页
li.item 文档
li.item 归档
li.item 关于
ul.oplist
li.item 注册/登陆
.userProfile.mb
.head 围城
img(src=avatarURL, alt="topuser", srcset="").avatar
.text
.userName 龙门客栈
.userDesc.over-ellipsis 白龙马,蹄儿朝西
.line
.panel
h1 出师表
span.author 诸葛亮
.content!= content
.float 订阅

6
test.js

@ -0,0 +1,6 @@
const glob = require('glob')
console.log(glob.sync("src/common/**/*", {
ignore: "src/**/__*/**"
}));
Loading…
Cancel
Save