mirror of
https://gitee.com/layui/layui.git
synced 2025-11-24 08:33:12 +08:00
chore: 优化打包工具,修复 IE11 下的若干报错 (#2920)
* build: 修复 git 在 Windows 中的换行符转换问题 * fix: 修复 IE11 下的若干异常问题 * build: 优化打包脚本,确保模块正确的顺序 原计划升级 gulp 5(因 npm audit 提示 gulp 4 漏洞),但由于其改动太大,考虑到 v2 已作为 stable 版本,暂时保留现状。 * Update src/modules/laydate.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore(laydate): 格式化代码 --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
||||
* text=auto eol=lf
|
||||
@@ -358,10 +358,7 @@
|
||||
|
||||
// 局部自定义标签符
|
||||
laytpl(
|
||||
`
|
||||
<% var job = ["前端工程师"]; %>
|
||||
<%= d.name %>是一名<%= job[d.index] %>。
|
||||
`,
|
||||
'<% var job = ["前端工程师"]; %><%= d.name %>是一名<%= job[d.index] %>。',
|
||||
{
|
||||
open: '<%',
|
||||
close: '%>'
|
||||
|
||||
@@ -262,10 +262,13 @@
|
||||
console.log('beforeClose', data);
|
||||
|
||||
// 关闭确认提示
|
||||
layer.confirm(`确定关闭标签「${this.innerText}」吗?`, function (i) {
|
||||
layer.confirm(
|
||||
'确定关闭标签「' + this.innerText + '」吗?',
|
||||
function (i) {
|
||||
tabs.close('demoTabs1', data.index, true); // 强制关闭对应的标签项
|
||||
layer.close(i); // 关闭确认框
|
||||
});
|
||||
}
|
||||
);
|
||||
return false; // 阻止标签默认关闭
|
||||
});
|
||||
|
||||
|
||||
@@ -261,7 +261,7 @@
|
||||
var dateString = util.toDateString(new Date(), format);
|
||||
$('#test3').html(dateString);
|
||||
};
|
||||
timer = setInterval(() => {
|
||||
timer = setInterval(function () {
|
||||
toDateString($('#test2').val());
|
||||
}, 50);
|
||||
|
||||
|
||||
32
gulpfile.js
32
gulpfile.js
@@ -9,19 +9,16 @@ const sourcemaps = require('gulp-sourcemaps');
|
||||
const zip = require('gulp-zip');
|
||||
const del = require('del');
|
||||
const minimist = require('minimist');
|
||||
const yargs = require('yargs');
|
||||
const pkg = require('./package.json');
|
||||
|
||||
// 基础配置
|
||||
const config = {
|
||||
// 头部注释
|
||||
comment: [
|
||||
'/** v<%= pkg.version %> | <%= pkg.license %> Licensed */<%= js %>',
|
||||
{ pkg: pkg, js: ';' }
|
||||
],
|
||||
comment: `/** v${pkg.version} | ${pkg.license} Licensed */;`,
|
||||
|
||||
// 全部模块
|
||||
modules:
|
||||
'lay,i18n,laytpl,laypage,laydate,jquery,component,layer,util,dropdown,slider,colorpicker,tab,nav,breadcrumb,progress,collapse,element,upload,form,table,treeTable,tabs,tree,transfer,carousel,rate,flow,code'
|
||||
'layui.all,lay,i18n,laytpl,laypage,laydate,jquery,component,layer,util,dropdown,slider,colorpicker,tab,nav,breadcrumb,progress,collapse,element,upload,form,table,treeTable,tabs,tree,transfer,carousel,rate,flow,code'
|
||||
};
|
||||
|
||||
// 获取参数
|
||||
@@ -45,7 +42,10 @@ const dest = './dist';
|
||||
|
||||
// js
|
||||
const js = () => {
|
||||
let src = ['./src/**/{layui,layui.all,' + config.modules + '}.js'];
|
||||
let src = [
|
||||
'./src/layui.js',
|
||||
...config.modules.split(',').map((mod) => `./src/modules/${mod}.js`)
|
||||
];
|
||||
return gulp
|
||||
.src(src)
|
||||
.pipe(sourcemaps.init())
|
||||
@@ -58,7 +58,7 @@ const js = () => {
|
||||
})
|
||||
)
|
||||
.pipe(concat('layui.js', { newLine: '' }))
|
||||
.pipe(header.apply(null, config.comment))
|
||||
.pipe(header(config.comment))
|
||||
.pipe(sourcemaps.write('.'))
|
||||
.pipe(gulp.dest(dest));
|
||||
};
|
||||
@@ -141,10 +141,14 @@ exports.release = gulp.series(
|
||||
}
|
||||
);
|
||||
|
||||
// helper
|
||||
exports.help = () => {
|
||||
let usage = '\nUsage: gulp [options] tasks';
|
||||
let parser = yargs.usage(usage, {
|
||||
/**
|
||||
* 显示 gulp tasks 命令行帮助
|
||||
* 由于 gulp-cli 依赖了 yargs,此处直接使用
|
||||
* @returns
|
||||
*/
|
||||
exports.helper = () => {
|
||||
let usage = '\nUsage: gulp [options] tasks\n';
|
||||
let parser = require('yargs').options({
|
||||
dest: {
|
||||
type: 'string',
|
||||
desc: '自定义输出路径'
|
||||
@@ -154,11 +158,11 @@ exports.help = () => {
|
||||
desc: '生成一个带版本号的文件夹'
|
||||
}
|
||||
});
|
||||
|
||||
console.log(usage);
|
||||
parser.showHelp(console.log);
|
||||
console.log(
|
||||
[
|
||||
'Tasks:',
|
||||
'\nTasks:',
|
||||
' default 默认任务',
|
||||
' release 发行任务',
|
||||
' cp 将 dist 目录复制一份到参数 --dest 指向的目录'
|
||||
|
||||
@@ -188,6 +188,7 @@ layui.define(['lay', 'i18n'], function (exports) {
|
||||
YearBeforeMonthLocale.indexOf(options.lang) > -1
|
||||
);
|
||||
} else {
|
||||
try {
|
||||
var formatter = new Intl.DateTimeFormat(options.lang, {
|
||||
year: 'numeric',
|
||||
month: 'short'
|
||||
@@ -200,6 +201,11 @@ layui.define(['lay', 'i18n'], function (exports) {
|
||||
}
|
||||
});
|
||||
that.i18nMessages.monthBeforeYear = order[0] === 'month';
|
||||
} catch (e) {
|
||||
that.i18nMessages.monthBeforeYear = !(
|
||||
YearBeforeMonthLocale.indexOf(options.lang) > -1
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user