添加开发者选项的总开关
This commit is contained in:
+25
-8
@@ -20,9 +20,9 @@
|
||||
|
||||
// 预设筛选常量
|
||||
let FILTER_OPTIONS = {
|
||||
names: ["盘螺", "螺纹钢", "高线"],
|
||||
specs: ["Φ6", "Φ8-10", "Φ8", "Φ10", "Φ12", "Φ14", "Φ16", "Φ18", "Φ20", "Φ22", "Φ25", "Φ28", "Φ32", "Φ36-40", "Φ36", "Φ40"],
|
||||
materials: ["HPB300", "HRB400", "HRB400E", "HRB500E"]
|
||||
names: ["盘螺", "螺纹钢", "高线", "TEST"],
|
||||
specs: ["Φ6", "Φ8-10", "Φ8", "Φ10", "Φ12", "Φ14", "Φ16", "Φ18", "Φ20", "Φ22", "Φ25", "Φ28", "Φ32", "Φ36-40", "Φ36", "Φ40", "TEST"],
|
||||
materials: ["HPB300", "HRB400", "HRB400E", "HRB500E", "TEST"]
|
||||
};
|
||||
|
||||
// 尝试加载本地存储的动态筛选项目
|
||||
@@ -49,7 +49,7 @@
|
||||
|
||||
// 读取本地缓存的筛选条件
|
||||
function loadSavedFilters() {
|
||||
const defaultFilters = { names: [], specs: [], materials: [], exportFormat: 'csv', exportFilename: '钢材透视价格表', debugMode: false };
|
||||
const defaultFilters = { names: [], specs: [], materials: [], exportFormat: 'csv', exportFilename: '钢材透视价格表', debugMode: false, devMode: false };
|
||||
const saved = localStorage.getItem('mysteel_filters');
|
||||
if (saved) {
|
||||
try {
|
||||
@@ -66,18 +66,19 @@
|
||||
localStorage.setItem('mysteel_filters', JSON.stringify(filters));
|
||||
}
|
||||
|
||||
// 获取当前活动筛选条件 (直接从 DOM 获取)
|
||||
function getCurrentFilters() {
|
||||
const formatEl = document.getElementById('ms-filter-format');
|
||||
const filenameEl = document.getElementById('ms-filter-filename');
|
||||
const debugModeEl = document.getElementById('ms-debug-mode');
|
||||
const devModeEl = document.getElementById('ms-dev-mode-switch');
|
||||
return {
|
||||
names: Array.from(document.querySelectorAll('input[name="ms-filter-names"]:checked')).map(el => el.value),
|
||||
specs: Array.from(document.querySelectorAll('input[name="ms-filter-specs"]:checked')).map(el => el.value),
|
||||
materials: Array.from(document.querySelectorAll('input[name="ms-filter-materials"]:checked')).map(el => el.value),
|
||||
exportFormat: formatEl ? formatEl.value : 'csv',
|
||||
exportFilename: filenameEl ? filenameEl.value : '钢材透视价格表',
|
||||
debugMode: debugModeEl ? debugModeEl.checked : false
|
||||
devMode: devModeEl ? devModeEl.checked : false,
|
||||
debugMode: (devModeEl && devModeEl.checked && debugModeEl) ? debugModeEl.checked : false
|
||||
};
|
||||
}
|
||||
|
||||
@@ -200,13 +201,23 @@
|
||||
<input type="text" id="ms-filter-filename" value="${savedFilters.exportFilename || '钢材透视价格表'}" style="width:100%; padding:4px 8px; font-size:13px; height:28px; box-sizing:border-box; border:1px solid #ccc; border-radius:4px; outline:none;">
|
||||
</div>
|
||||
</div>
|
||||
<div style="font-size:16px; font-weight:bold; margin-bottom:15px; border-bottom:1px solid #eee; padding-bottom:8px; margin-top:15px;">开发者选项</div>
|
||||
<div style="margin-bottom:12px; display:flex; justify-content:space-between; align-items:center;">
|
||||
<div style="font-size:16px; font-weight:bold; margin-bottom:15px; border-bottom:1px solid #eee; padding-bottom:8px; margin-top:15px; display:flex; justify-content:space-between; align-items:center;">
|
||||
<span>开发者选项</span>
|
||||
<label style="display:flex; align-items:center; cursor:pointer;">
|
||||
<input type="checkbox" id="ms-dev-mode-switch" ${savedFilters.devMode ? 'checked' : ''} style="margin:0;">
|
||||
</label>
|
||||
</div>
|
||||
<div id="ms-dev-options-container" style="display:${savedFilters.devMode ? 'block' : 'none'}; margin-bottom:12px;">
|
||||
<div style="display:flex; justify-content:space-between; align-items:center;">
|
||||
<label style="display:flex; align-items:center; font-size:13px; cursor:pointer; color:#ff4d4f; font-weight:bold;">
|
||||
<input type="checkbox" id="ms-debug-mode" style="margin-right:4px;" ${savedFilters.debugMode ? 'checked' : ''}> DEBUG_MODE
|
||||
</label>
|
||||
<div>
|
||||
<button id="ms-extract-options-btn" title="从当前页面获取筛选项目并更新到脚本配置中" style="background:#52c41a; color:#fff; border:none; padding:4px 8px; border-radius:4px; font-size:12px; cursor:pointer; font-weight:bold; outline:none; margin-right:6px;">SYNC</button>
|
||||
<button id="ms-reset-options-btn" title="恢复出厂设置并清除所有缓存数据" style="background:#ff4d4f; color:#fff; border:none; padding:4px 8px; border-radius:4px; font-size:12px; cursor:pointer; font-weight:bold; outline:none;">RESET</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button id="ms-close-panel-btn" style="width:100%; padding:8px; background:#1890ff; color:#fff; border:none; border-radius:4px; cursor:pointer; font-weight:bold;">保存并关闭</button>
|
||||
`;
|
||||
@@ -244,6 +255,12 @@
|
||||
container.appendChild(gearBtn);
|
||||
document.body.appendChild(container);
|
||||
|
||||
// 绑定开发者模式开关事件
|
||||
document.getElementById('ms-dev-mode-switch').addEventListener('change', (e) => {
|
||||
const devContainer = document.getElementById('ms-dev-options-container');
|
||||
devContainer.style.display = e.target.checked ? 'block' : 'none';
|
||||
});
|
||||
|
||||
// 绑定更新筛选项目按钮事件
|
||||
document.getElementById('ms-extract-options-btn').addEventListener('click', () => {
|
||||
const getList = (num) => {
|
||||
|
||||
Reference in New Issue
Block a user