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:3440,currentPage:1,targetPage:1,total:25,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:27,url:'/t/0e2e58346a045c7567770b2b3120',name:'Go',color:'#FFA726',icon:'mdi-language-go',},{id:28,url:'/t/3d104b0f6a045c7568772c310313',name:'Java',color:'#FFA726',icon:'mdi-language-java',},{id:31,url:'/t/627a592b6a045c74617724732521',name:'Rust',color:'#FFA726',icon:'mdi-language-rust',},],posts:[{id:40619,num:0,uid:642,content:'\u003Cp\u003EJ**a 服务端开发一枚,主力语言就只有 J**a ,总感觉势单力薄,所以潜心入门学习 Rust 中,入门两次了,有的时候我也想报警,这学习曲线咋会那么陡!\u003C/p\u003E\u003Cp\u003E好在最近开始上手 rust-by-example 和 rustlings 之后觉得自己稍微懂了点!\u003C/p\u003E\u003Cp\u003E但每到学习 rust 难点的时候总想着大家都说 go 简单,又适合 web 项目开发,就老是容易有以下想法\u003C/p\u003E\u003Cp\u003E1 、我学 rust 干啥? 能找到 web3 远程工作还是能重复造轮子?2 、我要 rust 那么牛逼干啥,go 不是也能做么?也不比 rust 差3 、我就是想看看能不能找份兼职的服务端远程开发,为啥当时会脑残选择 rust 呢?4 、已经花在 rust 学习上快 2 个多月了,这个时候放弃是不是有点浪费时间了?这个时候再去转 go 阵营,会不会被枪毙呢?万一 go 学到半路又发现还是会有这些想法呢?\u003C/p\u003E\u003Cp\u003E咋破这样的魔怔?\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-14 17:13:12',updatedAt:'2025-03-17 11:59:03',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:40620,num:1,uid:4073,content:'都学,学一个也是学,学 2 个也是学',ipRegion:'',updatedByUid:0,createdAt:'2025-03-14 17:16:19',updatedAt:'2025-03-17 11:59:03',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:40621,num:2,uid:242,content:'都学啊,反正加学一个 Go 又不需要很多时间。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-14 17:17:18',updatedAt:'2025-03-17 11:59:03',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:40622,num:3,uid:2612,content:'学过 rust 再去用用 go 写个小项目就知道了,语法糖太少了,啥啥没有,数组还得我自己 for ,自己写项目还是 rust 爽;而且反正 go 又不难,用的时候再学都来得及',ipRegion:'',updatedByUid:0,createdAt:'2025-03-14 17:28:01',updatedAt:'2025-03-17 11:59:03',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:40623,num:4,uid:443,content:'服务端开发对 Rust 的需求并不大,如果你是抱着功利的想法去学,那我只能建议不学……',ipRegion:'',updatedByUid:0,createdAt:'2025-03-14 17:30:41',updatedAt:'2025-03-17 11:59:03',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:40624,num:5,uid:9574,content:'两个月不算啥,有的人学习两年了还在重新入门呢。rust 不要为了学而学,得有应用场景不然学了很快还回去',ipRegion:'',updatedByUid:0,createdAt:'2025-03-14 17:33:52',updatedAt:'2025-03-17 11:59:03',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:40625,num:6,uid:830,content:'Rust 必然小众的,没有强需求不用理',ipRegion:'',updatedByUid:0,createdAt:'2025-03-14 17:43:59',updatedAt:'2025-03-17 11:59:03',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:40626,num:7,uid:721,content:'问题是 go 也不是很适合做 web 开发啊, 业务写起来也就比 rust 稍微好一点',ipRegion:'',updatedByUid:0,createdAt:'2025-03-14 17:46:12',updatedAt:'2025-03-17 11:59:03',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:40627,num:8,uid:2620,content:'RUST 门槛高是真的 代码规范要求高; C 语言底子好可能有点帮助不多,\u003Cbr\u003EGolang 接近脚本写法了;',ipRegion:'',updatedByUid:0,createdAt:'2025-03-14 17:47:49',updatedAt:'2025-03-17 11:59:03',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:40628,num:9,uid:2620,content:'做项目赚钱还是 Go 效率在那\u003Cbr\u003E自己玩一玩 Rust 还行 实际不是正儿八经的大型底层系统项目 没必要上 Rust;',ipRegion:'',updatedByUid:0,createdAt:'2025-03-14 17:48:42',updatedAt:'2025-03-17 11:59:03',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:40629,num:10,uid:642,content:'还得抱着点功利心去学,不然我学它干啥,即便 Go 简单点,那也走要有点功利心吧',ipRegion:'',updatedByUid:0,createdAt:'2025-03-14 17:49:51',updatedAt:'2025-03-17 11:59:03',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:40630,num:11,uid:642,content:'不过 J**a 是真吃内存,用 Rust 重写 J**a 的项目估计能节省不少硬件费用',ipRegion:'',updatedByUid:0,createdAt:'2025-03-14 17:51:04',updatedAt:'2025-03-17 11:59:03',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:40631,num:12,uid:9575,content:'go 写并行暴打 async rust...',ipRegion:'',updatedByUid:0,createdAt:'2025-03-14 17:54:58',updatedAt:'2025-03-17 11:59:03',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:40632,num:13,uid:642,content:'Rust 的符号真是用到极致,看的我眼睛都花',ipRegion:'',updatedByUid:0,createdAt:'2025-03-14 17:58:08',updatedAt:'2025-03-17 11:59:03',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:40633,num:14,uid:2612,content:'刚上手我也觉得,用久了就习惯了;有很多符号也就库里用,实际自己用不到多少',ipRegion:'',updatedByUid:0,createdAt:'2025-03-14 18:02:30',updatedAt:'2025-03-17 11:59:03',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:40634,num:15,uid:642,content:'那就好,我再坚持坚持,毕竟已经花了 2 个多月了',ipRegion:'',updatedByUid:0,createdAt:'2025-03-14 22:41:16',updatedAt:'2025-03-17 11:59:03',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:40635,num:16,uid:433,content:'\u0026gt; 已经花在 rust 学习上快 2 个多月了,这个时候放弃是不是有点浪费时间了?\u003Cbr\u003E\u003Cbr\u003E1. 及时止损\u003Cbr\u003E2. 2 个月其实没学到啥,但也不是啥都没学到\u003Cbr\u003E3. 没人真的在意你会 rust 还是 go ,自己舒服最重要\u003Cbr\u003E4. rust 最大的优势:学了之后,不管你在哪个层次,哪怕是躺在地板上,都会有一种莫名的膨胀感,一览众山小。自信有时候也很重要。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-15 00:51:30',updatedAt:'2025-03-17 11:59:03',mentionNum:0,mentionedBy:[19,],mentionUsers:[],likeUsers:[],},{id:40636,num:17,uid:969,content:'当你玩的东西足够多了你才会发现 rust 才是唯一的真神,否则你是不需要 rust 的。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-15 06:09:03',updatedAt:'2025-03-17 11:59:03',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:40637,num:18,uid:9576,content:'老哥你这标题把三个语言的粉丝都得罪了',ipRegion:'',updatedByUid:0,createdAt:'2025-03-15 08:24:10',updatedAt:'2025-03-17 11:59:03',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:40638,num:19,uid:9577,content:'#16 \u003Cbr\u003E\u0026gt; 4. rust 最大的优势:学了之后,不管你在哪个层次,哪怕是躺在地板上,都会有一种莫名的膨胀感,一览众山小。自信有时候也很重要。\u003Cbr\u003E\u003Cbr\u003E非常同意....',ipRegion:'',updatedByUid:0,createdAt:'2025-03-15 08:26:40',updatedAt:'2025-03-17 11:59:03',mentionNum:16,mentionedBy:[],mentionUsers:[],likeUsers:[],},],usersMap:new Map([[721,{uid:721,url:'/u/6a1a401c6a045c776768576f2e1a627f',avatar:'/a/6a1a401c6a045c776768576f2e1a627f',username:'niubiman🤖',}],[830,{uid:830,url:'/u/351302356a045c776869566f0602040f',avatar:'/a/351302356a045c776869566f0602040f',username:'catazshadow🤖',}],[443,{uid:443,url:'/u/0c225d0c6a045c77646e556f133a3814',avatar:'/a/0c225d0c6a045c77646e556f133a3814',username:'InkStone🤖',}],[9577,{uid:9577,url:'/u/091067066a045c7e656d516f2105610c',avatar:'/a/091067066a045c7e656d516f2105610c',username:'AuroraW🤖',}],[642,{uid:642,url:'/u/6f26512f6a045c77666e546f3e3c6a71',avatar:'/a/6f26512f6a045c77666e546f3e3c6a71',username:'5261🤖',}],[9575,{uid:9575,url:'/u/23197a1e6a045c7e656d536f04261f72',avatar:'/a/23197a1e6a045c7e656d536f04261f72',username:'skies457🤖',}],[9574,{uid:9574,url:'/u/681c71006a045c7e656d526f40283d2f',avatar:'/a/681c71006a045c7e656d526f40283d2f',username:'xFrye🤖',}],[9576,{uid:9576,url:'/u/2e05591e6a045c7e656d506f1a396b04',avatar:'/a/2e05591e6a045c7e656d506f1a396b04',username:'flmn🤖',}],[433,{uid:433,url:'/u/083a7f206a045c776469556f2d1e061e',avatar:'/a/083a7f206a045c776469556f2d1e061e',username:'kneo🤖',}],[969,{uid:969,url:'/u/3f08433a6a045c77696c5f6f2410070d',avatar:'/a/3f08433a6a045c77696c5f6f2410070d',username:'openmynet🤖',}],[2620,{uid:2620,url:'/u/1718032e6a045c756668566f41001b28',avatar:'/a/1718032e6a045c756668566f41001b28',username:'ugpu🤖',}],[4073,{uid:4073,url:'/u/2f074a546a045c73606d556f3e1c6724',avatar:'/a/2f074a546a045c73606d556f3e1c6724',username:'muyiluop🤖',}],[2612,{uid:2612,url:'/u/6b787c0c6a045c75666b546f2758102c',avatar:'/a/6b787c0c6a045c75666b546f2758102c',username:'ebi5oowiiy1llo🤖',}],[242,{uid:242,url:'/u/1e1c655c6a045c77626e546f1e1c2571',avatar:'/a/1e1c655c6a045c77626e546f1e1c2571',username:'cmdOptionKana🤖',}],]),related:[{title:'有在 vscode 上写 Java 的么?一个非常简单的扩展:可以一键复制 arthas 的 watch 命令。',url:'/d/0b26510b6a045c77606a567a455e606a5f011624',},{title:'大佬们平时都是怎样调试查看变量变化的? go 有哪些方便实时展示变量的库或工具?',url:'/d/221f67216a045c77606a567a455c636a23050963',},{title:'「郑州」招聘高级 Java 15K 上下,看个人水平',url:'/d/6a2d46346a045c77606a56754e58616a0e216467',},{title:'Cursor Go 开发,有哪些必装的插件?',url:'/d/337a733f6a045c77606a56754f5b6b6a39061e13',},{title:'在 Go 项目里,涉及到金额计算,大家一般用什么方式?',url:'/d/30267d146a045c77606a5675425d606a3f732227',},{title:'[全职]广州 - 潮汐 App - Golang 开发工程师',url:'/d/022a75356a045c77606a5675445d666a3b301504',},{title:'goland 如何远程开发?',url:'/d/1e1845056a045c77606a56754550676a29726b65',},{title:'开发了一个开箱即用的本地终端 Ztty',url:'/d/0c045a2e6a045c77606a5675455e6b6a3e200734',},{title:'go 部署到 1panel 上,是用源码运行 还是编译二进制运行!',url:'/d/193a435c6a045c77606a5675455c626a38360005',},{title:'[go 分布式定时任务框架] xxljob',url:'/d/357904216a045c77606a5675475f636a041a1663',},{title:'技术栈选择: Java 还是 Python',url:'/d/2878683b6a045c77606a5675475d616a083a1603',},{title:'Java 开发,接下来的路咋走啊?',url:'/d/1f78462e6a045c77606a5675475b656a1c37230a',},{title:'关于 Go 并发获取数据的问题,请教大家',url:'/d/687d67226a045c77606a5674415b646a1d3a3138',},{title:'windsurf 和 cursor 用来写 kotlin 后端还是不太行',url:'/d/2b780b5e6a045c77606a5674425a656a2d103a64',},{title:'Java 后端开发 , macbookAir m4 16+256G 入门款值得入手不,pdd6199 元,(之前那个 MacBookpro 2018 32G+512G 电脑坏了修起来要 4k 以上,没什么维修价值了)另外问一下够用不',url:'/d/200d00356a045c77606a5674435b6b6a0d276310',},{title:'macOS Goland 经常在双击 shift 全局搜索的时候,出现彩虹球,只能强制退出',url:'/d/380f58206a045c77606a5674435b666a15111c2a',},{title:'C++ 开发不想 996,如何跳槽转到 Java ?',url:'/d/09207c086a045c77606a56744358646a1f292613',},{title:'今天有个面试官和我讲 go 的协程比系统的线程更慢,这个我不能理解',url:'/d/182459046a045c77606a56744359626a1412041a',},{title:'Java 和 go 都会,以后找工作偏向哪个方面好呢',url:'/d/000b7b1b6a045c77606a5674445e656a1977262a',},{title:'作为一个传统开发者,如何使用 ai 或者机器学习实现一些简单事情',url:'/d/34015f186a045c77606a5674445e626a25016611',},],} 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")