feat(api): 实装 /api/status 接口——无鉴权公开接口,换算比率权威来源

- endpoints:AuthMode 扩展 'none'(完全公开),追加 /api/status 定义(考证实证文案 + 实测示例响应),置于列表首位
- endpoint-info-line:鉴权徽标三态化(公开/宽松/严格,map 驱动 + none 中性样式)
- endpoint-panel:requiresKey——无鉴权接口隐藏 sk-key 输入行、按钮不因空 key 禁用、空态文案区分
- spec:接口数 5→6、顺序、鉴权分布(none+strict×3+lenient×2)断言更新
- docs:接口文档同步 479 行新版(/api/status 详解 + QuotaPerUnit 考证);交互设计 §1 清单加第 0 行;README 与 side-nav 计数更新
- 验证:test 64/64 + type-check + lint + build 四绿
This commit is contained in:
2026-09-09 01:27:02 +08:00
parent 19b69e2d5a
commit 86d2ac304b
8 changed files with 143 additions and 28 deletions
+18 -5
View File
@@ -44,12 +44,17 @@ const {
sendRequest,
} = useManualEndpointQuery(endpointPathRef, skKeyInput);
/** 无鉴权接口(如 /api/status)不需要 sk-key:隐藏输入行、按钮不因空 key 禁用 */
const requiresKey = computed(() => endpoint.value.authMode !== 'none');
const keyInputStatus = computed(() =>
hasSent.value && !skKeyInput.value.trim() ? 'error' : 'default',
hasSent.value && requiresKey.value && !skKeyInput.value.trim() ? 'error' : 'default',
);
const sendButtonDisabled = computed(() => requiresKey.value && !skKeyInput.value.trim());
function handleSend(): void {
if (!skKeyInput.value.trim()) return; // 空 key 不发(输入框已标红提示)
if (sendButtonDisabled.value) return; // 空 key 不发(输入框已标红提示);无鉴权接口直接发
sendRequest();
}
@@ -100,10 +105,11 @@ function downloadResponseAsFile(): void {
</t-collapse>
</section>
<!-- 调试行:sk-key + 发送 -->
<!-- 调试行:sk-key + 发送(无鉴权接口隐藏 key 输入) -->
<section class="panel-section">
<div class="request-row">
<t-input
v-if="requiresKey"
v-model="skKeyInput"
class="sk-key-input"
type="password"
@@ -113,10 +119,11 @@ function downloadResponseAsFile(): void {
:tips="keyInputStatus === 'error' ? '请填写 sk-key' : ''"
@enter="handleSend"
/>
<span v-else class="no-key-hint">公开接口,无需 sk-key</span>
<t-button
theme="primary"
:loading="isFetching"
:disabled="!skKeyInput.trim()"
:disabled="sendButtonDisabled"
@click="handleSend"
>
发送请求
@@ -156,7 +163,7 @@ function downloadResponseAsFile(): void {
<JsonTextView :json="responseData.json" :raw-text="responseData.text" />
</section>
<section v-else-if="!hasSent" class="panel-section response-placeholder">
填写 sk-key 后点击「发送请求」
{{ requiresKey ? '填写 sk-key 后点击「发送请求」' : '点击「发送请求」查看站点配置' }}
</section>
</div>
</template>
@@ -186,6 +193,12 @@ function downloadResponseAsFile(): void {
max-width: 480px;
}
.no-key-hint {
align-self: center;
font-size: 12.5px;
color: var(--td-text-color-placeholder);
}
.response-section {
flex: 1;
min-height: 220px; /* 响应区保底高度:窄窗口下不被上部固定分区压缩到不可用 */