MCPcopy
hub / github.com/helloxz/onenav / parse

Method parse

templates/default2/assets/index.js:178–178  ·  view source on GitHub ↗
(t,n)

Source from the content-addressed store, hash-verified

176${t}</tr>
177`}tablecell(t){const n=this.parser.parseInline(t.tokens),o=t.header?"th":"td";return(t.align?`<${o} align="${t.align}">`:`<${o}>`)+n+`</${o}>
178`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${Ul(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:n,tokens:o}){const r=this.parser.parseInline(o),l=JO(t);if(l===null)return r;t=l;let a='<a href="'+t+'"';return n&&(a+=' title="'+Ul(n)+'"'),a+=">"+r+"</a>",a}image({href:t,title:n,text:o}){const r=JO(t);if(r===null)return Ul(o);t=r;let l=`<img src="${t}" alt="${o}"`;return n&&(l+=` title="${Ul(n)}"`),l+=">",l}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:Ul(t.text)}}class K_{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}}class Ja{constructor(t){Zn(this,"options");Zn(this,"renderer");Zn(this,"textRenderer");this.options=t||vc,this.options.renderer=this.options.renderer||new o0,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new K_}static parse(t,n){return new Ja(n).parse(t)}static parseInline(t,n){return new Ja(n).parseInline(t)}parse(t,n=!0){var r,l;let o="";for(let a=0;a<t.length;a++){const s=t[a];if((l=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&l[s.type]){const u=s,d=this.options.extensions.renderers[u.type].call({parser:this},u);if(d!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(u.type)){o+=d||"";continue}}const i=s;switch(i.type){case"space":{o+=this.renderer.space(i);continue}case"hr":{o+=this.renderer.hr(i);continue}case"heading":{o+=this.renderer.heading(i);continue}case"code":{o+=this.renderer.code(i);continue}case"table":{o+=this.renderer.table(i);continue}case"blockquote":{o+=this.renderer.blockquote(i);continue}case"list":{o+=this.renderer.list(i);continue}case"html":{o+=this.renderer.html(i);continue}case"paragraph":{o+=this.renderer.paragraph(i);continue}case"text":{let u=i,d=this.renderer.text(u);for(;a+1<t.length&&t[a+1].type==="text";)u=t[++a],d+=`
179`+this.renderer.text(u);n?o+=this.renderer.paragraph({type:"paragraph",raw:d,text:d,tokens:[{type:"text",raw:d,text:d,escaped:!0}]}):o+=d;continue}default:{const u='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return o}parseInline(t,n=this.renderer){var r,l;let o="";for(let a=0;a<t.length;a++){const s=t[a];if((l=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&l[s.type]){const u=this.options.extensions.renderers[s.type].call({parser:this},s);if(u!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){o+=u||"";continue}}const i=s;switch(i.type){case"escape":{o+=n.text(i);break}case"html":{o+=n.html(i);break}case"link":{o+=n.link(i);break}case"image":{o+=n.image(i);break}case"strong":{o+=n.strong(i);break}case"em":{o+=n.em(i);break}case"codespan":{o+=n.codespan(i);break}case"br":{o+=n.br(i);break}case"del":{o+=n.del(i);break}case"text":{o+=n.text(i);break}default:{const u='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return o}}class Tp{constructor(t){Zn(this,"options");Zn(this,"block");this.options=t||vc}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?Za.lex:Za.lexInline}provideParser(){return this.block?Ja.parse:Ja.parseInline}}Zn(Tp,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class kEe{constructor(...t){Zn(this,"defaults",D_());Zn(this,"options",this.setOptions);Zn(this,"parse",this.parseMarkdown(!0));Zn(this,"parseInline",this.parseMarkdown(!1));Zn(this,"Parser",Ja);Zn(this,"Renderer",o0);Zn(this,"TextRenderer",K_);Zn(this,"Lexer",Za);Zn(this,"Tokenizer",n0);Zn(this,"Hooks",Tp);this.use(...t)}walkTokens(t,n){var r,l;let o=[];for(const a of t)switch(o=o.concat(n.call(this,a)),a.type){case"table":{const s=a;for(const i of s.header)o=o.concat(this.walkTokens(i.tokens,n));for(const i of s.rows)for(const u of i)o=o.concat(this.walkTokens(u.tokens,n));break}case"list":{const s=a;o=o.concat(this.walkTokens(s.items,n));break}default:{const s=a;(l=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&l[s.type]?this.defaults.extensions.childTokens[s.type].forEach(i=>{const u=s[i].flat(1/0);o=o.concat(this.walkTokens(u,n))}):s.tokens&&(o=o.concat(this.walkTokens(s.tokens,n)))}}return o}use(...t){const n=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(o=>{const r={...o};if(r.async=this.defaults.async||r.async||!1,o.extensions&&(o.extensions.forEach(l=>{if(!l.name)throw new Error("extension name required");if("renderer"in l){const a=n.renderers[l.name];a?n.renderers[l.name]=function(...s){let i=l.renderer.apply(this,s);return i===!1&&(i=a.apply(this,s)),i}:n.renderers[l.name]=l.renderer}if("tokenizer"in l){if(!l.level||l.level!=="block"&&l.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const a=n[l.level];a?a.unshift(l.tokenizer):n[l.level]=[l.tokenizer],l.start&&(l.level==="block"?n.startBlock?n.startBlock.push(l.start):n.startBlock=[l.start]:l.level==="inline"&&(n.startInline?n.startInline.push(l.start):n.startInline=[l.start]))}"childTokens"in l&&l.childTokens&&(n.childTokens[l.name]=l.childTokens)}),r.extensions=n),o.renderer){const l=this.defaults.renderer||new o0(this.defaults);for(const a in o.renderer){if(!(a in l))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;const s=a,i=o.renderer[s],u=l[s];l[s]=(...d)=>{let c=i.apply(l,d);return c===!1&&(c=u.apply(l,d)),c||""}}r.renderer=l}if(o.tokenizer){const l=this.defaults.tokenizer||new n0(this.defaults);for(const a in o.tokenizer){if(!(a in l))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;const s=a,i=o.tokenizer[s],u=l[s];l[s]=(...d)=>{let c=i.apply(l,d);return c===!1&&(c=u.apply(l,d)),c}}r.tokenizer=l}if(o.hooks){const l=this.defaults.hooks||new Tp;for(const a in o.hooks){if(!(a in l))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;const s=a,i=o.hooks[s],u=l[s];Tp.passThroughHooks.has(a)?l[s]=d=>{if(this.defaults.async)return Promise.resolve(i.call(l,d)).then(h=>u.call(l,h));const c=i.call(l,d);return u.call(l,c)}:l[s]=(...d)=>{let c=i.apply(l,d);return c===!1&&(c=u.apply(l,d)),c}}r.hooks=l}if(o.walkTokens){const l=this.defaults.walkTokens,a=o.walkTokens;r.walkTokens=function(s){let i=[];return i.push(a.call(this,s)),l&&(i=i.concat(l.call(this,s))),i}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,n){return Za.lex(t,n??this.defaults)}parser(t,n){return Ja.parse(t,n??this.defaults)}parseMarkdown(t){return(o,r)=>{const l={...r},a={...this.defaults,...l},s=this.onError(!!a.silent,!!a.async);if(this.defaults.async===!0&&l.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof o>"u"||o===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof o!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(o)+", string expected"));a.hooks&&(a.hooks.options=a,a.hooks.block=t);const i=a.hooks?a.hooks.provideLexer():t?Za.lex:Za.lexInline,u=a.hooks?a.hooks.provideParser():t?Ja.parse:Ja.parseInline;if(a.async)return Promise.resolve(a.hooks?a.hooks.preprocess(o):o).then(d=>i(d,a)).then(d=>a.hooks?a.hooks.processAllTokens(d):d).then(d=>a.walkTokens?Promise.all(this.walkTokens(d,a.walkTokens)).then(()=>d):d).then(d=>u(d,a)).then(d=>a.hooks?a.hooks.postprocess(d):d).catch(s);try{a.hooks&&(o=a.hooks.preprocess(o));let d=i(o,a);a.hooks&&(d=a.hooks.processAllTokens(d)),a.walkTokens&&this.walkTokens(d,a.walkTokens);let c=u(d,a);return a.hooks&&(c=a.hooks.postprocess(c)),c}catch(d){return s(d)}}}onError(t,n){return o=>{if(o.message+=`
180Please report this to https://github.com/markedjs/marked.`,t){const r="<p>An error occurred:</p><pre>"+Ul(o.message+"",!0)+"</pre>";return n?Promise.resolve(r):r}if(n)return Promise.reject(o);throw o}}}const lc=new kEe;function Fn(e,t){return lc.parse(e,t)}Fn.options=Fn.setOptions=function(e){return lc.setOptions(e),Fn.defaults=lc.defaults,ZN(Fn.defaults),Fn};Fn.getDefaults=D_;Fn.defaults=vc;Fn.use=function(...e){return lc.use(...e),Fn.defaults=lc.defaults,ZN(Fn.defaults),Fn};Fn.walkTokens=function(e,t){return lc.walkTokens(e,t)};Fn.parseInline=lc.parseInline;Fn.Parser=Ja;Fn.parser=Ja.parse;Fn.Renderer=o0;Fn.TextRenderer=K_;Fn.Lexer=Za;Fn.lexer=Za.lex;Fn.Tokenizer=n0;Fn.Hooks=Tp;Fn.parse=Fn;Fn.options;Fn.setOptions;Fn.use;Fn.walkTokens;Fn.parseInline;Ja.parse;Za.lex;const tI="data:image/svg+xml,%3csvg%20t='1734494657975'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='6843'%20width='200'%20height='200'%3e%3cpath%20d='M27.016%20680.908c0%2030.928%2025.072%2056%2056%2056H930c30.928%200%2056-25.072%2056-56v-115.844c0-30.928-25.072-56-56-56H83.016c-30.928%200-56%2025.072-56%2056v115.844z'%20fill='%2354BCE8'%20p-id='6844'%3e%3c/path%3e%3cpath%20d='M930%20754.916H83.016c-40.804%200-74-33.196-74-74v-115.852c0-40.804%2033.196-74%2074-74H930c40.804%200%2074%2033.192%2074%2074v115.852c0%2040.804-33.196%2074-74%2074zM83.016%20527.064c-20.952%200-38%2017.048-38%2038v115.852c0%2020.948%2017.048%2038%2038%2038H930c20.952%200%2038-17.052%2038-38v-115.852c0-20.952-17.048-38-38-38H83.016z'%20fill='%234A4A4A'%20p-id='6845'%3e%3c/path%3e%3cpath%20d='M881.236%20835.864c0%2068.096-55.716%20123.816-123.812%20123.816H258.612c-68.1%200-123.816-55.72-123.816-123.816v-425.76c0-68.1%2055.716-123.816%20123.816-123.816h498.804c68.1%200%20123.82%2055.716%20123.82%20123.816v425.76z'%20fill='%237FDDFF'%20p-id='6846'%3e%3c/path%3e%3cpath%20d='M345.284%20575.208m-114.972%200a114.972%20114.972%200%201%200%20229.944%200%20114.972%20114.972%200%201%200-229.944%200Z'%20fill='%23E6E8F3'%20p-id='6847'%3e%3c/path%3e%3cpath%20d='M345.284%20707.184c-72.772%200-131.976-59.204-131.976-131.98%200-72.772%2059.204-131.976%20131.976-131.976%2072.776%200%20131.98%2059.204%20131.98%20131.976%200%2072.776-59.204%20131.98-131.98%20131.98z%20m0-229.944c-54.02%200-97.968%2043.948-97.968%2097.972%200%2054.016%2043.948%2097.968%2097.968%2097.968s97.972-43.952%2097.972-97.968c0-54.024-43.948-97.972-97.972-97.972z'%20fill='%234A4A4A'%20p-id='6848'%3e%3c/path%3e%3cpath%20d='M672.08%20575.208m-114.972%200a114.972%20114.972%200%201%200%20229.944%200%20114.972%20114.972%200%201%200-229.944%200Z'%20fill='%23E6E8F3'%20p-id='6849'%3e%3c/path%3e%3cpath%20d='M672.08%20707.184c-72.768%200-131.976-59.204-131.976-131.98%200-72.772%2059.208-131.976%20131.976-131.976%2072.776%200%20131.984%2059.204%20131.984%20131.976-0.008%2072.776-59.208%20131.98-131.984%20131.98z%20m0-229.944c-54.016%200-97.968%2043.948-97.968%2097.972%200%2054.016%2043.952%2097.968%2097.968%2097.968%2054.024%200%2097.976-43.952%2097.976-97.968%200-54.024-43.956-97.972-97.976-97.972z'%20fill='%234A4A4A'%20p-id='6850'%3e%3c/path%3e%3cpath%20d='M757.416%20977.684H258.612c-78.196%200-141.816-63.62-141.816-141.82v-425.76c0-78.196%2063.62-141.816%20141.816-141.816h498.804c78.204%200%20141.82%2063.62%20141.82%20141.816v425.756c0%2078.204-63.62%20141.824-141.82%20141.824zM258.612%20304.288c-58.348%200-105.816%2047.468-105.816%20105.816v425.756c0%2058.352%2047.468%20105.82%20105.816%20105.82h498.804c58.352%200%20105.82-47.468%20105.82-105.82V410.104c0-58.348-47.468-105.816-105.82-105.816H258.612z'%20fill='%234A4A4A'%20p-id='6851'%3e%3c/path%3e%3cpath%20d='M320%20555.212h48.792V604H320zM647.688%20555.212h48.792V604h-48.792z'%20fill='%234A4A4A'%20p-id='6852'%3e%3c/path%3e%3c/svg%3e",EEe="data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1734495933883'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='10439'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='200'%20height='200'%3e%3cpath%20d='M637.953132%20548.278251c71.730695-40.298821%20120.348995-116.815519%20120.348995-204.542536%200-129.46256-105.705484-234.781234-235.641835-234.781234-129.936351%200-235.628532%20105.318674-235.628532%20234.781234%200%2084.393085%2045.041846%20158.307516%20112.302739%20199.683878-152.041812%2047.787376-262.605953%20189.523471-262.605953%20356.600721%200%205.058203%200.560772%209.956769%200.762363%2014.97404l52.356438%200c-0.230244-4.986571-0.76134-9.914814-0.76134-14.97404%200-177.279612%20144.855132-321.502341%20322.909387-321.502341%20178.054255%200%20322.910411%20144.222729%20322.910411%20321.502341%200%205.058203-0.532119%209.987468-0.775666%2014.97404l52.371788%200c0.200568-5.016247%200.760317-9.914814%200.760317-14.97404C887.263268%20737.931682%20783.009855%20600.017636%20637.953132%20548.278251zM339.389222%20343.735715c0-100.588953%2082.208327-182.423773%20183.27107-182.423773%20101.06479%200%20183.272094%2081.83482%20183.272094%20182.423773%200%20100.589976-82.207303%20182.423773-183.272094%20182.423773C421.597549%20526.159488%20339.389222%20444.325691%20339.389222%20343.735715z'%20p-id='10440'%20fill='%23515151'%3e%3c/path%3e%3c/svg%3e",xEe={class:"category"},TEe={class:"form"},OEe={__name:"AiSetting",setup(e){const t=W({url:"",sk:"",model:"",status:"1",custom_model:""}),n=W(null),o=W([]),r=W([{name:"DeepSeek(硅基流动)",value:"deepseek-ai/DeepSeek-V3"},{name:"Qwen2.5-72B(硅基流动)",value:"Qwen/Qwen2.5-72B-Instruct"},{name:"DeepSeek(官方)",value:"deepseek-chat"},{name:"qwen-plus",value:"qwen-plus"},{name:"qwen-turbo",value:"qwen-turbo"},{name:"GLM-4-Air",value:"glm-4-air"},{name:"gpt-4o-mini",value:"gpt-4o-mini"},{name:"gpt-4o(推荐)",value:"gpt-4o"},{name:"自定义模型",value:"custom"}]),l=()=>{let d=t.value.url;return d.includes("deepseek")?(o.value=r.value.filter(c=>c.value==="deepseek-chat"),!0):d.includes("siliconflow")?(o.value=r.value.filter(c=>c.value.includes("/")||c.value.includes("custom")),!0):d.includes("aliyun")?(o.value=r.value.filter(c=>c.value.includes("qwen")),!0):d.includes("openai")?(o.value=r.value.filter(c=>c.value.includes("gpt")),!0):d.includes("bigmodel")?(o.value=r.value.filter(c=>c.value.includes("glm")),!0):(o.value=r.value,!1)},a=()=>{t.value.model="",l()},s=qt({url:[{required:!0,message:"请填写API地址",trigger:"blur"},{pattern:/^(http|https):\/\//,message:"请填写正确的API地址",trigger:"blur"}],sk:[{required:!0,message:"请填写密钥信息",trigger:"blur"},{pattern:/^[a-zA-Z0-9_.-]+$/,message:"请填写正确的密钥信息",trigger:"blur"}],model:[{required:!0,message:"请选择模型",trigger:"change"}],status:[{required:!0,message:"请选择状态",trigger:"change"}]}),i=()=>{n.value.validate(d=>{if(d){let c="/index.php?c=api&method=new_set_option",h=ts({key:"ai_setting",value:JSON.stringify(t.value)});Qn.post(c,h).then(v=>{v.data.code===200?vn({message:"保存成功!",type:"success"}):vn({message:"保存失败!",type:"error"})}).catch(()=>{vn({message:"请求失败,请稍后重试!",type:"error"})})}else return vn({message:"请检查表单输入是否正确!",type:"warning"}),!1})},u=()=>{Qn.get("/index.php?c=api&method=get_option_base&key=ai_setting").then(c=>{c.data.code===200&&(t.value=c.data.data)})};return kt(()=>{l(),u()}),(d,c)=>{const h=co,v=eu,m=Ui,g=Al,w=Lh,b=Dh,E=Un,S=Qi,C=nu,_=tu;return P(),G("div",xEe,[U(_,null,{default:X(()=>[U(C,{xs:24},{default:X(()=>[c[8]||(c[8]=j("div",{class:"notice"},[_t(" 请参考"),j("a",{href:"https://dwz.ovh/ay7f4",target:"_blank"},"帮助文档"),_t("完成API设置! ")],-1)),j("div",TEe,[U(S,{ref_key:"formRef",ref:n,rules:s,"label-position":"top",model:t.value,"label-width":"auto",style:{"max-width":"600px"}},{default:X(()=>[U(v,{onInput:a,prop:"url",label:"API地址"},{default:X(()=>[U(h,{modelValue:t.value.url,"onUpdate:modelValue":c[0]||(c[0]=k=>t.value.url=k)},null,8,["modelValue"])]),_:1}),U(v,{prop:"sk",label:"API密钥"},{default:X(()=>[U(h,{modelValue:t.value.sk,"onUpdate:modelValue":c[1]||(c[1]=k=>t.value.sk=k)},null,8,["modelValue"])]),_:1}),U(v,{prop:"model",label:"模型"},{default:X(()=>[U(g,{modelValue:t.value.model,"onUpdate:modelValue":c[2]||(c[2]=k=>t.value.model=k),placeholder:"请选择模型"},{default:X(()=>[(P(),we(m,{key:0,label:"请选择模型",value:""})),(P(!0),G(tt,null,Dt(o.value,k=>(P(),we(m,{key:k.value,label:k.name,value:k.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1}),t.value.model=="custom"?(P(),we(v,{key:0,prop:"custom_model",label:"模型名称"},{default:X(()=>[U(h,{placeholder:"doubao-1-5-pro-32k-250115",modelValue:t.value.custom_model,"onUpdate:modelValue":c[3]||(c[3]=k=>t.value.custom_model=k)},null,8,["modelValue"])]),_:1})):me("",!0),U(v,{prop:"status",label:"状态"},{default:X(()=>[U(b,{modelValue:t.value.status,"onUpdate:modelValue":c[4]||(c[4]=k=>t.value.status=k)},{default:X(()=>[U(w,{value:"on",size:"large"},{default:X(()=>c[5]||(c[5]=[_t("启用")])),_:1}),U(w,{value:"off",size:"large"},{default:X(()=>c[6]||(c[6]=[_t("关闭")])),_:1})]),_:1},8,["modelValue"])]),_:1}),U(v,null,{default:X(()=>[U(E,{onClick:i,type:"primary"},{default:X(()=>c[7]||(c[7]=[_t("保存设置")])),_:1})]),_:1})]),_:1},8,["rules","model"])])]),_:1})]),_:1})])}}},IEe=Cr(OEe,[["__scopeId","data-v-1685030c"]]),$Ee={},MEe={class:"privacy"};function REe(e,t){const n=nu,o=tu;return P(),G("div",MEe,[U(o,null,{default:X(()=>[U(n,{xs:24},{default:X(()=>t[0]||(t[0]=[j("div",{class:"notice"},[j("ol",null,[j("li",null,[j("b",null,"AI 功能数据传输"),_t(":启用AI功能后,您的浏览器书签将会发送给AI服务器进行处理,以便根据输入的关键词查找匹配的书签。")]),j("li",null,[j("b",null,"OneNav 不收集书签数据"),_t(":OneNav官方本身不会收集或存储您的浏览器书签数据。所有的书签数据仅会在与AI交互时临时发送给AI服务器,AI的目的是帮助您智能查找相关书签。")]),j("li",null,[j("b",null,"隐私保护"),_t(":我们建议您了解使用此功能时的隐私风险,并谨慎使用。启用AI功能即表示您同意将书签数据发送给AI进行处理。")]),j("li",null,[j("b",null,"可选功能"),_t(":AI功能是可选的,您可以选择不使用此功能以保护书签隐私。")])])],-1)])),_:1})]),_:1})])}const AEe=Cr($Ee,[["render",REe],["__scopeId","data-v-58cca4f1"]]),PEe={class:"new-body"},NEe={class:"ai"},LEe={class:"ai-notice"},DEe={class:"avatar"},BEe=["src"],FEe={class:"msg"},VEe={key:0,class:"user"},HEe={class:"avatar"},zEe=["src"],WEe={class:"msg"},KEe={key:1,class:"onenav-ai"},jEe={class:"avatar"},UEe=["src"],GEe=["innerHTML"],YEe={class:"input-box"},qEe={class:"input"},XEe={class:"btns"},ZEe={class:"left-btn"},JEe={class:"right-btn"},QEe={class:"feature"},exe={class:"dialog-footer"},txe={__name:"Ai",setup(e){const t=Ma(),n=W(null),o=W(!1),r=W(!1),l=W(!1),a=W("search"),s=W({number:120,placeholder:"请输入关键词或描述以进行书签检索,支持Ctrl + Enter或Command + Enter提交"}),i=()=>{a.value==="search"?(s.value.number=120,s.value.placeholder="请输入关键词或描述以进行书签检索,支持Ctrl + Enter或Command + Enter提交"):(s.value.number=3e3,s.value.placeholder="请输入需要翻译的内容,支持Ctrl + Enter或Command + Enter提交")},u=W(""),d=W([]),c={link({href:b,title:E,text:S}){return`<a href="${b}" title="${E||""}" target="_blank">${S}</a>`}};Fn.use({renderer:c});const h=W(""),v=()=>{n.value&&n.value.scrollTo({top:n.value.scrollHeight,behavior:"smooth"})},m=()=>{localStorage.setItem("ai_privacy","agree"),l.value=!1},g=b=>{(b.ctrlKey||event.metaKey)&&b.key==="Enter"&&w()},w=async()=>{if(localStorage.getItem("ai_privacy")!=="agree")return l.value=!0,!1;if(u.value.trim()==="")return vn.error("请输入关键词!"),!1;if(u.value.trim().length<2)return vn.error("关键词长度过短!"),!1;if(u.value.trim().length>s.value.number)return vn.error("内容过长!"),!1;if(h.value="",!u.value.trim())return;const b=u.value;d.value.push({type:"user",msg:b}),u.value="";const E={type:"ai",msg:"思索中..."};d.value.push(E),o.value=!0,v();try{const S=await fetch("/index.php?c=api&method=ai_search",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({content:b,feature:a.value})});if(!S.body)return vn.error("浏览器不支持!"),o.value=!1,!1;const C=S.body.getReader();if(S.headers.get("content-type").includes("application/json")){const{done:I,value:T}=await C.read(),R=new TextDecoder("utf-8").decode(T),$=JSON.parse(R);if($.code===-1002){let L="参数错误!";$.err_msg=="Authorization failure!"&&(L="认证失败,请先登录!"),d.value[d.value.length-1].msg=L}else $.code===-2e3||$.msg?d.value[d.value.length-1].msg=$.msg:d.value[d.value.length-1].msg=$.err_msg;return o.value=!1,!1}const k=new TextDecoder("utf-8");let O="";for(;;){const{done:I,value:T}=await C.read();if(I)break;O+=k.decode(T,{stream:!0});let M=O.split(`
181`);O=M.pop();for(let R of M)if(R=R.trim(),R.startsWith("data:")){const $=R.substring(5).trim();if($==="[DONE]"){o.value=!1;return}console.log($);let L=JSON.parse($),V="";if(L.choices[0].delta.content&&(V=L.choices[0].delta.content),h.value+=V,d.value[d.value.length-1].msg=Fn.parse(h.value),v(),$==="[DONE]"){o.value=!1;return}}}}catch(S){console.error("请求失败:",S),o.value=!1}};return(b,E)=>{const S=Bh,C=co,_=lt,k=Lo,O=F6,I=Dh,T=Un,M=df;return P(),G(tt,null,[j("div",PEe,[j("div",NEe,[Tt(j("div",null,[U(S,null,{template:X(()=>[j("div",LEe,[j("div",DEe,[j("img",{src:f(tI),alt:""},null,8,BEe)]),j("div",FEe,[E[10]||(E[10]=_t(" OneNav AI将为您服务 ")),j("p",null,[j("a",{onClick:E[0]||(E[0]=R=>r.value=!0),href:"javascript:;"},"API设置"),E[9]||(E[9]=_t(" | ")),j("a",{onClick:E[1]||(E[1]=R=>l.value=!0),href:"javascipt:;"},"隐私说明")])])])]),_:1})],512),[[jt,d.value.length<=0]]),d.value.length>0?(P(),G("div",{key:0,ref_key:"listID",ref:n,class:"chat-list"},[(P(!0),G(tt,null,Dt(d.value,(R,$)=>(P(),G("div",{key:$},[R.type==="user"?(P(),G("div",VEe,[j("div",HEe,[j("img",{src:f(EEe),alt:""},null,8,zEe)]),j("div",WEe,We(R.msg),1)])):(P(),G("div",KEe,[j("div",jEe,[j("img",{src:f(tI),alt:""},null,8,UEe)]),j("div",{class:"msg markdown-body",innerHTML:R.msg},null,8,GEe)]))]))),128))],512)):me("",!0),j("div",YEe,[j("div",qEe,[U(C,{onKeydown:g,modelValue:u.value,"onUpdate:modelValue":E[2]||(E[2]=R=>u.value=R),style:{width:"100%",resize:"none"},rows:2,type:"textarea",autofocus:!0,placeholder:s.value.placeholder},null,8,["modelValue","placeholder"])]),j("div",XEe,[j("div",ZEe,[U(k,{effect:"dark",content:"API设置",placement:"top"},{default:X(()=>[j("a",{href:"javascript:;",onClick:E[3]||(E[3]=R=>r.value=!0)},[U(_,null,{default:X(()=>[U(f(nZ))]),_:1})])]),_:1}),U(k,{effect:"dark",content:"隐私说明",placement:"top"},{default:X(()=>[j("a",{href:"javascript:;",onClick:E[4]||(E[4]=R=>l.value=!0)},[U(_,null,{default:X(()=>[U(f(A0))]),_:1})])]),_:1})]),j("div",JEe,[j("div",QEe,[U(I,{onChange:i,modelValue:a.value,"onUpdate:modelValue":E[5]||(E[5]=R=>a.value=R)},{default:X(()=>[U(O,{label:"检索",value:"search"}),U(O,{label:"翻译",value:"translation"})]),_:1},8,["modelValue"])]),U(T,{title:"支持Ctrl + Enter或Command + Enter提交",disabled:u.value=="",loading:o.value,onClick:w,type:"primary",icon:f(WX),round:""},null,8,["disabled","loading","icon"])])])])])]),U(M,{top:f(t).dialogTop,width:f(t).dialogWidth,modal:"","append-to-body":!0,modelValue:r.value,"onUpdate:modelValue":E[6]||(E[6]=R=>r.value=R),title:"API设置"},{default:X(()=>[U(IEe)]),_:1},8,["top","width","modelValue"]),U(M,{top:f(t).dialogTop,width:f(t).dialogWidth,modal:"","append-to-body":!0,modelValue:l.value,"onUpdate:modelValue":E[8]||(E[8]=R=>l.value=R),title:"隐私提示"},{footer:X(()=>[j("div",exe,[U(T,{onClick:E[7]||(E[7]=R=>l.value=!1)},{default:X(()=>E[11]||(E[11]=[_t("取消")])),_:1}),U(T,{type:"primary",onClick:m},{default:X(()=>E[12]||(E[12]=[_t(" 同意 ")])),_:1})])]),default:X(()=>[U(AEe)]),_:1},8,["top","width","modelValue"])],64)}}},nxe=Cr(txe,[["__scopeId","data-v-d48b039d"]]),oxe={class:"redeem"},rxe={class:"form"},axe={__name:"Redeem",setup(e){const t=W({code:"",email:"",domain:""}),n=W(null),o=Ma();W({});const r=W(!1),l=qt({code:[{required:!0,message:"请填写兑换码",trigger:"blur"}],email:[{required:!0,message:"请填写正确的邮箱",trigger:"blur"}],domain:[{required:!0,message:"请填写域名",trigger:"change"}]}),a=()=>{n.value.validate(i=>{if(i){let u="https://shop.xiuping.net/api/onenav/redeem";r.value=!0,To.post(u,ts(t.value)).then(d=>{if(d.data.code==200){let c=d.data.data,h="/index.php?c=api&method=set_subscribe",v=ts({order_id:c.trade_no,email:t.value.email,domain:t.value.domain,end_time:c.end_time});Qn.post(h,v).then(m=>{m.data.code==0?(vn.success("兑换成功,请刷新页面查看!"),sessionStorage.removeItem("subscribe"),o.getSubscribeStatus()):vn.error(m.data.err_msg)})}else vn.error(d.data.msg)}).finally(()=>{r.value=!1})}else return!1})},s=()=>{Qn("/index.php?c=api&method=app_info").then(u=>{if(u.data.code==200){t.value.email=u.data.data.email.trim();let c=window.location.host.split(":")[0];t.value.domain=c}})};return kt(()=>{s()}),(i,u)=>{const d=co,c=eu,h=Un,v=Qi,m=nu,g=tu,w=x2;return P(),G("div",oxe,[U(g,null,{default:X(()=>[U(m,{xs:24},{default:X(()=>[j("div",rxe,[u[4]||(u[4]=j("div",{class:"notice"},[j("ul",null,[j("li",null,"重复使用兑换码,订阅时长不会叠加!"),j("li",null,"请填写正确的邮箱,以便接收订阅通知!"),j("li",null,"如果您已经存在订阅,使用兑换码后当前订阅将被替换,请谨慎操作!")])],-1)),Tt((P(),we(v,{ref_key:"formRef",ref:n,rules:l,"label-position":"top",model:t.value,"label-width":"auto",style:{"min-width":"260px","max-width":"600px"}},{default:X(()=>[U(c,{prop:"code",label:"兑换码"},{default:X(()=>[U(d,{modelValue:t.value.code,"onUpdate:modelValue":u[0]||(u[0]=b=>t.value.code=b)},null,8,["modelValue"])]),_:1}),U(c,{prop:"email",label:"邮箱"},{default:X(()=>[U(d,{modelValue:t.value.email,"onUpdate:modelValue":u[1]||(u[1]=b=>t.value.email=b)},null,8,["modelValue"])]),_:1}),U(c,{style:{display:"none"},prop:"domain",label:"域名"},{default:X(()=>[U(d,{modelValue:t.value.domain,"onUpdate:modelValue":u[2]||(u[2]=b=>t.value.domain=b)},null,8,["modelValue"])]),_:1}),U(c,null,{default:X(()=>[U(h,{style:{width:"100%"},onClick:a,type:"primary"},{default:X(()=>u[3]||(u[3]=[_t("立即兑换")])),_:1})]),_:1})]),_:1},8,["rules","model"])),[[w,r.value]])])]),_:1})]),_:1})])}}},lxe=Cr(axe,[["__scopeId","data-v-d037ea7d"]]),sxe=jbe({history:Cbe(),routes:[{path:"/",name:"home",component:Ske},{path:"/go/:id",name:"go",component:Yke},{path:"/ai",name:"ai",component:nxe},{path:"/redeem",name:"redeem",component:lxe}]}),yy=Dp(kwe);yy.use(Fye());yy.use(sxe);yy.use(Bye);yy.mount("#app")});export default ixe();

Callers 15

layui.jsFile · 0.80
dFunction · 0.80
jquery.min.jsFile · 0.80
layui.jsFile · 0.80
pFunction · 0.80
layer.jsFile · 0.80
XHRFunction · 0.80
getDataFunction · 0.80
XHRFunction · 0.80
getDataFunction · 0.80
mdui.min.jsFile · 0.80
atFunction · 0.80

Calls 10

spaceMethod · 0.45
hrMethod · 0.45
headingMethod · 0.45
codeMethod · 0.45
tableMethod · 0.45
blockquoteMethod · 0.45
listMethod · 0.45
htmlMethod · 0.45
paragraphMethod · 0.45
textMethod · 0.45

Tested by

no test coverage detected