chore: configure eslint and prettier
This commit is contained in:
parent
7553091ada
commit
322917982e
@ -1,36 +1,44 @@
|
|||||||
/* eslint-env node */
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
root: true,
|
env: {
|
||||||
env: { browser: true, es2020: true },
|
browser: true,
|
||||||
|
es2021: true,
|
||||||
|
},
|
||||||
extends: [
|
extends: [
|
||||||
"eslint:recommended",
|
"eslint:recommended",
|
||||||
"plugin:@typescript-eslint/recommended",
|
"plugin:@typescript-eslint/recommended",
|
||||||
"plugin:@typescript-eslint/recommended-requiring-type-checking",
|
"plugin:@typescript-eslint/recommended-requiring-type-checking",
|
||||||
|
"plugin:react/recommended",
|
||||||
"plugin:react-hooks/recommended",
|
"plugin:react-hooks/recommended",
|
||||||
"prettier"
|
"eslint-config-prettier",
|
||||||
],
|
],
|
||||||
|
overrides: [
|
||||||
|
{
|
||||||
|
env: { node: true },
|
||||||
|
files: [".eslintrc.{js,cjs}"],
|
||||||
|
parserOptions: { sourceType: "script" },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
settings: { react: { version: "detect" } },
|
||||||
parser: "@typescript-eslint/parser",
|
parser: "@typescript-eslint/parser",
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
ecmaVersion: "latest",
|
ecmaVersion: "latest",
|
||||||
sourceType: "module",
|
sourceType: "module",
|
||||||
project: true,
|
project: true,
|
||||||
tsconfigRootDir: __dirname
|
tsconfigRootDir: __dirname,
|
||||||
},
|
},
|
||||||
plugins: ["react-refresh"],
|
plugins: ["@typescript-eslint", "react", "react-refresh", "prettier"],
|
||||||
rules: {
|
rules: {
|
||||||
"react-refresh/only-export-components": [
|
"linebreak-style": ["error", "unix"],
|
||||||
"warn",
|
"quotes": ["error", "double"],
|
||||||
{ allowConstantExport: true }
|
"react/react-in-jsx-scope": ["off"],
|
||||||
],
|
|
||||||
"@typescript-eslint/no-non-null-assertion": "off",
|
|
||||||
"@typescript-eslint/no-unused-vars": [
|
"@typescript-eslint/no-unused-vars": [
|
||||||
"warn",
|
"warn",
|
||||||
{
|
{
|
||||||
"argsIgnorePattern": "^_",
|
"argsIgnorePattern": "^_",
|
||||||
"varsIgnorePattern": "^_",
|
"varsIgnorePattern": "^_",
|
||||||
"caughtErrorsIgnorePattern": "^_"
|
"caughtErrorsIgnorePattern": "^_",
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
}
|
"prettier/prettier": ["error"],
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
4
.prettierignore
Normal file
4
.prettierignore
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
node_modules/
|
||||||
|
dist/
|
||||||
|
.eslintrc.cjs
|
||||||
|
pnpm-lock.yaml
|
@ -1,3 +1,9 @@
|
|||||||
{
|
{
|
||||||
"tabWidth": 4
|
"bracketSpacing": true,
|
||||||
|
"endOfLine": "lf",
|
||||||
|
"printWidth": 120,
|
||||||
|
"semi": true,
|
||||||
|
"singleQuote": false,
|
||||||
|
"tabWidth": 4,
|
||||||
|
"trailingComma": "all"
|
||||||
}
|
}
|
||||||
|
12
package.json
12
package.json
@ -12,10 +12,10 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ant-design/icons": "^5.2.6",
|
"@ant-design/icons": "^5.2.6",
|
||||||
"@ant-design/pro-components": "^2.6.43",
|
"@ant-design/pro-components": "^2.6.43",
|
||||||
"@sentry/react": "^7.90.0",
|
"@sentry/react": "^7.91.0",
|
||||||
"@sentry/vite-plugin": "^2.10.2",
|
"@sentry/vite-plugin": "^2.10.2",
|
||||||
"ace-builds": "^1.32.2",
|
"ace-builds": "^1.32.2",
|
||||||
"antd": "^5.12.4",
|
"antd": "^5.12.5",
|
||||||
"axios": "^1.6.2",
|
"axios": "^1.6.2",
|
||||||
"dayjs": "^1.11.10",
|
"dayjs": "^1.11.10",
|
||||||
"github-markdown-css": "^5.5.0",
|
"github-markdown-css": "^5.5.0",
|
||||||
@ -23,7 +23,7 @@
|
|||||||
"react-ace": "^10.1.0",
|
"react-ace": "^10.1.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-markdown": "^8.0.7",
|
"react-markdown": "^8.0.7",
|
||||||
"react-router-dom": "^6.21.0",
|
"react-router-dom": "^6.21.1",
|
||||||
"react-syntax-highlighter": "^15.5.0",
|
"react-syntax-highlighter": "^15.5.0",
|
||||||
"rehype-mathjax": "^4.0.3",
|
"rehype-mathjax": "^4.0.3",
|
||||||
"rehype-raw": "^6.1.1",
|
"rehype-raw": "^6.1.1",
|
||||||
@ -36,11 +36,13 @@
|
|||||||
"@types/react": "^18.2.45",
|
"@types/react": "^18.2.45",
|
||||||
"@types/react-dom": "^18.2.18",
|
"@types/react-dom": "^18.2.18",
|
||||||
"@types/react-syntax-highlighter": "^15.5.11",
|
"@types/react-syntax-highlighter": "^15.5.11",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
"@typescript-eslint/eslint-plugin": "^6.15.0",
|
||||||
"@typescript-eslint/parser": "^5.62.0",
|
"@typescript-eslint/parser": "^6.15.0",
|
||||||
"@vitejs/plugin-react-swc": "^3.5.0",
|
"@vitejs/plugin-react-swc": "^3.5.0",
|
||||||
"eslint": "^8.56.0",
|
"eslint": "^8.56.0",
|
||||||
"eslint-config-prettier": "^8.10.0",
|
"eslint-config-prettier": "^8.10.0",
|
||||||
|
"eslint-plugin-prettier": "^5.1.1",
|
||||||
|
"eslint-plugin-react": "^7.33.2",
|
||||||
"eslint-plugin-react-hooks": "^4.6.0",
|
"eslint-plugin-react-hooks": "^4.6.0",
|
||||||
"eslint-plugin-react-refresh": "^0.4.5",
|
"eslint-plugin-react-refresh": "^0.4.5",
|
||||||
"prettier": "3.0.0",
|
"prettier": "3.0.0",
|
||||||
|
3106
pnpm-lock.yaml
3106
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
@ -1,9 +1,6 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
|
||||||
axios.defaults.baseURL =
|
axios.defaults.baseURL = import.meta.env.MODE === "production" ? "/api/v1" : "http://127.0.0.1:8000/api/v1";
|
||||||
import.meta.env.MODE === "production"
|
|
||||||
? "/api/v1"
|
|
||||||
: "http://127.0.0.1:8000/api/v1";
|
|
||||||
|
|
||||||
export interface ResponseWrap<T> {
|
export interface ResponseWrap<T> {
|
||||||
code: number;
|
code: number;
|
||||||
@ -23,11 +20,7 @@ export interface Meta {
|
|||||||
DeletedAt: Date;
|
DeletedAt: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function send<D, T>(
|
export async function send<D, T>(api: string, data?: D, token?: string): Promise<T> {
|
||||||
api: string,
|
|
||||||
data?: D,
|
|
||||||
token?: string,
|
|
||||||
): Promise<T> {
|
|
||||||
try {
|
try {
|
||||||
const resp = await axios.post<ResponseWrap<T>>(api, data, {
|
const resp = await axios.post<ResponseWrap<T>>(api, data, {
|
||||||
headers: { Authorization: token },
|
headers: { Authorization: token },
|
||||||
|
@ -50,10 +50,7 @@ export interface UploadResp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class ProblemApi {
|
export class ProblemApi {
|
||||||
static async CreateVersion(
|
static async CreateVersion(data: CreateVersionReq, token: string): Promise<void> {
|
||||||
data: CreateVersionReq,
|
|
||||||
token: string,
|
|
||||||
): Promise<void> {
|
|
||||||
return send("/problem/create_version", data, token);
|
return send("/problem/create_version", data, token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,24 +65,15 @@ export interface QueryByVersionResp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class StatusApi {
|
export class StatusApi {
|
||||||
static async Query(
|
static async Query(data: QueryReq, token: string): Promise<WithCount<SubmissionWithPoint>> {
|
||||||
data: QueryReq,
|
|
||||||
token: string,
|
|
||||||
): Promise<WithCount<SubmissionWithPoint>> {
|
|
||||||
return send("/status/query", data, token);
|
return send("/status/query", data, token);
|
||||||
}
|
}
|
||||||
|
|
||||||
static async QueryBySubmission(
|
static async QueryBySubmission(data: QueryBySubmissionReq, token: string): Promise<StatusInfo> {
|
||||||
data: QueryBySubmissionReq,
|
|
||||||
token: string,
|
|
||||||
): Promise<StatusInfo> {
|
|
||||||
return send("/status/query/submission", data, token);
|
return send("/status/query/submission", data, token);
|
||||||
}
|
}
|
||||||
|
|
||||||
static async QueryByVersion(
|
static async QueryByVersion(data: QueryByVersionReq, token: string): Promise<WithCount<StatusInfo>> {
|
||||||
data: QueryByVersionReq,
|
|
||||||
token: string,
|
|
||||||
): Promise<WithCount<StatusInfo>> {
|
|
||||||
return send("/status/query/version", data, token);
|
return send("/status/query/version", data, token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,27 +7,14 @@ import { useAuth } from "./hook.ts";
|
|||||||
interface AuthContextType {
|
interface AuthContextType {
|
||||||
token: string;
|
token: string;
|
||||||
isLoggedIn: boolean;
|
isLoggedIn: boolean;
|
||||||
login: (
|
login: (username: string, password: string, onSuccess?: VoidFunction, onFailed?: (error: string) => void) => void;
|
||||||
username: string,
|
logout: (onSuccess?: VoidFunction, onFailed?: (error: string) => void) => void;
|
||||||
password: string,
|
|
||||||
onSuccess?: VoidFunction,
|
|
||||||
onFailed?: (error: string) => void,
|
|
||||||
) => void;
|
|
||||||
logout: (
|
|
||||||
onSuccess?: VoidFunction,
|
|
||||||
onFailed?: (error: string) => void,
|
|
||||||
) => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const AuthContext = React.createContext<AuthContextType>({
|
const AuthContext = React.createContext<AuthContextType>({
|
||||||
token: "",
|
token: "",
|
||||||
isLoggedIn: false,
|
isLoggedIn: false,
|
||||||
login: (
|
login: (_username: string, _password: string, _onSuccess?: VoidFunction, onFailed?: (error: string) => void) => {
|
||||||
_username: string,
|
|
||||||
_password: string,
|
|
||||||
_onSuccess?: VoidFunction,
|
|
||||||
onFailed?: (error: string) => void,
|
|
||||||
) => {
|
|
||||||
onFailed && onFailed("not implemented");
|
onFailed && onFailed("not implemented");
|
||||||
},
|
},
|
||||||
logout: (_onSuccess?: VoidFunction, onFailed?: (error: string) => void) => {
|
logout: (_onSuccess?: VoidFunction, onFailed?: (error: string) => void) => {
|
||||||
@ -67,10 +54,7 @@ function AuthProvider({ children }: { children: React.ReactNode }) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const logout = (
|
const logout = (onSuccess?: VoidFunction, onFailed?: (error: string) => void) => {
|
||||||
onSuccess?: VoidFunction,
|
|
||||||
onFailed?: (error: string) => void,
|
|
||||||
) => {
|
|
||||||
localStorage.removeItem("token");
|
localStorage.removeItem("token");
|
||||||
setToken("");
|
setToken("");
|
||||||
setIsLoggedIn(false);
|
setIsLoggedIn(false);
|
||||||
@ -92,9 +76,7 @@ function AuthProvider({ children }: { children: React.ReactNode }) {
|
|||||||
|
|
||||||
const value = { token, isLoggedIn, login, logout };
|
const value = { token, isLoggedIn, login, logout };
|
||||||
|
|
||||||
return (
|
return <AuthContext.Provider value={value}> {children} </AuthContext.Provider>;
|
||||||
<AuthContext.Provider value={value}> {children} </AuthContext.Provider>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function RequireAuth({ children }: { children: React.ReactNode }) {
|
function RequireAuth({ children }: { children: React.ReactNode }) {
|
||||||
|
@ -18,9 +18,7 @@ interface LoginFormProps<T> {
|
|||||||
extra?: React.ReactNode;
|
extra?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function MyLoginForm<T = LoginFormValues>(
|
export default function MyLoginForm<T = LoginFormValues>(props: LoginFormProps<T>) {
|
||||||
props: LoginFormProps<T>,
|
|
||||||
) {
|
|
||||||
const [msg, msgContextHolder] = message.useMessage();
|
const [msg, msgContextHolder] = message.useMessage();
|
||||||
const [errMsg, setErrMsg] = useState("");
|
const [errMsg, setErrMsg] = useState("");
|
||||||
|
|
||||||
|
@ -20,24 +20,20 @@ export default function Markdown(props: MarkdownProps) {
|
|||||||
const rehypePlugins = [rehypeRaw, rehypeMathJaxSvg];
|
const rehypePlugins = [rehypeRaw, rehypeMathJaxSvg];
|
||||||
|
|
||||||
const renderers: Components = {
|
const renderers: Components = {
|
||||||
code: function makeCodeBlock({
|
code: function makeCodeBlock({ inline, className, children, ...props }) {
|
||||||
inline,
|
|
||||||
className,
|
|
||||||
children,
|
|
||||||
...props
|
|
||||||
}) {
|
|
||||||
const match = /language-(\w+)/.exec(className || "");
|
const match = /language-(\w+)/.exec(className || "");
|
||||||
const codeBlock = (
|
const codeBlock = (
|
||||||
<PrismAsync
|
<PrismAsync
|
||||||
{...props}
|
{...props}
|
||||||
language={(match || ["", "text"])[1]}
|
language={(match || ["", "text"])[1]}
|
||||||
PreTag="div"
|
PreTag="div"
|
||||||
children={String(children).replace(/\n$/, "")}
|
|
||||||
wrapLines={true}
|
wrapLines={true}
|
||||||
showLineNumbers={true}
|
showLineNumbers={true}
|
||||||
wrapLongLines={true}
|
wrapLongLines={true}
|
||||||
style={oneLight}
|
style={oneLight}
|
||||||
/>
|
>
|
||||||
|
{String(children).replace(/\n$/, "")}
|
||||||
|
</PrismAsync>
|
||||||
);
|
);
|
||||||
const codeInline = <code {...props}>{children}</code>;
|
const codeInline = <code {...props}>{children}</code>;
|
||||||
return !inline && match ? codeBlock : codeInline;
|
return !inline && match ? codeBlock : codeInline;
|
||||||
@ -48,11 +44,12 @@ export default function Markdown(props: MarkdownProps) {
|
|||||||
<>
|
<>
|
||||||
<ReactMarkdown
|
<ReactMarkdown
|
||||||
className={"markdown-body"}
|
className={"markdown-body"}
|
||||||
children={props.markdown}
|
|
||||||
remarkPlugins={remarkPlugins}
|
remarkPlugins={remarkPlugins}
|
||||||
rehypePlugins={rehypePlugins}
|
rehypePlugins={rehypePlugins}
|
||||||
components={renderers}
|
components={renderers}
|
||||||
/>
|
>
|
||||||
|
{props.markdown}
|
||||||
|
</ReactMarkdown>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -49,9 +49,7 @@ const columns: ProColumns<SubmissionInfo>[] = [
|
|||||||
return (
|
return (
|
||||||
<Space>
|
<Space>
|
||||||
<Button>
|
<Button>
|
||||||
<Link to={`/problem/${entity.problem_id}`}>
|
<Link to={`/problem/${entity.problem_id}`}>查看问题</Link>
|
||||||
查看问题
|
|
||||||
</Link>
|
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button>
|
<Button>
|
||||||
|
@ -16,9 +16,7 @@ export default function UserInfo(props: UserInfoProps) {
|
|||||||
void UserApi.Profile({ uid: props.uid }, props.token).then(setProfile);
|
void UserApi.Profile({ uid: props.uid }, props.token).then(setProfile);
|
||||||
}, [props.uid, props.token]);
|
}, [props.uid, props.token]);
|
||||||
|
|
||||||
const roleName = Object.entries(UserRole).filter(
|
const roleName = Object.entries(UserRole).filter(([, v]) => v === profile?.role);
|
||||||
([_, v]) => v === profile?.role,
|
|
||||||
);
|
|
||||||
|
|
||||||
const items: CollapseProps["items"] = [
|
const items: CollapseProps["items"] = [
|
||||||
{
|
{
|
||||||
@ -26,14 +24,9 @@ export default function UserInfo(props: UserInfoProps) {
|
|||||||
label: "User Info",
|
label: "User Info",
|
||||||
children: (
|
children: (
|
||||||
<Descriptions bordered column={1} size="small">
|
<Descriptions bordered column={1} size="small">
|
||||||
<Descriptions.Item label="Nickname">
|
<Descriptions.Item label="Nickname">{profile?.nick_name || "Not Found"}</Descriptions.Item>
|
||||||
{profile?.nick_name || "Not Found"}
|
|
||||||
</Descriptions.Item>
|
|
||||||
<Descriptions.Item label="Joined at">
|
<Descriptions.Item label="Joined at">
|
||||||
{(profile?.meta.CreatedAt &&
|
{(profile?.meta.CreatedAt && dayjs(profile?.meta.CreatedAt).format("YYYY-MM-DD HH:mm:ss")) ||
|
||||||
dayjs(profile?.meta.CreatedAt).format(
|
|
||||||
"YYYY-MM-DD HH:mm:ss",
|
|
||||||
)) ||
|
|
||||||
"N/A"}
|
"N/A"}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="Role">
|
<Descriptions.Item label="Role">
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
body {
|
body {
|
||||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto",
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans",
|
||||||
"Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans",
|
"Droid Sans", "Helvetica Neue", sans-serif;
|
||||||
"Helvetica Neue", sans-serif;
|
|
||||||
-webkit-font-smoothing: antialiased;
|
-webkit-font-smoothing: antialiased;
|
||||||
-moz-osx-font-smoothing: grayscale;
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
|
||||||
@ -9,6 +8,5 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
code {
|
code {
|
||||||
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
|
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", monospace;
|
||||||
monospace;
|
|
||||||
}
|
}
|
||||||
|
@ -43,8 +43,7 @@ Sentry.init({
|
|||||||
replaysOnErrorSampleRate: 1.0,
|
replaysOnErrorSampleRate: 1.0,
|
||||||
});
|
});
|
||||||
|
|
||||||
const sentryCreateBrowserRouter =
|
const sentryCreateBrowserRouter = Sentry.wrapCreateBrowserRouter(createBrowserRouter);
|
||||||
Sentry.wrapCreateBrowserRouter(createBrowserRouter);
|
|
||||||
|
|
||||||
const router = sentryCreateBrowserRouter([
|
const router = sentryCreateBrowserRouter([
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
import {
|
import { useRouteError, isRouteErrorResponse, useNavigate } from "react-router-dom";
|
||||||
useRouteError,
|
|
||||||
isRouteErrorResponse,
|
|
||||||
useNavigate,
|
|
||||||
} from "react-router-dom";
|
|
||||||
import { Button, Result, Space } from "antd";
|
import { Button, Result, Space } from "antd";
|
||||||
|
|
||||||
const ErrorPage = () => {
|
const ErrorPage = () => {
|
||||||
|
@ -14,18 +14,11 @@ export default function ProblemPage() {
|
|||||||
<Space wrap>
|
<Space wrap>
|
||||||
<Button
|
<Button
|
||||||
icon={<PlayCircleOutlined />}
|
icon={<PlayCircleOutlined />}
|
||||||
onClick={() =>
|
onClick={() => navigate(`/problem/${details.problem.meta.ID}/submit`)}
|
||||||
navigate(`/problem/${details.problem.meta.ID}/submit`)
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
Submit
|
Submit
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button icon={<SearchOutlined />} onClick={() => navigate(`/problem/${details.problem.meta.ID}/status`)}>
|
||||||
icon={<SearchOutlined />}
|
|
||||||
onClick={() =>
|
|
||||||
navigate(`/problem/${details.problem.meta.ID}/status`)
|
|
||||||
}
|
|
||||||
>
|
|
||||||
Status
|
Status
|
||||||
</Button>
|
</Button>
|
||||||
</Space>
|
</Space>
|
||||||
|
@ -15,20 +15,14 @@ type RegisterFormValues = {
|
|||||||
export default function RegisterPage() {
|
export default function RegisterPage() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const onFinish: CallbackType<RegisterFormValues> = (
|
const onFinish: CallbackType<RegisterFormValues> = (values, setErrMsg, msg) => {
|
||||||
values,
|
|
||||||
setErrMsg,
|
|
||||||
msg,
|
|
||||||
) => {
|
|
||||||
UserApi.Create({
|
UserApi.Create({
|
||||||
username: values.username,
|
username: values.username,
|
||||||
nickname: values.nickname,
|
nickname: values.nickname,
|
||||||
password: values.password,
|
password: values.password,
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
void msg
|
void msg.success("注册成功").then(() => navigate("/login", { replace: true }));
|
||||||
.success("注册成功")
|
|
||||||
.then(() => navigate("/login", { replace: true }));
|
|
||||||
})
|
})
|
||||||
.catch((err: string) => setErrMsg(err));
|
.catch((err: string) => setErrMsg(err));
|
||||||
};
|
};
|
||||||
|
@ -1,19 +1,8 @@
|
|||||||
import React, { useEffect } from "react";
|
import React, { useEffect } from "react";
|
||||||
import { Link, Outlet, useLocation, useNavigate } from "react-router-dom";
|
import { Link, Outlet, useLocation, useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
import {
|
import { DefaultFooter, PageContainer, ProLayout, ProLayoutProps } from "@ant-design/pro-components";
|
||||||
DefaultFooter,
|
import { BlockOutlined, LoginOutlined, LogoutOutlined, PlusCircleOutlined, ProfileOutlined } from "@ant-design/icons";
|
||||||
PageContainer,
|
|
||||||
ProLayout,
|
|
||||||
ProLayoutProps,
|
|
||||||
} from "@ant-design/pro-components";
|
|
||||||
import {
|
|
||||||
BlockOutlined,
|
|
||||||
LoginOutlined,
|
|
||||||
LogoutOutlined,
|
|
||||||
PlusCircleOutlined,
|
|
||||||
ProfileOutlined,
|
|
||||||
} from "@ant-design/icons";
|
|
||||||
import { Dropdown, message, Skeleton } from "antd";
|
import { Dropdown, message, Skeleton } from "antd";
|
||||||
|
|
||||||
import { NavConfigs } from "../routes.tsx";
|
import { NavConfigs } from "../routes.tsx";
|
||||||
@ -36,9 +25,7 @@ const LayoutProps: ProLayoutProps = {
|
|||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
menuItemRender: (item, dom) => <Link to={item.path || "/"}>{dom}</Link>,
|
menuItemRender: (item, dom) => <Link to={item.path || "/"}>{dom}</Link>,
|
||||||
footerRender: () => (
|
footerRender: () => <DefaultFooter copyright="2023 WOJ Created by WHUPRJ" />,
|
||||||
<DefaultFooter copyright="2023 WOJ Created by WHUPRJ" />
|
|
||||||
),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const AvatarUserItems = [
|
const AvatarUserItems = [
|
||||||
@ -115,9 +102,7 @@ export default function Root() {
|
|||||||
return (
|
return (
|
||||||
<Dropdown
|
<Dropdown
|
||||||
menu={{
|
menu={{
|
||||||
items: auth.isLoggedIn
|
items: auth.isLoggedIn ? AvatarUserItems : AvatarGuestItems,
|
||||||
? AvatarUserItems
|
|
||||||
: AvatarGuestItems,
|
|
||||||
onClick: (key) => avatarActions[key.key](),
|
onClick: (key) => avatarActions[key.key](),
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@ -128,11 +113,7 @@ export default function Root() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ProLayout
|
<ProLayout {...LayoutProps} location={{ pathname: curTab }} avatarProps={avatarProps}>
|
||||||
{...LayoutProps}
|
|
||||||
location={{ pathname: curTab }}
|
|
||||||
avatarProps={avatarProps}
|
|
||||||
>
|
|
||||||
{msgContextHolder}
|
{msgContextHolder}
|
||||||
<PageContainer>
|
<PageContainer>
|
||||||
<React.Suspense fallback={<Skeleton />}>
|
<React.Suspense fallback={<Skeleton />}>
|
||||||
|
@ -27,9 +27,7 @@ export default function SubmitPage() {
|
|||||||
const auth = useAuth();
|
const auth = useAuth();
|
||||||
const [msg, msgContextHolder] = message.useMessage();
|
const [msg, msgContextHolder] = message.useMessage();
|
||||||
|
|
||||||
const langOptions = AvailLang.filter((l) =>
|
const langOptions = AvailLang.filter((l) => details.context.Languages.some((x) => x.Lang === l.value));
|
||||||
details.context.Languages.some((x) => x.Lang === l.value),
|
|
||||||
);
|
|
||||||
|
|
||||||
const [lang, setLang] = useState(langOptions[0].value);
|
const [lang, setLang] = useState(langOptions[0].value);
|
||||||
const [code, setCode] = useState("");
|
const [code, setCode] = useState("");
|
||||||
|
Reference in New Issue
Block a user