Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
web
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
iuav
web
Commits
9dcf8df6
提交
9dcf8df6
authored
5月 25, 2023
作者:
翁进城
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
微信登录功能开发
上级
b906ce6c
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
71 行增加
和
37 行删除
+71
-37
index.tsx
api/index.tsx
+25
-0
index.module.scss
components/NavHeader/index.module.scss
+1
-5
index.tsx
components/loginModal/index.tsx
+22
-11
hooks.js
lib/hooks.js
+13
-21
_app.page.tsx
pages/_app.page.tsx
+9
-0
type.d.ts
typings/type.d.ts
+1
-0
没有找到文件。
api/index.tsx
浏览文件 @
9dcf8df6
...
...
@@ -8,9 +8,34 @@ export interface RegionResp {
pid
:
number
;
}
export
interface
UserInfoParams
{
userAccountId
:
number
;
}
export
interface
UserInfoResp
{
id
:
number
;
accountType
:
number
;
uid
:
string
;
phoneNum
:
string
;
userName
:
string
;
nickName
:
string
;
userImg
:
string
;
userSex
:
number
;
email
:
string
;
source
:
number
;
accountStatus
:
number
;
remark
:
string
;
portType
:
number
;
createTime
:
string
;
}
export
default
{
//获取区域数据
region
:
():
Promise
<
Response
<
Array
<
RegionResp
>>>
=>
{
return
request
(
"/pms/webDevice/getSecondDistrictInfo"
);
},
//获取用户基本信息
userInfo
:
(
params
:
UserInfoParams
):
Promise
<
Response
<
UserInfoResp
>>
=>
{
return
request
(
"/userapp/user-account/info"
,
"get"
,
params
,
{});
},
};
components/NavHeader/index.module.scss
浏览文件 @
9dcf8df6
...
...
@@ -78,8 +78,4 @@
background
:
none
;
}
.headImg
{
width
:
48px
;
height
:
48px
;
background
:
#ffffff
;
}
components/loginModal/index.tsx
浏览文件 @
9dcf8df6
import
React
,
{
useState
}
from
"react"
;
import
{
Modal
}
from
"antd"
;
import
React
,
{
use
Effect
,
use
State
}
from
"react"
;
import
{
AutoComplete
,
Modal
}
from
"antd"
;
import
Image
from
"next/image"
;
type
Props
=
{
open
:
boolean
;
onCancel
:
()
=>
void
;
};
export
default
function
loginModal
(
props
:
Props
)
{
useEffect
(()
=>
{
if
(
props
.
open
)
{
var
obj
=
new
window
.
WxLogin
({
self_redirect
:
true
,
id
:
"login_container"
,
appid
:
"wx18b7883acd204278"
,
scope
:
"snsapi_login"
,
redirect_uri
:
encodeURIComponent
(
"https://iuav.mmcuav.cn/"
),
state
:
""
,
style
:
""
,
href
:
""
,
});
}
},
[
props
.
open
]);
return
(
<>
<
Modal
...
...
@@ -30,16 +44,13 @@ export default function loginModal(props: Props) {
>
欢迎来到云享飞
</
div
>
<
Image
alt=
""
src=
""
width=
{
160
}
height=
{
160
}
style=
{
{
margin
:
"auto"
,
display
:
"block"
}
}
></
Image
>
<
div
id=
"login_container"
style=
{
{
margin
:
"auto"
,
display
:
"table"
}
}
></
div
>
<
div
style=
{
{
marginTop
:
39
,
marginTop
:
-
120
,
marginBottom
:
52
,
fontSize
:
14
,
fontFamily
:
"MicrosoftYaHei"
,
...
...
lib/hooks.js
浏览文件 @
9dcf8df6
/* import { useEffect } from "react";
import Router from "next/router";
import request from '~/api/request';
import useSWR, { SWRResponse } from "swr"; */
import
{
useEffect
,
useState
}
from
"react"
;
import
api
,
{
UserInfoResp
}
from
"~/api"
;
/*
const fetcher = (url) =>
fetch(url)
...
...
@@ -10,24 +8,18 @@ const fetcher = (url) =>
return { user: data?.user || null };
}); */
export
function
useUser
({
redirectTo
,
redirectIfFound
}
=
{})
{
return
{};
/* const { data, error } = useSWR("/api/user", request);
const user = data?.user;
const finished = Boolean(data);
const hasUser = Boolean(user);
export
function
useUser
()
{
const
[
user
,
setUser
]
=
useState
(
null
);
useEffect
(()
=>
{
if (!redirectTo || !finished) return;
if (
// If redirectTo is set, redirect if the user was not found.
(redirectTo && !redirectIfFound && !hasUser) ||
// If redirectIfFound is also set, redirect if the user was found
(redirectIfFound && hasUser)
) {
Router.push(redirectTo);
}
}, [redirectTo, redirectIfFound, finished, hasUser]);
api
.
userInfo
({
userAccountId
:
0
,
})
.
then
((
res
)
=>
{
setUser
(
res
.
result
);
});
},
[]);
return
error ? null : user; */
return
user
;
}
pages/_app.page.tsx
浏览文件 @
9dcf8df6
...
...
@@ -4,6 +4,8 @@ import type { AppProps } from 'next/app';
import
withTheme
from
'../theme'
;
import
{
message
}
from
'antd'
;
import
{
useEffect
}
from
'react'
;
import
Head
from
"next/head"
;
import
Script
from
'next/script'
;
export
default
function
App
({
Component
,
pageProps
}:
AppProps
)
{
const
[
messageApi
,
contextHolder
]
=
message
.
useMessage
();
...
...
@@ -14,6 +16,13 @@ export default function App({ Component, pageProps }: AppProps) {
return
withTheme
(
<>
<
Head
>
<
meta
name=
"viewport"
content=
"width=device-width,initial-scale=1"
></
meta
>
</
Head
>
<
Script
src=
"https://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js"
></
Script
>
{
contextHolder
}
<
Component
{
...
pageProps
}
/>
</>
...
...
typings/type.d.ts
浏览文件 @
9dcf8df6
...
...
@@ -3,5 +3,6 @@ import { MessageInstance } from 'antd/es/message/interface';
declare
global
{
interface
Window
{
messageApi
:
MessageInstance
;
WxLogin
:
any
;
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论