feat: 文案工具箱接入NewAPI模型选择 — /ai/models实时拉取41个对话模型(过滤生图), 页面右上模型下拉默认qwen, 生成请求带model参数由relay透传NewAPI

This commit is contained in:
personal82555 committed 2026-10-13 00:33:15 +08:00
1 parent 14f4dc7830
commit 282101b533
2 files changed
+78 -6

No files matched your search

+51 -3
View File
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref } from 'vue';
import { onMounted, ref } from 'vue';
import { useHead } from '@vueuse/head';
import { getMachineId } from '@/tools/license/license';
import { useGenHistory } from '@/tools/gen-history/gen-history';
@@ -16,6 +16,25 @@ const SCENES = [
] as const;
const scene = ref<(typeof SCENES)[number]['key']>('rewrite');
// NewAPI 模型选择
const model = ref('');
const models = ref<string[]>([]);
async function loadModels() {
try {
const res = await fetch('/relay/ai/models');
const j = await res.json();
if (j.code === 200 && j.data.models.length) {
models.value = j.data.models;
if (!model.value || !models.value.includes(model.value)) {
model.value = models.value.find(m => m.includes('qwen')) || models.value[0];
}
}
}
catch { /* 列表失败时留空走后端默认 */ }
}
onMounted(loadModels);
const input = ref('');
const output = ref('');
const busy = ref(false);
@@ -35,7 +54,7 @@ async function run() {
const res = await fetch('/relay/ai/copy', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ machine: getMachineId(), scene: scene.value, text: input.value }),
body: JSON.stringify({ machine: getMachineId(), scene: scene.value, text: input.value, model: model.value }),
});
const j = await res.json().catch(() => ({}));
if (!res.ok || j.code !== 200) {
@@ -72,6 +91,13 @@ function switchScene(k: (typeof SCENES)[number]['key']) {
{{ s.icon }} {{ s.name }}
</button>
<span class="cw-note">{{ cur().hint }}</span>
<label class="cw-model" title="由 NewAPI 网关提供模型">
模型
<select v-model="model" class="cw-model-sel">
<option v-if="!models.length" value="">默认(qwen3.8-flash)</option>
<option v-for="m in models" :key="m" :value="m">{{ m }}</option>
</select>
</label>
</div>
<div class="cw-cols">
@@ -132,11 +158,33 @@ function switchScene(k: (typeof SCENES)[number]['key']) {
}
.cw-note {
margin-left: auto;
font-size: 11.5px;
opacity: 0.5;
}
.cw-model {
margin-left: auto;
display: flex;
align-items: center;
gap: 7px;
font-size: 12px;
opacity: 0.85;
.cw-model-sel {
border: 1px solid rgba(128, 128, 128, 0.35);
border-radius: 7px;
padding: 5px 9px;
font-size: 12.5px;
background: #fff;
outline: none;
max-width: 220px;
&:focus {
border-color: #e60012;
}
}
}
.cw-cols {
display: flex;
gap: 14px;