From 6b1fe48077ca914398488248bf4c363114c74382 Mon Sep 17 00:00:00 2001 From: 1549469775 <1549469775@qq.com> Date: Wed, 8 Sep 2021 00:30:04 +0800 Subject: [PATCH] pages --- gulpfile.js/index.js | 23 +++--- package-lock.json | 8 +-- package.json | 3 + src/common/__common.less | 2 - src/common/__less/common.less | 57 +++++++++++++++ src/common/__less/meida.less | 28 ++++++++ src/common/__meida.less | 28 -------- src/common/reset.css | 48 +++++++++++++ src/common/style.less | 23 ++++-- src/css/index/index.less | 161 ++++++++++++++++++++++++++++++++++++++++-- src/html/index.pug | 33 ++++++++- test.js | 6 ++ 12 files changed, 362 insertions(+), 58 deletions(-) delete mode 100644 src/common/__common.less create mode 100644 src/common/__less/common.less create mode 100644 src/common/__less/meida.less delete mode 100644 src/common/__meida.less create mode 100644 src/common/reset.css create mode 100644 test.js diff --git a/gulpfile.js/index.js b/gulpfile.js/index.js index 375f747..fb82353 100644 --- a/gulpfile.js/index.js +++ b/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, diff --git a/package-lock.json b/package-lock.json index 92b6871..c1e35fa 100644 --- a/package-lock.json +++ b/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", diff --git a/package.json b/package.json index a4bc6a7..794c949 100644 --- a/package.json +++ b/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" diff --git a/src/common/__common.less b/src/common/__common.less deleted file mode 100644 index 822510c..0000000 --- a/src/common/__common.less +++ /dev/null @@ -1,2 +0,0 @@ -@import (reference) "./__meida.less"; -@red: red; \ No newline at end of file diff --git a/src/common/__less/common.less b/src/common/__less/common.less new file mode 100644 index 0000000..b93dec7 --- /dev/null +++ b/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%; +} \ No newline at end of file diff --git a/src/common/__less/meida.less b/src/common/__less/meida.less new file mode 100644 index 0000000..a4b6ac6 --- /dev/null +++ b/src/common/__less/meida.less @@ -0,0 +1,28 @@ +.choose(@type, @style) when (@type=xs){ + @media (max-width: 768px){ + @style(); + } +} +.choose(@type, @style) when (@type=sm){ + @media (max-width: 920px){ + @style(); + } +} +.choose(@type, @style) when (@type=md){ + @media (max-width: 1200px){ + @style(); + } +} +.choose(@type, @style) when (@type=lg){ + @media (max-width: 1366px){ + @style(); + } +} +.loop(@i,@style,@list) when (@i