10 Commits
v1.2 ... 1.5

Author SHA1 Message Date
unknown
19df4739ad 会员中心学习时间不显示天 2023-11-15 10:04:45 +08:00
白书科技
e5315f621f !3 优化
Merge pull request !3 from 白书科技/fix/0922
2023-09-24 00:47:56 +00:00
unknown
0f811618b7 iconfont优化 2023-09-22 15:29:30 +08:00
xxx
21e152cb74 兼容安卓钉钉 2023-09-20 10:23:06 +08:00
滕勇志
23b332826d Merge pull request #3 from PlayEdu/dev
v1.3
2023-09-06 17:10:42 +08:00
白书科技
95b7b2306e !2 优化
Merge pull request !2 from 白书科技/fix/0906
2023-09-06 01:55:31 +00:00
unknown
e7ed87649d 登录页面文案修改 2023-09-06 09:49:21 +08:00
白书科技
c445b4c04e !1 优化
Merge pull request !1 from 白书科技/fix/0904
2023-09-04 09:11:34 +00:00
unknown
34dd41a810 学员登录ldap优化 2023-09-04 17:03:19 +08:00
unknown
5d03a69888 学员登录ldap优化 2023-09-04 16:57:32 +08:00
10 changed files with 59 additions and 37 deletions

View File

@@ -28,9 +28,11 @@
"devDependencies": {
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"@vitejs/plugin-legacy": "^4.1.1",
"@vitejs/plugin-react-swc": "^3.0.0",
"rollup-plugin-gzip": "^3.1.0",
"sass": "^1.59.3",
"terser": "^5.19.4",
"typescript": "^4.9.3",
"vite": "^4.2.0"
}

View File

@@ -10,3 +10,10 @@ export function login(email: string, password: string) {
export function logout() {
return client.post("/api/v1/auth/logout", {});
}
export function loginLdap(email: string, password: string) {
return client.post("/api/v1/auth/login/ldap", {
username: email,
password: password,
});
}

View File

@@ -1,5 +1,3 @@
@import "./assets/iconfont/iconfont.css";
body {
margin: 0;
}

View File

@@ -2,6 +2,7 @@ import ReactDOM from "react-dom/client";
import { Provider } from "react-redux";
import store from "./store";
import { BrowserRouter } from "react-router-dom";
import "./assets/iconfont/iconfont.css";
import "./main.scss";
import App from "./App";
import AutoScorllTop from "./AutoTop";

View File

@@ -24,6 +24,7 @@ export const InitPage = (props: Props) => {
if (props.configData) {
let config: SystemConfigStoreInterface = {
//系统配置
"ldap-enabled": props.configData["ldap-enabled"],
systemApiUrl: props.configData["system-api-url"],
systemH5Url: props.configData["system-h5-url"],
systemLogo: props.configData["system-logo"],

View File

@@ -1,7 +1,7 @@
import { useState, useEffect } from "react";
import { Button, Toast, Input, Image } from "antd-mobile";
import styles from "./index.module.scss";
import { useDispatch } from "react-redux";
import { useDispatch, useSelector } from "react-redux";
import { useNavigate } from "react-router-dom";
import { login, system, user } from "../../api/index";
import { setToken } from "../../utils/index";
@@ -19,6 +19,7 @@ const LoginPage = () => {
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [bodyHeight, setBodyHeight] = useState(0);
const systemConfig = useSelector((state: any) => state.systemConfig.value);
useEffect(() => {
document.title = "登录";
@@ -29,7 +30,7 @@ const LoginPage = () => {
const loginSubmit = async (e: any) => {
if (!email) {
Toast.show({
content: "请输入学员邮箱账号",
content: "请输入邮箱或UID",
});
return;
}
@@ -47,17 +48,32 @@ const LoginPage = () => {
return;
}
setLoading(true);
try {
let res: any = await login.login(email, password);
setToken(res.data.token); //将token写入本地
await getSystemConfig(); //获取系统配置并写入store
await getUser(); //获取登录用户的信息并写入store
setLoading(false);
navigate("/member", { replace: true });
} catch (e) {
console.error("错误信息", e);
setLoading(false);
if (systemConfig["ldap-enabled"] === "1") {
try {
let res: any = await login.loginLdap(email, password);
setToken(res.data.token); //将token写入本地
await getSystemConfig(); //获取系统配置并写入store
await getUser(); //获取登录用户的信息并写入store
setLoading(false);
navigate("/member", { replace: true });
} catch (e) {
console.error("错误信息", e);
setLoading(false);
}
}else{
try {
let res: any = await login.login(email, password);
setToken(res.data.token); //将token写入本地
await getSystemConfig(); //获取系统配置并写入store
await getUser(); //获取登录用户的信息并写入store
setLoading(false);
navigate("/member", { replace: true });
} catch (e) {
console.error("错误信息", e);
setLoading(false);
}
}
};
const getUser = async () => {
@@ -70,6 +86,7 @@ const LoginPage = () => {
if (configRes.data) {
let config: SystemConfigStoreInterface = {
//系统配置
"ldap-enabled": configRes.data["ldap-enabled"],
systemApiUrl: configRes.data["system-api-url"],
systemH5Url: configRes.data["system-h5-url"],
systemLogo: configRes.data["system-logo"],
@@ -110,7 +127,7 @@ const LoginPage = () => {
<div className={styles["input-box"]}>
<Input
className={styles["input-item"]}
placeholder="请输入学员邮箱账号"
placeholder="请输入邮箱或UID"
value={email}
onChange={(val) => {
setEmail(val);

View File

@@ -22,10 +22,8 @@ const MemberPage = () => {
url: "",
},
]);
const [learnTodayDay, setLearnTodayDay] = useState(0);
const [learnTodayHour, setLearnTodayHour] = useState(0);
const [learnTodayMin, setLearnTodayMin] = useState(0);
const [learnTotalDay, setLearnTotalDay] = useState(0);
const [learnTotalHour, setLearnTotalHour] = useState(0);
const [learnTotalMin, setLearnTotalMin] = useState(0);
const user = useSelector((state: any) => state.loginUser.value.user);
@@ -60,19 +58,17 @@ const MemberPage = () => {
setStats(res.data.stats);
let todayData = studyTimeFormat(res.data.stats.today_learn_duration);
if (todayData) {
setLearnTodayDay(todayData[0]);
setLearnTodayHour(todayData[1]);
setLearnTodayMin(todayData[2]);
if (todayData[2] === 0 && todayData[3] > 0) {
setLearnTodayHour(todayData[0]);
setLearnTodayMin(todayData[1]);
if (todayData[1] === 0 && todayData[2] > 0) {
setLearnTodayMin(1);
}
}
let totalData = studyTimeFormat(res.data.stats.learn_duration);
if (totalData) {
setLearnTotalDay(totalData[0]);
setLearnTotalHour(totalData[1]);
setLearnTotalMin(totalData[2]);
if (totalData[2] === 0 && totalData[3] > 0) {
setLearnTotalHour(totalData[0]);
setLearnTotalMin(totalData[1]);
if (totalData[1] === 0 && totalData[2] > 0) {
setLearnTodayMin(1);
}
}
@@ -191,11 +187,6 @@ const MemberPage = () => {
<div className={styles["stats-content"]}>
<div className={styles["stat-item"]}>
<span className={styles["time"]}>
{learnTodayDay > 0 && (
<>
<strong>{learnTodayDay} </strong>
</>
)}
<strong> {learnTodayHour} </strong>
<strong> {learnTodayMin} </strong>
</span>
@@ -203,11 +194,6 @@ const MemberPage = () => {
</div>
<div className={styles["stat-item"]}>
<span className={styles["time"]}>
{learnTotalDay > 0 && (
<>
<strong>{learnTotalDay} </strong>
</>
)}
<strong> {learnTotalHour} </strong>
<strong> {learnTotalMin} </strong>
</span>

View File

@@ -1,6 +1,7 @@
import { createSlice } from "@reduxjs/toolkit";
type SystemConfigStoreInterface = {
"ldap-enabled": string;
systemApiUrl: string;
systemPcUrl: string;
systemH5Url: string;
@@ -16,6 +17,7 @@ type SystemConfigStoreInterface = {
};
let defaultValue: SystemConfigStoreInterface = {
"ldap-enabled": "",
systemApiUrl: "",
systemPcUrl: "",
systemH5Url: "",

View File

@@ -54,7 +54,6 @@ export function changeAppUrl(str: string) {
export function studyTimeFormat(dateStr: number) {
var d = moment.duration(dateStr / 1000, "seconds");
let value = [];
value.push(Math.floor(d.asDays()));
value.push(d.hours());
value.push(d.minutes());
value.push(d.seconds());

View File

@@ -1,13 +1,22 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import gzipPlugin from "rollup-plugin-gzip";
import legacy from "@vitejs/plugin-legacy";
// https://vitejs.dev/config/
export default defineConfig({
server: {
host: "0.0.0.0",
},
plugins: [react()],
plugins: [
react(),
legacy({
targets: ["chrome 52"],
additionalLegacyPolyfills: ["regenerator-runtime/runtime"],
renderLegacyChunks: true,
modernPolyfills: true,
}),
],
build: {
rollupOptions: {
plugins: [gzipPlugin()],