import{d as a,r as e,o as l,M as t,g as s,y as u,N as c,c as n,w as d,i,b as r,e as o,f,h as _,Z as v,t as m,A as p,m as h,l as x,j as g,F as y,k,K as b,X as w,_ as A,J as C}from"./index-Co9nPWLO.js";import{_ as I}from"./_plugin-vue_export-helper.BCo6x5W8.js";const B=I(a({__name:"index",setup(a){const I=e(""),B=e(!1),Q=e(""),j=e([]),V=e([{id:"tongyi-xiaomi-analysis-pro",name:"通义小米分析专业版 (免费)"},{id:"qwen3.5-122b-a10b",name:"Qwen3.5-122B-A10B (免费)"},{id:"qwen-plus",name:"Qwen-Plus (付费)"}]),q=e(0);function P(a){q.value=a.detail.value}async function F(){var a;if(I.value.trim()&&!B.value){B.value=!0,t({title:"AI 思考中..."});try{const e=await b("/ai/generate",{prompt:I.value,model:null==(a=V.value[q.value])?void 0:a.id});Q.value=e.text,j.value.unshift({prompt:I.value,text:e.text}),j.value.length>10&&j.value.pop(),u({title:"生成成功",icon:"success"})}catch(e){console.error("AI 生成失败:",e),u({title:e.message||"生成失败",icon:"none"})}finally{B.value=!1,c()}}}function J(){w({data:Q.value,success:()=>{u({title:"已复制",icon:"success"})}})}function K(){A("ai_generated_text",Q.value),C()}function M(){Q.value&&A("ai_generated_text",Q.value),C()}return l(async()=>{t({title:"加载中..."});try{const a=await s("/ai/models");a.models&&(V.value=a.models.map(a=>({id:a,name:a.includes("xiaomi")?"通义小米分析专业版 (免费)":a.includes("122b")?"Qwen3.5-122B-A10B (免费)":"Qwen-Plus (付费)"})),q.value=0)}catch(a){console.error("获取模型列表失败:",a),u({title:"获取模型失败",icon:"none"})}finally{c()}}),(a,e)=>{const l=f,t=i,s=v,u=p,c=h;return r(),n(t,{class:"page"},{default:d(()=>[o(t,{class:"nav-bar"},{default:d(()=>[o(t,{class:"nav-content"},{default:d(()=>[o(t,{class:"nav-left",onClick:M},{default:d(()=>[o(l,{class:"back-icon"},{default:d(()=>[_("←")]),_:1})]),_:1}),o(l,{class:"page-title"},{default:d(()=>[_("AI 智能生成")]),_:1}),o(t,{class:"nav-right"},{default:d(()=>[o(l)]),_:1})]),_:1})]),_:1}),o(t,{class:"main-content"},{default:d(()=>[o(t,{class:"card model-card"},{default:d(()=>[o(t,{class:"card-header"},{default:d(()=>[o(l,{class:"card-title"},{default:d(()=>[_("📡 选择模型")]),_:1})]),_:1}),o(t,{class:"model-select"},{default:d(()=>[o(s,{value:q.value,range:V.value,"range-key":"name",onChange:P},{default:d(()=>[o(t,{class:"picker-content"},{default:d(()=>[o(l,{class:"picker-text"},{default:d(()=>{var a;return[_(m((null==(a=V.value[q.value])?void 0:a.name)||"请选择模型"),1)]}),_:1}),o(l,{class:"picker-arrow"},{default:d(()=>[_("▼")]),_:1})]),_:1})]),_:1},8,["value","range"])]),_:1}),o(t,{class:"model-hint"},{default:d(()=>[o(l,null,{default:d(()=>{var a;return[_("优先使用免费模型："+m(null==(a=V.value[0])?void 0:a.name),1)]}),_:1})]),_:1})]),_:1}),o(t,{class:"card input-card"},{default:d(()=>[o(t,{class:"card-header"},{default:d(()=>[o(l,{class:"card-title"},{default:d(()=>[_("🤖 输入问题")]),_:1})]),_:1}),o(u,{modelValue:I.value,"onUpdate:modelValue":e[0]||(e[0]=a=>I.value=a),class:"prompt-input",placeholder:"输入你想了解的内容，例如：计算机原理是什么？什么是人工智能？",maxlength:500},null,8,["modelValue"]),o(t,{class:"prompt-hint"},{default:d(()=>[o(l,null,{default:d(()=>[_("AI 将根据你的输入生成相关文本内容")]),_:1})]),_:1})]),_:1}),o(c,{class:"generate-btn",disabled:!I.value.trim()||B.value,onClick:F},{default:d(()=>[o(l,{class:"btn-text"},{default:d(()=>[_(m(B.value?"生成中...":"生成文本"),1)]),_:1})]),_:1},8,["disabled"]),Q.value?(r(),n(t,{key:0,class:"card result-card"},{default:d(()=>[o(t,{class:"card-header"},{default:d(()=>[o(l,{class:"card-title"},{default:d(()=>[_("📝 生成的文本")]),_:1}),o(t,{class:"result-actions"},{default:d(()=>[o(l,{class:"action-text",onClick:J},{default:d(()=>[_("复制")]),_:1}),o(l,{class:"action-text use-text",onClick:K},{default:d(()=>[_("使用此文本")]),_:1})]),_:1})]),_:1}),o(t,{class:"result-content"},{default:d(()=>[o(l,{class:"result-text"},{default:d(()=>[_(m(Q.value),1)]),_:1})]),_:1}),o(t,{class:"result-footer"},{default:d(()=>[o(l,{class:"word-count"},{default:d(()=>[_(m(Q.value.length)+" 字",1)]),_:1})]),_:1})]),_:1})):x("",!0),j.value.length>0?(r(),n(t,{key:1,class:"card history-card"},{default:d(()=>[o(t,{class:"card-header"},{default:d(()=>[o(l,{class:"card-title"},{default:d(()=>[_("📜 历史记录")]),_:1})]),_:1}),o(t,{class:"history-list"},{default:d(()=>[(r(!0),g(y,null,k(j.value,(a,e)=>(r(),n(t,{key:e,class:"history-item",onClick:e=>function(a){I.value=a.prompt,Q.value=a.text}(a)},{default:d(()=>[o(l,{class:"history-prompt"},{default:d(()=>[_(m(a.prompt),1)]),_:2},1024),o(l,{class:"history-text"},{default:d(()=>[_(m(a.text.slice(0,50))+"...",1)]),_:2},1024)]),_:2},1032,["onClick"]))),128))]),_:1})]),_:1})):x("",!0)]),_:1})]),_:1})}}}),[["__scopeId","data-v-b3136c67"]]);export{B as default};
