diff --git a/src/App.tsx b/src/App.tsx
index 291c456..fd28198 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -1,6 +1,6 @@
-import React, { Component } from 'react';
+import React, { Component, useEffect } from 'react';
import './App.less';
-import { Outlet } from "react-router-dom"
+import { useLocation, useNavigate, Outlet } from 'react-router-dom';
import PubSub from 'pubsub-js';
import { Input } from 'antd';
import Logo from '@views/imgs/logo.jpg'
@@ -70,13 +70,21 @@ class NavTop extends Component {
);
}
}
-export default class App extends Component {
- render() {
- return (
-
-
-
-
- );
- }
+
+const App = () => {
+ const location = useLocation();
+ const navigate = useNavigate()
+ useEffect(() => {
+ if (location.pathname === '/') {
+ navigate('/question-bank')
+ }
+ }, [location])
+ return (
+
+
+
+
+ )
}
+
+export default App
diff --git a/src/main.tsx b/src/main.tsx
index d43380b..ce4ab26 100644
--- a/src/main.tsx
+++ b/src/main.tsx
@@ -2,31 +2,11 @@ import './main.less'
import React from 'react'
import ReactDOM from 'react-dom/client'
-import App from './App'
-import QuestionBank from '@views/question-bank';
-import UploadQuestions from '@views/upload-questions';
-import BrushQuestions from '@views/brush-questions'
+import router from '@/router'
import {
- createBrowserRouter,
RouterProvider,
} from "react-router-dom";
-const router = createBrowserRouter([
- {
- path: "/",
- element: ,
- children: [
- {
- path: "question-bank",
- element: ,
- },
- {
- path: "brush-question",
- element: ,
- },
- ],
- },
-]);
ReactDOM.createRoot(document.getElementById('root')!).render(
diff --git a/src/router/index.ts b/src/router/index.ts
deleted file mode 100644
index 2b9cc5c..0000000
--- a/src/router/index.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-
-import QuestionBank from '@views/question-bank';
-import UploadQuestions from '@views/upload-questions';
-import BrushQuestions from '@views/brush-questions'
-
-export default [
- // {
- // path: '/question-bank',
- // exact: true,
- // component: QuestionBank,
- // },
- // {
- // path: '/upload-questions',
- // exact: true,
- // component: UploadQuestions,
- // },
- // {
- // path: '/brush-questions',
- // exact: true,
- // component: BrushQuestions,
- // },
-];
diff --git a/src/router/index.tsx b/src/router/index.tsx
new file mode 100644
index 0000000..5753743
--- /dev/null
+++ b/src/router/index.tsx
@@ -0,0 +1,31 @@
+
+import App from '@/App'
+import QuestionBank from '@views/question-bank';
+import UploadQuestions from '@views/upload-questions';
+import BrushQuestions from '@views/brush-questions'
+import {
+ createBrowserRouter,
+} from "react-router-dom";
+
+const router = createBrowserRouter([
+ {
+ path: "/",
+ element: ,
+ children: [
+ {
+ path: "question-bank",
+ element: ,
+ },
+ {
+ path: "brush-question",
+ element: ,
+ },
+ {
+ path: "upload-question",
+ element: ,
+ },
+ ],
+ },
+]);
+
+export default router
\ No newline at end of file
diff --git a/src/views/question-bank/index.tsx b/src/views/question-bank/index.tsx
index 72beeea..e3e7909 100644
--- a/src/views/question-bank/index.tsx
+++ b/src/views/question-bank/index.tsx
@@ -24,7 +24,7 @@ const QuestionBank = () => {
/**
- * 获取一级分类数据
+ * 获取大类分类
*/
const getPrimaryCategoryInfo = () => {
setIsShowSpin(true)
@@ -35,16 +35,34 @@ const QuestionBank = () => {
})
.then((res: Record) => {
if (res.data && res.data.length > 0) {
- setPromaryCategoryId(res.data[0].primaryCategoryId);
+ setPromaryCategoryId(res.data[0].id);
setFirstCategoryList(res.data)
- setIsShowSpin(false)
- } else {
- setIsShowSpin(false)
}
})
- .catch((err: string) => console.log(err));
+ .catch((err: string) => {
+ console.log(err)
+ }).finally(() => {
+ setIsShowSpin(false)
+ })
}
+ // 获取大类下分类
+ const getCategoryByPrimary = () => {
+ req({
+ method: 'post',
+ url: apiName.queryCategoryByPrimary,
+ data: { categoryType: 1, parentId: 1 }
+ }).then(res => {
+ console.log(res)
+ })
+ }
+
+ useEffect(() => {
+ if (primaryCategoryId) {
+ getCategoryByPrimary()
+ }
+ }, [primaryCategoryId])
+
/**
* 切换一级分类
* @param {*} e
diff --git a/src/views/upload-questions/components/kind-editor/index.jsx b/src/views/upload-questions/components/kind-editor/index.jsx
index fdf7c91..f6ba25f 100644
--- a/src/views/upload-questions/components/kind-editor/index.jsx
+++ b/src/views/upload-questions/components/kind-editor/index.jsx
@@ -50,6 +50,7 @@ export default class KindEditor extends Component {
componentDidMount() {
const elemMenu = this.refs.editorElemMenu;
const elemBody = this.refs.editorElemBody;
+ if (this.editor) return
this.editor = new Editor(elemMenu, elemBody);
// // 使用 onchange 函数监听内容的变化,并实时更新到 state 中
this.editor.config.onchange = (html) => {
diff --git a/src/views/upload-questions/constant.js b/src/views/upload-questions/constant.js
index c326ce1..8c73523 100644
--- a/src/views/upload-questions/constant.js
+++ b/src/views/upload-questions/constant.js
@@ -36,24 +36,24 @@ export const ModuleType = {
export const starList = [
{
categoryId: 1,
- categoryName: 'T4',
+ categoryName: '初级',
active: true,
},
{
categoryId: 2,
- categoryName: 'T5',
+ categoryName: '中级',
},
{
categoryId: 3,
- categoryName: 'T6',
+ categoryName: '高级',
},
{
categoryId: 4,
- categoryName: 'T7',
+ categoryName: '资深',
},
{
categoryId: 5,
- categoryName: 'T8',
+ categoryName: '专家',
},
];
@@ -63,24 +63,24 @@ export const starList = [
export const uploadLayout = [
{
id: 1,
- title: '问答题',
+ title: '简答题',
active: true,
},
- {
- id: 2,
- title: '单选题',
- active: false,
- },
- {
- id: 3,
- title: '多选题',
- active: false,
- },
- {
- id: 4,
- title: '判断题',
- active: false,
- },
+ // {
+ // id: 2,
+ // title: '单选题',
+ // active: false,
+ // },
+ // {
+ // id: 3,
+ // title: '多选题',
+ // active: false,
+ // },
+ // {
+ // id: 4,
+ // title: '判断题',
+ // active: false,
+ // },
];
/**