-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Allen Zhang (张涛)
committed
Jan 16, 2024
1 parent
58f1004
commit bb806a7
Showing
12 changed files
with
258 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Field, ID, ObjectType } from '@nestjs/graphql'; | ||
|
||
// total、pageSize、current | ||
@ObjectType() | ||
export class PageInfoModel { | ||
} |
11 changes: 11 additions & 0 deletions
11
packages/canyon-backend/src/project/project-pages.model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import {Field, ID, ObjectType, Resolver} from '@nestjs/graphql'; | ||
import { Project } from './project.model'; | ||
|
||
@ObjectType() | ||
export class ProjectPagesModel { | ||
@Field(() => [Project]) | ||
data: Project[]; | ||
|
||
@Field(() => Number) | ||
total: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,27 @@ | ||
import { Args, Mutation, Query, Resolver } from '@nestjs/graphql'; | ||
import { Args, Int, Mutation, Query, Resolver } from '@nestjs/graphql'; | ||
import { GqlAuthGuard } from '../guards/gql-auth.guard'; | ||
import { UseGuards } from '@nestjs/common'; | ||
import { GqlUser } from '../decorators/gql-user.decorator'; | ||
import { AuthUser } from '../types/AuthUser'; | ||
import { Project } from './project.model'; | ||
import { ProjectPagesModel } from './project-pages.model'; | ||
import { ProjectService } from './project.service'; | ||
@Resolver(() => 'Project') | ||
export class ProjectResolver { | ||
constructor(private readonly projectService: ProjectService) {} | ||
@Query(() => [Project], { | ||
@Query(() => ProjectPagesModel, { | ||
description: '获取Project', | ||
}) | ||
@UseGuards(GqlAuthGuard) | ||
getProjects( | ||
@GqlUser() user: AuthUser, | ||
// @Args('projectID', { type: () => String }) projectID: string, | ||
): Promise<Project[]> { | ||
return this.projectService.getProjects(); | ||
@Args('current', { type: () => Int }) current: number, | ||
@Args('pageSize', { type: () => Int }) pageSize: number, | ||
@Args('keyword', { type: () => String }) keyword: string, | ||
): Promise<ProjectPagesModel> { | ||
console.log(current, pageSize); | ||
return this.projectService.getProjects(current, pageSize, keyword); | ||
// console.log(da); | ||
// return da | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,67 @@ | ||
import {FC, ReactNode, useEffect, useState} from "react"; | ||
import {theme} from "antd"; | ||
import { theme } from 'antd'; | ||
import { FC, ReactNode, useEffect, useState } from 'react'; | ||
const { useToken } = theme; | ||
|
||
const ScrollBasedLayout: FC<{ | ||
sideBar: ReactNode, | ||
mainContent: ReactNode, | ||
footer: ReactNode, | ||
}> = ({ | ||
sideBar, | ||
mainContent, | ||
footer, | ||
}) => { | ||
const {token} = useToken(); | ||
const [isScrolled, setIsScrolled] = useState(false); | ||
sideBar: ReactNode; | ||
mainContent: ReactNode; | ||
footer: ReactNode; | ||
}> = ({ sideBar, mainContent, footer }) => { | ||
const { token } = useToken(); | ||
const [isScrolled, setIsScrolled] = useState(false); | ||
|
||
useEffect(() => { | ||
const handleScroll = () => { | ||
const scrollY = window.scrollY || document.documentElement.scrollTop; | ||
const footer = document.getElementById('footer'); | ||
useEffect(() => { | ||
const handleScroll = () => { | ||
const scrollY = window.scrollY || document.documentElement.scrollTop; | ||
const footer = document.getElementById('footer'); | ||
|
||
console.log(scrollY, 'scrollY', window.innerHeight) | ||
// 检查滚动是否超过100vh | ||
setIsScrolled(scrollY + window.innerHeight > footer.offsetTop); | ||
}; | ||
// console.log(scrollY, 'scrollY', window.innerHeight) | ||
// 检查滚动是否超过100vh | ||
setIsScrolled(scrollY + window.innerHeight > footer.offsetTop); | ||
}; | ||
|
||
// 添加滚动事件监听器 | ||
window.addEventListener('scroll', handleScroll); | ||
// 添加滚动事件监听器 | ||
window.addEventListener('scroll', handleScroll); | ||
|
||
// 在组件卸载时移除监听器,以防止内存泄漏 | ||
return () => { | ||
window.removeEventListener('scroll', handleScroll); | ||
}; | ||
}, []); // 仅在组件挂载和卸载时运行 | ||
// 在组件卸载时移除监听器,以防止内存泄漏 | ||
return () => { | ||
window.removeEventListener('scroll', handleScroll); | ||
}; | ||
}, []); // 仅在组件挂载和卸载时运行 | ||
|
||
return <div> | ||
<div style={{display: 'flex',borderBottom:`1px solid ${token.colorBorder}`}}> | ||
<div style={{ | ||
width: '260px', background: '', position: `${isScrolled ? 'unset' : 'fixed'}`, | ||
display: `${!isScrolled ? 'unset' : 'flex'}`, | ||
flexDirection: 'column', | ||
}}> | ||
return ( | ||
<div> | ||
<div style={{ display: 'flex', borderBottom: `1px solid ${token.colorBorder}` }}> | ||
<div | ||
style={{ | ||
width: '260px', | ||
background: '', | ||
position: `${isScrolled ? 'unset' : 'fixed'}`, | ||
display: `${!isScrolled ? 'unset' : 'flex'}`, | ||
flexDirection: 'column', | ||
}} | ||
> | ||
<div style={{ flex: '1' }}></div> | ||
|
||
<div style={{flex: '1'}}> | ||
|
||
</div> | ||
|
||
<div style={{height: '100vh', background: ''}}> | ||
{sideBar} | ||
</div> | ||
</div> | ||
|
||
<div style={{ | ||
flex: '1', background: 'skyblue', marginLeft: `${ | ||
!isScrolled ? '260px' : '0' | ||
}`, | ||
minHeight:'100vh', | ||
}}> | ||
{mainContent} | ||
</div> | ||
<div style={{ height: '100vh', background: '' }}>{sideBar}</div> | ||
</div> | ||
<div id={'footer'} style={{height: '200px'}}> | ||
{footer} | ||
|
||
<div | ||
style={{ | ||
flex: '1', | ||
background: 'skyblue', | ||
marginLeft: `${!isScrolled ? '260px' : '0'}`, | ||
minHeight: '100vh', | ||
}} | ||
> | ||
{mainContent} | ||
</div> | ||
</div> | ||
<div id={'footer'} style={{ height: '200px' }}> | ||
{footer} | ||
</div> | ||
</div> | ||
} | ||
); | ||
}; | ||
|
||
export default ScrollBasedLayout | ||
export default ScrollBasedLayout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
"footer": [ | ||
{ | ||
"title": "Product", | ||
"children": [ | ||
{ | ||
"label": "Arex on GitHub", | ||
"link": "https://github.com/arextest" | ||
}, | ||
{ | ||
"label": "Star Us on GitHub", | ||
"link": "https://github.com/arextest/arex" | ||
} | ||
] | ||
}, | ||
{ | ||
"title": "Resources", | ||
"children": [ | ||
{ | ||
"label": "Docs", | ||
"link": "https://docs.arextest.com" | ||
}, | ||
{ | ||
"label": "Changelog", | ||
"link": "https://github.com/arextest/arex-agent-java" | ||
} | ||
] | ||
}, | ||
{ | ||
"title": "Company", | ||
"children": [ | ||
{ | ||
"label": "Home", | ||
"link": "https://arextest.com" | ||
}, | ||
{ | ||
"label": "Pricing", | ||
"link": "https://arextest.com/pricing" | ||
} | ||
] | ||
}, | ||
{ | ||
"title": "Legal", | ||
"children": [ | ||
{ | ||
"label": "Terms of service", | ||
"link": "https://expo.dev/terms" | ||
}, | ||
{ | ||
"label": "Guidelines", | ||
"link": "https://expo.dev/terms" | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 11 additions & 8 deletions
19
packages/canyon-platform/src/helpers/backend/gql/queries/GetProjects.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
query GetProjects { | ||
getProjects { | ||
id | ||
name | ||
pathWithNamespace | ||
description | ||
reportTimes | ||
lastReportTime | ||
query GetProjects($current: Int!, $pageSize: Int!, $keyword: String!) { | ||
getProjects(current:$current, pageSize:$pageSize, keyword:$keyword) { | ||
total | ||
data { | ||
id | ||
name | ||
pathWithNamespace | ||
description | ||
reportTimes | ||
lastReportTime | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.