文本与代码预览
gemini-code-1795829558608.html
html · 11.24 KB
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>配置与接口调试页(支持自定义 uniqid)</title>
<style>
body {
font-family: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
max-width: 960px;
margin: 24px auto;
padding: 0 16px 40px;
background: #f4f6f9;
color: #1f2937;
}
.card {
background: #fff;
border-radius: 10px;
padding: 16px 20px;
margin-bottom: 16px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
h1 { font-size: 20px; margin: 0 0 6px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.meta { font-size: 13px; color: #6b7280; margin-bottom: 12px; }
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
gap: 10px;
}
.kv {
background: #f9fafb;
border: 1px solid #e5e7eb;
border-radius: 8px;
padding: 10px 12px;
font-size: 13px;
word-break: break-all;
}
.kv strong { display: block; color: #374151; margin-bottom: 4px; }
.row {
display: flex;
flex-wrap: wrap;
gap: 8px;
align-items: center;
margin-bottom: 12px;
}
label {
font-size: 13px;
font-weight: 600;
color: #374151;
}
input[type="text"] {
flex: 1;
min-width: 240px;
padding: 8px 12px;
border: 1px solid #d1d5db;
border-radius: 6px;
font-size: 13px;
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
button {
padding: 8px 12px;
border: 1px solid #2563eb;
background: #2563eb;
color: #fff;
border-radius: 6px;
font-size: 13px;
cursor: pointer;
}
button:hover { background: #1d4ed8; }
button.secondary {
background: #fff;
color: #2563eb;
}
button.secondary:hover { background: #eff6ff; }
pre {
background: #0f172a;
color: #e2e8f0;
padding: 12px 14px;
border-radius: 8px;
font-size: 12px;
line-height: 1.5;
overflow: auto;
max-height: 360px;
margin: 0;
}
.tip { font-size: 12px; color: #6b7280; line-height: 1.5; }
</style>
</head>
<body>
<script>
var SERVER_DATA = {
"weather": { "city_code": "101010100" },
"guess_track": false,
"qhback_domain": {},
"h360comHuid": "",
"qttk": null,
"request_id": "a0ca70201844c2d46caf2b5b96a0e27e"
};
var PAGE_START_TIME = (new Date).getTime(), WEBINDEXCK = "360WEBINDEXCK", DEBUG = 0;
var API_VERSION = { "hotwordinject": "1.0" }, API_SNAPSHOTNUM = {};
var PROJECT = 'v2022';
var HAO_CONFIG = {
version: 2.0,
hotwordinject: {
host: 'https://hao.ssl.dhrest.com/api.php',
api: 'hotwordinject',
v: API_VERSION.hotwordinject || "1.0",
r: API_SNAPSHOTNUM.hotwordinject || "",
threshold: 300000,
expires: 1800000
},
weather: {
host: 'http://weather.hao.360.cn/',
cnd_host: 'https://cdn.weather.hao.360.cn/',
weather: { path: 'sed_api_weather_info.php', api: 'weather', v: '2', r: 'so', quietUpdateTime: 7200000, expires: 14400000 },
area: { path: 'sed_api_area_query.php', api: 'area', v: '1.1', r: 'www' }
},
pm25: {
host: 'https://cdn.weather.hao.360.cn/sed_api_weather_info.php',
api: 'pm25',
v: '1',
r: 'pm25_1',
quietUpdateTime: 7200000,
expires: 14400000
},
search: { api: 'search', v: '1', r: 'aaa' },
timeSVC: { host: 'https://hao.ssl.dhrest.com/time.php', v: '1.0' },
hotword: {
host: 'https://hao.ssl.dhrest.com/api.php',
api: 'hotword',
v: API_VERSION.hotword || "1.0",
r: API_SNAPSHOTNUM.hotword || "",
quietUpdateTime: 1800000,
expires: 7200000
},
dataConf: { host: 'https://api.dhrest.com/dataconfapi', threshold: 300000 },
mysite: { host: 'https://hao.ssl.dhrest.com/sitelist.php', api: 'mysite', v: '1.0', r: '1' },
praise: { host: 'https://user.dhrest.com' },
cube: {
host: 'https://i.dhrest.com',
api: {
tool: 'gw/APPQ2TDvvFr3kT/toolplate/list/v1',
content: 'gw/APPQ2TDvvFr3kT/contentplate/list/v1'
}
}
};
var STATIC_CONFIG = {
monitor: {
jiechi: 'https://s.360.cn/wzdh/jiechi.html',
cdnReport: 'https://s.360.cn/cdn/monitor.gif',
huidsync: 'https://top.ssl.dhrest.com/u2m.gif',
midsync: 'https://reg.hao.360.cn/',
haoMonitor: 'https://top.ssl.dhrest.com/',
haoStat: 'https://s.360.cn/haostat/',
custom: 'https://s.360.cn/wzdh/',
seachSuggest: 'https://s.360.cn/sou/suggest.gif',
themeLog: 'https://s.360.cn/wzdh/theme2013.html'
},
soHotWord: {
apiHost: 'https://query.rec.360.cn/gasucs/query_rec',
log: 'https://s.360.cn/wzdh/query_rec.html'
},
search: {
soSuggest: 'https://sug.so.360.cn/suggest',
soSmartSuggest: 'https://smart.sug.so.com/'
}
};
</script>
<div class="card">
<h1>独立配置与接口探测页</h1>
<div class="meta">
支持直接修改 <code>uniqid</code> 参数测试 <code>dataconfapi</code> 响应,并查看历史请求日志。
</div>
<div class="grid" id="summaryGrid"></div>
</div>
<div class="card">
<h2>dataConf (uniqid) 与接口探测</h2>
<div class="row">
<label for="uniqidInput">uniqid:</label>
<input
id="uniqidInput"
type="text"
value="Nm7qzd4hFGLFgq92"
placeholder="输入 uniqid(留空可测试参数校验提示)"
/>
<button id="btnDataConf">测试 dataConf (JSONP)</button>
<button class="secondary" id="btnClearUniqid">清空 uniqid</button>
</div>
<div class="actions">
<button class="secondary" id="btnTimeSvc">测试 timeSVC (Fetch)</button>
<button class="secondary" id="btnHotword">测试 hotword (JSONP)</button>
<button class="secondary" id="btnCubeTool">拼接 cube 接口地址</button>
<button class="secondary" id="btnDumpConfig">导出完整配置 JSON</button>
<button class="secondary" id="btnClearLog">清空日志</button>
</div>
<div class="tip">
提示:此前未带 <code>uniqid</code> 时,<code>dataconfapi</code> 返回了 <code>{"errno":1,"msg":"uniqid param error!","data":{}}</code>;填写后可观察返回结果是否变化。
</div>
</div>
<div class="card">
<h2>运行与请求日志</h2>
<pre id="output">页面初始化完成。</pre>
</div>
<script>
const outputEl = document.getElementById('output');
const summaryGridEl = document.getElementById('summaryGrid');
const uniqidInputEl = document.getElementById('uniqidInput');
let seq = 1;
function log(title, data) {
const ts = new Date().toLocaleTimeString();
const body = typeof data === 'string' ? data : JSON.stringify(data, null, 2);
outputEl.textContent = `[${ts}] ${title}\n${body}\n\n` + outputEl.textContent;
}
function renderSummary() {
const items = [
['PROJECT', PROJECT],
['DEBUG / WEBINDEXCK', `${DEBUG} / ${WEBINDEXCK}`],
['request_id', SERVER_DATA.request_id],
['weather.city_code', SERVER_DATA.weather.city_code],
['PAGE_START_TIME', `${PAGE_START_TIME} (+${Date.now() - PAGE_START_TIME}ms)`],
['dataConf.host', HAO_CONFIG.dataConf.host],
['cube.host', HAO_CONFIG.cube.host],
['timeSVC.host', HAO_CONFIG.timeSVC.host]
];
summaryGridEl.innerHTML = items
.map(([k, v]) => `<div class="kv"><strong>${k}</strong><span>${v}</span></div>`)
.join('');
}
function sendJsonp(url, cbParamName = 'callback', timeoutMs = 6000) {
const cbName = `__cfg_cb_${Date.now()}_${seq++}__`;
const sep = url.includes('?') ? '&' : '?';
const fullUrl = `${url}${sep}${encodeURIComponent(cbParamName)}=${encodeURIComponent(cbName)}&_t=${Date.now()}`;
const script = document.createElement('script');
const cleanup = () => {
delete window[cbName];
if (script.parentNode) script.parentNode.removeChild(script);
};
const timer = setTimeout(() => {
cleanup();
log('JSONP 超时或未触发回调', fullUrl);
}, timeoutMs);
window[cbName] = (payload) => {
clearTimeout(timer);
cleanup();
log('JSONP 返回成功', { url: fullUrl, payload });
};
script.onerror = () => {
clearTimeout(timer);
cleanup();
log('JSONP 脚本加载失败', fullUrl);
};
script.src = fullUrl;
log('发起 JSONP 请求', fullUrl);
document.body.appendChild(script);
}
document.getElementById('btnDataConf').addEventListener('click', () => {
const uniqidVal = uniqidInputEl.value.trim();
const params = new URLSearchParams();
if (uniqidVal) {
params.set('uniqid', uniqidVal);
}
const queryStr = params.toString();
const targetUrl = queryStr
? `${HAO_CONFIG.dataConf.host}?${queryStr}`
: HAO_CONFIG.dataConf.host;
sendJsonp(targetUrl, 'callback');
});
document.getElementById('btnClearUniqid').addEventListener('click', () => {
uniqidInputEl.value = '';
log('已清空 uniqid 输入框', '点击“测试 dataConf (JSONP)”可测试空 uniqid 的返回情况。');
});
document.getElementById('btnHotword').addEventListener('click', () => {
const { host, api, v, r } = HAO_CONFIG.hotword;
const qs = new URLSearchParams({ api, v, r, t: String(Date.now()) }).toString();
sendJsonp(`${host}?${qs}`, 'callback');
});
document.getElementById('btnTimeSvc').addEventListener('click', async () => {
const url = `${HAO_CONFIG.timeSVC.host}?v=${encodeURIComponent(HAO_CONFIG.timeSVC.v)}&_t=${Date.now()}`;
log('发起 Fetch 请求', url);
try {
const res = await fetch(url);
const text = await res.text();
log('Fetch 响应', { status: res.status, ok: res.ok, body: text.slice(0, 1000) });
} catch (err) {
log('Fetch 失败(常见原因为 CORS 或网络限制)', err.message || String(err));
}
});
document.getElementById('btnCubeTool').addEventListener('click', () => {
const cubeToolUrl = `${HAO_CONFIG.cube.host.replace(/\/+$/, '')}/${HAO_CONFIG.cube.api.tool.replace(/^\/+/, '')}`;
const cubeContentUrl = `${HAO_CONFIG.cube.host.replace(/\/+$/, '')}/${HAO_CONFIG.cube.api.content.replace(/^\/+/, '')}`;
log('Cube 接口地址拼接结果', { cubeToolUrl, cubeContentUrl });
});
document.getElementById('btnDumpConfig').addEventListener('click', () => {
log('完整配置快照', {
SERVER_DATA,
PAGE_START_TIME,
WEBINDEXCK,
DEBUG,
API_VERSION,
API_SNAPSHOTNUM,
PROJECT,
HAO_CONFIG,
STATIC_CONFIG
});
});
document.getElementById('btnClearLog').addEventListener('click', () => {
outputEl.textContent = '日志已清空。\n';
});
renderSummary();
log('已加载配置对象', { defaultUniqid: uniqidInputEl.value, dataConfHost: HAO_CONFIG.dataConf.host });
</script>
</body>
</html>