From 65ca323f1dd9801158c6d234379c09c96c2b00e3 Mon Sep 17 00:00:00 2001 From: wuzuowei Date: Fri, 19 Jul 2024 09:36:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=99=BB=E5=BD=95=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platform-code/src/microhost/models/system.ts | 1 + .../src/microhost/system/runtimes/user.ts | 4 +- platform-code/src/pages/tech/login/index.tsx | 182 +++++++++--------- 3 files changed, 95 insertions(+), 92 deletions(-) diff --git a/platform-code/src/microhost/models/system.ts b/platform-code/src/microhost/models/system.ts index cab4b5e..1f7efcb 100644 --- a/platform-code/src/microhost/models/system.ts +++ b/platform-code/src/microhost/models/system.ts @@ -37,6 +37,7 @@ export class SystemData extends RemoteRequest { }) } public setlog = async (obj: any) => { + // console.log("日志参数11111111111111", obj); return request.post('/Personnel/Personnelapi/LogRecording', obj) } diff --git a/platform-code/src/microhost/system/runtimes/user.ts b/platform-code/src/microhost/system/runtimes/user.ts index c4643b5..8c5029c 100644 --- a/platform-code/src/microhost/system/runtimes/user.ts +++ b/platform-code/src/microhost/system/runtimes/user.ts @@ -164,7 +164,9 @@ export default class RuntimeUser { OperateUser: loginId || "未登录", Operate: `${loginId}登陆了工艺数据管理子系统` } - await this.model.setlog(obj) + + this.model.setlog(obj) + // console.log("日志参数", obj, loginId,); return true } } diff --git a/platform-code/src/pages/tech/login/index.tsx b/platform-code/src/pages/tech/login/index.tsx index 8abf414..ad54197 100644 --- a/platform-code/src/pages/tech/login/index.tsx +++ b/platform-code/src/pages/tech/login/index.tsx @@ -5,7 +5,7 @@ import { useState, useLayoutEffect, useRef, useEffect } from 'react' import styles from './index.less' import { SystemData } from '@/microhost/models/system' import Api from '@/config/Api' -import {defaultSetting as cfg} from "@/config/default" +import { defaultSetting as cfg } from "@/config/default" import MicroApps from '@/microhost/system/apps' import "./styles.less" import { DesktopOutlined, KeyOutlined, MobileOutlined, UserOutlined } from '@ant-design/icons' @@ -13,17 +13,17 @@ import utils from "@/microhost/common" import { isString } from 'lodash' const TechLoginView = () => { - const [isLoading, setIsLoading] = useState(false) + const [isLoading, setIsLoading] = useState(false) const [loginType, setLoginType] = useState<"account" | "qrcode">("account") const cookieLoginKey = "_defs_ln" const [thisForm] = Form.useForm() const defln = utils.loadCookie(cookieLoginKey) - const [cookieLoginName, setCookieLoginName] = useState(!!defln && defln != "null" ? defln : undefined) + const [cookieLoginName, setCookieLoginName] = useState(!!defln && defln != "null" ? defln : undefined) const isRemembered = useRef(!!defln && defln != "null") useEffect(() => { let def = !!defln && defln != "null" ? defln : undefined - if(def){ + if (def) { thisForm.setFieldsValue({ loginId: def }) @@ -41,35 +41,35 @@ const TechLoginView = () => { return; } - if(isRemembered.current){ + if (isRemembered.current) { let month = new Date().getTime() + 1000 * 24 * 3600 * 30 * 3 utils.saveCookie(cookieLoginKey, loginId, month) } let result = await MicroApps.GetRuntimeUser().doLogin(loginId, password) - - if(isString(result)){ + + if (isString(result)) { message.error(result) return } let redirect: any = history.location.query?.redirect let jumpTo: string | undefined = undefined - if(redirect){ + if (redirect) { let rd = decodeURIComponent(redirect) jumpTo = isUrl(rd) ? rd : undefined } - if(jumpTo){ - + if (jumpTo) { + } - else{ + else { let routes = await MicroApps.BuildRouteTree(loginId) - if(!routes || routes.length == 0){ + if (!routes || routes.length == 0) { history.push("/noauth") return } - else{ + else { jumpTo = "/" //routes[0].defaultPath && routes[0].defaultPath.length > 0 ? routes[0].defaultPath : "/welcome" } } @@ -77,97 +77,97 @@ const TechLoginView = () => { history.push(`/animate?url=${encodeURIComponent(jumpTo)}`) } - const isUrl = (addr: any) => { + const isUrl = (addr: any) => { var v = new RegExp( - '^((http|https|ftp)://|//)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$', - 'i', + '^((http|https|ftp)://|//)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$', + 'i', ); let uri: string = addr; uri = !uri || uri.length == 0 ? '' : uri[0] == '/' ? uri.substring(1) : uri; return v.test(uri); } - return ( - <> -
-
{ - doLogin(values) - }}> - -
- -
-
- - 用户名: - - - -
-
- - 密    码: - - - -
-
- { - let checked = event.target.checked - isRemembered.current = checked - if(checked){ - let vals = thisForm.getFieldsValue() - let month = new Date().getTime() + 1000 * 24 * 3600 * 30 * 3 - utils.saveCookie(cookieLoginKey, vals.loginId ? vals.loginId : "", month) - } - else{ - utils.removeCookie(cookieLoginKey) - } - }}>记住账号 - {/* */} -
-
- - - -
-
-
使用其他终端
-
-
- -
-
- {/*
{ +
+ + + +
+
+
使用其他终端
+
+
+
+ +
+
+ {/*
{ setLoginType("qrcode") }} title='手机端'>
*/} +
-
-
-
-
-
使用其他终端
-
-
-
- -
-
-
{ - setLoginType("account") - }} title='网页端'>
+
+
+
+
使用其他终端
+
+
+
+ +
+
+
{ + setLoginType("account") + }} title='网页端'>
+
-
- - -
- - ) + + +
+ + ) } -export default TechLoginView \ No newline at end of file +export default TechLoginView