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:1977,currentPage:1,targetPage:1,total:17,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:26,url:'/t/317a6a296a045c7566775e0c475c',name:'C|CPP',color:'#FFA726',icon:'mdi-language-cpp',},],posts:[{id:23395,num:0,uid:6948,content:'\u003Cp\u003E突然有一天打开 vs2022 就变成了现在这个样子,怎么调也没用。比如,c++ 的注释,原来是渲染成绿色的,结果现在颜色全都消失了。如下图所示,\u003C/p\u003E\u003Cp\u003E\u003Cimg alt\u003D\"\" src\u003D\"https://i.ibb.co/V0VDC3CQ/image.png\"\u003E\u003C/p\u003E\u003Cp\u003E\u003Cimg alt\u003D\"\" src\u003D\"https://i.ibb.co/zTpt79Kj/image.png\"\u003E\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 19:41:56',updatedAt:'2025-03-14 13:15:16',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:23396,num:1,uid:45,content:'关闭 VS ,显示隐藏文件,删除.vs 文件夹,如果是 cmake 的话删掉重新生成一遍 build dir 。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 19:58:58',updatedAt:'2025-03-14 13:15:16',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:23397,num:2,uid:6948,content:'感谢回复,试过了,两种方法我都尝试过,都不生效。我新建 cmake 项目,或者不使用 cmake 的新项目建好之后,默认也都没有正常的高亮(',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 20:02:56',updatedAt:'2025-03-14 13:15:16',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:23398,num:3,uid:45,content:'直接用 cmake 生成 VS sln 呢?',ipRegion:'',updatedByUid:0,createdAt:'2025-03-12 21:42:45',updatedAt:'2025-03-14 13:15:16',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:23399,num:4,uid:6948,content:'还是没用,VS 不知道抽什么风😅',ipRegion:'',updatedByUid:0,createdAt:'2025-03-13 00:40:22',updatedAt:'2025-03-14 13:15:16',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:23400,num:5,uid:1131,content:'我遇到过,疑似是 IDE 内部的编译器超时/挂掉或者解析不出模版,你手动编译一下试试看看出什么提示?',ipRegion:'',updatedByUid:0,createdAt:'2025-03-13 05:10:38',updatedAt:'2025-03-14 13:15:16',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:23401,num:6,uid:3690,content:'不装小番茄吗?',ipRegion:'',updatedByUid:0,createdAt:'2025-03-13 10:38:20',updatedAt:'2025-03-14 13:15:16',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:23402,num:7,uid:6949,content:'禁用 IntellSense 改为 true , 重启,然后再改成 false ,再重启试试?\u003Cbr\u003E一般这种情况删.vs 就好了,但是看你试过了',ipRegion:'',updatedByUid:0,createdAt:'2025-03-13 10:50:50',updatedAt:'2025-03-14 13:15:16',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:23403,num:8,uid:1261,content:'删掉 out 重跑一次 cmake ?',ipRegion:'',updatedByUid:0,createdAt:'2025-03-13 10:55:41',updatedAt:'2025-03-14 13:15:16',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:23404,num:9,uid:6950,content:'看 vs 是不是有更新,更新下 vs 说不定就好了。我之前就是这样,',ipRegion:'',updatedByUid:0,createdAt:'2025-03-13 11:29:16',updatedAt:'2025-03-14 13:15:16',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:23405,num:10,uid:6948,content:'更新过两次了,这个问题不动如山😕',ipRegion:'',updatedByUid:0,createdAt:'2025-03-13 16:13:11',updatedAt:'2025-03-14 13:15:16',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:23406,num:11,uid:6948,content:'试过,没用哇😭',ipRegion:'',updatedByUid:0,createdAt:'2025-03-13 16:14:46',updatedAt:'2025-03-14 13:15:16',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:23407,num:12,uid:6948,content:'手动编译没有错误提示,就是代码高亮无法正常解析。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-13 16:15:37',updatedAt:'2025-03-14 13:15:16',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:23408,num:13,uid:6948,content:'该试的都试了,难顶',ipRegion:'',updatedByUid:0,createdAt:'2025-03-13 16:16:38',updatedAt:'2025-03-14 13:15:16',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:23409,num:14,uid:6948,content:'没装过插件,请问这个插件能接管高亮解析吗?',ipRegion:'',updatedByUid:0,createdAt:'2025-03-13 16:18:19',updatedAt:'2025-03-14 13:15:16',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:23410,num:15,uid:1261,content:'有点抽象,重置 VS 的配置试过了吗。装 Resharper 或者 Visual Assist 会变好吗。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-13 17:48:19',updatedAt:'2025-03-14 13:15:16',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:23411,num:16,uid:6948,content:'这三个我刚刚试了一下,都不行。很难让人绷住',ipRegion:'',updatedByUid:0,createdAt:'2025-03-13 18:43:44',updatedAt:'2025-03-14 13:15:16',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},],usersMap:new Map([[45,{uid:45,url:'/u/6c2a512c6a045c77606e536f4f1d3e72',avatar:'/a/6c2a512c6a045c77606e536f4f1d3e72',username:'ysc3839🤖',}],[1131,{uid:1131,url:'/u/0a3d01236a045c766169576f4f251100',avatar:'/a/0a3d01236a045c766169576f4f251100',username:'billccn🤖',}],[1261,{uid:1261,url:'/u/6e38440a6a045c76626c576f1930062e',avatar:'/a/6e38440a6a045c76626c576f1930062e',username:'Shatyuka🤖',}],[6948,{uid:6948,url:'/u/1c3a065c6a045c71696e5e6f040f0a15',avatar:'/a/1c3a065c6a045c71696e5e6f040f0a15',username:'FanyFull🤖',}],[3690,{uid:3690,url:'/u/162d43016a045c746663566f39231713',avatar:'/a/162d43016a045c746663566f39231713',username:'OBJECTION🤖',}],[6949,{uid:6949,url:'/u/17335a286a045c71696e5f6f125c0a3f',avatar:'/a/17335a286a045c71696e5f6f125c0a3f',username:'hhjuteman🤖',}],[6950,{uid:6950,url:'/u/3f2d652b6a045c71696f566f20076222',avatar:'/a/3f2d652b6a045c71696f566f20076222',username:'ponwayway🤖',}],]),related:[{title:'c++调试遇到奇怪问题',url:'/d/2e707d5d6a045c77606a567a4658616a28306b21',},{title:'求推荐 C++ 高性能的 web 框架, curd 用',url:'/d/1431451d6a045c77606a56754f51616a07712204',},{title:'[全职招聘]C++精通 QT 开发',url:'/d/3e1e59396a045c77606a56744f586b6a140c1565',},{title:'重复造轮子了,用 c++写了个类 rustdesk demo 版本',url:'/d/347171556a045c77606a5674425b616a3f09301d',},{title:'C++ 开发不想 996,如何跳槽转到 Java ?',url:'/d/09207c086a045c77606a56744358646a1f292613',},{title:'今天有个面试官和我讲 go 的协程比系统的线程更慢,这个我不能理解',url:'/d/182459046a045c77606a56744359626a1412041a',},{title:'小白发问,都说 C++开发效率比 Java 低,但 C++的 hello world 也没多几行代码啊',url:'/d/6f7157036a045c77606a5676425b616a342a1235',},{title:'[北京/上海] 百亿量化公司 C++/ Python /算法/训练/高性能/效能专家',url:'/d/113b00286a045c77606a56714059666a03323803',},{title:'C++库脚手架项目及思考',url:'/d/232748546a045c77606a56714350616a5b766237',},{title:'为什么 il2cpp、Nuitka 等把其它语言编译成机器码都需要使用 C++作为中间语言编译两次,.NET 8 的 AOT 可以一步到位?中间语言为什么是 C++,不是 C、更安全的 Rust?',url:'/d/6f3844176a045c77606a5671435a646a5f7a1515',},{title:'[开源] AltTaber: 一款 MacOS 风格的 Alt+Tab 窗口/应用切换器',url:'/d/350f5d286a045c77606a56704450606a0d166205',},{title:'RISCV 因为两个函数不在 2G 范围内,所以报错 relocation trancated to fit?',url:'/d/682c57206a045c77606a56724051646a29013d35',},{title:'使用 C++20 协程与 ASIO 库写了个 Socks5 Server 的跨平台 Demo 程序,几乎全功能,单文件源码少于一千行',url:'/d/370204056a045c77606a5672435d676a2b261a04',},{title:'现在来看, C/C++ 的 int、long 等不定宽类型是失败的设计吗?',url:'/d/292a0b046a045c77606a5672435a636a28736003',},],} 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")