From 05cc9b3f6968e058b4d3bfe19683356e13ab64dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=B7=E5=AD=90=E5=B0=A7?= Date: Sun, 27 Nov 2022 00:15:08 +0800 Subject: [PATCH 1/5] finish merge --- package-lock.json | 17 +- package.json | 3 +- src/App.vue | 2 + src/assets/github.png | Bin 0 -> 1036 bytes src/components/404.vue | 16 ++ src/components/Demo.vue | 3 + src/components/RepoBrowser.vue | 489 ++++++++++++++++++++++++++++++++- src/components/UserPage.vue | 1 + src/components/login.vue | 154 +++++++++++ src/main.js | 23 +- src/mock/index.js | 56 ++-- src/router/index.js | 12 + src/store/index.js | 30 ++ 13 files changed, 772 insertions(+), 34 deletions(-) create mode 100644 src/assets/github.png create mode 100644 src/components/404.vue create mode 100644 src/components/login.vue create mode 100644 src/store/index.js diff --git a/package-lock.json b/package-lock.json index 37e26af..21e45ec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,7 +28,8 @@ "vue": "^2.6.14", "vue-router": "^3.6.5", "vue-simple-uploader": "^0.7.6", - "vuetify": "^2.6.12" + "vuetify": "^2.6.12", + "vuex": "^3.6.2" }, "devDependencies": { "@vue/cli-plugin-babel": "~5.0.0", @@ -10727,6 +10728,14 @@ "vue": "^2.6.4" } }, + "node_modules/vuex": { + "version": "3.6.2", + "resolved": "https://registry.npmmirror.com/vuex/-/vuex-3.6.2.tgz", + "integrity": "sha512-ETW44IqCgBpVomy520DT5jf8n0zoCac+sxWnn+hMe/CzaSejb/eVw2YToiXYX+Ex/AuHHia28vWTq4goAexFbw==", + "peerDependencies": { + "vue": "^2.0.0" + } + }, "node_modules/watchpack": { "version": "2.4.0", "resolved": "https://registry.npmmirror.com/watchpack/-/watchpack-2.4.0.tgz", @@ -19866,6 +19875,12 @@ "integrity": "sha512-qe3hcMpWmT1O15tp+p65lOS7UKZ/hQYQktCsw9iXx2u3RwVbX6GR82gY2iROrKsiAzYDvMgrYxWQwY/pUfkekw==", "requires": {} }, + "vuex": { + "version": "3.6.2", + "resolved": "https://registry.npmmirror.com/vuex/-/vuex-3.6.2.tgz", + "integrity": "sha512-ETW44IqCgBpVomy520DT5jf8n0zoCac+sxWnn+hMe/CzaSejb/eVw2YToiXYX+Ex/AuHHia28vWTq4goAexFbw==", + "requires": {} + }, "watchpack": { "version": "2.4.0", "resolved": "https://registry.npmmirror.com/watchpack/-/watchpack-2.4.0.tgz", diff --git a/package.json b/package.json index 5d71940..e77ae94 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,8 @@ "vue": "^2.6.14", "vue-router": "^3.6.5", "vue-simple-uploader": "^0.7.6", - "vuetify": "^2.6.12" + "vuetify": "^2.6.12", + "vuex": "^3.6.2" }, "devDependencies": { "@vue/cli-plugin-babel": "~5.0.0", diff --git a/src/App.vue b/src/App.vue index 517befc..7a1d0de 100644 --- a/src/App.vue +++ b/src/App.vue @@ -9,6 +9,7 @@ import Demo from './components/Demo.vue' import UserPage from './components/UserPage.vue' import RepoBrowser from './components/RepoBrowser.vue' +import page404 from './components/404.vue' export default { @@ -17,6 +18,7 @@ export default { Demo, UserPage, RepoBrowser, + page404, }, computed: { key() { diff --git a/src/assets/github.png b/src/assets/github.png new file mode 100644 index 0000000000000000000000000000000000000000..4e88f4e0c6b45649706e599bf83b1643344c067f GIT binary patch literal 1036 zcmV+n1oQieP)D#&d-(JE+9Ps@budSJnrGhs|5gd`6>xY+~tCL4{L1I0`R$m7B>wL%6(qi zqz2$b((6rI)v5o3q&N9HB>=62HHssw9(EewiT{!Wm9idJgx3-~2LQK!Pg;On&wjEA zvVg@av<)MR_JTy^u{Hy}KPt+o+6RdZYcz@?3RP)cRuYSus6<7IJib+d>gDn<-|sFhXXIgcN|sI=2bH%t{7;BPI4*>ox(v zPIBSG01%7s16dfU+yOPN$nOS`*vm(fPRt;@?^WE}b^?&a0RX(@HN?}AxxQOQAZpV- z03zXYjk=bx(bdA8gZ90(jsOs88`1*i?!1ry^@Ut$tz!UqoQr~OC2wwQtDsG_DFR@d z$(sZ4oI3&VC~Ft-Z$P{}xB|dmC(ep(>_Tzwsqp|zvF!oaWeCwSFmtLd0Ko07-kuir zp699!{qGgn%SaMq8vt%JK^p|X4^UiiWuSJ zP5-7!%*2iHiMO^%rxB-O@1a##FV+m)HX6Ff-NfwKGXRl1;3YzceBcheiG}e*gMC+M z?J-4!0f>f?DFgsOmdXhXrt@5z`!o+-M zC%|T$Qf-LUQ!An@Q;MK#txXP~#sJ1X{Ew$|5c83CWVYAq*Hm3&!qP>hbVEyPKst#d zFBlJ!e7(#xatam=Gq~DKD-Wf$nPi8jYoa7Bxe#5&uDAvOF9RZFp5}*!s1=D^4|Ow_ zMShL8TX)@3yrX~+@mJ>=U|w^Z>xqgcNj{&+eB3KyKAOdK81D7l0`N z2wt+UIU@kl`6qP-k9QNpC;$UOei&N?(rHbE7$^CMyV`%PO46RP7yE$#0000 +
+ + +
+ + + \ No newline at end of file diff --git a/src/components/Demo.vue b/src/components/Demo.vue index fb0b5ec..ad5e61e 100644 --- a/src/components/Demo.vue +++ b/src/components/Demo.vue @@ -34,6 +34,9 @@ + + 62 + diff --git a/src/components/RepoBrowser.vue b/src/components/RepoBrowser.vue index 2ecca97..cc05bd7 100644 --- a/src/components/RepoBrowser.vue +++ b/src/components/RepoBrowser.vue @@ -47,11 +47,32 @@ Code + + + + - @@ -229,13 +280,124 @@ -
- About +
+
+
About
+

The description of this repository

+
+ + + + + 0stars + +
+ +
+ + + + + + 0watching + +
+ +
+ + + + + 0fork + +
+
+ + + +
+
+
Card title
+
Card subtitle
+

Some quick example text to build on the card title and make up the bulk of the card's content.

+ Card link + Another link +
+
+ +
+
Contributer
+ +
+
+
+ + Avatar + + +
+
Contributer1
+
+
+ +
+
+
+ + Avatar + + +
+
Contributer2
+
+
+ + +
+
+ +
+
+
+ Commits +
+ + + + + + + + + +
+
+ @@ -354,11 +516,144 @@ - + + + + + + +
+
+ + +
+ + +
+ + +
+ + + + + +
+ +
+
+ {{this.PRshow}} pull requests +
+ + + + +
+ + + + + {{item.PRTitle}} + + +
+
+ + + + + +
+
+
+
-
@@ -389,6 +684,7 @@ import Demo from './Demo.vue' import axios from 'axios' axios.defaults.baseURL = 'http://localhost:8080'; +// axios.defaults.baseURL = 'http://10.27.133.155:8080'; import 'markdown-it-vue/dist/markdown-it-vue.css' import content from '../file/README.md' @@ -410,14 +706,37 @@ export default { data: function() { return { content, - codeFile: "int main(){\n\tint a = 1;\n\ta += 1;\n\t}", + codeFile: "int a;\n\tint main(){\\tint a = 1;\n\ta += 1;\n\t}", file: '', + + commitList:[ + + ], + rollbackJudge:0, + branchform:{name:''}, + branchFormVisible:false, + + //issue form issueTitle: '', issueComment: '', + //PR part + baseBrach: '--', + compareBranch: '--', + targetUser: '--', + forkedUser: 'none', + PRshow: 'open', + PRopen: 'open', + PRclosed: 'closed', + PRList: [ + {PRTitle: "Merge a brach", status:"open", target: "JoeyZi1", targetBranch: 'master', from: 'JoeyZi1', fromBranch: 'dev'}, + {PRTitle: "Merge a brach", status:"open", target: "JoeyZi1", targetBranch: 'master', from: 'JoeyZi1', fromBranch: 'public'}, + {PRTitle: "Merge a brach", status:"closed", target: "JoeyZi1", targetBranch: 'master', from: 'JoeyZi1', fromBranch: 'dev'}, + ], + root: "root", @@ -477,6 +796,119 @@ export default { }, methods: { + //pr part + shiftPRtarget: function(b){ + console.log(b); + this.targetUser = b; + }, + + shiftBaseBranch: function(b) { + this.baseBrach = b; + }, + + shiftCompareBranch: function(b) { + this.compareBranch = b; + }, + + async deleteBranch(branchname){ + var deleteJudge = 0 + await axios.get("/createBranch/" + this.$route.params.userName + '/' + this.$route.params.repoParam + '/' + this.$route.params.branchName ).then((response)=>{ + branchJudge = response.data + }) + }, + enterBranch(branchname){ + this.$router.push({ + name: "RepoBrowser", + params:{ + userName: this.$route.params.userName, + repoParam: this.$route.params.repoParam, + branchName: branchname, + queryPath: "root" + }, + query: { + path: +new Date() + } + } + ) + }, + async submitBranchForm(){ + var newBranchName = this.branchform.name + var branchJudge = 0 + await axios.get("/createBranch/" + this.$route.params.userName + '/' + this.$route.params.repoParam + '/' + this.$route.params.branchName + "/" + newBranchName).then((response)=>{ + branchJudge = response.data + }) + console.log('-------------------------------------------create branch','branchjudge',branchJudge) + console.log("/RepoBrowser/" + this.$route.params.userName + '/' + this.$route.params.repoParam + '/' + this.$route.params.branchName + "/createBranch/" + newBranchName) + this.branchFormVisible = false + if (branchJudge==0){ + alert('Create failed.'); + } else{ + this.branchList.push(newBranchName) + this.$router.push({ + name: "RepoBrowser", + params:{ + userName: this.$router.params.userName, + repoParam: this.$router.params.repoParam, + branchName: newBranchName, + queryPath: "root" + }, + query: { + path: +new Date() + } + } + ) + + } + }, + createBranch(){ + this.branchFormVisible = true + }, + async rollback(id){ + console.log('---------------------------------------------rollback', id) + console.log("/RepoBrowser/" + this.$route.params.userName + '/' + this.$route.params.repoParam + '/' + this.$route.params.branchName + id + '/Rollback') + await axios.get("/RepoBrowser/" + this.$route.params.userName + '/' + this.$route.params.repoParam + '/' + this.$route.params.branchName + "/" + id + '/Rollback').then((response)=>{ + this.rollbackJudge = response.data + }) + console.log(this.rollbackJudge) + if(this.rollbackJudge==1){ + + // window.location.reload(); + console.log('this.rollbackJudge=================================') + this.$router.push( + { + name: "RepoBrowser", + params:{ + userName: this.$route.params.userName, + repoParam: this.$route.params.repoParam, + branchName: this.$route.params.branchName, + queryPath: "root" + }, + query: { + path: +new Date() + } + } + ) + console.log('this.rollbackJudge========sgdhsjdfjf=========================') + + } else{ + alert('Rollback failed!') + // , ' ', function(){ + // // window.location.reload(); + // this.$router.push({ + // name: "RepoBrowser", + // params:{ + // userName: this.$router.params.userName, + // repoParam: this.$router.params.repoParam, + // branchName: "master", + // queryPath: "root" + // } + // } + // ) + // }); + } + }, + + addComment: function(name) { var index = this.issueList.findIndex(issue => { if (issue.id == name) { @@ -503,6 +935,14 @@ export default { } }, + filterPR: function(flag) { + if (flag === this.PRopen) { + this.PRshow = "open" + } else { + this.PRshow = "closed" + } + }, + //提取path test: function(item) { var temp = this.$route.params.queryPath.split(item) @@ -638,13 +1078,17 @@ export default { }, created: function() { - // console.log("the get axio is", this.$route.fullPath) axios.get(this.$route.path).then((response)=>{ this.itemList = response.data.itemList this.branchList = response.data.branchList this.display = response.data.display this.fileContent = response.data.response }) + console.log("----------------------sdfsghgdhfgh----------------------------"); + console.log('/RepoBrowser/'+ this.$route.params.userName + '/' + this.$route.params.repoParam + '/' + this.$route.params.branchName + '/upload'); + axios.get("/RepoBrowser/" + this.$route.params.userName + '/' + this.$route.params.repoParam + '/' + this.$route.params.branchName + '/getCommitList').then((response)=>{ + this.commitList = response.data.commitList + }) }, @@ -672,6 +1116,29 @@ export default { return arr }, + filterIssueList_ () { + var arr = this.issueList.filter(item => item.issueCondition === this.issueOpen) + return arr + }, + + issueNumber () { + return this.filterIssueList_.length; + }, + + filterPRList () { + var arr = this.PRList.filter(item => item.status === this.PRshow) + return arr + }, + + filterPRList_ () { + var arr = this.PRList.filter(item => item.status === this.PRopen) + return arr + }, + + PRNumber () { + return this.filterPRList_.length; + }, + //提取path @@ -698,7 +1165,7 @@ export default { } }, - + } diff --git a/src/components/UserPage.vue b/src/components/UserPage.vue index 27b79f3..1a9dc52 100644 --- a/src/components/UserPage.vue +++ b/src/components/UserPage.vue @@ -217,6 +217,7 @@ import axios from 'axios'; import Demo from './Demo.vue' axios.defaults.baseURL = 'http://localhost:8080'; +// axios.defaults.baseURL = 'http://10.27.133.155:8080'; export default { components: { diff --git a/src/components/login.vue b/src/components/login.vue new file mode 100644 index 0000000..1842cb9 --- /dev/null +++ b/src/components/login.vue @@ -0,0 +1,154 @@ + + + + > + + \ No newline at end of file diff --git a/src/main.js b/src/main.js index a256d50..9464f15 100644 --- a/src/main.js +++ b/src/main.js @@ -15,6 +15,25 @@ import 'highlight.js/styles/googlecode.css' //样式文件 import {lineNumbersBlock} from '@/highlight/highlight-line-number' import Vuetify from 'vuetify' import vuetify from './plugins/vuetify' +import store from "./store"; + +// router.beforeEach((to, from, next) => { +// if (to.name!='login') { +// let token = window.sessionStorage.getItem("Token") +// console.log(token) +// if (token) { +// next() +// } else { +// Vue.prototype.$message({ +// type: "error", +// message: "请先登录" +// }); +// next('/login') +// } +// } else { +// next() +// } +// }) Vue.directive('highlight', { update(el){ @@ -41,10 +60,10 @@ Vue.use(uploader); Vue.use(jQuery); Vue.use(hljs); Vue.use(Vuetify); -// Vue.use(hljs.vuePlugin); new Vue({ vuetify, render: h => h(App), - router: router + router: router, + store }).$mount('#app') diff --git a/src/mock/index.js b/src/mock/index.js index c83af45..e3deb11 100644 --- a/src/mock/index.js +++ b/src/mock/index.js @@ -56,6 +56,8 @@ let joey_repo_root = Mock.mock({ "display": /list/, "branchList": [ {"branchName": "master"}, + {"branchName": "public"}, + {"branchName": "dev"}, ], "itemList": [ { @@ -81,6 +83,8 @@ let joey_repo_src = Mock.mock({ "display": /list/, "branchList": [ {"branchName": "master"}, + {"branchName": "public"}, + {"branchName": "dev"}, ], "itemList": [ { @@ -102,6 +106,8 @@ let joey_repo_public = Mock.mock({ "display": /list/, "branchList": [ {"branchName": "master"}, + {"branchName": "public"}, + {"branchName": "dev"}, ], "itemList": [ { @@ -117,6 +123,8 @@ let joey_repo_mock = Mock.mock({ "display": /list/, "branchList": [ {"branchName": "master"}, + {"branchName": "public"}, + {"branchName": "dev"}, ], "itemList": [ { @@ -133,6 +141,8 @@ let joey_repo_components = Mock.mock({ "display": /list/, "branchList": [ {"branchName": "master"}, + {"branchName": "public"}, + {"branchName": "dev"}, ], "itemList": [ { @@ -145,29 +155,42 @@ let joey_repo_components = Mock.mock({ }) -// Mock.mock('http://localhost:8080/UserPage/JoeyZi1', () => { +Mock.mock('http://localhost:8080/UserPage/JoeyZi1', () => { + return joey_userpage +}) +Mock.mock('http://localhost:8080/RepoBrowser/JoeyZi1/OOAD_Project/master/root_src_components', () => { + return joey_repo_components +}) +Mock.mock('http://localhost:8080/RepoBrowser/JoeyZi1/OOAD_Project/master/root_src_mock', () => { + return joey_repo_mock +}) +Mock.mock('http://localhost:8080/RepoBrowser/JoeyZi1/OOAD_Project/master/root_src', () => { + return joey_repo_src +}) +Mock.mock('http://localhost:8080/RepoBrowser/JoeyZi1/OOAD_Project/master/root_public', () => { + return joey_repo_public +}) +Mock.mock('http://localhost:8080/RepoBrowser/JoeyZi1/OOAD_Project/master/root', () => { + console.log("mock info") + return joey_repo_root +}) + +// Mock.mock('http://10.27.133.155:8080/UserPage/JoeyZi1', () => { // return joey_userpage // }) - - -// Mock.mock(RegExp('/RepoBrowser/JoeyZi1/OOAD_Project/master/root_src_components'), () => { +// Mock.mock('http://10.27.133.155:8080/RepoBrowser/JoeyZi1/OOAD_Project/master/root_src_components', () => { // return joey_repo_components // }) - -// Mock.mock(RegExp('/RepoBrowser/JoeyZi1/OOAD_Project/master/root_src_mock'), () => { +// Mock.mock('http://10.27.133.155:8080/RepoBrowser/JoeyZi1/OOAD_Project/master/root_src_mock', () => { // return joey_repo_mock // }) - -// Mock.mock(RegExp('/RepoBrowser/JoeyZi1/OOAD_Project/master/root_src'), () => { +// Mock.mock('http://10.27.133.155:8080/RepoBrowser/JoeyZi1/OOAD_Project/master/root_src', () => { // return joey_repo_src // }) - -// Mock.mock(RegExp('/RepoBrowser/JoeyZi1/OOAD_Project/master/root_public'), () => { +// Mock.mock('http://10.27.133.155:8080/RepoBrowser/JoeyZi1/OOAD_Project/master/root_public', () => { // return joey_repo_public // }) - - -// Mock.mock(RegExp('/RepoBrowser/JoeyZi1/OOAD_Project/master/root'), () => { +// Mock.mock('http://10.27.133.155:8080/RepoBrowser/JoeyZi1/OOAD_Project/master/root', () => { // console.log("mock info") // return joey_repo_root // }) @@ -178,9 +201,4 @@ let joey_repo_components = Mock.mock({ let upload_response = Mock.mock({ "status": 200 -}) - -// Mock.mock(RegExp('http://127.0.0.1:8081/upload'), () => { -// console.log("accept file") -// return upload_response -// }) \ No newline at end of file +}) \ No newline at end of file diff --git a/src/router/index.js b/src/router/index.js index 231c990..dbc594b 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -3,6 +3,8 @@ import Demo from '../components/Demo.vue' import RepoBrowser from '../components/RepoBrowser.vue' import UserPage from '../components/UserPage.vue' import VueRouter from 'vue-router' +import page404 from '../components/404.vue' +// import login from '../components/login.vue' Vue.use(VueRouter) @@ -22,6 +24,16 @@ const router = new VueRouter({ name: "RepoBrowser", component: RepoBrowser }, + { + path: '/404', + component: page404, + hidden: true + }, + // { + // path: '/login', + // name: "login", + // component: login + // }, ] }) diff --git a/src/store/index.js b/src/store/index.js new file mode 100644 index 0000000..34473d5 --- /dev/null +++ b/src/store/index.js @@ -0,0 +1,30 @@ +import Vue from 'vue' +import Vuex from 'vuex' + +// 1. 安装插件 vue的底层会执行 Vue.install +Vue.use(Vuex) + +// 2. 创建对象 +const store = new Vuex.Store({ + state:{ + userName:'' + }, + mutations:{ + edit(state, username){ + state.userName = username + } + }, + actions:{ + + }, + getters:{ + + }, + modules:{ + + } + +}) + +// 3. 导出store对象 +export default store \ No newline at end of file From 2e1028781445da789dae9c3241af1a2179bf538a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=B7=E5=AD=90=E5=B0=A7?= Date: Sun, 27 Nov 2022 21:53:36 +0800 Subject: [PATCH 2/5] merge --- package-lock.json | 26 ++++++++ package.json | 2 + src/App.vue | 106 +++++++++++++++++++++++++++++++-- src/axios/index.js | 35 +++++++++++ src/components/Demo.vue | 101 ++++++++++++++++++------------- src/components/RepoBrowser.vue | 40 +++++++------ src/components/UserPage.vue | 23 ++++--- src/components/login.vue | 16 ++--- src/main.js | 56 +++++++++++------ src/router/index.js | 12 ++-- src/store/index.js | 63 ++++++++++++++++++-- 11 files changed, 370 insertions(+), 110 deletions(-) create mode 100644 src/axios/index.js diff --git a/package-lock.json b/package-lock.json index 21e45ec..c806a0a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,11 +21,13 @@ "markdown-loader": "^8.0.0", "marked": "^4.2.2", "mockjs": "^1.1.0", + "nprogress": "^0.2.0", "popper.js": "^1.16.1", "sass-loader": "^13.2.0", "showdown": "^2.1.0", "showdown-highlight": "^3.1.0", "vue": "^2.6.14", + "vue-avatar": "^2.3.3", "vue-router": "^3.6.5", "vue-simple-uploader": "^0.7.6", "vuetify": "^2.6.12", @@ -8090,6 +8092,11 @@ "node": ">=4" } }, + "node_modules/nprogress": { + "version": "0.2.0", + "resolved": "https://registry.npmmirror.com/nprogress/-/nprogress-0.2.0.tgz", + "integrity": "sha512-I19aIingLgR1fmhftnbWWO3dXc0hSxqHQHQb3H8m+K3TnEn/iSeTZZOyvKXWqQESMwuUVnatlCnZdLBZZt2VSA==" + }, "node_modules/nth-check": { "version": "2.1.1", "resolved": "https://registry.npmmirror.com/nth-check/-/nth-check-2.1.1.tgz", @@ -10547,6 +10554,15 @@ "csstype": "^3.1.0" } }, + "node_modules/vue-avatar": { + "version": "2.3.3", + "resolved": "https://registry.npmmirror.com/vue-avatar/-/vue-avatar-2.3.3.tgz", + "integrity": "sha512-Z57ILRTkFIAuCH9JiFBxX74C5zua5ub/jRDM/KZ+QKXNfscvmUOgWBs3kA2+wrpZMowIvfLHIT0gvQu1z+zpLg==", + "engines": { + "node": ">= 4.0.0", + "npm": ">= 3.0.0" + } + }, "node_modules/vue-hot-reload-api": { "version": "2.3.4", "resolved": "https://registry.npmmirror.com/vue-hot-reload-api/-/vue-hot-reload-api-2.3.4.tgz", @@ -17844,6 +17860,11 @@ "path-key": "^2.0.0" } }, + "nprogress": { + "version": "0.2.0", + "resolved": "https://registry.npmmirror.com/nprogress/-/nprogress-0.2.0.tgz", + "integrity": "sha512-I19aIingLgR1fmhftnbWWO3dXc0hSxqHQHQb3H8m+K3TnEn/iSeTZZOyvKXWqQESMwuUVnatlCnZdLBZZt2VSA==" + }, "nth-check": { "version": "2.1.1", "resolved": "https://registry.npmmirror.com/nth-check/-/nth-check-2.1.1.tgz", @@ -19731,6 +19752,11 @@ "csstype": "^3.1.0" } }, + "vue-avatar": { + "version": "2.3.3", + "resolved": "https://registry.npmmirror.com/vue-avatar/-/vue-avatar-2.3.3.tgz", + "integrity": "sha512-Z57ILRTkFIAuCH9JiFBxX74C5zua5ub/jRDM/KZ+QKXNfscvmUOgWBs3kA2+wrpZMowIvfLHIT0gvQu1z+zpLg==" + }, "vue-hot-reload-api": { "version": "2.3.4", "resolved": "https://registry.npmmirror.com/vue-hot-reload-api/-/vue-hot-reload-api-2.3.4.tgz", diff --git a/package.json b/package.json index e77ae94..807311c 100644 --- a/package.json +++ b/package.json @@ -20,11 +20,13 @@ "markdown-loader": "^8.0.0", "marked": "^4.2.2", "mockjs": "^1.1.0", + "nprogress": "^0.2.0", "popper.js": "^1.16.1", "sass-loader": "^13.2.0", "showdown": "^2.1.0", "showdown-highlight": "^3.1.0", "vue": "^2.6.14", + "vue-avatar": "^2.3.3", "vue-router": "^3.6.5", "vue-simple-uploader": "^0.7.6", "vuetify": "^2.6.12", diff --git a/src/App.vue b/src/App.vue index 7a1d0de..79106bb 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,7 +1,43 @@ @@ -10,6 +46,8 @@ import Demo from './components/Demo.vue' import UserPage from './components/UserPage.vue' import RepoBrowser from './components/RepoBrowser.vue' import page404 from './components/404.vue' +import Avatar from 'vue-avatar' +import store from '@/store' export default { @@ -19,12 +57,72 @@ export default { UserPage, RepoBrowser, page404, + Avatar, }, + + data: function(){ + return { + name: "store.state.userName" + }; + }, + computed: { key() { - return this.$route.fullPath + return this.$route.fullPath + }, + userName(){ + var userInfo = store.state.userName; + console.log(userInfo); + return userInfo; } - } + }, + + methods: { + extractColorByName(name) { + var temp = []; + temp.push("#"); + for (let index = 0; index < name.length; index++) { + temp.push(parseInt(name[index].charCodeAt(0), 10).toString(16)); + } + return temp.slice(0, 5).join('').slice(0, 4); + }, + + gotoUser() { + this.$router.push( + { + name: "UserPage", + params:{ + userName: this.$route.params.userName, + }, + } + ) + }, + + // 退出事件 + logout() { + this.$confirm('确定退出系统?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'info' + }).then(() => { + this.$store.dispatch('userLogout') + // this.$store.commit('SET_PERMS', '') + this.$message({ + type: 'success', + message: '退出成功!' + }) + setTimeout(() => { + location.reload() // 强制刷新 + }, 1000) + }).catch(() => { + this.$message({ + type: 'info', + message: '已取消退出' + }) + }) + }, + + } } diff --git a/src/axios/index.js b/src/axios/index.js new file mode 100644 index 0000000..4e41b2e --- /dev/null +++ b/src/axios/index.js @@ -0,0 +1,35 @@ +import axios from 'axios' +// 引入进度条 +import nprogress from 'nprogress' +// 引入进度条的样式 +import 'nprogress/nprogress.css' +// 引入store +import store from '@/store' +// 创建axios实例 + +const requests = axios.create({ + baseURL:"http://10.27.133.155:8080", + // 请求超时的时间 + timeout:5000, +}); + +// 请求拦截器 -- 在请求发出前做些事情 +requests.interceptors.request.use((config) => { + // 需要携带token给服务器 + if(store.state.token) { + config.headers.Token = store.state.token; + } + nprogress.start(); + // config 是配置对象,里面包含请求头headers + return config; +}); + +// 响应拦截器 +requests.interceptors.response.use((res) => { + nprogress.done(); + return res.data; +},(err) => { + return Promise.reject(new Error('fail')) +}); + +export default requests; diff --git a/src/components/Demo.vue b/src/components/Demo.vue index ad5e61e..741446c 100644 --- a/src/components/Demo.vue +++ b/src/components/Demo.vue @@ -1,53 +1,72 @@ \ No newline at end of file diff --git a/src/components/RepoBrowser.vue b/src/components/RepoBrowser.vue index 97b6ac0..23b21ef 100644 --- a/src/components/RepoBrowser.vue +++ b/src/components/RepoBrowser.vue @@ -1,17 +1,20 @@ @@ -830,8 +849,8 @@ import markdown from '../file/README.md' import 'highlight.js/styles/github.css' // 其他元素使用 github 的样式 import 'github-markdown-css' -import Avatar from 'vue-avatar' import store from '@/store' +import Avatar from 'vue-avatar' import nprogress from 'nprogress' import 'nprogress/nprogress.css' @@ -849,11 +868,15 @@ export default { data: function() { return { - downloadURL: 'http://10.27.133.155:8080'+'/RepoBrowser/' + this.$route.params.userName + '/' + this.$route.params.repoParam + '/' + this.$route.params.branchName+"/download", + checkNull: '', + visibility: 'public', + markdownvalue: '', + downloadURL: 'http://10.27.133.155:8080'+'/RepoBrowser/download/' + this.$route.params.userName + '/' + this.$route.params.repoParam + '/' + this.$route.params.branchName+"/aaa/bbb/ccc/ddd", overlay: false, - uploadURL: 'http://10.27.133.155:8080'+this.$route.path+ '/upload', + uploadURL: 'http://10.27.133.155:8080'+this.$route.path+ '/upload/'+ store.state.userName, root: "root", + private_: "private", itemType_folder: "folder", itemType_file: "file", pageType_list: "list", @@ -868,16 +891,14 @@ export default { branchRules: { name: [{ required: true, message: "Please enter the branch name!", trigger: "blur" }], }, - markdownvalue:'

Jgit:

\n

fasd

\n

ffasdf

\n

1234q5afsd

\n

######

\n

fasdf

\n

a

\n
s1f
', - setitems: [ { title: 'Dashboard', icon: 'dashboard' }, { title: 'Account', icon: 'account_box' }, { title: 'Admin', icon: 'gavel' }, ], content, - codeFile: "\n#!/usr/bin/python\n# -*- coding: UTF-8 -*-\n\nimport socket# 客户端 发送一个数据,再接收一个数据\nclient = socket.socket(socket.AF_INET,socket.SOCK_STREAM) #声明socket类型,同时生成链接对象\nclient.connect(('localhost',6999)) #建立一个链接,连接到本地的6969端口\nwhile True:\n # addr = client.accept()\n # print '连接地址:', addr\n msg = '欢迎访问菜鸟教程!' #strip默认取出字符串的头尾空格\n client.send(msg.encode('utf-8')) #发送一条信息 python3 只接收btye流\n data = client.recv(1024) #接收一个信息,并指定接收的大小 为1024字节\n print('recv:',data.decode()) #输出我接收的信息\n client.close()\n\n", - file: [], + codeFile: "", + file: '', commitList:[], rollbackJudge:0, branchform:{name:''}, @@ -927,7 +948,7 @@ export default { repoWatch: -1, haveStared: false, haveForked: false, - haveWatched: true, + haveWatched: false, //setting @@ -949,43 +970,39 @@ export default { ] }, - {issueName: "Consider adding keyboard shortcut image", issueCondition: "open", - issueContent: [ - {comment: 'Test comment', user: 'Joey', commentDate: new Date()}, - {comment: 'Test comment 2', user: 'Peter', commentDate: new Date()} - ] - - }, - {issueName: "Consider adding tere", issueCondition: "closed", - issueContent: [ - {comment: 'Test comment', user: 'Joey', commentDate: new Date()}, - {comment: 'Test comment 2', user: 'Peter', commentDate: new Date()} - ] - - }, ], } }, methods: { - deleteRepo() { - axios.get('/Repository/delete/'+this.$route.params.userName+'/'+this.$route.params.repoParam).then((response)=>{ + clearUpFile() { + this.file = '' + }, + + async deleteRepo() { + await axios.get('/Repository/delete/'+this.$route.params.userName+'/'+this.$route.params.repoParam).then((response)=>{ this.$message({ - type: 'success', message: '仓库删除!' }) }) }, - startFork() { - axios.get('/PR/fork/'+store.state.userName+'/'+this.$route.params.repoParam+'/'+this.$route.params.userName+'/'+this.$route.params.repoParam+'/'+'master').then((response)=>{ + async startFork() { + s = await axios.get('/PR/fork/'+store.state.userName+'/'+this.$route.params.repoParam+'/'+this.$route.params.userName+'/'+this.$route.params.repoParam+'/'+'master').then((response)=>{ + console.log('fork response') + console.log(response) this.$message({ - type: 'success', - message: 'merge发送!' + message: 'try to fork' + }).catch(function(error) { + console.log('errrrr') + console.log(error) }) }) + + console.log('errrrr') + console.log(s) }, codeDownload() { @@ -1067,11 +1084,45 @@ export default { } }, - addPR(repo) { + async clickWatch() { + if (this.haveWatched) { //remove watch + await axios.get('/watch/delete/'+this.$route.params.userName+'/'+this.$route.params.repoParam+'/'+store.state.userName).then((response)=>{ + this.$message({ + type: 'success', + message: 'remove watch!' + }) + }) + console.log(this.$route.path) + this.$router.push( + { + URL:this.$route.path, + query: { + path: +new Date() //保证每次点击路由的query项都是不一样的,确保会重新刷新view + } + }) + + } else { //add watch + await axios.get('/watch/add/'+this.$route.params.userName+'/'+this.$route.params.repoParam+'/'+store.state.userName).then((response)=>{ + this.$message({ + type: 'success', + message: 'watch this repo!' + }) + }) + console.log(this.$route.path) + this.$router.push( + { + URL:this.$route.path, + query: { + path: +new Date() //保证每次点击路由的query项都是不一样的,确保会重新刷新view + } + }) + } + }, + + async addPR(repo) { console.log('add PR') - axios.get('/PR/Request/'+this.targetUser+'/'+repo+'/'+this.baseBrach+'/'+this.$route.params.userName+'/'+repo+'/'+this.compareBranch+'/'+this.PRTitleInput).then((response)=>{ + await axios.get('/PR/Request/'+this.targetUser+'/'+repo+'/'+this.baseBrach+'/'+this.$route.params.userName+'/'+repo+'/'+this.compareBranch+'/'+this.PRTitleInput).then((response)=>{ this.$message({ - type: 'success', message: 'add PR!', }) }) @@ -1079,20 +1130,18 @@ export default { this.flush() }, - acptPR(repo,tar,tarBranch,from,fromBranch,id) { - axios.get('/PR/merge/'+tar+'/'+repo+'/'+tarBranch+'/'+from+'/'+repo+'/'+fromBranch+'/'+id).then((response)=>{ + async acptPR(repo,tar,tarBranch,from,fromBranch,id) { + await axios.get('/PR/merge/'+tar+'/'+repo+'/'+tarBranch+'/'+from+'/'+repo+'/'+fromBranch+'/'+id).then((response)=>{ this.$message({ - type: 'success', message: 'accept merge!' }) }) this.flush() }, - rejPR(repo,tar,tarBranch,from,fromBranch,id) { - axios.get('/PR/rejectMerge/'+tar+'/'+repo+'/'+tarBranch+'/'+from+'/'+repo+'/'+fromBranch+'/'+id).then((response)=>{ + async rejPR(repo,tar,tarBranch,from,fromBranch,id) { + await axios.get('/PR/rejectMerge/'+tar+'/'+repo+'/'+tarBranch+'/'+from+'/'+repo+'/'+fromBranch+'/'+id).then((response)=>{ this.$message({ - type: 'success', message: 'reject merge!' }) }) @@ -1100,23 +1149,21 @@ export default { }, - inviteContributer() { + async inviteContributer() { var cont = this.addContributerPane; this.addContributerPane = ''; - axios.get("/RepoBrowser/AddContributer/" + this.$route.params.userName + '/' + this.$route.params.repoParam + '/' + cont).then((response)=>{ + await axios.get("/RepoBrowser/AddContributer/" + this.$route.params.userName + '/' + this.$route.params.repoParam + '/' + cont).then((response)=>{ this.$message({ - type: 'success', - message: 'add user!' + message: 'add user' }) }) this.flush() }, - deleteContributer(name) { - axios.get("/RepoBrowser/removeContributer/" + this.$route.params.userName + '/' + this.$route.params.repoParam + '/' + name).then((response)=>{ + async deleteContributer(name) { + await axios.get("/RepoBrowser/removeContributer/" + this.$route.params.userName + '/' + this.$route.params.repoParam + '/' + name).then((response)=>{ this.$message({ - type: 'success', - message: 'remove user!' + message: 'remove user' }) }) this.flush() @@ -1181,9 +1228,9 @@ export default { this.baseBrach = b; }, - shiftCompareBranch: function(b) { + shiftCompareBranch: async function(b) { this.compareBranch = b; - axios.get('/PR/getTargetInfo/'+this.$route.params.userName + '/'+this.$route.params.repoParam + '/' + b).then((response)=>{ + await axios.get('/PR/getTargetInfo/'+this.$route.params.userName + '/'+this.$route.params.repoParam + '/' + b).then((response)=>{ this.$message({ type: 'success', message: 'change branch!' @@ -1297,20 +1344,92 @@ export default { } }, - addComment: function(name) { + async CloseIssue(id){ var index = this.issueList.findIndex(issue => { - if (issue.id == name) { + if (issue.issueID == id) { return true; } }); - this.issueList[index].issueContent.push({comment: this.issueComment, user: "Joey", commentDate: new Date()}) + var judge = 0 + await axios.get("/Issue/openIssue/"+this.issueList[index].issueID+"/0").then((response)=>{ + judge = response.status + }) + if(judge == 1){ + this.issueList[index].issueCondition = 'closed' + alert('Close successfully!') + }else{ + alert('Close failed!') + } + }, + async deleteIssue(id){ + var index = this.issueList.findIndex(issue => { + if (issue.issueID == id) { + return true; + } + }); + var judge = 0 + console.log("/Issue/deleteIssue/"+this.issueList[index].issueID) + await axios.get("/Issue/deleteIssue/"+this.issueList[index].issueID).then((response)=>{ + judge = response.status + console.log(response.status) + }) + if(judge==1){ + alert('Delete successfully!') + this.issueList.splice(index,1) + }else{ + alert('Delete failed!') + } + }, + addComment: async function(id) { + var index = this.issueList.findIndex(issue => { + if (issue.issueID == id) { + return true; + } + }); + console.log('this is id',id) + console.log('thisis index',index) + var judge = 0 + await axios.get("/Issue/commentIssue/"+this.issueList[index].issueID+'/'+this.$store.state.userName+'/'+this.issueComment).then((response)=>{ + judge = response.status + console.log(response.status) + }) + if(judge == 1){ + alert('Comment successfully!') + this.issueList=[] + await axios.get('/Issue/showAllIssues/'+this.$route.params.userName+'/'+this.$route.params.repoParam).then((response)=>{ + for(var i=0; i{ + judge = response.status + }) + if(judge == 0){ + alert('Create issue failed!') + } else{ + alert('Create issue successfully!') + this.issueList=[] + await axios.get('/Issue/showAllIssues/'+this.$route.params.userName+'/'+this.$route.params.repoParam).then((response)=>{ + for(var i=0; i{ + await axios.get(this.$route.path).then((response)=>{ this.itemList = response.itemList this.branchList = response.branchList this.display = response.display @@ -1460,25 +1583,50 @@ export default { }, - created: function() { - axios.get(this.$route.path).then((response)=>{ + created: async function() { + if (sessionStorage.getItem("name")){ + store.commit('USERNAME', sessionStorage.getItem('name')) + sessionStorage.removeItem('name') + } + window.addEventListener('beforeunload',()=>{ + sessionStorage.setItem('name', store.state.userName) + }) + + await axios.get(this.$route.path).then((response)=>{ console.log(response) this.itemList = response.itemList this.branchList = response.branchList this.display = response.display this.fileContent = response.response this.haveStared = response.canStar + this.haveWatched = response.canWatch this.repoStar = response.Star + this.repoWatch = response.watch + this.repoFork = response.Fork this.PRList = response.PRList + this.visibility = response.Auth this.contributerList = response.contributorsList + this.markdownvalue = response.fileContent + this.codeFile = String("\n"+response.fileContent) }) - axios.get("/RepoBrowser/" + this.$route.params.userName + '/' + this.$route.params.repoParam + '/' + this.$route.params.branchName + '/getCommitList').then((response)=>{ + await axios.get("/RepoBrowser/" + this.$route.params.userName + '/' + this.$route.params.repoParam + '/' + this.$route.params.branchName + '/getCommitList').then((response)=>{ this.commitList = response.commitList }) + this.issueList = [] + await axios.get('/Issue/showAllIssues/'+this.$route.params.userName+'/'+this.$route.params.repoParam).then((response)=>{ + for(var i=0; i item.type === "folder") diff --git a/src/components/UserPage.vue b/src/components/UserPage.vue index 87fa683..993c560 100644 --- a/src/components/UserPage.vue +++ b/src/components/UserPage.vue @@ -1,12 +1,20 @@