这个玩意超好用!尤其是小学期的时候疯狂代码开发之后呢!
灵感来源于多校第五场的K题。同样是大作业一样的题目,与之前不同的是,本次的题目有标程。
题意:合并一些代码,使代码长度最短,输出方案。
与其他人一起编写代码有时意味着浪费时间——至少你会花很多时间来合并不同的分支并测试它们是否存在潜在的bug。有时,git标记的区别只是不同的编码风格!
#include <bits/stdc++.h> int main() { <<<<<<< branch1 printf("Hello world!"); ======= puts("Hello World!"); >>>>>>> branch2 }
下面是一个合并helloworld的例子。branch1上的一个使用printf,但是第二个程序员更喜欢puts。好吧,解决这个问题的一个办法是,在不同的预设开启时,做一些适当的定义,让事情正常运作。最简单的方法之一是将git的标记改为define,也就是说:
#include <bits/stdc++.h> int main() { #ifdef branch1 printf("Hello world!"); #else puts("Hello World!"); #endif }
然而,有时git不会标记一个精确的范围,以简单的方式替换标记不会得到一个最短的答案。如果add定义不同,以下代码可能会更短。
#include <bits/stdc++.h> using namespace std; int main() { int a, b; <<<<<<< branch1 cin >> a >> b; ======= scanf("%d%d", &a, &b); >>>>>>> branch2 if (a < 0 || b < 0) return 1; <<<<<<< branch1 cout << a + b << endl; ======= printf("%d\n", a + b); >>>>>>> branch2 }
你的任务是输出一些最短的合并答案,一些C++代码。
#ifdef branch1 #ifdef branch2 #else #endif
输入文件最多包含4000行代码或git标记,每行最多256个字节,包括“\n”。
当然,至少有一个冲突和至少一个代码行。
输出具有最少行数的代码,当不同的定义on时,将与两个分支完全匹配。如果有多个答案,请打印任何答案。
检查器将尝试修复一些令人不快的问题,包括忽略行尾的空格和文件末尾的额外换行符。不过,建议您将答案以样本格式输出,以避免由于呈现错误而导致的错误答案。
输出必须少于5000行,每行最多300字节,包括'\n'。否则,您将收到错误的答案判决。
样例一:
#include <bits/stdc++.h> using namespace std; int main() { int a, b; <<<<<<< branch1 cin >> a >> b; ======= scanf("%d%d", &a, &b); >>>>>>> branch2 if (a < 0 || b < 0) return 1; <<<<<<< branch1 cout << a + b << endl; ======= printf("%d\n", a + b);a >>>>>>> branch2 }
#include <bits/stdc++.h> using namespace std; int main() { int a, b; #ifdef branch1 cin >> a >> b; if (a < 0 || b < 0) return 1; cout << a + b << endl; #else scanf("%d%d", &a, &b); if (a < 0 || b < 0) return 1; printf("%d\n", a + b);a #endif }
样例二:
<<<<<<< branch1 int main() { return 0; } ======= int main() { } >>>>>>> branch2
int main() { #ifdef branch1 return 0; #endif }
样例三:
<<<<<<< branch1 int main() {} ======= int main() {} >>>>>>> branch2
int main() {}
以输入文件2为例,让我们来验证输入文件的格式是否正确:
“«««< branch1\nint main() {\n return 0;\n}\n=======\nint main() {\n}\n»»»> branch2\n”
一个可能的输出(作为样本输出2)是:
“int main() {\n#ifdef branch1\n return 0;\n#endif\n}\n”
请注意,如果在Windows上运行测试,则在使用getline()时必须注意到“\r”问题。测试数据将不包含任何'\r'。
大模拟。
先预处理出两个文件,然后 dp[i][j][0/1/2] 表示第一个文件第 i 行,第二个文件第 j 行,在公用/ifdef 1/ifdef 2 内,切换有代价 1,dp n m 0 是答案。dp 可以存在 short 里。
只使用了C语言。
点击以显示 ⇲
点击以隐藏 ⇱
#include<stdio.h> #include<string.h> const char op1[]="<<<<<<< branch1"; const char op2[]="======="; const char op3[]=">>>>>>> branch2"; struct pp { int first; int second; }; struct pp makepp(int a,int b) { struct pp temp; temp.first=a; temp.second=b; return temp; } struct pp op1hash,op2hash,op3hash; char s1[4007][267],s2[4007][267]; int len1[4007],len2[4007]; char s[267]; int n1=0,n2=0; struct pp hash1[4007],hash2[4007]; short f[4007][4007][3],g[4007][4007][3]; struct qq { struct pp first; int second; }; struct qq makeqq(struct pp a,int b) { struct qq temp; temp.first=a; temp.second=b; return temp; } struct qq que[4007]; int cnt=0; int main() { op1hash=makepp(0,0); int i; for(i=0;i<strlen(op1);i++) { op1hash.first=(1LL*307*op1hash.first+op1[i]+1)%998244353; op1hash.second=(1LL*307*op1hash.second+op1[i]+1)%100000007; } op2hash=makepp(0,0); for(i=0;i<strlen(op2);i++) { op2hash.first=(1LL*307*op2hash.first+op2[i]+1)%998244353; op2hash.second=(1LL*307*op2hash.second+op2[i]+1)%100000007; } op3hash=makepp(0,0); for(i=0;i<strlen(op3);i++) { op3hash.first=(1LL*307*op3hash.first+op3[i]+1)%998244353; op3hash.second=(1LL*307*op3hash.second+op3[i]+1)%100000007; } int curstatus=0; char ch=getchar(); while(ch!=EOF) { int len=0; while(ch!='\n'&&ch!=EOF) { s[len++]=ch; ch=getchar(); } struct pp h=makepp(0,0); for(i=0;i<len;i++) { h.first=(1LL*307*h.first+s[i]+1)%998244353; h.second=(1LL*307*h.second+s[i]+1)%100000007; } if(h.first==op1hash.first&&h.second==op1hash.second) { curstatus=1; } else if(h.first==op2hash.first&&h.second==op2hash.second) { curstatus=2; } else if(h.first==op3hash.first&&h.second==op3hash.second) { curstatus=0; } else { if(curstatus!=1) { len2[++n2]=len; hash2[n2]=h; for(i=0;i<len;i++) { s2[n2][i]=s[i]; } } if(curstatus!=2) { len1[++n1]=len; hash1[n1]=h; for(i=0;i<len;i++) { s1[n1][i]=s[i]; } } } if(ch!=EOF) { ch=getchar(); } } for(i=0;i<=n1;i++) { int j; for(j=0;j<=n2;j++) { int k; for(k=0;k<3;k++) { f[i][j][k]=10007; g[i][j][k]=0; } } } f[0][0][0]=0; f[0][0][1]=1; g[0][0][1]=0; f[0][0][2]=1; g[0][0][2]=0; for(i=0;i<=n1;i++) { int j; for(j=0;j<=n2;j++) { if(i==0&&j==0) { continue; } if(i>0) { if(f[i][j][1]>f[i-1][j][1]+1) { f[i][j][1]=f[i-1][j][1]+1; g[i][j][1]=-1; } } if(j>0) { if(f[i][j][2]>f[i][j-1][2]+1) { f[i][j][2]=f[i][j-1][2]+1; g[i][j][2]=-1; } } if(i>0&&j>0&&hash1[i].first==hash2[j].first&&hash1[i].second==hash2[j].second) { if(f[i][j][0]>f[i-1][j-1][0]+1) { f[i][j][0]=f[i-1][j-1][0]+1; g[i][j][0]=-1; } } int k1; for(k1=0;k1<3;k1++) { int k2; for(k2=0;k2<3;k2++) { if(f[i][j][k1]>f[i][j][k2]+1) { f[i][j][k1]=f[i][j][k2]+1; g[i][j][k1]=k2; } } } } } que[++cnt]=makeqq(makepp(n1,n2),0); while(que[cnt].first.first!=0||que[cnt].first.second!=0||que[cnt].second!=0) { int x=que[cnt].first.first; int y=que[cnt].first.second; int k=que[cnt].second; if(g[x][y][k]!=-1) { k=g[x][y][k]; } else if(k==0) { --x,--y; } else if(k==1) { --x; } else { --y; } que[++cnt]=makeqq(makepp(x,y),k); } for(i=cnt-1;i;i--) { int x=que[i].first.first; int y=que[i].first.second; int k=que[i].second; if(g[x][y][k]!=-1) { if(g[x][y][k]==0) { if(k==1) { printf("#ifdef branch1\n"); } else if(k==2) { printf("#ifdef branch2\n"); } } else { if(k==0) { printf("#endif\n"); } else { printf("#else\n"); } } } else { if(k==1) { int ii; for(ii=0;ii<len1[x];ii++) { printf("%c",s1[x][ii]); } printf("\n"); } else { int ii; for(ii=0;ii<len2[y];ii++) { printf("%c",s2[y][ii]); } printf("\n"); } } } return 0; }
以Home.vue文件为例:
点击以显示 ⇲
点击以隐藏 ⇱
#include<stdio.h> #include<string.h> const char op1[]="<<<<<<< branch1"; const char op2[]="======="; const char op3[]=">>>>>>> branch2"; struct pp { int first; int second; }; struct pp makepp(int a,int b) { struct pp temp; temp.first=a; temp.second=b; return temp; } struct pp op1hash,op2hash,op3hash; char s1[4007][267],s2[4007][267]; int len1[4007],len2[4007]; char s[267]; int n1=0,n2=0; struct pp hash1[4007],hash2[4007]; short f[4007][4007][3],g[4007][4007][3]; struct qq { struct pp first; int second; }; struct qq makeqq(struct pp a,int b) { struct qq temp; temp.first=a; temp.second=b; return temp; } struct qq que[4007]; int cnt=0; int main() { FILE* f1; FILE* f2; f1=fopen("Home.vue","r"); f2=fopen("out.txt","w"); op1hash=makepp(0,0); int i; for(i=0;i<strlen(op1);i++) { op1hash.first=(1LL*307*op1hash.first+op1[i]+1)%998244353; op1hash.second=(1LL*307*op1hash.second+op1[i]+1)%100000007; } op2hash=makepp(0,0); for(i=0;i<strlen(op2);i++) { op2hash.first=(1LL*307*op2hash.first+op2[i]+1)%998244353; op2hash.second=(1LL*307*op2hash.second+op2[i]+1)%100000007; } op3hash=makepp(0,0); for(i=0;i<strlen(op3);i++) { op3hash.first=(1LL*307*op3hash.first+op3[i]+1)%998244353; op3hash.second=(1LL*307*op3hash.second+op3[i]+1)%100000007; } int curstatus=0; char ch=fgetc(f1); while(ch!=EOF) { int len=0; while(ch!='\n'&&ch!=EOF) { s[len++]=ch; ch=fgetc(f1); } struct pp h=makepp(0,0); for(i=0;i<len;i++) { h.first=(1LL*307*h.first+s[i]+1)%998244353; h.second=(1LL*307*h.second+s[i]+1)%100000007; } if(h.first==op1hash.first&&h.second==op1hash.second) { curstatus=1; } else if(h.first==op2hash.first&&h.second==op2hash.second) { curstatus=2; } else if(h.first==op3hash.first&&h.second==op3hash.second) { curstatus=0; } else { if(curstatus!=1) { len2[++n2]=len; hash2[n2]=h; for(i=0;i<len;i++) { s2[n2][i]=s[i]; } } if(curstatus!=2) { len1[++n1]=len; hash1[n1]=h; for(i=0;i<len;i++) { s1[n1][i]=s[i]; } } } if(ch!=EOF) { ch=fgetc(f1); } } for(i=0;i<=n1;i++) { int j; for(j=0;j<=n2;j++) { int k; for(k=0;k<3;k++) { f[i][j][k]=10007; g[i][j][k]=0; } } } f[0][0][0]=0; f[0][0][1]=1; g[0][0][1]=0; f[0][0][2]=1; g[0][0][2]=0; for(i=0;i<=n1;i++) { int j; for(j=0;j<=n2;j++) { if(i==0&&j==0) { continue; } if(i>0) { if(f[i][j][1]>f[i-1][j][1]+1) { f[i][j][1]=f[i-1][j][1]+1; g[i][j][1]=-1; } } if(j>0) { if(f[i][j][2]>f[i][j-1][2]+1) { f[i][j][2]=f[i][j-1][2]+1; g[i][j][2]=-1; } } if(i>0&&j>0&&hash1[i].first==hash2[j].first&&hash1[i].second==hash2[j].second) { if(f[i][j][0]>f[i-1][j-1][0]+1) { f[i][j][0]=f[i-1][j-1][0]+1; g[i][j][0]=-1; } } int k1; for(k1=0;k1<3;k1++) { int k2; for(k2=0;k2<3;k2++) { if(f[i][j][k1]>f[i][j][k2]+1) { f[i][j][k1]=f[i][j][k2]+1; g[i][j][k1]=k2; } } } } } que[++cnt]=makeqq(makepp(n1,n2),0); while(que[cnt].first.first!=0||que[cnt].first.second!=0||que[cnt].second!=0) { int x=que[cnt].first.first; int y=que[cnt].first.second; int k=que[cnt].second; if(g[x][y][k]!=-1) { k=g[x][y][k]; } else if(k==0) { --x,--y; } else if(k==1) { --x; } else { --y; } que[++cnt]=makeqq(makepp(x,y),k); } for(i=cnt-1;i;i--) { int x=que[i].first.first; int y=que[i].first.second; int k=que[i].second; if(g[x][y][k]!=-1) { if(g[x][y][k]==0) { if(k==1) { fprintf(f2,"#ifdef branch1\n"); } else if(k==2) { fprintf(f2,"#ifdef branch2\n"); } } else { if(k==0) { fprintf(f2,"#endif\n"); } else { fprintf(f2,"#else\n"); } } } else { if(k==1) { int ii; for(ii=0;ii<len1[x];ii++) { fprintf(f2,"%c",s1[x][ii]); } fprintf(f2,"\n"); } else { int ii; for(ii=0;ii<len2[y];ii++) { fprintf(f2,"%c",s2[y][ii]); } fprintf(f2,"\n"); } } } fclose(f1); fclose(f2); return 0; }
处理前:
点击以显示 ⇲
点击以隐藏 ⇱
<<<<<<< branch1 <template> <div class="home"> <Navigator return="home" /> <el-row :span="10"> <!-- 左侧导航栏 --> <el-col :span="5"> <el-menu default-active="1" class="el-menu-vertical-demo"> <el-menu-item index="1" @click="pageflag=1"> <i class="el-icon-menu"></i> <span slot="title" v-bind:disabled="isteamspace">工作台</span> </el-menu-item> <el-menu-item index="2" @click="pageflag=2"> <i class="el-icon-message"></i> <span slot="title" >收件箱</span> </el-menu-item> <el-menu-item index="3" @click="pageflag=3"> <i class="el-icon-delete"></i> <span slot="title" >回收站</span> </el-menu-item> <el-submenu index="4"> <template slot="title"> <i class="el-icon-s-custom"></i> <span>团队空间</span> </template> <el-menu-item-group> <el-menu-item @click="toggleModalCreate"> <template slot="title" > <i class="el-icon-plus"></i> <span slot="title" >新建团队</span> </template> </el-menu-item> <el-menu-item @click="toggleModalJoin"> <i class="el-icon-zoom-in"></i> <span slot="title" >加入团队</span> </el-menu-item> <el-menu-item v-for="item in allteams.data" :key="item.id"> </el-menu-item> </el-menu-item-group> </el-submenu> </el-menu> </el-col> <!-- 右侧内容 --> <el-col :span="19"> <!-- 工作台页面 --> <div v-if="pageflag==1"> <!-- 上方分类 --> <el-row> <el-menu default-active="1" mode="horizontal"> <el-menu-item index="1" @click="changesearchkind(1)">最近使用</el-menu-item> <el-menu-item index="2" @click="changesearchkind(2)">我创建的</el-menu-item> <el-menu-item index="3" @click="changesearchkind(3)">我的收藏</el-menu-item> <el-menu-item index="4" style="float:right">新建文档</el-menu-item> <el-menu-item index="5" style="float:right">按模版新建</el-menu-item> </el-menu> </el-row> <!-- 下方内容 --> <el-row> <div class="files" v-for="item in allfiles.data" :key="item.id"> <div class="afile"> </div> </div> </el-row> </div> <!-- 收件箱页面 --> <div v-if="pageflag==2"> hi2 </div> <!-- 回收站页面 --> <div v-if="pageflag==3"> <el-row> <div class="deletefiles" v-for="item in alldeleted.data" :key="item.id"> <div class="deletefile"> </div> </div> </el-row> </div> </el-col> </el-row> <div v-if="showCreateModal" v-on:closeme="closeme"> <div class="modal-backdrop"> <div class="modal" :style="mainStyles"> <div class="modal-header"> <h3>新建团队</h3> </div> <div class="modal-body"> <el-form ref="createTeam_form" :model="createTeam_form" :rules="rules" label-width="80px" > <el-form-item label="团队名称" prop="team_name"> <el-input placeholder="team name" v-model="createTeam_form.team_name" class="input-with-select" ></el-input> </el-form-item> </el-form> </div> <div class="modal-footer"> <button type="button" class="btn-confirm" @click="submitForm('createTeam_form')">确认</button> <button type="button" class="btn-close" @click="closemeCreate">关闭</button> </div> </div> </div> </div> <div v-if="showJoinModal" v-on:closeme="closeme"> <div class="modal-backdrop"> <div class="modal" :style="mainStyles"> <div class="modal-header"> <h3>加入团队</h3> </div> <div class="modal-body"> <el-form ref="createTeam_form" :model="createTeam_form" :rules="rules" label-width="80px" > <el-form-item label="团队名称" prop="team_name"> <el-input placeholder="team name" v-model="createTeam_form.team_name" class="input-with-select" ></el-input> </el-form-item> </el-form> </div> <div class="modal-footer"> <button type="button" class="btn-confirm" @click="submitForm('createTeam_form')">确认</button> <button type="button" class="btn-close" @click="closemeJoin">关闭</button> </div> </div> </div> </div> </div> </template> <script> // @ is an alias to /src import Navigator from "@/components/Navigator.vue"; import global from "@/components/global.vue"; import axios from "axios"; export default { name: "Home", components: { Navigator, }, data() { return { userid:0, searchkind:1, pageflag:1, allfiles:{}, alldeleted:{}, allteams:{}, showCreateModal:false, showJoinModal:false, createTeam_form:{ email: "", team_name:"" }, rules:{ team_name:[ { required: true, message: '请输入团队名称', trigger: 'blur' }, { min: 5, max: 15, message: '长度在 5 到 15 个字符', trigger: 'blur' } ], }, }; }, created() { this.userid=global.userid this.search() }, methods: { changesearchkind(aint) { this.searchkind=aint, this.search() }, search() { var that = this; axios .post("http://127.0.0.1:8080/home", {//175.24.53.216:8080 127.0.0.1:8080 id: that.userid, kind: that.searchkind }) .then(function(response) { alert("搜索完成(测试)"); alert(response.data.msg); }) .catch(function(error) { alert(error); }); }, submitForm(formName) { this.$refs[formName].validate((valid) => { if (valid) { var that = this; that.createTeam_form.email=global.userEmail; axios .post("http://127.0.0.1:8080/buildteam", that.createTeam_form)//175.24.53.216:8080 127.0.0.1:8080 .then(function(response) { alert(response.data.msg); }) .catch(function(error) { alert(error); console.log(error); }); } else { console.log('error submit!!'); return false; } }); }, toggleModalCreate:function(){ this.showCreateModal = !this.showCreateModal; }, closemeCreate:function(){ this.showCreateModal = !this.showCreateModal; }, toggleModalJoin:function(){ this.showJoinModal = !this.showJoinModal; }, closemeJoin:function(){ this.showJoinModal = !this.showJoinModal; } } }; </script> <style scoped> .each { width: 30%; border: 1px solid black; margin: 5px; cursor: pointer; } .el-dropdown-link { cursor: pointer; color: #409EFF; } .el-icon-arrow-down { font-size: 12px; } .box { border: 1px solid #DCDFE6; margin: 10px auto; padding: 10px 35px 15px 35px; border-radius: 5px; -webkit-border-radius: 5px; -moz-border-radius: 5px; box-shadow: 0 0 5px #909399; opacity: 1 } .art-more { height: 40px; display: flex; justify-content: flex-end; align-items: flex-end; } .art-more .view { color: #aaa; } h5{ font-size: 18px; } .pagination { background-color: #F9F9F9; } .name{ margin-top:10px ; margin-left: 5px; } .art-time { margin-right: 20px; } .art-title { border-left: 3px solid #409EFF; padding-left: 5px; cursor: pointer; } .art-title:hover { padding-left: 10px; color: #409EFF; } .name{ margin-top:10px ; margin-left: 5px; cursor: pointer; } .name:hover{ padding-left: 10px; color: #409EFF; } </style> <style> .modal-backdrop { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background-color: rgba(0,0,0,.3); display: flex; justify-content: center; align-items: center; } .modal { background-color: #fff; box-shadow: 2px 2px 20px 1px; overflow-x:auto; display: flex; flex-direction: column; border-radius: 16px; width: 700px; } .modal-header { border-bottom: 1px solid #eee; color: #313131; justify-content: space-between; padding: 15px; display: flex; } .modal-footer { border-top: 1px solid #eee; justify-content: flex-end; padding: 15px; display: flex; } .modal-body { position: relative; padding: 20px 10px; } .btn-close, .btn-confirm { border-radius: 8px; margin-left:16px; width:56px; height: 36px; border:none; cursor: pointer; } .btn-close { color: #313131; background-color:transparent; } .btn-confirm { color: #fff; background-color: #2d8cf0; } .login-box { border: 1px solid #DCDFE6; width: 350px; margin: 180px auto; padding: 35px 35px 15px 0px; border-radius: 5px; -webkit-border-radius: 5px; -moz-border-radius: 5px; box-shadow: 0 0 25px #909399; } .login-title { text-align: center; margin: 0 auto 40px auto; padding: 0px 0px 0px 10px; color: #303133; } .submitBtn { display:block; text-align: center; margin: 0px auto; background-color: transparent; color: #39f; width: 200px; } ======= <template> <div class="home"> <Navigator return="home" /> <el-row :span="10"> <!-- 左侧导航栏 --> <el-col :span="5"> <el-menu default-active="1" class="el-menu-vertical-demo"> <el-menu-item index="1" @click="pageflag=1"> <i class="el-icon-menu"></i> <span slot="title" >工作台</span> </el-menu-item> <el-menu-item index="2" @click="pageflag=2"> <i class="el-icon-message"></i> <span slot="title" >收件箱</span> </el-menu-item> <el-menu-item index="3" @click="pageflag=3"> <i class="el-icon-delete"></i> <span slot="title" >回收站</span> </el-menu-item> <el-submenu index="4"> <template slot="title"> <i class="el-icon-s-custom"></i> <span>团队空间</span> </template> <el-menu-item-group> <el-menu-item v-for="item in allteams.data" :key="item.id"> </el-menu-item> </el-menu-item-group> </el-submenu> </el-menu> </el-col> <!-- 右侧内容 --> <el-col :span="19"> <!-- 工作台页面 --> <div v-if="pageflag==1"> <!-- 上方分类 --> <el-row> <el-menu default-active="1" class="el-menu-demo" mode="horizontal"> <el-menu-item index="1" @click="changesearchkind(1)">最近使用</el-menu-item> <el-menu-item index="2" @click="changesearchkind(2)">我创建的</el-menu-item> <el-menu-item index="3" @click="changesearchkind(3)">我的收藏</el-menu-item> <el-menu-item index="4" style="float:right" @click="createdoc()">新建文档</el-menu-item> <el-menu-item index="5" style="float:right">按模版新建</el-menu-item> </el-menu> </el-row> <!-- 下方内容 --> <el-row> <div class="files" v-for="item in allfiles.data" :key="item.id"> <div class="afile"> </div> </div> </el-row> </div> <!-- 收件箱页面 --> <div v-if="pageflag==2"> hi2 </div> <!-- 回收站页面 --> <div v-if="pageflag==3"> <el-row> <div class="deletefiles" v-for="item in alldeleted.data" :key="item.id"> <div class="deletefile"> </div> </div> </el-row> </div> </el-col> </el-row> </div> </template> <script> // @ is an alias to /src import Navigator from "@/components/Navigator.vue"; import global from "@/components/global.vue"; import axios from "axios"; export default { name: "Home", components: { Navigator }, data() { return { userid:0, searchkind:1, pageflag:1, allfiles:{}, alldeleted:{}, allteams:{} }; }, created() { this.userid=global.userid this.search() }, methods: { createdoc() { this.$router.push({ name: "Viewdoc", params: { kind: 1 } }); }, changesearchkind(aint) { this.searchkind=aint, this.search() }, search() { var that = this; axios .post("http://127.0.0.1:8080/home", { id: that.userid, kind: that.searchkind }) .then(function(response) { alert("搜索完成(测试)"); alert(response.data.msg); }) .catch(function(error) { alert(error); }); }, } }; </script> <style scoped> .each { width: 30%; border: 1px solid black; margin: 5px; cursor: pointer; } .el-dropdown-link { cursor: pointer; color: #409EFF; } .el-icon-arrow-down { font-size: 12px; } .searchBox{ } .searchInput{ } .searchButton{ } .box { border: 1px solid #DCDFE6; margin: 10px auto; padding: 10px 35px 15px 35px; border-radius: 5px; -webkit-border-radius: 5px; -moz-border-radius: 5px; box-shadow: 0 0 5px #909399; opacity: 1 } .art-more { height: 40px; display: flex; justify-content: flex-end; align-items: flex-end; } .art-more .view { color: #aaa; } h5{ font-size: 18px; } .pagination { background-color: #F9F9F9; } .name{ margin-top:10px ; margin-left: 5px; } .art-time { margin-right: 20px; } .art-title { border-left: 3px solid #409EFF; padding-left: 5px; cursor: pointer; } .art-title:hover { padding-left: 10px; color: #409EFF; } .name{ margin-top:10px ; margin-left: 5px; cursor: pointer; } .name:hover{ padding-left: 10px; color: #409EFF; } >>>>>>> branch2 </style>
处理后:
点击以显示 ⇲
点击以隐藏 ⇱
<template> <div class="home"> <Navigator return="home" /> <el-row :span="10"> <!-- 左侧导航栏 --> <el-col :span="5"> <el-menu default-active="1" class="el-menu-vertical-demo"> <el-menu-item index="1" @click="pageflag=1"> <i class="el-icon-menu"></i> #ifdef branch2 <span slot="title" >工作台</span> #else <span slot="title" v-bind:disabled="isteamspace">工作台</span> #endif </el-menu-item> <el-menu-item index="2" @click="pageflag=2"> <i class="el-icon-message"></i> <span slot="title" >收件箱</span> </el-menu-item> <el-menu-item index="3" @click="pageflag=3"> <i class="el-icon-delete"></i> <span slot="title" >回收站</span> </el-menu-item> <el-submenu index="4"> <template slot="title"> <i class="el-icon-s-custom"></i> <span>团队空间</span> </template> <el-menu-item-group> #ifdef branch2 <el-menu-item v-for="item in allteams.data" :key="item.id"> #else <el-menu-item @click="toggleModalCreate"> <template slot="title" > <i class="el-icon-plus"></i> <span slot="title" >新建团队</span> </template> </el-menu-item> <el-menu-item @click="toggleModalJoin"> <i class="el-icon-zoom-in"></i> <span slot="title" >加入团队</span> </el-menu-item> <el-menu-item v-for="item in allteams.data" :key="item.id"> #endif </el-menu-item> </el-menu-item-group> </el-submenu> </el-menu> </el-col> <!-- 右侧内容 --> <el-col :span="19"> <!-- 工作台页面 --> <div v-if="pageflag==1"> <!-- 上方分类 --> <el-row> #ifdef branch2 <el-menu default-active="1" class="el-menu-demo" mode="horizontal"> <el-menu-item index="1" @click="changesearchkind(1)">最近使用</el-menu-item> <el-menu-item index="2" @click="changesearchkind(2)">我创建的</el-menu-item> <el-menu-item index="3" @click="changesearchkind(3)">我的收藏</el-menu-item> <el-menu-item index="4" style="float:right" @click="createdoc()">新建文档</el-menu-item> #else <el-menu default-active="1" mode="horizontal"> <el-menu-item index="1" @click="changesearchkind(1)">最近使用</el-menu-item> <el-menu-item index="2" @click="changesearchkind(2)">我创建的</el-menu-item> <el-menu-item index="3" @click="changesearchkind(3)">我的收藏</el-menu-item> <el-menu-item index="4" style="float:right">新建文档</el-menu-item> #endif <el-menu-item index="5" style="float:right">按模版新建</el-menu-item> </el-menu> </el-row> <!-- 下方内容 --> <el-row> <div class="files" v-for="item in allfiles.data" :key="item.id"> <div class="afile"> </div> </div> </el-row> </div> <!-- 收件箱页面 --> <div v-if="pageflag==2"> hi2 </div> <!-- 回收站页面 --> <div v-if="pageflag==3"> <el-row> <div class="deletefiles" v-for="item in alldeleted.data" :key="item.id"> <div class="deletefile"> </div> </div> </el-row> </div> #ifdef branch2 </el-col> </el-row> </div> #else </el-col> </el-row> <div v-if="showCreateModal" v-on:closeme="closeme"> <div class="modal-backdrop"> <div class="modal" :style="mainStyles"> <div class="modal-header"> <h3>新建团队</h3> </div> <div class="modal-body"> <el-form ref="createTeam_form" :model="createTeam_form" :rules="rules" label-width="80px" > <el-form-item label="团队名称" prop="team_name"> <el-input placeholder="team name" v-model="createTeam_form.team_name" class="input-with-select" ></el-input> </el-form-item> </el-form> </div> <div class="modal-footer"> <button type="button" class="btn-confirm" @click="submitForm('createTeam_form')">确认</button> <button type="button" class="btn-close" @click="closemeCreate">关闭</button> </div> </div> </div> </div> <div v-if="showJoinModal" v-on:closeme="closeme"> <div class="modal-backdrop"> <div class="modal" :style="mainStyles"> <div class="modal-header"> <h3>加入团队</h3> </div> <div class="modal-body"> <el-form ref="createTeam_form" :model="createTeam_form" :rules="rules" label-width="80px" > <el-form-item label="团队名称" prop="team_name"> <el-input placeholder="team name" v-model="createTeam_form.team_name" class="input-with-select" ></el-input> </el-form-item> </el-form> </div> <div class="modal-footer"> <button type="button" class="btn-confirm" @click="submitForm('createTeam_form')">确认</button> <button type="button" class="btn-close" @click="closemeJoin">关闭</button> </div> </div> </div> </div> </div> #endif </template> <script> // @ is an alias to /src import Navigator from "@/components/Navigator.vue"; import global from "@/components/global.vue"; import axios from "axios"; export default { name: "Home", components: { #ifdef branch2 Navigator #else Navigator, #endif }, data() { return { userid:0, searchkind:1, pageflag:1, allfiles:{}, alldeleted:{}, #ifdef branch2 allteams:{} #else allteams:{}, showCreateModal:false, showJoinModal:false, createTeam_form:{ email: "", team_name:"" }, rules:{ team_name:[ { required: true, message: '请输入团队名称', trigger: 'blur' }, { min: 5, max: 15, message: '长度在 5 到 15 个字符', trigger: 'blur' } ], }, #endif }; }, created() { this.userid=global.userid this.search() }, methods: { #ifdef branch2 createdoc() { this.$router.push({ name: "Viewdoc", params: { kind: 1 } }); }, changesearchkind(aint) #else changesearchkind(aint) #endif { this.searchkind=aint, this.search() }, search() { var that = this; axios #ifdef branch2 .post("http://127.0.0.1:8080/home", { #else .post("http://127.0.0.1:8080/home", {//175.24.53.216:8080 127.0.0.1:8080 #endif id: that.userid, kind: that.searchkind }) .then(function(response) { alert("搜索完成(测试)"); alert(response.data.msg); }) .catch(function(error) { alert(error); }); #ifdef branch2 }, #else }, submitForm(formName) { this.$refs[formName].validate((valid) => { if (valid) { var that = this; that.createTeam_form.email=global.userEmail; axios .post("http://127.0.0.1:8080/buildteam", that.createTeam_form)//175.24.53.216:8080 127.0.0.1:8080 .then(function(response) { alert(response.data.msg); }) .catch(function(error) { alert(error); console.log(error); }); } else { console.log('error submit!!'); return false; } }); }, toggleModalCreate:function(){ this.showCreateModal = !this.showCreateModal; }, closemeCreate:function(){ this.showCreateModal = !this.showCreateModal; }, toggleModalJoin:function(){ this.showJoinModal = !this.showJoinModal; }, closemeJoin:function(){ this.showJoinModal = !this.showJoinModal; } #endif } }; </script> <style scoped> .each { width: 30%; border: 1px solid black; margin: 5px; cursor: pointer; } .el-dropdown-link { cursor: pointer; color: #409EFF; } .el-icon-arrow-down { font-size: 12px; } #ifdef branch2 .searchBox{ } .searchInput{ } .searchButton{ } #endif .box { border: 1px solid #DCDFE6; margin: 10px auto; padding: 10px 35px 15px 35px; border-radius: 5px; -webkit-border-radius: 5px; -moz-border-radius: 5px; box-shadow: 0 0 5px #909399; opacity: 1 } .art-more { height: 40px; display: flex; justify-content: flex-end; align-items: flex-end; } .art-more .view { color: #aaa; } h5{ font-size: 18px; } .pagination { background-color: #F9F9F9; } .name{ margin-top:10px ; margin-left: 5px; } .art-time { margin-right: 20px; } .art-title { border-left: 3px solid #409EFF; padding-left: 5px; cursor: pointer; } .art-title:hover { padding-left: 10px; color: #409EFF; } .name{ margin-top:10px ; margin-left: 5px; cursor: pointer; } .name:hover{ padding-left: 10px; color: #409EFF; } #ifdef branch1 </style> <style> .modal-backdrop { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background-color: rgba(0,0,0,.3); display: flex; justify-content: center; align-items: center; } .modal { background-color: #fff; box-shadow: 2px 2px 20px 1px; overflow-x:auto; display: flex; flex-direction: column; border-radius: 16px; width: 700px; } .modal-header { border-bottom: 1px solid #eee; color: #313131; justify-content: space-between; padding: 15px; display: flex; } .modal-footer { border-top: 1px solid #eee; justify-content: flex-end; padding: 15px; display: flex; } .modal-body { position: relative; padding: 20px 10px; } .btn-close, .btn-confirm { border-radius: 8px; margin-left:16px; width:56px; height: 36px; border:none; cursor: pointer; } .btn-close { color: #313131; background-color:transparent; } .btn-confirm { color: #fff; background-color: #2d8cf0; } .login-box { border: 1px solid #DCDFE6; width: 350px; margin: 180px auto; padding: 35px 35px 15px 0px; border-radius: 5px; -webkit-border-radius: 5px; -moz-border-radius: 5px; box-shadow: 0 0 25px #909399; } .login-title { text-align: center; margin: 0 auto 40px auto; padding: 0px 0px 0px 10px; color: #303133; } .submitBtn { display:block; text-align: center; margin: 0px auto; background-color: transparent; color: #39f; width: 200px; } #endif </style>
超好用啊有木有!感谢假期能打如此实用的比赛!