Skip to content

Commit

Permalink
normal commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Peng Kaifan committed Feb 24, 2021
1 parent 02ff58b commit 7162489
Show file tree
Hide file tree
Showing 35 changed files with 2,280 additions and 590 deletions.
865 changes: 430 additions & 435 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"lint": "vue-cli-service lint"
},
"dependencies": {
"@github/details-menu-element": "^1.0.9",
"@github/file-attachment-element": "^1.0.3",
"@github/markdown-toolbar-element": "^1.1.1",
"@primer/css": "^15.2.0",
Expand All @@ -20,7 +21,7 @@
"gsap": "^3.0.1",
"jsonp": "^0.2.1",
"marked": "^0.8.0",
"node-sass": "^4.13.0",
"node-sass": "^4.14.1",
"numeral": "^2.0.6",
"parse-link-header": "^1.0.1",
"vue": "^2.6.10",
Expand Down
6 changes: 5 additions & 1 deletion src/components/Popover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
:style="popoverStyle">
<Cover class="cover" v-show="show" @click.stop="close"></Cover>

<Main class="main bg-white">
<Main class="main bg-white" @click.stop="closeByClick && close()">
<slot></slot>
</Main>
</Container>
Expand All @@ -25,6 +25,10 @@
required: false
},
smooth: Boolean,
closeByClick: {
type: Boolean,
default: false
}
},
data() {
return {
Expand Down
1 change: 1 addition & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import plugin_common from './plugin/common'
import plugin_githubBusiness from './plugin/githubBusiness'
import plugin_topNotice from './plugin/topNotice'
import VueClipboard from 'vue-clipboard2'
import '@github/details-menu-element'
Vue.use(Router)
Vue.use(VueClipboard)
Vue.use(plugin_themeColor)
Expand Down
84 changes: 59 additions & 25 deletions src/mixins/RouteUpdateAwareMixin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
<script>
import {cancelAndUpdateAxiosCancelTokenSource} from '@/network'
import ComponentActiveAwareMixin from './ComponentActiveAwareMixin'
import {util_throttle} from '@/util'
export default {
mixins: [ComponentActiveAwareMixin],
data() {
return {
cacheRouterMeta: undefined,
cancelSources: [],
resetBeforeUpdate: false,
resetBeforeUpdate: true,
watchRouterMeta: true
}
},
Expand All @@ -19,24 +20,23 @@
return this.generateRouterMeta()
}
},
beforeRouteLeave(to, from, next) {
this.cacheRouterMeta = this.routerMeta
next()
created() {
this.cacheRouterMeta = this.generateRouterMeta()
},
beforeRouteEnter (to, from, next) {
next(async vm => {
if(vm.debug) {
/* if(vm.debug) {
console.log('==============================beforeRouteEnter===============================')
console.log(vm.cacheRouterMeta)
console.log(vm.routerMeta)
console.log(vm.componentActive)
console.log(vm.cacheRouterMeta && vm.cacheRouterMeta != vm.routerMeta && vm.componentActive)
console.log("vm.cacheRouterMeta:" + vm.cacheRouterMeta)
console.log("vm.routerMeta:" + vm.routerMeta)
console.log("vm.cacheRouterMeta && vm.cacheRouterMeta != vm.routerMeta && vm.componentActive:" + vm.cacheRouterMeta && vm.cacheRouterMeta != vm.routerMeta)
console.log('==============================beforeRouteEnter===============================')
}
if(!vm.cacheRouterMeta) {
window && window.scrollTo && window.scrollTo(0,0)
}
if(vm.cacheRouterMeta && vm.cacheRouterMeta != vm.routerMeta && vm.componentActive) {
if(vm.cacheRouterMeta && vm.cacheRouterMeta != vm.routerMeta) {
if(vm.debug) console.log("get data ===== beforeRouteEnter")
window && window.scrollTo && window.scrollTo(0,0)
vm.$el.style.display = 'none'
if(!vm.resetBeforeUpdate) vm.routeResetHook(to,from)
Expand All @@ -45,24 +45,45 @@
setTimeout(() => {
vm.$el.style.display = 'block'
},500)
} */
if(vm.debug) {
console.log('==============================beforeRouteEnter===============================')
console.log("vm.cacheRouterMeta:" + vm.cacheRouterMeta)
console.log("vm.routerMeta:" + vm.routerMeta)
console.log(vm.cacheRouterMeta && vm.cacheRouterMeta != vm.routerMeta)
console.log('==============================beforeRouteEnter===============================')
}
if(vm.cacheRouterMeta && vm.cacheRouterMeta != vm.routerMeta) {
vm.$el.style.display = 'none'
}
})
},
/* beforeRouteUpdate (to, from, next) {
if(this.routerMeta != this.generateRouterMeta() && this.componentActive) {
activated() {
/* if(this.debug) {
console.log('==============================activated===============================')
console.log("this.cacheRouterMeta:" + this.cacheRouterMeta)
console.log("this.routerMeta:" + this.routerMeta)
console.log(this.cacheRouterMeta && this.cacheRouterMeta != this.routerMeta)
console.log('==============================activated===============================')
}
if(this.cacheRouterMeta && this.cacheRouterMeta != this.routerMeta) {
if(this.debug) {
console.log(this.routerMeta)
console.log(this.generateRouterMeta())
console.log("get data ===== activated")
}
window && window.scrollTo && window.scrollTo(0,0)
this.$el.style.display = 'none'
if(!this.resetBeforeUpdate) this.routeResetHook()
this.cancelUntimelyAxios()
this.routeUpdateHook(to,from)
this.routerMeta = this.generateRouterMeta()
}
next()
}, */
this.routeUpdateHook()
setTimeout(() => {
this.$el.style.display = 'block'
},500)
} */
},
methods: {
generateRouterMeta() {
if(!this.componentActive) return undefined
//if(!this.componentActive) return undefined
return JSON.stringify(this.$route.params) + JSON.stringify(this.$route.query)
},
routeUpdateHook(){
Expand All @@ -71,8 +92,9 @@
this.network_getData()
},
routeResetHook(){
// console.log('routeResetHook')
if(this.debug) console.log('routeResetHook')
Object.assign(this.$data,this.$options.data())
},
cancelUntimelyAxios() {
this.cancelSources.forEach(item => {
Expand All @@ -95,10 +117,22 @@
console.log(this.componentActive)
console.log('========================watch routerMeta========================')
}
if(newOne && oldOne && this.componentActive && this.watchRouterMeta) {
this.cancelUntimelyAxios()
this.routeUpdateHook()
}
util_throttle.throttleByDelay(() => {
if(newOne && this.componentActive && this.watchRouterMeta && this.routerMeta != this.cacheRouterMeta) {
if(this.debug) console.log("get data ===== watch-routerMeta")
//window && window.scrollTo && window.scrollTo(0,0)
//this.$el.style.display = 'none'
this.cancelUntimelyAxios()
this.routeUpdateHook()
setTimeout(() => {
this.$el.style.display = 'block'
},0)
this.cacheRouterMeta = this.routerMeta
/* setTimeout(() => {
this.$el.style.display = 'block'
},3000) */
}
},50,this)
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/pages/Explore/Collections/CollectionDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@
this.rawContent = window.atob(res.data.content)
this.network_getRepositories()
}).catch(e => {
this.handleError(e,{handle404:true})
this.handleError(e,{
})
}).finally(() =>{
this.loading = false
})
Expand Down
6 changes: 5 additions & 1 deletion src/pages/Explore/Topics/TopicDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,11 @@
authRequiredGet(url_rawContent,{cancelToken}).then(res => {
this.rawContent = window.atob(res.data.content)
}).catch(e => {
this.handleError(e,{handle404:true})
this.handleError(e,{
httpErrorHandler: {
404: () => this.$router.replace('/404')
}
})
}).finally(() => {
this.loading = false
})
Expand Down
6 changes: 5 additions & 1 deletion src/pages/Organization(deprecated)/People/People.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@
}catch(e) {
this.handleError(e,{handle404:true})
this.handleError(e,{
httpErrorHandler: {
404: () => this.$router.replace('/404')
}
})
}finally{
this.loading = false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,11 @@
this.firstLoadedFlag = true
}catch(e) {
this.handleError(e,{handle404: true})
this.handleError(e,{
httpErrorHandler: {
404: () => this.$router.replace('/404')
}
})
}finally{
this.loading = false
}
Expand Down
6 changes: 5 additions & 1 deletion src/pages/Organization/People/People.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@
if(this.accessToken) this.network_getExtraData()
}catch(e) {
this.handleError(e,{handle404:true})
this.handleError(e,{
httpErrorHandler: {
404: () => this.$router.replace('/404')
}
})
}finally{
this.loading = false
}
Expand Down
6 changes: 5 additions & 1 deletion src/pages/Organization/Repositories/Repositories.vue
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,11 @@
}
}catch(e) {
this.handleError(e,{handle404: true})
this.handleError(e,{
httpErrorHandler: {
404: () => this.$router.replace('/404')
}
})
}finally{
this.loading = false
}
Expand Down
6 changes: 5 additions & 1 deletion src/pages/Repository(deprecated)/Repository.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@
).then(res => {
this.data = res.data
}).catch(e => {
this.handleError(e,{handle404:true})
this.handleError(e,{
httpErrorHandler: {
404: () => this.$router.replace('/404')
}
})
}).finally(() => this.loading = false)
//获取open issues count
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import * as graphql from './graphql'
var parse = require('parse-link-header');
export default {
inject: ['repoBasicInfo','repoSubscription','viewerPermission','viewerBlocked'],
inject: ['repoBasicInfo','repoSubscription','viewerPermission','viewerBlocked','viewerCanManageIssue'],
mixins: [RouteUpdateAwareMixin],
provide() {
return {
Expand Down Expand Up @@ -224,7 +224,7 @@
},
viewerCanComment() {
if(this.viewerBlocked()) return false
if(this.viewerPermission() == 'ADMIN' || this.viewerPermission() == 'TRIAGE' || this.viewerPermission() == 'WRITE') return true
if(this.viewerCanManageIssue()) return true
if(!this.data.locked) return true
return false
},
Expand Down
6 changes: 5 additions & 1 deletion src/pages/Repository/Issues/IssuesBrowser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@
data: [],
loading: false
},
resetBeforeUpdate: true
}
},
computed: {
Expand Down Expand Up @@ -739,7 +740,10 @@
})
}
this.availableLabels.data = availableLabels
}
},
generateRouterMeta() {
return `${this.owner}-${this.repo}` + JSON.stringify(this.$route.query)
},
},
components: {
SelectMenuItem,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<CommonLoadingWrapper class="px-3" :loading="reviewComments.loading || reviewCommentsExtraData.loading || changedFiles.loading || pendingReview.loading || pendingReview.reviewComments.loading" :position="changedFiles.loading ? 'center' : 'corner'">
<div ref="actionRow" class="d-flex flex-justify-between pt-3 action-row" @scroll="scrollEventListener">
<div ref="actionRow" class="d-flex flex-justify-between py-3 action-row" @scroll="scrollEventListener">
<button class="btn-link muted-link select-menu-button" @click="triggerSwitcherStretch" >
<strong style="font-size:13px;" class="mr-1">Jump to...</strong>
</button>
Expand All @@ -15,7 +15,7 @@


<transition-group name="fade-group" appear>
<ChangedFileItem :id="`diff-${item.sha}`" v-for="item in changedFiles.data" :key="item.sha" :file="item"></ChangedFileItem>
<ChangedFileItem class="change-file-item" :id="`diff-${item.sha}`" v-for="item in changedFiles.data" :key="item.sha" :file="item"></ChangedFileItem>
</transition-group>

<!-- <EditorHeader class="editor-header" v-if="changedFiles.data.length > 0 && repoOwnerType() == 'User'">
Expand Down Expand Up @@ -405,7 +405,7 @@
reviewId: review.id,
})
let res = await authRequiredGet(url)
let res = await authRequiredGet(url,{headers:{"accept":"application/vnd.github.squirrel-girl-preview"}})
res.data[0] && this.reviewComments.data.push(res.data[0])
this.network_getReviewCommentsExtraData(res.data)
Expand Down Expand Up @@ -450,10 +450,6 @@
return
}
}
console.log('state_deletedReviewComments')
console.log(newOne)
console.log(oldOne)
console.log(oldOne == newOne)
this.network_getReviewComments()
},
deep: true
Expand Down Expand Up @@ -615,4 +611,8 @@
background: linear-gradient(rgba(0,0,0,.075),rgba(0,0,0,.001)) repeat-x 0 0;
border-top: 1px solid rgba(0,0,0,.15);
}
.change-file-item:first-child {
margin-top: 0;
}
</style>
Loading

0 comments on commit 7162489

Please sign in to comment.