fuc-new/doc/node_modules/@vuepress/plugin-git/lib/client/GitChangelog-BNkLXo_s.js
hellcat 6adbc04d4b 1
2025-10-03 17:17:08 +08:00

3 lines
2.9 KiB
JavaScript

import{useToggle as O}from"@vueuse/core";import{computed as p,toValue as m,defineComponent as S,h as e}from"vue";import{u as h,V as I}from"./VPHeader-CxSnSiPZ.js";import"./styles/vars.css";import"./styles/changelog.css";import{useData as u}from"vuepress/client";import{isLinkHttp as T}from"@vuepress/helper/client";const v=typeof __GIT_OPTIONS__>"u"?{}:__GIT_OPTIONS__,w=(a,s)=>!a||T(a)?a:s==="github"?`https://github.com/${a}`:s==="gitee"?`https://gitee.com/${a}`:a,L=/#(\d+)/g,d=typeof __GIT_CHANGELOG__=="boolean"&&__GIT_CHANGELOG__?(a=!0)=>{const{frontmatter:s,lang:n,page:i}=u(),{pattern:l={},provider:r}=v,o=w(v.repo,r);return p(()=>{if(s.value.changelog===!1||!m(a))return[];const c=new Intl.DateTimeFormat(n.value,{dateStyle:"short"});return(i.value.git?.changelog??[]).map(g=>{const t={date:c.format(g.time),...g};return l.issue&&o&&(t.message=t.message.replace(L,(f,G)=>`<a href="${l.issue.replace(":issue",G).replace(":repo",o)}" target="_blank" rel="noopener noreferrer">${f}</a>`)),l.commit&&o&&(t.commitUrl=l.commit.replace(":hash",t.hash).replace(":repo",o)),l.tag&&o&&t.tag&&(t.tagUrl=l.tag.replace(":tag",t.tag).replace(":repo",o)),t})})}:()=>p(()=>[]),_=(a=!0)=>{const{lang:s,page:n}=u(),i=h();return p(()=>{if(!m(a))return null;const l=n.value.git?.updatedTime??n.value.git?.changelog?.[0].time;if(!l)return null;const r=new Date(l),o=new Intl.DateTimeFormat(s.value,{dateStyle:"short",timeStyle:"short"}).format(l);return{date:r,text:o,iso:r.toISOString(),locale:i.value.latestUpdateAt}})},y=S({name:"GitChangelog",props:{title:String,headerLevel:{type:Number,default:2}},setup(a){const s=d(),n=h(),i=_(),[l,r]=O(),o=()=>e("div",{class:"vp-changelog-header",onClick:()=>r()},[e("div",{class:"vp-latest-updated"},[e("span",{class:"vp-changelog-icon"}),e("span",{"data-allow-mismatch":""},i.value.text)]),e("div",[e("span",{class:"vp-changelog-menu-icon"}),e("span",n.value.viewChangelog)])]),c=({item:t})=>e("li",{class:"vp-changelog-item-tag"},e("div",[e("a",{class:"vp-changelog-tag"},e("code",t.tag)),e("span",{class:"vp-changelog-date","data-allow-mismatch":""},[n.value.timeOn," ",e("time",{datetime:new Date(t.time).toISOString()},t.date)])])),g=({item:t})=>e("li",{class:"vp-changelog-item-commit"},[e(t.commitUrl?"a":"span",{class:"vp-changelog-hash",href:t.commitUrl,target:"_blank",rel:"noreferrer"},[e("code",t.hash.slice(0,5))]),e("span",{class:"vp-changelog-divider"},"-"),e("span",{class:"vp-changelog-message",innerHTML:t.message}),e("span",{class:"vp-changelog-date","data-allow-mismatch":""},[n.value.timeOn||"on"," ",e("time",{datetime:new Date(t.time).toISOString()},t.date)])]);return()=>s.value.length?[e(I,{level:a.headerLevel,anchor:"doc-changelog",text:a.title||n.value.changelog}),e("div",{class:["vp-changelog-wrapper",{active:l.value}]},[e(o),e("ul",{class:"vp-changelog-list"},[s.value.map(t=>t.tag?e(c,{item:t,key:t.tag}):e(g,{item:t,key:t.hash}))])])]:null}});export{y as G,_ as a,d as u};
//# sourceMappingURL=GitChangelog-BNkLXo_s.js.map