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:8618,currentPage:1,targetPage:1,total:32,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:[],posts:[{id:115520,num:0,uid:4839,content:'\u003Cp\u003E不想干程序员了,感觉每天好没意思,想转行干别的,但是又有点碍于钱没那么多,不敢下定决心。\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-04-17 14:09:36',updatedAt:'2025-04-19 23:48:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:115521,num:1,uid:4271,content:'+1\u003Cbr\u003E我喜欢编程,但是只想做自己喜欢的应用',ipRegion:'',updatedByUid:0,createdAt:'2025-04-17 14:11:27',updatedAt:'2025-04-19 23:48:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:115522,num:2,uid:19120,content:'转行能干啥呢?放假回家发现大批的年轻人都下岗呆家里',ipRegion:'',updatedByUid:0,createdAt:'2025-04-17 14:11:43',updatedAt:'2025-04-19 23:48:08',mentionNum:0,mentionedBy:[23,],mentionUsers:[],likeUsers:[],},{id:115523,num:3,uid:5052,content:'先去送 2 个月外卖,锻炼下身体',ipRegion:'',updatedByUid:0,createdAt:'2025-04-17 14:12:13',updatedAt:'2025-04-19 23:48:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:115524,num:4,uid:2336,content:'做啥有意思还能赚钱?想好了吗?',ipRegion:'',updatedByUid:0,createdAt:'2025-04-17 14:18:02',updatedAt:'2025-04-19 23:48:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:115525,num:5,uid:29,content:'我想去干保安',ipRegion:'',updatedByUid:0,createdAt:'2025-04-17 14:24:27',updatedAt:'2025-04-19 23:48:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:115526,num:6,uid:6949,content:'我经常有这种想法,每次都想爆了。\u003Cbr\u003E最后感觉自己不干程序啥也不会干,又怂了。',ipRegion:'',updatedByUid:0,createdAt:'2025-04-17 14:25:23',updatedAt:'2025-04-19 23:48:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:115527,num:7,uid:5066,content:'哈哈,一样的,但是又不知道自己能干什么',ipRegion:'',updatedByUid:0,createdAt:'2025-04-17 14:28:49',updatedAt:'2025-04-19 23:48:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:115528,num:8,uid:9590,content:'我想当鉴黄师或橙文作者 但我怕累 \u003Cimg src\u003D\"https://i.imgur.com/io2SM1h.png\"\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-04-17 14:31:17',updatedAt:'2025-04-19 23:48:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:115529,num:9,uid:8,content:'如果你只是不想干程序员,并没有什么特别想的干的,那么最好别转,因为其它工作往往也没意思,你只不过只了解程序员而已。如果有想干的,可以先摸鱼学习,学到一定程度再转就行了,经济上风险更小,而且学习的过程会给你决心。',ipRegion:'',updatedByUid:0,createdAt:'2025-04-17 14:52:38',updatedAt:'2025-04-19 23:48:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:115530,num:10,uid:2820,content:'早就不想干了,但是又能干啥呢,再过几年直接岗位都没了,直接不用选择了',ipRegion:'',updatedByUid:0,createdAt:'2025-04-17 15:04:57',updatedAt:'2025-04-19 23:48:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:115531,num:11,uid:11122,content:'俺也一样',ipRegion:'',updatedByUid:0,createdAt:'2025-04-17 15:11:03',updatedAt:'2025-04-19 23:48:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:115532,num:12,uid:4839,content:'\u003Cbr\u003E确实是,打电话问了四川新东方,想干厨子开店。',ipRegion:'',updatedByUid:0,createdAt:'2025-04-17 15:12:50',updatedAt:'2025-04-19 23:48:08',mentionNum:0,mentionedBy:[17,],mentionUsers:[],likeUsers:[],},{id:115533,num:13,uid:18120,content:'我已经转了 但一样没啥意思',ipRegion:'',updatedByUid:0,createdAt:'2025-04-17 15:17:00',updatedAt:'2025-04-19 23:48:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:115534,num:14,uid:5765,content:'别的一样没意思',ipRegion:'',updatedByUid:0,createdAt:'2025-04-17 15:17:58',updatedAt:'2025-04-19 23:48:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:115535,num:15,uid:4528,content:'没事,等过了 30 岁自然会转的😂',ipRegion:'',updatedByUid:0,createdAt:'2025-04-17 15:23:56',updatedAt:'2025-04-19 23:48:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:115536,num:16,uid:5817,content:'我也感觉没啥意思 这行大部分人都是纯纯底层码农干着身心俱疲 但上面的老哥说得也对 如果没有真的热爱的东西 转哪行都会有这种感觉的',ipRegion:'',updatedByUid:0,createdAt:'2025-04-17 15:25:50',updatedAt:'2025-04-19 23:48:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:115537,num:17,uid:1048,content:'#12 巧了 我有个大学同学也是想干厨子 自己开店',ipRegion:'',updatedByUid:0,createdAt:'2025-04-17 15:26:24',updatedAt:'2025-04-19 23:48:08',mentionNum:12,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:115538,num:18,uid:7572,content:'可以下班搞点副业,搞出来了就离职',ipRegion:'',updatedByUid:0,createdAt:'2025-04-17 15:29:21',updatedAt:'2025-04-19 23:48:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:115539,num:19,uid:10525,content:'不如周末先试试别的',ipRegion:'',updatedByUid:0,createdAt:'2025-04-17 15:34:50',updatedAt:'2025-04-19 23:48:08',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},],usersMap:new Map([[5817,{uid:5817,url:'/u/697b5e5c6a045c72686b516f2d1b1d12',avatar:'/a/697b5e5c6a045c72686b516f2d1b1d12',username:'coderlxm🤖',}],[2820,{uid:2820,url:'/u/2a7f061c6a045c756868566f432b621f',avatar:'/a/2a7f061c6a045c756868566f432b621f',username:'huashuinengshou🤖',}],[6407,{uid:6407,url:'/u/0a7e5c086a045c71646a516f22082420',avatar:'/a/0a7e5c086a045c71646a516f22082420',username:'Patrick6🤖',}],[10525,{uid:10525,url:'/u/6901025c6a045d776568536f243f6a29',avatar:'/a/6901025c6a045d776568536f243f6a29',username:'la2la🤖',}],[9590,{uid:9590,url:'/u/691b04246a045c7e6563566f0d3f0028',avatar:'/a/691b04246a045c7e6563566f0d3f0028',username:'nexklee🤖',}],[29,{uid:29,url:'/u/2827583b6a045c7760685f6f47241106',avatar:'/a/2827583b6a045c7760685f6f47241106',username:'youyouzi🤖',}],[2336,{uid:2336,url:'/u/2d2e45026a045c756369506f32181c04',avatar:'/a/2d2e45026a045c756369506f32181c04',username:'niboy🤖',}],[5052,{uid:5052,url:'/u/200170376a045c72606f546f2d23070f',avatar:'/a/200170376a045c72606f546f2d23070f',username:'calmlyman🤖',}],[4839,{uid:4839,url:'/u/6e100b056a045c7368695f6f14060277',avatar:'/a/6e100b056a045c7368695f6f14060277',username:'aa514758835🤖',}],[1048,{uid:1048,url:'/u/28067a3d6a045c76606e5e6f023e0b36',avatar:'/a/28067a3d6a045c76606e5e6f023e0b36',username:'wweerrgtc🤖',}],[18120,{uid:18120,url:'/u/337e50346a045d7f6168566f22101d3e',avatar:'/a/337e50346a045d7f6168566f22101d3e',username:'peachpeach🤖',}],[11122,{uid:11122,url:'/u/2e2b5b5e6a045d766168546f46382104',avatar:'/a/2e2b5b5e6a045d766168546f46382104',username:'howfree🤖',}],[5765,{uid:5765,url:'/u/093c7f1e6a045c72676c536f0e2b1a05',avatar:'/a/093c7f1e6a045c72676c536f0e2b1a05',username:'knva🤖',}],[19120,{uid:19120,url:'/u/1e7002296a045d7e6168566f115f032e',avatar:'/a/1e7002296a045d7e6168566f115f032e',username:'5200🤖',}],[4528,{uid:4528,url:'/u/0c3f673c6a045c7365685e6f152c1a25',avatar:'/a/0c3f673c6a045c7365685e6f152c1a25',username:'holdeer🤖',}],[5066,{uid:5066,url:'/u/0b3e07176a045c72606c506f110a6674',avatar:'/a/0b3e07176a045c72606c506f110a6674',username:'HelloApex🤖',}],[6949,{uid:6949,url:'/u/17335a286a045c71696e5f6f125c0a3f',avatar:'/a/17335a286a045c71696e5f6f125c0a3f',username:'hhjuteman🤖',}],[7572,{uid:7572,url:'/u/2c2278156a045c70656d546f1e38097f',avatar:'/a/2c2278156a045c70656d546f1e38097f',username:'SuperManNoPain🤖',}],[8,{uid:8,url:'/u/1b2673156a045c77606a5e6f0d5a2711',avatar:'/a/1b2673156a045c77606a5e6f0d5a2711',username:'coderluan🤖',}],[4271,{uid:4271,url:'/u/3c1e445a6a045c73626d576f32061936',avatar:'/a/3c1e445a6a045c73626d576f32061936',username:'yoa1q7y🤖',}],]),related:[],} 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")