diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index beac2bb..8453200 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,12 +3,9 @@ name: GitHub Classroom Workflow on: - schedule: - - cron: '0 */1 * * *' push: branches: - main - workflow_dispatch: jobs: build: name: Autograding @@ -26,22 +23,14 @@ jobs: - name: add pnpm run: | npm i pnpm -g - npm i yarn -g - - name: install spider pkg and run - run: | - cd spider && yarn - yarn start + - name: build beta pages run: | cd web-beta && pnpm install --no-frozen-lockfile pnpm run build pnpm run export mv out ../build - - name: build pages - run: | - cd web && pnpm install --no-frozen-lockfile - pnpm run build - cp dist ../build/older_version -r + - name: GitHub Pages uses: crazy-max/ghaction-github-pages@v3.0.0 with: diff --git a/web-beta/common/constants.ts b/web-beta/common/constants.ts index 9696c24..05ade11 100644 --- a/web-beta/common/constants.ts +++ b/web-beta/common/constants.ts @@ -2,7 +2,7 @@ export const Links: { [key: string]: MenuLink } = { link1: { key: '/link1', url: "https://learningos.github.io/classroom-grading", label: 'rCore内核排行榜', year: '2022春夏季' }, //2022 夏季os - link2: { key: '/link2', url: "https:/os2edu.cn/ranking/rank", label: 'OS训练营排行榜', year: '2022秋冬季' }, //2022 秋冬季os + link2: { key: '/link2', url: "https://os2edu.cn/ranking/rank", label: 'OS训练营排行榜', year: '2022秋冬季' }, //2022 秋冬季os link3: { key: '/link3', url: "https://learningos.github.io/rust-rustlings-ranking", label: 'Rust编程排行榜', year: '2023春夏季' },//2023春夏季 rust link4: { key: '/link4', url: "https://learningos.github.io/2023S-OS-uCore-Classroom-Rank-list/", label: 'uCore内核排行榜', year: '2023春夏季' },//2023春夏季 基于C语言的uCore Tutorial ClassRoom排行榜 link5: { key: '/link5', url: "https://learningos.github.io/2023S-OS-rCore-Classroom-Rank-list/", label: 'rCore内核排行榜', year: '2023春夏季' },//2023春夏季 基于Rust语言的rCore Tutorial ClassRoom排行榜 diff --git a/web-beta/components/Iframe/index.module.scss b/web-beta/components/Iframe/index.module.scss index 60d228f..bcc6373 100644 --- a/web-beta/components/Iframe/index.module.scss +++ b/web-beta/components/Iframe/index.module.scss @@ -2,4 +2,11 @@ width: 100%; height:120vh; border: none; +} +.empty{ + width: 100%; + height:80vh; + display: flex; + align-items: center; + justify-content: center; } \ No newline at end of file diff --git a/web-beta/components/Iframe/index.tsx b/web-beta/components/Iframe/index.tsx index 6bc1c6a..94a22dd 100644 --- a/web-beta/components/Iframe/index.tsx +++ b/web-beta/components/Iframe/index.tsx @@ -8,7 +8,7 @@ type Iprops = { const Iframe = (props: Iprops) => { return <> - {props.src === '/' ? : { + {props.src === '/' ? : { console.log('onload'); props.setLoading(false) }} >} diff --git a/web-beta/components/layout.tsx b/web-beta/components/layout.tsx index 9c69575..29c5a54 100644 --- a/web-beta/components/layout.tsx +++ b/web-beta/components/layout.tsx @@ -64,6 +64,7 @@ export default function DefaultLayout({ children }: { children: React.ReactNode setCurrLink(key.split('/')[1] as LinksKey) } else { setCurrLink('/') + } router.push(key) } @@ -80,7 +81,7 @@ export default function DefaultLayout({ children }: { children: React.ReactNode + // customRender: } }} style={{ diff --git a/web-beta/next.config.js b/web-beta/next.config.js index 54a870d..d57a766 100644 --- a/web-beta/next.config.js +++ b/web-beta/next.config.js @@ -3,7 +3,7 @@ const nextConfig = { reactStrictMode: true, swcMinify: true, - basePath: '/ranking' + basePath: '/standings' } module.exports = nextConfig diff --git a/web-beta/pages/[link].tsx b/web-beta/pages/[link].tsx index 40de931..aa0cc96 100644 --- a/web-beta/pages/[link].tsx +++ b/web-beta/pages/[link].tsx @@ -2,20 +2,17 @@ import { useEffect, useState } from "react"; import { Links, LinksKey } from "../common/constants"; import Iframe from "../components/Iframe"; import { Spin } from "antd"; -import RankPage from "./rank"; export default function RankIframe() { const [loading, setLoading] = useState(true) const key = location.pathname.split('/')[2] as LinksKey useEffect(() => { setLoading(true) + Links[key].url === '/' && setTimeout(() => setLoading(false), 1000) }, [location.pathname]) return - {key === 'link2' ? - : - - } + diff --git a/web-beta/pages/list.tsx b/web-beta/pages/list.tsx deleted file mode 100644 index 4c09610..0000000 --- a/web-beta/pages/list.tsx +++ /dev/null @@ -1,68 +0,0 @@ -import { Table } from 'antd' -import { ColumnsType } from 'antd/lib/table'; -import Head from 'next/head' -import { useEffect, useState } from 'react'; -import { getQuestionPassRate, getQuestions } from '../requests'; -import styles from '../styles/List.module.css' - -interface DataType { - name: string, - index: number, - rate: number -} - -const columns: ColumnsType = [ - { - title: '题号', - dataIndex: 'index', - align: 'center', - width: 80, - sorter: (a, b) => a > b ? 1 : -1, - key: 'index', - }, - { - title: '题目', - dataIndex: 'name', - key: 'name', - }, - { - title: '通过率', - key: 'rate', - align: 'center', - dataIndex: 'rate', - sorter: (a, b) => a.rate > b.rate ? 1 : -1, - render: (rate) => { - return {rate}% - } - } -]; - -export default function Home() { - const [list, setList] = useState([]); - - useEffect(() => { - getQuestions() - .then(async res => { - let arr: any[] = []; - for(let i in res) { - arr[parseInt(i)] = { - index: parseInt(i) + 1, - name: res[i], - rate: await getQuestionPassRate(res[i]) - }; - } - setList(arr); - }); - }, []); - - return ( - <> - - 题目列表 - - - > - ) -} \ No newline at end of file diff --git a/web-beta/pages/rank.tsx b/web-beta/pages/rank.tsx deleted file mode 100644 index f8b0262..0000000 --- a/web-beta/pages/rank.tsx +++ /dev/null @@ -1,81 +0,0 @@ -import { Avatar, List, Skeleton } from 'antd'; -import React, { useEffect, useState } from 'react'; -import { getQuestionsLen, getRankingList, getUpdateTime } from '../requests'; -import styles from '../styles/List.module.css' -import { orderBy } from 'lodash'; -import dayjs from 'dayjs'; - - -interface DataType { - rank?: number, - avatar: string, - details: any, - grades: any, - name: string, - repo_url: string -} - -export default function RankPage() { - const [initLoading, setInitLoading] = useState(true); - const [list, setList] = useState([]); - const [questionsNumber, setQuestionsNumber] = useState(1); - - useEffect(() => { - getRankingList() - .then(res => { - let students: DataType[] = orderBy(res, function(o) { - return o.grades.default; - }, 'desc'); - for(let i = 0; i < students.length; i++) { - students[i].rank = i + 1; - } - return students; - }) - .then(res => { - console.log(res); - setInitLoading(false); - setList(res as DataType[]); - }); - getQuestionsLen().then((value) => setQuestionsNumber(value)); - }, []); - - - - return ( - 榜单更新时间: {dayjs(getUpdateTime()).format('YYYY-MM-DD HH:mm:ss')} - } - className={styles.container} - loading={initLoading} - itemLayout="horizontal" - dataSource={list} - pagination={{ - position: 'bottom' - }} - renderItem={item => { - let description = ""; - if(item.details.default) { - description = `${Object.values(item.details.default).filter((value: any) => value == true).length}`; - } else { - description = "0"; - } - return ( - - {item.rank} - - } - title={{item.name}} - description={`Pass ${description} questions`} - /> - 完成度: {(parseInt(description) / questionsNumber * 100).toFixed(2)}% - - - ); - }} - /> - ); -}; \ No newline at end of file diff --git a/web-beta/requests/index.ts b/web-beta/requests/index.ts deleted file mode 100644 index 07cf0f7..0000000 --- a/web-beta/requests/index.ts +++ /dev/null @@ -1,27 +0,0 @@ -import jsonData from '../data.json'; - -export async function getRankingList() { - return jsonData.students; -} - -export async function getQuestionsLen() { - return jsonData.questions.length; -} - -export async function getQuestions() { - return jsonData.questions; -} - -export function getUpdateTime() { - return jsonData.latestUpdatedAt; -} - -export async function getQuestionPassRate(questionName: string) { - let studentNum = jsonData.students.length; - if(studentNum == 0) return 0; - let passNum = jsonData.students.filter((student) => { - if(!student.details.default) return false; - return student.details.default[questionName as keyof typeof student.details.default]; - }).length; - return (passNum / studentNum * 100).toFixed(2); -} \ No newline at end of file