Merge pull request #1126 from layui/2.x

进一步优化代码构建,适配 v2.8.x
This commit is contained in:
贤心 2022-08-31 01:59:50 +08:00 committed by GitHub
commit d0dd3fde8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 37 additions and 23 deletions

View File

@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>完整库使用 - layui</title>
<link rel="stylesheet" href="../src/css/layui.css">
<link rel="stylesheet" href="../dist/css/layui.css">
<style>
body{padding: 10px;}
@ -187,7 +187,7 @@ layui.use(function(){
});
}
,'test-use': function(othis){
layui.use(['laytpl','laypage','laydate','jquery','layer','util','element','upload','slider','colorpicker','form','tree','transfer','table','carousel','rate','flow','layedit','code'], function(){
layui.use(['laytpl','laypage','laydate','jquery','layer','util','element','upload','slider','colorpicker','form','tree','transfer','table','carousel','rate','flow','code'], function(){
layer.tips('请观察 Network 是否有重复加载 js 文件。如果没有任何新的请求,则代表正常。', othis, {
time: 10*1000
});

View File

@ -17,11 +17,11 @@ const yargs = require('yargs');
const config = {
//注释
comment: [
'/** <%= pkg.version %> | <%= pkg.license %> Licensed */<%= js %>'
'/** v<%= pkg.version %> | <%= pkg.license %> Licensed */<%= js %>'
,{pkg: pkg, js: ';'}
]
//模块
,modules: 'lay,laytpl,laypage,laydate,jquery,layer,util,dropdown,slider,colorpicker,element,upload,form,table,tree,transfer,carousel,rate,flow,layedit,code'
,modules: 'lay,laytpl,laypage,laydate,jquery,layer,util,dropdown,slider,colorpicker,element,upload,form,table,tree,transfer,carousel,rate,flow,code'
};
// 获取参数
@ -60,13 +60,14 @@ const js = () => {
// css
const css = () => {
let src = [
'./src/css/**/*.css'
,'!./src/css/**/font.css'
'./src/css/layui.css',
'./src/css/modules/**/*.css',
'!./src/css/**/font.css'
];
return gulp.src(src).pipe(cleanCSS({
compatibility: 'ie8'
}))
//.pipe(concat('layui.css', {newLine: ''}))
.pipe(concat('layui.css', {newLine: ''}))
.pipe(gulp.dest(dest +'/css'));
};
@ -113,14 +114,13 @@ exports.rls = gulp.series(cleanRLS, rls); //release task
exports.layer = () => { // gulp layer
let dest = './release/layer';
gulp.src('./src/css/modules/layer/default/*')
.pipe(gulp.dest(dest + '/src/theme/default'));
gulp.src('./src/css/modules/layer.css')
.pipe(gulp.dest(dest + '/src'));
return gulp.src('./src/modules/layer.js')
.pipe(gulp.dest(dest + '/src'));
};
// laydate task
exports.laydate = () => { // gulp laydate
let dest = './release/laydate/'; // 发行目录
@ -131,7 +131,7 @@ exports.laydate = () => { // gulp laydate
// css
gulp.src('./src/css/modules/laydate.css')
.pipe(gulp.dest(dest + 'src/'));
.pipe(gulp.dest(dest + 'src'));
// js
return gulp.src(['./src/layui.js', './src/modules/{lay,laydate}.js'])

View File

@ -1,6 +1,6 @@
{
"name": "layui",
"version": "2.7.6",
"version": "2.8.0-beta.1",
"description": "Classic modular Front-End UI library",
"main": "dist/layui.js",
"license": "MIT",

View File

@ -15,7 +15,7 @@
}
,Layui = function(){
this.v = '2.7.6'; // layui 版本号
this.v = '2.8.0-beta.1'; // Layui 版本号
}
//识别预先可能定义的指定全局对象
@ -54,7 +54,6 @@
,laydate: 'laydate' //日期
,laypage: 'laypage' //分页
,laytpl: 'laytpl' //模板引擎
,layedit: 'layedit' //富文本编辑器
,form: 'form' //表单集
,upload: 'upload' //上传
,dropdown: 'dropdown' //下拉菜单

View File

@ -96,4 +96,9 @@ layui.define(['lay', 'util'], function(exports){
});
});
}).addcss('modules/code.css?v=3', 'skincodecss');
});
// 若为源码版,则自动加载该组件依赖的 css 文件
if(!layui['layui.all']){
layui.addcss('modules/code.css?v=3', 'skincodecss');
}

View File

@ -24,7 +24,7 @@
//外部调用
,laydate = {
v: '5.3.1' //layDate 版本号
v: '5.4.0' //layDate 版本号
,config: {
weekStart: 0, // 默认周日一周的开始
} //全局配置项
@ -39,10 +39,17 @@
}
// 主体 CSS 等待事件
,ready: function(fn){
var cssname = 'laydate', ver = ''
,path = (isLayui ? 'modules/' : 'css/') + 'laydate.css?v='+ laydate.v + ver;
isLayui ? layui.addcss(path, fn, cssname) : ready.link(path, fn, cssname);
,ready: function(callback){
var cssname = 'laydate';
var ver = ''
var path = (isLayui ? 'modules/' : 'css/') + 'laydate.css?v='+ laydate.v + ver;
isLayui ? (
layui['layui.all']
? (typeof callback === 'function' && callback())
: layui.addcss(path, callback, cssname)
) : ready.link(path, callback, cssname);
return this;
}
}

View File

@ -120,15 +120,18 @@ var layer = {
return this;
},
//主体 CSS 等待事件
// 主体 CSS 等待事件
ready: function(callback){
var cssname = 'layer', ver = ''
,path = (isLayui ? 'modules/' : 'css/') + 'layer.css?v='+ layer.v + ver;
var cssname = 'layer';
var ver = '';
var path = (isLayui ? 'modules/' : 'css/') + 'layer.css?v='+ layer.v + ver;
isLayui ? (
layui['layui.all']
? (typeof callback === 'function' && callback())
: layui.addcss(path, callback, cssname)
) : ready.link(path, callback, cssname);
return this;
},