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:5554,currentPage:1,targetPage:1,total:12,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:32,url:'/t/330554356a045c74627721761028',name:'Debian',color:'#66BB6A',icon:'mdi-debian',},],posts:[{id:63807,num:0,uid:5849,content:'各种小问题\u003Cbr\u003E最让人受不了的是 ibus 输入法。无论我是清除本地数据文件,还是 remove 再 reinstall ,都解决不了\u003Cbr\u003E这只是我的个案吗?\u003Cbr\u003E\u003Cbr\u003E看起来 debian 13 也快来了\u003Cbr\u003E不然我都想切换到 fedora',ipRegion:'',updatedByUid:0,createdAt:'2025-03-19 11:15:55',updatedAt:'2025-03-20 22:34:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:63808,num:1,uid:12285,content:'期待 13',ipRegion:'',updatedByUid:0,createdAt:'2025-03-19 11:19:56',updatedAt:'2025-03-20 22:34:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:63809,num:2,uid:11599,content:'fcitx5 试试',ipRegion:'',updatedByUid:0,createdAt:'2025-03-19 11:46:39',updatedAt:'2025-03-20 22:34:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:63810,num:3,uid:4148,content:'预装的 unattended-upgrade 更难绷, 不知道是 aws 还是 debian 的问题, 默认配置在早晚 6 点自动更新, 高占用能把机器跑到失联, aws 的管理面板点重启关机都没有, 我还以为是墙顺着网线把机器爆破了',ipRegion:'',updatedByUid:0,createdAt:'2025-03-19 12:01:41',updatedAt:'2025-03-20 22:34:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:63811,num:4,uid:1100,content:'debian 跑 cli 的呢,跑 desktop 肯定不能选 debian',ipRegion:'',updatedByUid:0,createdAt:'2025-03-19 14:44:12',updatedAt:'2025-03-20 22:34:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:63812,num:5,uid:6100,content:'别用 gnome 就解决你的问题了。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-19 14:50:58',updatedAt:'2025-03-20 22:34:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:63813,num:6,uid:519,content:'fcitx5 试试,有必要的话换个桌面环境,如果还不行那才能说明是 debian 的问题。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-19 14:56:03',updatedAt:'2025-03-20 22:34:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:63814,num:7,uid:793,content:'本地开发 arch 才是最适合的',ipRegion:'',updatedByUid:0,createdAt:'2025-03-19 15:08:50',updatedAt:'2025-03-20 22:34:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:63815,num:8,uid:11085,content:'fcitx5 应该没问题,不过我用的 arch 和 gnome',ipRegion:'',updatedByUid:0,createdAt:'2025-03-19 15:50:35',updatedAt:'2025-03-20 22:34:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:63816,num:9,uid:665,content:'图形化,但没有选择 Ubuntu ,是哪方面有顾虑呢。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-19 15:55:08',updatedAt:'2025-03-20 22:34:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:63817,num:10,uid:616,content:'fcitx5+cinnamon',ipRegion:'',updatedByUid:0,createdAt:'2025-03-19 16:03:44',updatedAt:'2025-03-20 22:34:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:63818,num:11,uid:63,content:'Xwindow 的输入法吗?\u003Cbr\u003E现在是不是跟以前一样还需要设置 GTK_IM_MODULE 或者是 XIM 之类的环境变量?',ipRegion:'',updatedByUid:0,createdAt:'2025-03-20 14:50:59',updatedAt:'2025-03-20 22:34:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},],usersMap:new Map([[11085,{uid:11085,url:'/u/36335b2a6a045d766062536f30043e15',avatar:'/a/36335b2a6a045d766062536f30043e15',username:'Maboroshii🤖',}],[6100,{uid:6100,url:'/u/0a2b6b5a6a045c71616a566f422c1937',avatar:'/a/0a2b6b5a6a045c71616a566f422c1937',username:'L4Linux🤖',}],[793,{uid:793,url:'/u/183d471f6a045c776763556f27203825',avatar:'/a/183d471f6a045c776763556f27203825',username:'june4🤖',}],[5849,{uid:5849,url:'/u/6b1e660b6a045c72686e5f6f30200213',avatar:'/a/6b1e660b6a045c72686e5f6f30200213',username:'wencan🤖',}],[11599,{uid:11599,url:'/u/632648546a045d7665635f6f2e011502',avatar:'/a/632648546a045d7665635f6f2e011502',username:'pooorguy🤖',}],[12285,{uid:12285,url:'/u/693a5c3c6a045d756262536f1b3e0221',avatar:'/a/693a5c3c6a045d756262536f1b3e0221',username:'tpxcer🤖',}],[519,{uid:519,url:'/u/682253096a045c77656b5f6f391a630c',avatar:'/a/682253096a045c77656b5f6f391a630c',username:'Cu635🤖',}],[63,{uid:63,url:'/u/1c187b5d6a045c77606c556f2d206420',avatar:'/a/1c187b5d6a045c77606c556f2d206420',username:'julyclyde🤖',}],[665,{uid:665,url:'/u/1204783a6a045c77666c536f32386b0f',avatar:'/a/1204783a6a045c77666c536f32386b0f',username:'gam2046🤖',}],[616,{uid:616,url:'/u/6f2c401b6a045c77666b506f0302161f',avatar:'/a/6f2c401b6a045c77666b506f0302161f',username:'imjiaoyuan🤖',}],[4148,{uid:4148,url:'/u/0d13632c6a045c73616e5e6f103b6177',avatar:'/a/0d13632c6a045c73616e5e6f103b6177',username:'wu67🤖',}],[1100,{uid:1100,url:'/u/0b2d76226a045c76616a566f153e173e',avatar:'/a/0b2d76226a045c76616a566f153e173e',username:'yinmin🤖',}],]),related:[{title:'问一下 debian如何全盘备份?',url:'/d/687d061d6a045c77606a56764459636a1d730225',},{title:'debian aarch64位鸡有什么好的代理工具?',url:'/d/007e072a6a045c77606a5673415d656a050e2717',},{title:'求众测,自己封装的debian12镜像,怎么dd后缺乏无法启动,镜像在原机器封装之前都可以重启开关机都没有问题',url:'/d/0a714a0b6a045c77606a5672455e666a36320b1e',},],} 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")