diff --git a/CHANGELOG.md b/CHANGELOG.md
index 17f9434..6f43ef8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,13 @@
更新记录
==========
+2.5.2
+------
+
+1. 修复 `alert_error` 和 `alert_warning` 接口的模态对话框。
+2. 支持解析xresloader的warning日志。
+3. 修复log文件的输出被转义的问题。
+
2.5.1
------
diff --git a/package-lock.json b/package-lock.json
index be93373..cd816db 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "xresconv-gui",
- "version": "2.5.1",
+ "version": "2.5.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "xresconv-gui",
- "version": "2.5.1",
+ "version": "2.5.2",
"license": "MIT",
"dependencies": {
"@popperjs/core": "^2.11.8",
diff --git a/package.json b/package.json
index ca69f90..7171e31 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "xresconv-gui",
- "version": "2.5.1",
+ "version": "2.5.2",
"publisher": "owent",
"description": "xresconv 批量转表工具-GUI\r ==========",
"main": "src/setup.js",
diff --git a/src/index.html b/src/index.html
index 7ca24c4..1217f5c 100644
--- a/src/index.html
+++ b/src/index.html
@@ -180,13 +180,13 @@
@@ -202,8 +202,8 @@ 高并行度警告
diff --git a/src/main.js b/src/main.js
index 899883f..74a5985 100644
--- a/src/main.js
+++ b/src/main.js
@@ -1,4 +1,5 @@
// WebKit的编码转换有点奇怪的
+const bootstrap = require("bootstrap");
var conv_data = {};
var xconv_gui_options = {
@@ -199,106 +200,107 @@ function logger_append_style_message(msg, module_name, style) {
conv_data.gui.append_log_callback_guard = false;
}
+ const log_item = document.createElement("div");
+ log_item.className = `alert ${log_object.style} alert-compact`;
+ log_item.setAttribute("role", "alert");
+
if (run_log) {
if (log_object.module_name) {
- run_log.append(
- `
[${
- log_object.module_name
- }]: ${log_object.message.toString()}
`
- );
+ log_item.innerHTML = `[${
+ log_object.module_name
+ }]: ${log_object.message.toString()}`;
} else {
- run_log.append(
- `${log_object.message.toString()}
`
- );
+ log_item.innerHTML = log_object.message.toString();
}
+ run_log.append(log_item);
run_log.scrollTop(run_log.prop("scrollHeight"));
}
+
+ return log_item;
}
function logger_append_info_message(msg, module_name) {
if (msg instanceof Error) {
- logger_append_error_message(
+ return logger_append_error_message(
logger_format_exception_message(msg, module_name),
module_name
);
- return;
}
- logger_append_style_message(msg, module_name, "alert-secondary");
+ const ret = logger_append_style_message(msg, module_name, "alert-secondary");
if (log4js) {
const log = log4js.getLogger(module_name);
if (log) {
- log.info(msg);
+ log.info(ret.innerText);
}
}
+ return ret;
}
function logger_append_notice_message(msg, module_name) {
if (msg instanceof Error) {
- logger_append_error_message(
+ return logger_append_error_message(
logger_format_exception_message(msg, module_name),
module_name
);
- return;
}
- logger_append_style_message(msg, module_name, "alert-primary");
+ const ret = logger_append_style_message(msg, module_name, "alert-primary");
if (log4js) {
const log = log4js.getLogger(module_name);
if (log) {
- log.info(msg);
+ log.info(ret.innerText);
}
}
+ return ret;
}
function logger_append_warning_message(msg, module_name, need_alert) {
if (msg instanceof Error) {
- logger_append_error_message(
+ return logger_append_error_message(
logger_format_exception_message(msg, module_name),
module_name,
need_alert
);
- return;
}
- logger_append_style_message(msg, module_name, "alert-warning");
- console.warn(msg);
+ const ret = logger_append_style_message(msg, module_name, "alert-warning");
+ console.warn(ret.innerText);
if (log4js) {
const log = log4js.getLogger(module_name);
if (log) {
- log.warn(msg);
+ log.warn(ret.innerText);
}
}
if (need_alert) {
- alert_error(msg);
+ alert_error(ret.innerHTML);
}
+ return ret;
}
function logger_append_error_message(msg, module_name, need_alert) {
if (msg instanceof Error) {
- logger_append_error_message(
+ return logger_append_error_message(
logger_format_exception_message(msg, module_name),
module_name,
need_alert
);
- return;
}
- logger_append_style_message(msg, module_name, "alert-danger");
- console.error(msg);
+ const ret = logger_append_style_message(msg, module_name, "alert-danger");
+ console.error(ret.innerText);
if (log4js) {
const log = log4js.getLogger(module_name);
if (log) {
- log.error(msg);
+ log.error(ret.innerText);
}
}
if (need_alert) {
- alert_error(msg);
+ alert_error(ret.innerHTML);
}
+ return ret;
}
function logger_format_exception_message(err, module_name, msg) {
@@ -835,22 +837,30 @@ function setup_custom_selectors() {
}
function alert_error(content, title) {
- jQuery("#dlg_alert_error_title", "#dlg_alert_error_modal").html(
- title || "出错啦"
- );
- jQuery("#dlg_alert_error_content", "#dlg_alert_error_modal").html(
- content || ""
- );
- jQuery("#dlg_alert_error_modal").modal();
+ const title_dom = document.getElementById("dlg_alert_error_title");
+ if (title_dom) {
+ title_dom.innerHTML = title || "出错啦";
+ }
+ const content_dom = document.getElementById("dlg_alert_error_content");
+ if (content_dom) {
+ content_dom.innerHTML = content || "";
+ }
+ const modal_dom = document.getElementById("dlg_alert_error_modal");
+ if (modal_dom) {
+ if (!modal_dom.bootstrapModal) {
+ modal_dom.bootstrapModal = new bootstrap.Modal(modal_dom);
+ }
+ modal_dom.bootstrapModal.show();
+ }
}
function alert_warning(content, tittle, options) {
options = options || {};
- const dlg = $("#dlg_parallelism_warning_modal");
- const dlg_body = $("#dlg_parallelism_warning_content", dlg);
- const dlg_head = $("#dlg_parallelism_warning_title", dlg);
- dlg_body.empty().append(content || "无内容,参数错误");
- dlg_head.empty().append(tittle || "警告");
+ const dlg = document.getElementById("dlg_parallelism_warning_modal");
+ const dlg_body = document.getElementById("dlg_parallelism_warning_content");
+ const dlg_head = document.getElementById("dlg_parallelism_warning_title");
+ dlg_body.innerHTML = content || "无内容,参数错误";
+ dlg_head.innerHTML = tittle || "警告";
const btn_yes = $(
''
@@ -859,7 +869,9 @@ function alert_warning(content, tittle, options) {
''
);
btn_yes.on("click", function () {
- dlg.modal("hide");
+ if (dlg.bootstrapModal) {
+ dlg.bootstrapModal.hide();
+ }
if (typeof options.yes == "function") {
options.yes.apply(this, [arguments]);
}
@@ -869,7 +881,9 @@ function alert_warning(content, tittle, options) {
});
btn_no.on("click", function () {
- dlg.modal("hide");
+ if (dlg.bootstrapModal) {
+ dlg.bootstrapModal.hide();
+ }
if (typeof options.no == "function") {
options.no.apply(this, [arguments]);
}
@@ -880,7 +894,10 @@ function alert_warning(content, tittle, options) {
});
$(".modal-footer", dlg).empty().append(btn_yes).append(btn_no);
- dlg.modal("show");
+ if (!dlg.bootstrapModal) {
+ dlg.bootstrapModal = new bootstrap.Modal(dlg);
+ }
+ dlg.bootstrapModal.show();
}
(function ($, window) {
@@ -1774,9 +1791,9 @@ function alert_warning(content, tittle, options) {
"IO",
`尝试读取文件失败: ${file_path}`
);
- logger_append_error_message(msg);
- console.error(err);
- alert(msg);
+ const log_item = logger_append_error_message(msg);
+ console.error(log_item.innerText);
+ alert(log_item.innerText);
reject.apply(this, [msg]);
});
@@ -2034,10 +2051,11 @@ function alert_warning(content, tittle, options) {
function run_one_cmd(xresloader_index, xresloader_proc) {
let msg;
+ let log_item;
if (pending_script.length > 0 && conv_data.run_seq == run_seq) {
var cmd = pending_script.pop();
msg = `[CONV ${xresloader_index}] ${cmd}\r\n`;
- logger_append_info_message(
+ log_item = logger_append_info_message(
shell_color_to_html(cmd),
`[CONV ${xresloader_index}]`
);
@@ -2053,11 +2071,11 @@ function alert_warning(content, tittle, options) {
}
msg = `[Process ${xresloader_proc.index} close stdin.]\r\n`;
- logger_append_info_message(msg, null);
+ log_item = logger_append_info_message(msg, null);
}
if (logger) {
- logger.info(msg);
+ logger.info(log_item.innerText);
}
}
@@ -2072,14 +2090,14 @@ function alert_warning(content, tittle, options) {
const msg = `[${work_dir}] Process ${xresloader_index} : ${xresloader_cmds.join(
" "
)}\r\n`;
- logger_append_info_message(
+ const log_item = logger_append_info_message(
shell_color_to_html(
`Process ${xresloader_index} : ${xresloader_cmds.join(" ")}\r\n`
),
`${work_dir}`
);
if (logger) {
- logger.info(msg);
+ logger.info(log_item.innerText);
}
console.log("start xresloader at " + work_dir);
@@ -2135,22 +2153,34 @@ function alert_warning(content, tittle, options) {
xresloader_proc.exec.on("close", handle_exit_fn);
xresloader_proc.exec.stdout.on("data", function (data) {
- logger_append_notice_message(
+ const log_item = logger_append_notice_message(
"" +
shell_color_to_html(data) +
""
);
if (logger) {
- logger.info(data);
+ logger.info(log_item.innerText);
}
run_log.scrollTop(run_log.prop("scrollHeight"));
run_one_cmd(xresloader_index, xresloader_proc);
});
xresloader_proc.exec.stderr.on("data", function (data) {
- logger_append_error_message(shell_color_to_html(data));
- if (logger) {
- logger.error(data);
+ const data_str = data ? data.toString() : "";
+ if (data_str && data_str.substr(0, 5).toLowerCase() == "[warn") {
+ const log_item = logger_append_warning_message(
+ shell_color_to_html(data_str)
+ );
+ if (logger) {
+ logger.warn(log_item.innerText);
+ }
+ } else {
+ const log_item = logger_append_error_message(
+ shell_color_to_html(data_str)
+ );
+ if (logger) {
+ logger.error(log_item.innerText);
+ }
}
run_log.scrollTop(run_log.prop("scrollHeight"));
run_one_cmd(xresloader_index, xresloader_proc);
@@ -2381,8 +2411,11 @@ function alert_warning(content, tittle, options) {
run_log.scrollTop(run_log.prop("scrollHeight"));
});
} catch (err) {
- logger_append_error_message(logger_format_exception_message(err), "CONV");
- console.error(err);
+ const log_item = logger_append_error_message(
+ logger_format_exception_message(err),
+ "CONV"
+ );
+ console.error(log_item.innerText);
alert("出错啦: " + err.toString());
}
}
diff --git a/yarn.lock b/yarn.lock
index 2d081a4..4fb31d5 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2276,7 +2276,7 @@ xmlbuilder@^9.0.7:
integrity sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=
"xresconv-gui@file:":
- version "2.5.1"
+ version "2.5.2"
resolved "file:"
dependencies:
"@popperjs/core" "^2.11.8"