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:2421,currentPage:1,targetPage:1,total:101,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:20,url:'/t/2c0b5e546a045c756077023a1a1e',name:'Js|Ts|H5',color:'#FFA726',icon:'mdi-language-javascript',},{id:27,url:'/t/0e2e58346a045c7567770b2b3120',name:'Go',color:'#FFA726',icon:'mdi-language-go',},{id:25,url:'/t/0d0f7d3d6a045c75657751293a0c',name:'C#',color:'#FFA726',icon:'mdi-language-csharp',},],posts:[{id:29420,num:0,uid:6605,content:'C# 性能远超 Go 来源\u003Cbr\u003E\u003Cbr\u003Ehttps://benchmarksgame-team.pages.debian.net/benchmarksgame/performance/fannkuchredux.html\u003Cbr\u003E以及这个网站的大部分项目\u003Cbr\u003E\u003Cbr\u003E别的 benchmark 网站结果也大致相同\u003Cbr\u003E\u003Cbr\u003E另外 C#和 TS 大部分类型都对应,实在找不到要用 Go 的理由',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 14:59:32',updatedAt:'2025-03-15 14:40:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:29421,num:1,uid:6630,content:'go 可移植性好',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 15:04:20',updatedAt:'2025-03-15 14:40:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:29422,num:2,uid:6605,content:'C#也能跨平台,虽然现在.NET Core 跨平台还是有些莫名其妙的问题,有的情况会内存泄漏,但已经可以上生产了',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 15:06:06',updatedAt:'2025-03-15 14:40:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:29423,num:3,uid:6453,content:'https://github.com/microsoft/typescript-go/discussions/411',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 15:08:22',updatedAt:'2025-03-15 14:40:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:29424,num:4,uid:6605,content:'我看过这个讨论串了,只提了 a bit of a vote of no confidence in C# 没有提具体的原因',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 15:10:51',updatedAt:'2025-03-15 14:40:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:29425,num:5,uid:6485,content:'他说了,C#更面向对象,js/ts 跟 go 更接近,更好 1:1 移植',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 15:11:48',updatedAt:'2025-03-15 14:40:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:29426,num:6,uid:5851,content:'https://github.com/microsoft/typescript-go/discussions/411#discussioncomment-12464695\u003Cbr\u003E\u003Cbr\u003E已经有很多讨论了,这是一个相对官方的回复',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 15:13:32',updatedAt:'2025-03-15 14:40:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:29427,num:7,uid:5851,content:'具体原因楼层我已经发了',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 15:13:56',updatedAt:'2025-03-15 14:40:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:29428,num:8,uid:6453,content:'#4',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 15:14:55',updatedAt:'2025-03-15 14:40:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:29429,num:9,uid:64,content:'如果用 c#便宜 ts ,以后装 react/vue with ts 是不是 npm 还得先装个.net runtime 。\u003Cbr\u003E这一下.net 的使用量就上来了,今年编程语言榜第一的就是 c# + .net 了(乐',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 15:18:55',updatedAt:'2025-03-15 14:40:45',mentionNum:0,mentionedBy:[21,],mentionUsers:[],likeUsers:[],},{id:29430,num:10,uid:228,content:'C# 设计上是字节码优先的,虽然有 AOT 但是缺少实战检验,而且最初也不是为这类场景设计的,有些环境会有问题。\u003Cbr\u003EGo 的代码组织方式和现有的代码更相近(函数 + 数据结构,非 OOP ),方便一比一翻译。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 15:20:30',updatedAt:'2025-03-15 14:40:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:29431,num:11,uid:6605,content:'我挺希望这样,现在 C#的跨平台 UI 框架没一个完善的,如果微软能让 C#上 Rank #1 我觉得这个问题能被改善',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 15:20:47',updatedAt:'2025-03-15 14:40:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:29432,num:12,uid:8097,content:'人家明确说了是移植,不是重写。单就这一点来说,C#是面向对象的,就不合适。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 15:21:29',updatedAt:'2025-03-15 14:40:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:29433,num:13,uid:6605,content:'如果单纯是这个原因的话,面向对象的语言也可以不使用和对象相关的特性',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 15:23:25',updatedAt:'2025-03-15 14:40:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:29434,num:14,uid:64,content:'别闹,现在 node_modules 已经够地狱了,.net 再拖家带口住进来,nodejs 就不能要了',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 15:25:24',updatedAt:'2025-03-15 14:40:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:29435,num:15,uid:6380,content:'现在 C#也可以 AOT ,所以这个不是问题',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 15:33:59',updatedAt:'2025-03-15 14:40:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:29436,num:16,uid:58,content:'他们是 port ,不是 rewrite 。用 Go 可以很简单的按文件翻译,代码长差不多。\u003Cbr\u003E\u003Cimg src\u003D\"https://i.imgur.com/PGA1y5u.png\"\u003E\u003Cbr\u003E\u003Cbr\u003E如果用 C#,为了高性能,就要大量使用 Span\u0026lt;T\u0026gt;和 Memory\u0026lt;T\u0026gt; ,那 port 工作量就太大了。C#的优势,模式匹配和异常处理,不擦除的泛型等等,都完全用不到,aot 编译耗时比 Go 长很多倍,得不偿失。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 15:41:44',updatedAt:'2025-03-15 14:40:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:29437,num:17,uid:2645,content:'因为 LOGO 都是蓝色的',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 15:42:42',updatedAt:'2025-03-15 14:40:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:29438,num:18,uid:5995,content:'我才知道有的语言编译器是不自举的',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 15:43:51',updatedAt:'2025-03-15 14:40:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:29439,num:19,uid:7021,content:'看到过好多次说 C#比 Go 好的了,希望这个事情让你门清醒。。。\u003Cbr\u003E\u003Cbr\u003EBTW ,这事情里的函数式不是通常说的函数式编程\u003Cbr\u003E函数式太多花活、隐藏机制、性能浪费,不是什么好玩意\u003Cbr\u003EOO 太多累赘、啥都得 class 、顶层设计难以预计未来、难以高效应对快速变化,不如面向过程更加通用\u003Cbr\u003E\u003Cbr\u003EGo 很务实,有的人认为他平庸,简洁、甚至 N 倍性能提升都进不了这些认为 Go 平庸的人的“法眼”,反过来还要喷“大道至简”,我无法对这些人的智力水平作出评价,因为我不想贬低别人但也更不想撒谎。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 16:17:44',updatedAt:'2025-03-15 14:40:45',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},],usersMap:new Map([[64,{uid:64,url:'/u/200101596a045c77606c526f31313604',avatar:'/a/200101596a045c77606c526f31313604',username:'k9982874🤖',}],[8097,{uid:8097,url:'/u/1e1e41246a045c7f6063516f1831302b',avatar:'/a/1e1e41246a045c7f6063516f1831302b',username:'Hellert🤖',}],[6380,{uid:6380,url:'/u/291b503a6a045c716362566f1a2c0675',avatar:'/a/291b503a6a045c716362566f1a2c0675',username:'Mexion🤖',}],[228,{uid:228,url:'/u/031d655c6a045c7762685e6f12222113',avatar:'/a/031d655c6a045c7762685e6f12222113',username:'DTCPSS🤖',}],[6453,{uid:6453,url:'/u/392d77266a045c71646f556f1b5e0671',avatar:'/a/392d77266a045c71646f556f1b5e0671',username:'cyp0633🤖',}],[5995,{uid:5995,url:'/u/03385b286a045c726963536f410e192a',avatar:'/a/03385b286a045c726963536f410e192a',username:'idealhs🤖',}],[6485,{uid:6485,url:'/u/092240596a045c716462536f050a272c',avatar:'/a/092240596a045c716462536f050a272c',username:'guotie🤖',}],[58,{uid:58,url:'/u/6c314b256a045c77606f5e6f032a181e',avatar:'/a/6c314b256a045c77606f5e6f032a181e',username:'sagaxu🤖',}],[2645,{uid:2645,url:'/u/6b24422e6a045c75666e536f062c2514',avatar:'/a/6b24422e6a045c75666e536f062c2514',username:'TanKuku🤖',}],[7021,{uid:7021,url:'/u/2903781d6a045c706068576f0d2a1911',avatar:'/a/2903781d6a045c706068576f0d2a1911',username:'lesi**al🤖',}],[5851,{uid:5851,url:'/u/36315f1e6a045c72686f576f030f2914',avatar:'/a/36315f1e6a045c72686f576f030f2914',username:'stimw🤖',}],[6630,{uid:6630,url:'/u/6d0275076a045c716669566f471a1120',avatar:'/a/6d0275076a045c716669566f471a1120',username:'iyiluo🤖',}],[2844,{uid:2844,url:'/u/0e2a7c586a045c75686e526f3023363e',avatar:'/a/0e2a7c586a045c75686e526f3023363e',username:'Bazingal🤖',}],[6605,{uid:6605,url:'/u/3b0047256a045c71666a536f2f1b310e',avatar:'/a/3b0047256a045c71666a536f2f1b310e',username:'drymonfidelia🤖',}],]),related:[{title:'大佬们平时都是怎样调试查看变量变化的? go 有哪些方便实时展示变量的库或工具?',url:'/d/221f67216a045c77606a567a455c636a23050963',},{title:'推荐一款自己写的提升效率的浏览器插件: HarmonyAutoCopy,让文本复制更轻松!',url:'/d/6f06033d6a045c77606a567a475c646a1f371708',},{title:'Cursor Go 开发,有哪些必装的插件?',url:'/d/337a733f6a045c77606a56754f5b6b6a39061e13',},{title:'在 Go 项目里,涉及到金额计算,大家一般用什么方式?',url:'/d/30267d146a045c77606a5675425d606a3f732227',},{title:'程序猿创业失败,转行做独立开发',url:'/d/393e7d3e6a045c77606a56754350616a59191c16',},{title:'发现一个有意思的项目,把一个字符串隐藏到另一个字符串中',url:'/d/3c117a346a045c77606a56754359676a5b323b0b',},{title:'编程小白,终于成功上线了自己的第一个导航站😭 激动',url:'/d/333944256a045c77606a56754451666a3e0e3e67',},{title:'vue 指令更新问题',url:'/d/2f3c4a3e6a045c77606a5675445e636a250e3f24',},{title:'[全职]广州 - 潮汐 App - Golang 开发工程师',url:'/d/022a75356a045c77606a5675445d666a3b301504',},{title:'小红书 | 图文,视频,评论 浏览与导出工具',url:'/d/1b1806556a045c77606a56754458676a04343b26',},{title:'[BadouCMS] Vue3+TypeScript+ThinkPHP8 构建 CMS 系统(开源)',url:'/d/303350036a045c77606a56754458626a20390564',},{title:'goland 如何远程开发?',url:'/d/1e1845056a045c77606a56754550676a29726b65',},{title:'开发了一个开箱即用的本地终端 Ztty',url:'/d/0c045a2e6a045c77606a5675455e6b6a3e200734',},{title:'go 部署到 1panel 上,是用源码运行 还是编译二进制运行!',url:'/d/193a435c6a045c77606a5675455c626a38360005',},{title:'第一个完全用 AI 工具生成的工具站',url:'/d/6a18771a6a045c77606a5675475e616a01126104',},{title:'[go 分布式定时任务框架] xxljob',url:'/d/357904216a045c77606a5675475f636a041a1663',},{title:'为什么 vue 的 nuxt.js 不跟进 nextjs 的 app route 目录结构',url:'/d/02116a1e6a045c77606a56744f516a6a1b02141e',},{title:'Vite 开发服务器路径遍历漏洞(CVE-2025-30208)',url:'/d/2f2f0a2b6a045c77606a56744f5a646a231a021b',},{title:'做定时任务,一定要用这个神库!',url:'/d/2a1a550b6a045c77606a56744f5b626a5c151613',},{title:'XUGOU - 轻量级系统监控平台,基于 CloudFlare 零成本部署!',url:'/d/0a21430f6a045c77606a56744f58656a0f741e25',},],} 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")