Skip to content

Commit

Permalink
fixup setConfig API & 支持隐藏全部/部分参数分组
Browse files Browse the repository at this point in the history
  • Loading branch information
CcSimple committed Aug 19, 2024
1 parent 39a91a1 commit 456fd09
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/hiprint/hiprint.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -10297,7 +10297,7 @@ var hiprint = function (t) {
var r;
if (tabs.length) {
r = $('<div class="prop-tabs"><ul class="prop-tab-items"></ul></div>');
tabs.filter((e) => e.list.length > 0).forEach(function (tab) {
tabs.filter((e,idx) => e.list.length > 0 || (idx == 2 && o && o.length)).forEach(function (tab) {
var item = $('<li class="prop-tab-item"><span class="tab-title">' + i18n.__(tab.name) + '</span></li>')
r.find('.prop-tab-items').append(item)
var options = $('<div class="hiprint-option-items" data-title="' + i18n.__(tab.name) + '"></div>')
Expand Down Expand Up @@ -11163,6 +11163,10 @@ var hiprint = function (t) {
}

function cig(t) {
if (hiprint._config == void 0) {
hiprint._config = JSON.stringify(window.HIPRINT_CONFIG);
}
const oldConfig = JSON.parse(hiprint._config);
if (t) {
t && Object.keys(t).forEach(function (i) {
if (i == "optionItems" && t.optionItems && t.optionItems.length) {
Expand All @@ -11173,7 +11177,7 @@ var hiprint = function (t) {
if (tab.replace) {
$.extend(p.a.instance[i].tabs[idx], tab);
} else {
var options = tab.options || [], list = p.a.instance[i].tabs[idx].options;
var options = tab.options || [], list = oldConfig[i].tabs[idx].options;
options && options.forEach(function (o) {
var idx = list.findIndex(function (e) {
return e.name == o.name
Expand All @@ -11197,7 +11201,7 @@ var hiprint = function (t) {
delete t[i].tabs;
}
else if (t[i].supportOptions && t[i].supportOptions.length) {
var options = t[i].supportOptions, list = p.a.instance[i].supportOptions;
var options = t[i].supportOptions, list = oldConfig[i].supportOptions;
options.forEach(function (o) {
var idx = list.findIndex(function (e) {
return e.name == o.name
Expand All @@ -11218,13 +11222,13 @@ var hiprint = function (t) {
var keyMap = {};
keyMap[i] = t[i];
if (t[i].tabs && t[i].tabs.length == 0) {
keyMap[i].supportOptions = p.a.instance[i].supportOptions;
keyMap[i].supportOptions = oldConfig[i].supportOptions;
}
$.extend(p.a.instance, keyMap);
}
});
} else {
$.extend(p.a.instance, HIPRINT_CONFIG);
$.extend(p.a.instance, JSON.parse(hiprint._config));
}
}

Expand Down

0 comments on commit 456fd09

Please sign in to comment.