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 19, 2021
1 parent 838b55f commit da18b3f
Show file tree
Hide file tree
Showing 46 changed files with 2,260 additions and 3,721 deletions.
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<WithNotFoundNoticeWrapper ref="notFoundWrapper" v-on:not-found.native="go404" id="app-container" class="d-flex flex-column flex-grow-1">
<WithNotFoundNoticeWrapper ref="notFoundWrapper" v-on:not-found.native="go404" id="app-container" class="d-flex flex-column flex-grow-1" data-theme="light">
<router-view class="router-view header" name="header"/>
<keep-alive>
<router-view class="router-view flex-grow-1"/>
Expand Down
10 changes: 10 additions & 0 deletions src/i18n/messages/ch.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
export default {
common: {
error: {
actionResultValidationFailed: "验证失败:你现在无法执行这个操作"
},
},
pullRequestDetailFileChangesPage: {
pendingReviewExistNotice: '在此之前,你必须先提交被挂起的审查(Pending review)'
},
pullRequestDetailConversation: {
error: {
reopenFailed: "重新打开合并请求(Pull request)失败。"
}
}
}
10 changes: 10 additions & 0 deletions src/i18n/messages/en.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
export default {
common: {
error: {
actionResultValidationFailed: "Validation failed: You can't perform that action at this time."
},
},
pullRequestDetailFileChangesPage: {
pendingReviewExistNotice: "You can't submit a reply before submit the pending review"
},
pullRequestDetailConversation: {
error: {
reopenFailed: "Pull request reopen failed."
}
}
}
7 changes: 6 additions & 1 deletion src/network/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const CLIENT_ID = "125cb651f63615c6d362"
const SCOPE = "user public_repo repo repo_deployment repo:status read:repo_hook read:org read:public_key read:gpg_key repo:invite admin:repo_hook home admin:org admin:public_key admin:org_hook gist notifications delete_repo write:discussion read:discussion write:packages read:packages delete:packages admin:gpg_key workflow"
const GITHUB_REST_API_BASE = "https://api.github.com"
const BACK_END_API_BASE = "http://127.0.0.1:8088"
const PROXY_API_BASE = "http://127.0.0.1:8888"
export const PROXY_API_BASE = "http://127.0.0.1:8888"
const FILE_UPLOAD_PROXY_API_BASE = "http://127.0.0.1:8889"

export const API_GRAPHQL_ENDPOINT = "https://api.github.com/graphql"
Expand Down Expand Up @@ -450,3 +450,8 @@ export const API_PROXY_TAGS = payload => `${PROXY_API_BASE}/${payload.owner}/${p

export const API_ISSUE_ASSIGNEES_ACTION = payload => `${GITHUB_REST_API_BASE}/repos/${payload.owner}/${payload.repo}/issues/${payload.number}/assignees`

export const API_COMMIT_COMMENTS = payload => {
let query = util_queryParse.querify(payload.params)
return `${GITHUB_REST_API_BASE}/repos/${payload.owner}/${payload.repo}/commits/${payload.sha}/comments?${query}`
}

470 changes: 0 additions & 470 deletions src/pages/Repository/Commit/Commit(deprecated).vue

This file was deleted.

103 changes: 38 additions & 65 deletions src/pages/Repository/Commit/Commit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<SkeletonRectangle :height="16" class="mt-3" style="width:55%"></SkeletonRectangle>
<SkeletonRectangle :height="14" class="mt-3 mb-2" style="width:40%"></SkeletonRectangle>
</Skeleton>
<div v-else>
<router-link v-if="browseFilesRouterLink" :to="browseFilesRouterLink" class="float-right btn-outline btn" >
<div v-else style="min-height:40px">
<router-link v-if="browseFilesRouterLink" :to="browseFilesRouterLink" class="float-right btn-outline btn bg-white" >
Browse files
</router-link>

Expand All @@ -22,10 +22,12 @@
{{messageBody}}
</p>

<div v-if="messageBody && (associatedRefs.branch.name || associatedRefs.tags.length > 0)" class="divider width-full my-2 border-top"></div>

<Branches class="branches">
<!-- associated pulls -->
<svg v-if="associatedRefs.branch.name" class="octicon octicon-git-branch" viewBox="0 0 10 16" version="1.1" width="10" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M10 5c0-1.11-.89-2-2-2a1.993 1.993 0 00-1 3.72v.3c-.02.52-.23.98-.63 1.38-.4.4-.86.61-1.38.63-.83.02-1.48.16-2 .45V4.72a1.993 1.993 0 00-1-3.72C.88 1 0 1.89 0 3a2 2 0 001 1.72v6.56c-.59.35-1 .99-1 1.72 0 1.11.89 2 2 2 1.11 0 2-.89 2-2 0-.53-.2-1-.53-1.36.09-.06.48-.41.59-.47.25-.11.56-.17.94-.17 1.05-.05 1.95-.45 2.75-1.25S8.95 7.77 9 6.73h-.02C9.59 6.37 10 5.73 10 5zM2 1.8c.66 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2C1.35 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2zm0 12.41c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm6-8c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"></path></svg>
<span v-if="associatedRefs.branch.name" class="associated-pulls">
<svg v-if="associatedRefs.branch.name" class="octicon octicon-git-branch v-align-middle" viewBox="0 0 10 16" version="1.1" width="10" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M10 5c0-1.11-.89-2-2-2a1.993 1.993 0 00-1 3.72v.3c-.02.52-.23.98-.63 1.38-.4.4-.86.61-1.38.63-.83.02-1.48.16-2 .45V4.72a1.993 1.993 0 00-1-3.72C.88 1 0 1.89 0 3a2 2 0 001 1.72v6.56c-.59.35-1 .99-1 1.72 0 1.11.89 2 2 2 1.11 0 2-.89 2-2 0-.53-.2-1-.53-1.36.09-.06.48-.41.59-.47.25-.11.56-.17.94-.17 1.05-.05 1.95-.45 2.75-1.25S8.95 7.77 9 6.73h-.02C9.59 6.37 10 5.73 10 5zM2 1.8c.66 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2C1.35 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2zm0 12.41c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm6-8c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"></path></svg>
<span v-if="associatedRefs.branch.name" class="associated-pulls v-align-middle">
<span class="text-bold">{{associatedRefs.branch.name}}</span>
<span v-if="associatedRefs.pullRequest.number">
(<router-link :to="`/${owner}/${repo}/pulls/${associatedRefs.pullRequest.number}`" class="text-gray">#{{associatedRefs.pullRequest.number}}</router-link>)
Expand Down Expand Up @@ -109,7 +111,9 @@

<div>
<transition-group appear name="fade">
<Diff v-for="item in data.files || []" :key="item.raw_url" :file="item" :viewStyle="viewStyle"></Diff>
<Diff v-for="item in data.files || []" :key="item.raw_url" :file="item" :viewStyle="viewStyle" v-slot="slotProps">

</Diff>
</transition-group>
</div>

Expand All @@ -124,7 +128,7 @@
</div>
</AnimatedHeightWrapper>

<CommentWrapper v-for="item in comments.data" :key="item.id" class="comment-wrapper py-3 position-relative">
<!-- <CommentWrapper v-for="item in comments.data" :key="item.id" class="comment-wrapper py-3 position-relative">
<Comment :data="item">
</Comment>
Expand All @@ -140,7 +144,7 @@
<Comment :data="item">
</Comment>
</CommentWrapper>
</CommentWrapper> -->

<Editor v-if="accessToken && firstLoadFlag"
ref="editor"
Expand Down Expand Up @@ -172,10 +176,11 @@
import {CommonLoading,AnimatedHeightWrapper,LoadingIconEx,HiddenItemLoading,Editor,Subscription,ImgWrapper,CommonLoadingWrapper,SkeletonCircle,SkeletonRectangle} from '@/components'
import Comment from './Comment'
import {Diff,CommitStatusIcon} from '../components'
import { cancelAndUpdateAxiosCancelTokenSource,authRequiredGet,authRequiredGitHubGraphqlApiQuery,commonGet } from '@/network'
import { authRequiredGet,authRequiredGitHubGraphqlApiQuery,commonGet } from '@/network'
import * as api from '@/network/api'
import * as graphql from './graphql'
import {util_dateFormat} from '@/util'
const parse = require('parse-link-header')
export default {
name: 'commit_page',
mixins: [RouteUpdateAwareMixin],
Expand Down Expand Up @@ -207,16 +212,8 @@
comments: {
data: [],
loading: false,
latestData: {
data: [],
loading: false
},
perPage: 1,
reactionStatistic: {},
pageInfo: {},
totalCount: 0
},
firstLoadFlag: false
firstLoadFlag: false,
}
},
computed: {
Expand Down Expand Up @@ -284,6 +281,9 @@
if(!this.data.author.login) return
if(!this.data.committer.login) return
return this.data.author.login == this.data.committer.login
},
documentTitle() {
return this.messageHeadline
}
},
created() {
Expand Down Expand Up @@ -373,52 +373,27 @@
this.comments.loading = true
let cancelToken = this.cancelAndUpdateAxiosCancelTokenSource(this.name + ' get_comments')
let graphql_comments = graphql.GRAPHQL_COMMIT_COMMENTS(
{
nodeId: this.data.node_id,
after: this.comments.pageInfo.endCursor,
perPage: this.comments.perPage
}
)
let pageInfo
let res = await authRequiredGitHubGraphqlApiQuery(graphql_comments,{cancelToken})
let comments = []
//尝试获取末端数据
if(this.comments.data.length == 0) {
let commentsCountHolder
try{
commentsCountHolder = res.data.data.node.comments.totalCount
}catch(e) {
this.handleGraphqlError(res)
}
if(commentsCountHolder > this.comments.perPage) {
let itemCountRemained = commentsCountHolder - this.comments.perPage
let lastPageScale = itemCountRemained > this.comments.perPage ? this.comments.perPage : itemCountRemained
let graphql_commentsLatest = graphql.GRAPHQL_COMMIT_COMMENTS(
{
nodeId: this.data.node_id,
perPage: lastPageScale,
forward: false
}
)
let res_commentsLatest = await authRequiredGitHubGraphqlApiQuery(graphql_commentsLatest,{cancelToken:sourceAndCancelToken.cancelToken})
try{
this.comments.latestData.data = res_commentsLatest.data.data.node.comments.nodes
}catch(e) {
this.handleGraphqlError(res_commentsLatest)
}
}
while((!pageInfo || pageInfo.next) && comments.length <= 300) {
let url
if(pageInfo && pageInfo.next) url = pageInfo.next.url
if(!url) url = api.API_COMMIT_COMMENTS({
params: {
per_page: 100
},
repo: this.repo,
owner: this.owner,
sha: this.sha
})
let res = await authRequiredGet(url,{cancelToken})
pageInfo = parse(res.headers.link) || {}
comments = comments.concat(res.data)
}
try{
this.comments.data = this.comments.data.concat(res.data.data.node.comments.nodes)
this.comments.pageInfo = res.data.data.node.comments.pageInfo
this.comments.totalCount = res.data.data.node.comments.totalCount
}catch(e) {
this.handleGraphqlError(res)
}
this.comments.data = comments
}catch(e) {
console.log(e)
Expand Down Expand Up @@ -496,9 +471,9 @@
padding: 8px 8px 0;
margin: 10px 0;
font-size: 14px;
background: #eaf5ff;
background: rgb(241, 248, 255);
border: 1px solid rgba(27,31,35,.15);
border-radius: 3px;
border-radius: 6px;
a{
background-color: initial;
border-color: rgba(27,31,35,.15);
Expand All @@ -510,15 +485,13 @@
color: #05264c;
}
.desc{
padding-bottom: 10px;
max-width: 100%;
overflow: visible;
font-size: 13px;
word-wrap: break-word;
line-height: 1.45;
color: #444d56;
font-family: SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;
border-bottom: 1px solid rgba(27,31,35,.15);
}
.branches{
margin-bottom: 8px;
Expand All @@ -537,8 +510,8 @@
margin-left: -8px;
background: #fff;
border-top: 1px solid rgba(27,31,35,.15);
border-bottom-right-radius: 3px;
border-bottom-left-radius: 3px;
border-bottom-right-radius: 6px;
border-bottom-left-radius: 6px;
.user-mention {
font-weight: 600;
color: #24292e;
Expand Down
Loading

0 comments on commit da18b3f

Please sign in to comment.