const{createApp}=Vue const{createVuetify,useGoTo,useDisplay}=Vuetify var data={alert:{show:false,color:'success',text:'',timeout:0,},theme:{dark:false,},nav:{showDrawer:false,showTOC:true,tocPanel:0,tab:'account',post:{discussionId:6191,currentPage:1,targetPage:1,total:11,anchor:0,goToOptions:{container:null,duration:0,easing:'easeInOutCubic',offset:-100,},worker:null,task:[],active:[],apiLock:[],originLike:new Map([]),},related:{block:1,}},search:{width:80,text:null,loading:false,},tags:[{id:50,url:'/t/32715a296a045c7260770f713010',name:'图床',color:'#66BB6A',icon:'mdi-tag-heart',},],posts:[{id:72185,num:0,uid:1783,content:'\u003Cp\u003E看到好多人都开放公益\u003Cbr\u003E可是我觉得大部分图片没有观看的价值,存在服务器好像只是浪费空间,如果是自用,还可以把不要的删掉,论坛官方也可以清除10年前的图片,放在别人那有丢的风险\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-23 23:37:29',updatedAt:'2025-03-24 10:09:57',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:72186,num:1,uid:1892,content:'\u003Cp\u003E自己玩的开心罢了,跟博客差不多\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-23 23:38:31',updatedAt:'2025-03-24 10:09:57',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:72187,num:2,uid:3152,content:'\u003Cp\u003E吃灰🐔再利用\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-23 23:39:43',updatedAt:'2025-03-24 10:09:57',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:72188,num:3,uid:4444,content:'\u003Cp\u003E就两个字——折腾\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-23 23:41:32',updatedAt:'2025-03-24 10:09:57',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:72189,num:4,uid:1760,content:'\u003Cp\u003E买机不就是用来玩的么,重在玩,就跟为什么存在那么多开源项目一样\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-23 23:51:36',updatedAt:'2025-03-24 10:09:57',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:72190,num:5,uid:1424,content:'\u003Cp\u003E收集**助兴素材而已\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-23 23:53:58',updatedAt:'2025-03-24 10:09:57',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:72191,num:6,uid:3318,content:'\u003Cp\u003E随时关的\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-24 00:07:16',updatedAt:'2025-03-24 10:09:57',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:72192,num:7,uid:1891,content:'\u003Cp\u003E折腾\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-24 00:08:34',updatedAt:'2025-03-24 10:09:57',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:72193,num:8,uid:1563,content:'\u003Cp\u003E搭建了自用,然后再开放 \u003Cimg src\u003D\"/z/img/xhj/006.webp\"\u003E\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-24 00:09:29',updatedAt:'2025-03-24 10:09:57',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:72194,num:9,uid:1829,content:'\u003Cp\u003E吃灰🐔再利用\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-24 00:19:25',updatedAt:'2025-03-24 10:09:57',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:72195,num:10,uid:1924,content:'\u003Cp\u003E鸡放着也是放着,拿出来发光发热\u003C/p\u003E\u003Cp\u003E也算是给自己的鸡找了个存在的意义\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-24 00:20:43',updatedAt:'2025-03-24 10:09:57',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},],usersMap:new Map([[1424,{uid:1424,url:'/u/377874556a045c766468526f391d1437',avatar:'/a/377874556a045c766468526f391d1437',username:'陌生人🤖',}],[1829,{uid:1829,url:'/u/123e583e6a045c7668685f6f3f11252a',avatar:'/a/123e583e6a045c7668685f6f3f11252a',username:'flyblack🤖',}],[1924,{uid:1924,url:'/u/2b3c03386a045c766968526f21590602',avatar:'/a/2b3c03386a045c766968526f21590602',username:'DreamCloud🤖',}],[1892,{uid:1892,url:'/u/000c0b0a6a045c766863546f343f2229',avatar:'/a/000c0b0a6a045c766863546f343f2229',username:'skyytor🤖',}],[1760,{uid:1760,url:'/u/343101276a045c76676c566f241c3c17',avatar:'/a/343101276a045c76676c566f241c3c17',username:'Giraffe🤖',}],[1563,{uid:1563,url:'/u/1211601a6a045c76656c556f110f3530',avatar:'/a/1211601a6a045c76656c556f110f3530',username:'lbczzs🤖',}],[1891,{uid:1891,url:'/u/6d19481f6a045c766863576f1a51142a',avatar:'/a/6d19481f6a045c766863576f1a51142a',username:'昶-🤖',}],[1783,{uid:1783,url:'/u/31087b3f6a045c766762556f1a2f2517',avatar:'/a/31087b3f6a045c766762556f1a2f2517',username:'lxz07🤖',}],[4444,{uid:4444,url:'/u/6d186a346a045c73646e526f41032121',avatar:'/a/6d186a346a045c73646e526f41032121',username:'hoofei🤖',}],[3318,{uid:3318,url:'/u/0b20040b6a045c74636b5e6f1410107f',avatar:'/a/0b20040b6a045c74636b5e6f1410107f',username:'寒冰飞雪🤖',}],[3152,{uid:3152,url:'/u/290043196a045c74616f546f1a2a0534',avatar:'/a/290043196a045c74616f546f1a2a0534',username:'jsllxx🤖',}],]),related:[{title:'兰空图床马上要涨价了!',url:'/d/2f78602b6a045c77606a567a445d6b6a1d2a3b0a',},{title:'过客图床测试',url:'/d/33105d076a045c77606a5675405a6b6a1a73623e',},{title:'有大佬会minio接入CloudFlare-ImgBed',url:'/d/091e5f206a045c77606a5675405b606a2e39113c',},{title:'love图床 欢迎使用',url:'/d/160274006a045c77606a56774f51626a2e1b071d',},{title:'测一下图床速度',url:'/d/117f772f6a045c77606a56774f5b6b6a3a140460',},{title:'有服务器、网盘、nas、公网IP怎么搞一套最好的图床',url:'/d/340a7e026a045c77606a5677435d666a01316315',},{title:'上次看到有人分享avif的图床,是哪个的?',url:'/d/3d2107556a045c77606a56774658626a140e6420',},{title:'兰空开源版,有办法上传avif吗?',url:'/d/0d0b00176a045c77606a5676465a606a2b7b2907',},{title:'不懂就问 蓝空图床的注册点了之后没反应是怎么回事?',url:'/d/157c0a276a045c77606a56714e58626a3d071d04',},{title:'论坛只能用自建图床发图片吗?',url:'/d/303f642c6a045c77606a56714159626a08022562',},{title:'屌大的来个免费稳定的图床!',url:'/d/1f2277036a045c77606a567145586a6a0f2d6b28',},{title:'自建图床测试NSFW',url:'/d/6e2864386a045c77606a5671475f616a22326a26',},{title:'请教大佬们图床问题',url:'/d/6d70631e6a045c77606a5671475a6a6a3e753131',},{title:'废物利用自建php图床+插件',url:'/d/12185e1e6a045c77606a56704e5e666a2b0e2b38',},{title:'bing出问题了吗?简单图床登录界面抓取bing图片失败',url:'/d/6e394b256a045c77606a5670405a676a010d1507',},{title:'图床半挂?',url:'/d/192e7b226a045c77606a5670445b656a1c090935',},{title:'来花1H自建自己的图床吧',url:'/d/2a2b582a6a045c77606a56704651666a00070733',},{title:'Lsky 公益图床',url:'/d/3e22785c6a045c77606a5673465e666a25313067',},{title:'各位用公共图床会不会有不安全感',url:'/d/30227f076a045c77606a5673465d666a26082721',},{title:'收个二手蓝空图床正版认证',url:'/d/693941346a045c77606a56724e5e676a5f331825',},],} const App={setup(){const goTo=useGoTo() const{mdAndUp}=useDisplay() return{goTo,mdAndUp}},data(){return data;},mounted(){const themeDark=localStorage.getItem("themeDark") if(themeDark!==null){this.theme.dark=JSON.parse(themeDark)} if(this.nav.post.total>(this.nav.post.currentPage-1)*100+20){let moreLen=100 if(this.nav.post.total({id:null,num:(this.nav.post.currentPage-1)*100+v,uid:null,content:null,ipRegion:null,updatedByUid:null,createdAt:null,updatedAt:null,mentionNum:null,mentionedBy:null,mentionUsers:null,likeUsers:null,})) this.posts.push(...morePosts.slice(20))} this.workerStart() const hash=window.location.hash const match=hash.match(/#(\d+)/) if(match){const n=parseInt(match[1],10) if(n>=(this.nav.post.currentPage-1)*100&&n{this.jumpTo(n)})}} this.$nextTick(()=>{this.addHeadingIds() tocbot.init({tocSelector:'.toc',contentSelector:'#post-content-0',headingSelector:'h2, h3, h4',headingsOffset:100,scrollSmoothOffset:-100,scrollSmooth:true,collapseDepth:6,onClick:function(e){setTimeout(()=>{history.replaceState(null,'',window.location.pathname+window.location.search)},0)},}) tocbot.refresh()});},beforeUnmount(){this.workerStop() if(this.quill){this.quill.destroy() this.quill=null}},computed:{dposts(){return this.posts.slice(20);},},created(){},methods:{successAlert(msg){this.alert={show:true,color:'success',text:msg,timeout:1500,}},failureAlert(msg){this.alert={show:true,color:'error',text:msg,timeout:5000,}},flipThemeDark(){this.theme.dark=!this.theme.dark localStorage.setItem("themeDark",JSON.stringify(this.theme.dark))},toSearch(){if(!this.search.text){this.failureAlert('搜索词不能为空') return} let keywords=this.search.text.trim() if(keywords.length<1){this.failureAlert('搜索词不能为空') return} if(keywords.length>100){this.failureAlert('搜索词过长') return} this.doSearch(keywords)},toReg(){window.location.href="/reg"},toLogin(){window.location.href="/login"},toPage(){let url=window.location.href url=url.replace(/(\/\d+)?(#[0-9]+)?$/,this.nav.post.targetPage>1?`/${this.nav.post.targetPage}`:'') window.location.href=url},toLoadRelated({done}){if(this.my&&this.my.uid){this.apiLoadRelated({done})}else{done('ok')}},workerStart(){this.nav.post.worker=setInterval(()=>{this.workerLoad()},500);},workerStop(){if(this.nav.post.worker){clearInterval(this.nav.post.worker);this.nav.post.worker=null;}},async jumpTo(num){const page=Math.floor(num/100)+1 const i=num-(page-1)*100 if(page===this.nav.post.currentPage){this.goTo("#post-"+num,this.nav.post.goToOptions) if(!this.posts[i].id){const block=Math.floor(num/20)+1 this.nav.post.apiLock[block]=true await this.apiLoadPosts(block) this.$nextTick(()=>{this.goTo("#post-"+num,this.nav.post.goToOptions)})}}else{let url=window.location.href url=url.replace(/(\/\d+)?(#[0-9]+)?$/,page>1?`/${page}`:'') url=url+"#"+num window.location.href=url}},postIntersect(num){return(isIntersecting,entries,observer)=>{if(isIntersecting){this.nav.post.task.push(num) this.nav.post.active.push(num) this.nav.post.active=this.nav.post.active.filter(item=>Math.abs(item-num)<=5) this.nav.post.active.sort((a,b)=>a-b)}else{this.nav.post.active=this.nav.post.active.filter(item=>item!==num)} if(this.nav.post.active[0]){this.nav.post.anchor=this.nav.post.active[0]}else{this.nav.post.anchor=0}}},async apiLoadPosts(block){try{const response=await axios.post('/fapi/v1/post/block/'+block,{discussionId:this.nav.post.discussionId,}) if(response.data.code===0){response.data.data.posts.forEach(post=>{const i=post.num%100 Object.assign(this.posts[i],post)}) response.data.data.users.forEach(user=>{this.usersMap.set(user.uid,user)})}else{this.failureAlert('回帖数据加载失败: '+response.data.msg)}}catch(error){this.failureAlert('回帖数据加载失败: '+error)} this.nav.post.apiLock[block]=false},workerLoad(){while(this.nav.post.task.length){const num=this.nav.post.task.pop() const i=num-(this.nav.post.currentPage-1)*100 if(!this.posts[i].id){const block=Math.floor(num/20)+1 if(!this.nav.post.apiLock[block]){this.nav.post.apiLock[block]=true this.apiLoadPosts(block)}}}},getTimeInfo(t){if(!t){return ""} const now=new Date();const then=new Date(t);const diff=now-then;const minute=60*1000;const hour=minute*60;const day=hour*24;const month=day*30;const year=month*12;if(diffpost.num===num) if(!post){return "#"+num} const uid=post.uid const username=this.usersMap.get(uid)?.username if(!username){return "#"+num} return username},getUsernameByPostId(id){const post=this.posts.find(post=>post.id===id) if(!post){return "#"+this.getPostNumByPostId(id)} const uid=post.uid const username=this.usersMap.get(uid).username if(!username){return "#"+this.getPostNumByPostId(id)} return username},getPostNumByPostId(id){const post=this.posts.find(post=>post.id===id) return post.num},getPostById(id){const post=this.posts.find(post=>post.id===id) return post},getPostByNum(num){const post=this.posts.find(post=>post.num===num) return post},getAvatarByUid(uid){const avatar=this.usersMap.get(uid)?.avatar if(!avatar){return this.getRandomAvatar()} return avatar},getAvatarByPostNum(num){const post=this.posts.find(post=>post.num===num) if(!post){return this.getRandomAvatar()} const uid=post.uid return this.getAvatarByUid(uid)},getRandomAvatar(){const num=Math.floor(Math.random()*100) return "https://randomuser.me/api/portraits/men/"+num+".jpg"},getUrlByUid(uid){const url=this.usersMap.get(uid)?.url if(!url){return ""} return url},getTextByPostNum(num){const post=this.posts.find(post=>post.num===num) if(!post||!post.content){return '点击跳转到#'+num+'查看'} const parser=new DOMParser() const doc=parser.parseFromString(post.content,'text/html') const text=doc.body.textContent||'' return text.slice(0,100)},addHeadingIds(){const content=document.getElementById('post-content-0') if(!content){this.nav.showTOC=false return} const headings=content.querySelectorAll('h2, h3, h4') headings.forEach((heading,index)=>{if(!heading.id){heading.id=`toc-nav-${index}`}}) if(headings.length==0){this.nav.showTOC=false}},async doSearch(keywords){this.search.loading=true try{const response=await axios.post('/fapi/v1/search',{keywords:keywords,}) if(response.data.code===0){if(response.data.data.hash&&response.data.data.hash.length===32){window.location.href="/s/"+response.data.data.hash}else{this.failureAlert('搜索失败: 搜索服务异常')}}else{this.failureAlert('搜索失败: '+response.data.msg)}}catch(error){this.failureAlert('搜索失败: '+error)} this.search.loading=false},debounce(fn,delay){let timer=null return function(...args){if(timer)clearTimeout(timer) timer=setTimeout(()=>{fn.apply(this,args)},delay);};},},watch:{'nav.post.targetPage':{handler:async function(newV,oldV){this.toPage()},immediate:false},},} const vuetify=createVuetify({defaults:{global:{ripple:true,},},}) const app=createApp(App) app.use(vuetify).mount("#app")