Skip to content

Commit be4ed47

Browse files
authored
Merge pull request #546 from wenzhixin/feature/welcomes
Rebuild welcomes to es6 and fix some errors
2 parents 8a36d41 + 340eb45 commit be4ed47

File tree

89 files changed

+1449
-990
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1449
-990
lines changed

assets/js/template.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ function _scripts (scripts, callback) {
106106
}
107107

108108
function _themeUpdate (_data) {
109-
const data = _data.replace('<template>', '').replace('</template>', '')
109+
const data = _data
110110

111111
if (/bootstrap3.html$/.test(location.pathname)) {
112112
return data.replace(/btn-secondary/g, 'btn-default')
@@ -151,25 +151,33 @@ function _beautifySource (data) {
151151
let lines = data.split('\n')
152152
const scriptStart = lines.indexOf('<script>')
153153
const scriptEnd = lines.indexOf('</script>', scriptStart)
154-
let strings = lines.slice(scriptStart + 1, scriptEnd)
154+
const strings = lines.slice(scriptStart + 1, scriptEnd)
155+
.map(s => s.trim())
156+
const templateStart = lines.indexOf('<template>')
157+
const templateEnd = lines.indexOf('</template>', scriptStart)
158+
const templates = lines.slice(templateStart + 1, templateEnd)
159+
.map(s => s.replace(/^ {2}/, ''))
155160

156-
strings = $.map(strings, function (s) {
157-
return $.trim(s)
158-
})
159161
/* eslint-disable no-control-regex */
160162
const obj = eval(`(${strings.join('').replace(/[^\u0000-\u007E]/g, '')
161163
.replace(/^init\((.*)\)$/, '$1')})`)
162164

163165
let result = []
166+
const addEmptyLine = () => {
167+
if (result[result.length - 1] !== '') {
168+
result.push('')
169+
}
170+
}
164171

165172
result = result.concat($.map(obj.links, _getLink))
166-
result.push('')
173+
addEmptyLine()
167174
result = result.concat($.map(obj.scripts, function (script) {
168175
return _getScript(script, true)
169176
}))
170-
lines = result.concat(lines.slice(scriptEnd + 1))
177+
addEmptyLine()
178+
lines = result.concat(templates, lines.slice(templateEnd + 1))
171179

172-
const mountedStart = lines.indexOf(' function mounted() {')
180+
const mountedStart = lines.indexOf(' function mounted () {')
173181
const mountedEnd = lines.indexOf(' }', mountedStart)
174182

175183
lines[mountedStart] = ' $(function() {'
@@ -205,7 +213,9 @@ $(function () {
205213
$('#source').text(_beautifySource(data))
206214
window.hljs.highlightAll()
207215
} else {
208-
$('#example').html(data.replace(/ data-toggle="table"/g, ' data-toggle="bootstrap-table"'))
216+
$('#example').html(data
217+
.replace('<template>', '').replace('</template>', '')
218+
.replace(/ data-toggle="table"/g, ' data-toggle="bootstrap-table"'))
209219
}
210220
},
211221
error () {

crud/index.html

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ <h5 class="modal-title"></h5>
7777
stargazers_count: 0,
7878
forks_count: 0,
7979
description: ''
80-
} // default row value
80+
} // default row value
8181

8282
$modal.data('id', row.id)
8383
$modal.find('.modal-title').text(title)
@@ -90,7 +90,7 @@ <h5 class="modal-title"></h5>
9090
}
9191

9292
function showAlert (title, type) {
93-
$alert.attr('class', `alert alert-${type}` || 'success')
93+
$alert.attr('class', `alert alert-${type || 'success'}`)
9494
.html(`<i class="glyphicon glyphicon-check"></i> ${title}`).show()
9595
setTimeout(function () {
9696
$alert.hide()
@@ -128,12 +128,10 @@ <h5 class="modal-title"></h5>
128128
field: 'action',
129129
title: 'Action',
130130
align: 'center',
131-
formatter: function actionFormatter (value) {
132-
return [
133-
'<a class="update mr10" href="javascript:" title="Update Item"><i class="fa fa-edit"></i></a>',
134-
'<a class="remove" href="javascript:" title="Delete Item"><i class="fa fa-remove"></i></a>'
135-
].join('')
136-
},
131+
formatter: () => [
132+
'<a class="update mr10" href="javascript:" title="Update Item"><i class="fa fa-edit"></i></a>',
133+
'<a class="remove" href="javascript:" title="Delete Item"><i class="fa fa-remove"></i></a>'
134+
].join(''),
137135
events: {
138136
'click .update' (e, value, row) {
139137
showModal($(e.currentTarget).attr('title'), row)

eslint.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import eslintConfig from 'bootstrap-table/eslint.config.js'
2+
import html from 'eslint-plugin-html'
23
import vue from 'eslint-plugin-vue'
34

45
const globals = eslintConfig[eslintConfig.length - 1].languageOptions.globals
@@ -14,6 +15,10 @@ export default [
1415
'webpack-starter/'
1516
]
1617
},
18+
{
19+
files: ['**/*.html'],
20+
plugins: { html }
21+
},
1722
...eslintConfig,
1823
...vue.configs['flat/recommended'],
1924
{

extensions/custom-view.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ <h3 class="mb-0">%SNIPPETS%</h3>
215215
})
216216
}
217217

218-
function customViewFormatter (data) {
218+
window.customViewFormatter = data => {
219219
const template = $('#profileTemplate').html()
220220
let view = ''
221221

extensions/fixed-columns.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
checkbox: true,
9191
valign: 'middle'
9292
}
93-
]
93+
]
9494
const data = []
9595

9696
for (i = 0; i < cells; i++) {

extensions/treegrid.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
})
6565
}
6666

67-
function typeFormatter (value, row, index) {
67+
window.typeFormatter = value => {
6868
if (value === 'menu') {
6969
return '菜单'
7070
}
@@ -77,7 +77,7 @@
7777
return '-'
7878
}
7979

80-
function statusFormatter (value, row, index) {
80+
window.statusFormatter = value => {
8181
if (value === 1) {
8282
return '<span class="label label-success">正常</span>'
8383
}

issues/1167.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@
5151
</template>
5252

5353
<script>
54-
var $table = $('#table')
54+
const $table = $('#table')
5555

56-
function mounted() {
56+
function mounted () {
5757
$('#checkAll').click(function () {
5858
$table.bootstrapTable('togglePagination').bootstrapTable('checkAll').bootstrapTable('togglePagination')
5959
})

issues/137.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@
3737
</template>
3838

3939
<script>
40-
var $table = $('#table')
41-
function mounted() {
40+
const $table = $('#table')
41+
42+
function mounted () {
4243
$table.bootstrapTable({
4344
data: [
4445
{
@@ -49,7 +50,7 @@
4950
]
5051
})
5152
$('#button').click(function () {
52-
$table.bootstrapTable('refresh', {url: 'json/data1.json'})
53+
$table.bootstrapTable('refresh', { url: 'json/data1.json' })
5354
})
5455
}
5556
</script>

issues/152.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@
6565
</template>
6666

6767
<script>
68-
function queryParams(params) {
68+
window.queryParams = params => {
6969
params.your_param1 = 1 // add param1
7070
params.your_param2 = 2 // add param2
7171
// console.log(JSON.stringify(params));
7272
// {"limit":10,"offset":0,"order":"asc","your_param1":1,"your_param2":2}
7373
return params
7474
}
7575

76-
function postQueryParams(params) {
76+
window.postQueryParams = params => {
7777
params.your_param1 = 1 // add param1
7878
params.your_param2 = 2 // add param2
7979
return params // body data

issues/177.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,31 @@
1212
</template>
1313

1414
<script>
15-
var data = [
15+
const data = [
1616
{
17-
'firstName': 'zhixin',
18-
'lastName': 'wen',
19-
'field1': 'field1',
20-
'field2': 'field2',
21-
'field3': 'field3'
17+
firstName: 'zhixin',
18+
lastName: 'wen',
19+
field1: 'field1',
20+
field2: 'field2',
21+
field3: 'field3'
2222
}
2323
]
2424

25-
function mounted() {
25+
function mounted () {
2626
$('#table').bootstrapTable({
27-
data: data,
27+
data,
2828
columns: [
2929
{
3030
field: 'fullName',
3131
title: 'Full Name',
32-
formatter: function (value, row) {
32+
formatter (value, row) {
3333
return [row.firstName, row.lastName].join(' ')
3434
}
3535
},
3636
{
3737
field: 'field',
3838
title: 'Field',
39-
formatter: function (value, row) {
39+
formatter (value, row) {
4040
return [row.field1, row.field2, row.field3].join('+')
4141
}
4242
}

0 commit comments

Comments
 (0)