新增html转义函数

优化插件管理标题和描述
pull/462/MERGE
Karson 2024-03-27 17:40:08 +08:00
parent a5e1fe9cb6
commit 7c9841cee9
2 changed files with 24 additions and 2 deletions

View File

@ -115,7 +115,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'cookie']
align: 'left', align: 'left',
formatter: Controller.api.formatter.title formatter: Controller.api.formatter.title
}, },
{field: 'intro', title: __('Intro'), operate: 'LIKE', align: 'left', class: 'visible-lg'}, {
field: 'intro',
title: __('Intro'),
operate: 'LIKE',
align: 'left',
class: 'visible-lg',
formatter: Controller.api.formatter.intro
},
{ {
field: 'author', field: 'author',
title: __('Author'), title: __('Author'),
@ -710,12 +717,15 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'cookie']
if ($(".btn-switch.active").data("type") == "local") { if ($(".btn-switch.active").data("type") == "local") {
// return value; // return value;
} }
var title = '<a class="title" href="' + row.url + '" data-toggle="tooltip" title="' + __('View addon home page') + '" target="_blank">' + value + '</a>'; var title = '<a class="title" href="' + row.url + '" data-toggle="tooltip" title="' + __('View addon home page') + '" target="_blank"><span class="' + Fast.api.escape(row.color) + '">' + value + '</span></a>';
if (row.screenshots && row.screenshots.length > 0) { if (row.screenshots && row.screenshots.length > 0) {
title += ' <a href="javascript:;" data-index="' + index + '" class="view-screenshots text-success" title="' + __('View addon screenshots') + '" data-toggle="tooltip"><i class="fa fa-image"></i></a>'; title += ' <a href="javascript:;" data-index="' + index + '" class="view-screenshots text-success" title="' + __('View addon screenshots') + '" data-toggle="tooltip"><i class="fa fa-image"></i></a>';
} }
return title; return title;
}, },
intro: function (value, row, index) {
return row.intro + (row.extend ? "<a href='" + Fast.api.escape(row.extend[1]) + "' class='" + Fast.api.escape(row.extend[2]) + "'>" + Fast.api.escape(row.extend[0]) + "</a>" : "");
},
operate: function (value, row, index) { operate: function (value, row, index) {
return Template("operatetpl", {item: row, index: index}); return Template("operatetpl", {item: row, index: index});
}, },

View File

@ -278,6 +278,18 @@ define(['jquery', 'bootstrap', 'toastr', 'layer', 'lang'], function ($, undefine
time: 2000 time: 2000
}, callback); }, callback);
}, },
escape: function (text) {
if (typeof text === 'string') {
return text
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#039;')
.replace(/`/g, '&#x60;');
}
return text;
},
toastr: Toastr, toastr: Toastr,
layer: Layer layer: Layer
}, },