ci: auto build & obfuscate [2026-04-23 00:35:57] (Jenkins #17)

This commit is contained in:
Jenkins CI
2026-04-23 00:35:57 +08:00
parent 8d590073f4
commit 544937bb91
23 changed files with 160 additions and 84 deletions

View File

@@ -522,10 +522,11 @@ async function _fetchModels($c) {
let models;
if (provider === 'google') {
// Google 用原生 API以 ?key= 传参,返回 models[] 而非 data[]
// Google 用原生 APIKey 通过 x-goog-api-key 头传递避免 URL 泄露
if (!apiKey) { toastr.warning('请先填写 Google API Key。'); return; }
const resp = await fetch(
`https://generativelanguage.googleapis.com/v1beta/models?key=${encodeURIComponent(apiKey)}`
'https://generativelanguage.googleapis.com/v1beta/models',
{ headers: { 'x-goog-api-key': apiKey } }
);
if (!resp.ok) {
const status = resp.status;
@@ -614,7 +615,8 @@ async function _testConnection($c) {
return;
}
const resp = await fetch(
`https://generativelanguage.googleapis.com/v1beta/models?key=${encodeURIComponent(apiKey)}`
'https://generativelanguage.googleapis.com/v1beta/models',
{ headers: { 'x-goog-api-key': apiKey } }
);
if (resp.ok) {
const data = await resp.json();

View File

@@ -33,9 +33,9 @@ function escapeAttribute(text) {
}
function _populateHlyRuleProfileSelect(select, slot) {
const profiles = ruleProfileManager.listProfiles();
const assigned = ruleProfileManager.getAssignment(slot) || '';
function _populateHlyRuleProfileSelect(select, slot, detail) {
const profiles = detail?.profiles ?? ruleProfileManager.listProfiles();
const assigned = detail?.assignments?.[slot] ?? ruleProfileManager.getAssignment(slot) ?? '';
select.innerHTML = [
'<option value="">— 未分配 —</option>',
...profiles.map(p =>
@@ -414,9 +414,9 @@ function bindInternalUIEvents() {
}
// 规则配置中心保存/删除后自动刷新翰林院下拉选单
document.addEventListener('amily2:ruleProfilesChanged', () => {
if (condensationRuleSelect) _populateHlyRuleProfileSelect(condensationRuleSelect, 'condensation');
if (queryPrepRuleSelect) _populateHlyRuleProfileSelect(queryPrepRuleSelect, 'queryPreprocessing');
document.addEventListener('amily2:ruleProfilesChanged', (e) => {
if (condensationRuleSelect) _populateHlyRuleProfileSelect(condensationRuleSelect, 'condensation', e.detail);
if (queryPrepRuleSelect) _populateHlyRuleProfileSelect(queryPrepRuleSelect, 'queryPreprocessing', e.detail);
});
// 为自定义多选下拉框绑定事件
@@ -920,8 +920,8 @@ async function renderKnowledgeBases() {
} catch (error) {
console.error('[翰林院-枢纽] 渲染知识库列表失败:', error);
localContainer.innerHTML = `<p class="hly-notes log-error"><i>加载失败: ${error.message}</i></p>`;
globalContainer.innerHTML = `<p class="hly-notes log-error"><i>加载失败: ${error.message}</i></p>`;
localContainer.innerHTML = `<p class="hly-notes log-error"><i>加载失败: ${escapeTextareaContent(error.message)}</i></p>`;
globalContainer.innerHTML = `<p class="hly-notes log-error"><i>加载失败: ${escapeTextareaContent(error.message)}</i></p>`;
}
}
@@ -1020,8 +1020,8 @@ function _createKbItemElement(id, kb, scope, vectorCount) {
item.innerHTML = `
<div class="hly-kb-name-container">
<input type="checkbox" class="hly-kb-item-checkbox" data-kb-id="${id}">
<span class="hly-kb-name" title="ID: ${id}">${kb.name} (${vectorCount}条)</span>
<input type="checkbox" class="hly-kb-item-checkbox" data-kb-id="${escapeAttribute(id)}">
<span class="hly-kb-name" title="ID: ${escapeAttribute(id)}">${escapeTextareaContent(kb.name || '')} (${Number(vectorCount) || 0}条)</span>
</div>
<div class="hly-kb-actions">
${moveButtonHtml}
@@ -1529,11 +1529,11 @@ function updateEntryOptions(query, allEntries) {
filteredEntries.forEach(entry => {
const displayText = query ?
highlightSearchMatch(entry.comment, query) :
entry.comment;
escapeTextareaContent(entry.comment);
const optionHtml = `
<label class="hly-multiselect-option" title="${entry.comment} (Key: ${entry.key})">
<input type="checkbox" class="hly-hist-entry-checkbox" value="${entry.key}">
<label class="hly-multiselect-option" title="${escapeAttribute(entry.comment)} (Key: ${escapeAttribute(entry.key)})">
<input type="checkbox" class="hly-hist-entry-checkbox" value="${escapeAttribute(entry.key)}">
<span>${displayText}</span>
</label>`;
optionsContainer.insertAdjacentHTML('beforeend', optionHtml);
@@ -1778,7 +1778,7 @@ function log(message, type = 'info') {
}
p.className = `hly-log-entry ${colorClass}`;
p.innerHTML = `<i class="fa-solid ${icon}"></i> [${timestamp}] ${message}`;
p.innerHTML = `<i class="fa-solid ${escapeAttribute(icon)}"></i> [${escapeTextareaContent(timestamp)}] ${escapeTextareaContent(message)}`;
// 移除初始的占位符
const placeholder = logOutput.querySelector('.hly-log-placeholder');

View File

@@ -25,9 +25,9 @@ function _escapeHtml(text) {
return String(text ?? '').replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
}
function _populateHistRuleProfileSelect(select) {
const profiles = ruleProfileManager.listProfiles();
const assigned = ruleProfileManager.getAssignment('historiography') || '';
function _populateHistRuleProfileSelect(select, detail) {
const profiles = detail?.profiles ?? ruleProfileManager.listProfiles();
const assigned = detail?.assignments?.historiography ?? ruleProfileManager.getAssignment('historiography') ?? '';
select.innerHTML = [
'<option value="">— 未分配 —</option>',
...profiles.map(p =>
@@ -227,8 +227,8 @@ export function bindHistoriographyEvents() {
const name = histRuleSelect.selectedOptions[0]?.textContent || '';
toastr.info(histRuleSelect.value ? `史官提取规则已切换为「${name}` : '史官提取规则已取消分配');
});
document.addEventListener('amily2:ruleProfilesChanged', () => {
_populateHistRuleProfileSelect(histRuleSelect);
document.addEventListener('amily2:ruleProfilesChanged', (e) => {
_populateHistRuleProfileSelect(histRuleSelect, e.detail);
});
}

View File

@@ -2,6 +2,7 @@ import { getMemoryState, getHighlights } from '../core/table-system/manager.js';
import { extension_settings } from '/scripts/extensions.js';
import { extensionName } from '../utils/settings.js';
import { getContext } from '/scripts/extensions.js';
import { escapeHTML } from '../utils/utils.js';
const TABLE_CONTAINER_ID = 'amily2-chat-table-container';
const isTouchDevice = () => window.matchMedia('(pointer: coarse)').matches;
@@ -366,10 +367,11 @@ function renderTablesToHtml(tables, highlights) {
const icon = getTableIcon(table.name);
// 侧边栏按钮 (现在包含文字)
const safeTableName = escapeHTML(table.name || '');
sidebarHtml += `
<div class="amily2-game-tab ${isActive}" data-target="game-panel-${index}" title="${table.name}">
<div class="amily2-game-tab ${isActive}" data-target="game-panel-${index}" title="${safeTableName}">
<i class="fas ${icon}"></i>
<span class="tab-text">${table.name}</span>
<span class="tab-text">${safeTableName}</span>
</div>
`;
@@ -380,7 +382,7 @@ function renderTablesToHtml(tables, highlights) {
const theadHtml = `
<thead>
<tr>
${table.headers.map(header => `<th>${header}</th>`).join('')}
${table.headers.map(header => `<th>${escapeHTML(String(header ?? ''))}</th>`).join('')}
</tr>
</thead>
`;
@@ -396,7 +398,7 @@ function renderTablesToHtml(tables, highlights) {
const highlightKey = `${table.originalIndex}-${rowIndex}-${colIndex}`;
const isHighlighted = highlights.has(highlightKey);
const style = isHighlighted ? 'style="color: #00ff7f; font-weight: bold;"' : '';
tbodyHtml += `<td ${style}>${cell}</td>`;
tbodyHtml += `<td ${style}>${escapeHTML(String(cell ?? ''))}</td>`;
});
tbodyHtml += '</tr>';
});
@@ -413,7 +415,7 @@ function renderTablesToHtml(tables, highlights) {
contentHtml += `
<div id="game-panel-${index}" class="amily2-game-panel ${isActive}">
<div class="amily2-panel-title"><i class="fas ${icon}"></i> ${table.name}</div>
<div class="amily2-panel-title"><i class="fas ${icon}"></i> ${safeTableName}</div>
${tableHtml}
</div>
`;

View File

@@ -372,7 +372,8 @@ async function _fetchSlotModels(slot, card) {
return;
}
const resp = await fetch(
`https://generativelanguage.googleapis.com/v1beta/models?key=${encodeURIComponent(profile.apiKey)}`
'https://generativelanguage.googleapis.com/v1beta/models',
{ headers: { 'x-goog-api-key': profile.apiKey } }
);
if (!resp.ok) {
$result.text(`失败HTTP ${resp.status}`).css('color', 'var(--warning-color)');

View File

@@ -131,7 +131,7 @@ export function bindRuleConfigPanel(container) {
const saved = ruleProfileManager.saveProfile(profile);
fillEditor($c, saved);
renderProfileList($c);
document.dispatchEvent(new CustomEvent('amily2:ruleProfilesChanged'));
toastr.success('规则配置已保存。');
});
@@ -145,7 +145,7 @@ export function bindRuleConfigPanel(container) {
ruleProfileManager.deleteProfile(currentEditingId);
fillEditor($c, createEmptyProfile());
renderProfileList($c);
document.dispatchEvent(new CustomEvent('amily2:ruleProfilesChanged'));
toastr.success('规则配置已删除。');
});
}

View File

@@ -27,9 +27,9 @@ const getAllTablesContainer = () => document.getElementById('all-tables-containe
* @param {HTMLSelectElement} select
* @param {string} slot — RULE_SLOTS 中的功能槽名
*/
function _populateRuleProfileSelect(select, slot) {
const profiles = ruleProfileManager.listProfiles();
const assigned = ruleProfileManager.getAssignment(slot) || '';
function _populateRuleProfileSelect(select, slot, detail) {
const profiles = detail?.profiles ?? ruleProfileManager.listProfiles();
const assigned = detail?.assignments?.[slot] ?? ruleProfileManager.getAssignment(slot) ?? '';
const options = [
'<option value="">— 未分配 —</option>',
...profiles.map(p =>
@@ -1454,8 +1454,8 @@ export function bindTableEvents(panelElement = null) {
const name = tableRuleProfileSelect.selectedOptions[0]?.textContent || '';
toastr.info(tableRuleProfileSelect.value ? `表格提取规则已切换为「${name}` : '表格提取规则已取消分配');
});
document.addEventListener('amily2:ruleProfilesChanged', () => {
_populateRuleProfileSelect(tableRuleProfileSelect, 'table');
document.addEventListener('amily2:ruleProfilesChanged', (e) => {
_populateRuleProfileSelect(tableRuleProfileSelect, 'table', e.detail);
});
}