Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
boyueCEnd
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
游洁
boyueCEnd
Commits
a40ae852
Commit
a40ae852
authored
Dec 02, 2025
by
youjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
line 密钥
parent
f4387953
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
40 deletions
+51
-40
index.ts
src/router/index.ts
+1
-1
Login.vue
src/views/auth/Login.vue
+43
-29
account.vue
...views/personalCenter/components/accountCenter/account.vue
+7
-10
No files found.
src/router/index.ts
View file @
a40ae852
...
...
@@ -68,7 +68,7 @@ const router = createRouter({
]
},
{
path
:
"/login"
,
path
:
"/login
/:type?
"
,
name
:
"login"
,
component
:
()
=>
import
(
"../views/auth/Login.vue"
),
meta
:
{
title
:
"page.login"
},
...
...
src/views/auth/Login.vue
View file @
a40ae852
...
...
@@ -59,19 +59,6 @@
</a-form>
</a-space>
<!-- Line登录 -->
<div
v-if=
"loginMsg.reType==3"
class=
"login-form-content scan-content"
>
<div
class=
"qr-container"
>
<div
class=
"qr-box line-qr-box"
>
<div
class=
"qr-code-placeholder"
>
<i
class=
"ki-outline ki-message-text"
></i>
</div>
</div>
<p
class=
"scan-instruction"
>
{{ t('login.scanTip') }}
</p>
<p
class=
"scan-status"
>
{{ t('login.scanWaiting') }}
</p>
</div>
</div>
<div
class=
"mt-[40px] flex items-center justify-center"
>
<a-divider
orientation=
"center"
class=
"text-[16px] text-[#EEEFEB]"
></a-divider>
<span
class=
"text-nowrap customPrimary-5 px-[14px]"
>
{{ t('login.othenLogin') }}
</span>
...
...
@@ -152,12 +139,13 @@ const systemConfigStore = useSystemConfigStore()
const
loading
=
ref
(
true
)
const
router
=
useRouter
()
const
{
params
}
=
router
.
currentRoute
.
value
const
googleButtonContainer
=
ref
(
null
);
const
loginMsg
=
reactive
({
tenantId
:
systemConfigStore
.
tenantId
||
null
,
reType
:
0
,
//登录方式 0账号密码 1谷歌授权 3LINE授权 7FaceBook授权
reType
:
0
,
//登录方式 0账号密码 1谷歌授权
2微信授权
3LINE授权 7FaceBook授权
openId
:
""
,
email
:
""
,
//2310721242@qq.com
password
:
''
,
//yj123456
...
...
@@ -165,6 +153,7 @@ const loginMsg = reactive({
parentId
:
null
,
redirectUri
:
''
,
})
if
(
params
&&
params
.
type
)
loginMsg
.
reType
=
Number
(
params
.
type
)
const
loginMethods
=
ref
([
{
...
...
@@ -213,24 +202,48 @@ const rules = computed(() => ({
const
openInfo
=
ref
({}
as
any
)
// 随机生成 state 参数
const
generateState
=
()
=>
{
return
Math
.
random
().
toString
(
36
).
substring
(
2
);
// 简单的生成随机字符串
}
// line授权登录
const
loginWithLine
=
()
=>
{
const
channelId
=
openInfo
.
value
.
appId
;
// 替换为你的 LINE Channel ID
const
redirectUri
=
encodeURIComponent
(
openInfo
.
value
.
redirectUri
||
'https://www.oytour.com/#/login/3'
);
// 替换为你的重定向 URI
const
state
=
generateState
();
// 防止 CSRF 攻击,生成随机的 state 参数
// 构造 LINE 授权 URL
const
lineLoginUrl
=
`https://access.line.me/oauth2/v2.1/authorize?response_type=code&client_id=
${
channelId
}
&redirect_uri=
${
redirectUri
}
&state=
${
state
}
&scope=openid%20profile`
;
// 跳转到 LINE 登录页面
window
.
location
.
href
=
lineLoginUrl
;
}
// 微信授权登录
const
loginWechat
=
()
=>
{
const
redirect_url
=
openInfo
.
value
.
redirectUri
||
'https://www.oytour.com/#/login/2'
const
url
=
`https://open.weixin.qq.com/connect/qrconnect?appid=
${
openInfo
.
value
.
appId
}
&redirect_uri=
${
encodeURIComponent
(
redirect_url
)}
&response_type=code&scope=snsapi_login&state=
${
1
}
&wechat_redirect=
${
redirect_url
}
`
;
window
.
location
.
href
=
url
;
}
// 获取
微信登录
AppID 域名 重定向页面
const
getAppIdRedirectUri
=
async
()
=>
{
// 获取AppID 域名 重定向页面
const
getAppIdRedirectUri
=
async
(
providerType
:
string
)
=>
{
// const { AppID, State, OpenRedirectUri } = openInfo.value;
// let redirect_uri = OpenRedirectUri;
// const url = `https://open.weixin.qq.com/connect/qrconnect?appid=${AppID}&redirect_uri=${encodeURIComponent('https://www.oytour.com/#/login')}&response_type=code&scope=snsapi_login&state=${State}&wechat_redirect=${redirect_uri}`;
// window.location.href = url;
// return
loading
.
value
=
true
try
{
// 获取微信
登录
AppID 域名
const
response
=
await
userStore
.
getUserWechatAppIdAsync
(
loginMsg
.
tenantId
?.
toString
()
||
''
,
providerType
Enum
.
WECHAT
.
value
)
// 获取微信
绑定
AppID 域名
const
response
=
await
userStore
.
getUserWechatAppIdAsync
(
loginMsg
.
tenantId
?.
toString
()
||
''
,
providerType
)
if
(
response
.
status
==
'SUCCESS'
)
{
openInfo
.
value
=
response
.
data
[
0
]
const
{
appId
,
redirectUri
}
=
openInfo
.
value
;
const
redirect_url
=
redirectUri
?
redirectUri
:
'https://www.oytour.com/#/login'
const
url
=
`https://open.weixin.qq.com/connect/qrconnect?appid=
${
appId
}
&redirect_uri=
${
encodeURIComponent
(
redirect_url
)}
&response_type=code&scope=snsapi_login&state=
${
1
}
&wechat_redirect=
${
redirect_url
}
`
;
window
.
location
.
href
=
url
;
if
(
openInfo
.
value
.
appId
){
if
(
providerType
==
providerTypeEnum
.
WECHAT
.
value
){
loginWechat
()
}
else
if
(
providerType
==
providerTypeEnum
.
GOOGLE
.
value
){
renderGoogleButton
(
openInfo
.
value
.
appId
)
}
else
if
(
providerType
==
providerTypeEnum
.
LINE
.
value
){
loginWithLine
()
}
}
}
}
catch
(
error
:
any
)
{
Message
.
error
(
error
.
message
)
...
...
@@ -265,9 +278,10 @@ const handleClick = (path: string) => {
}
const
toggleLoginType
=
(
type
:
number
)
=>
{
if
(
type
==
3
||
type
==
7
)
return
Message
.
error
(
t
(
'login.loginTypeNotSupport'
))
if
(
type
==
7
)
return
Message
.
error
(
t
(
'login.loginTypeNotSupport'
))
loginMsg
.
reType
=
type
if
(
type
==
2
)
{
getAppIdRedirectUri
()
}
if
(
type
==
3
)
getAppIdRedirectUri
(
providerTypeEnum
.
LINE
.
value
)
if
(
type
==
2
)
getAppIdRedirectUri
(
providerTypeEnum
.
WECHAT
.
value
)
// if(type==1) {
// loginWithGoogle()
// }
...
...
@@ -399,17 +413,17 @@ onMounted(async () => {
})
const
queryParams
=
query
()
const
code
=
queryParams
.
code
if
(
code
)
{
loginMsg
.
reType
=
2
useWechatLogin
(
code
)
if
(
loginMsg
.
reType
==
2
)
useWechatLogin
(
code
)
else
if
(
loginMsg
.
reType
==
3
)
{}
}
try
{
await
initGoogleSDK
();
// 确保 SDK 加载完成后渲染按钮
await
new
Promise
(
resolve
=>
setTimeout
(
resolve
));
renderGoogleButton
()
getAppIdRedirectUri
(
providerTypeEnum
.
GOOGLE
.
value
)
}
catch
(
error
)
{
console
.
error
(
'SDK 初始化失败:'
,
error
);
...
...
src/views/personalCenter/components/accountCenter/account.vue
View file @
a40ae852
...
...
@@ -242,20 +242,20 @@ const generateState = () => {
// line授权
const
loginWithLine
=
()
=>
{
const
channelId
=
openInfo
.
value
.
appId
;
// 替换为你的 LINE Channel ID
const
redirectUri
=
encodeURIComponent
(
openInfo
.
value
.
redirectUri
||
'https://www.oytour.com/#/login'
);
// 替换为你的重定向 URI
const
redirectUri
=
encodeURIComponent
(
openInfo
.
value
.
redirectUri
||
'https://www.oytour.com/#/login
/3
'
);
// 替换为你的重定向 URI
const
state
=
generateState
();
// 防止 CSRF 攻击,生成随机的 state 参数
// 构造 LINE 授权 URL
const
lineLoginUrl
=
`https://access.line.me/oauth2/v2.1/authorize?response_type=code&client_id=
${
channelId
}
&redirect_uri=
${
redirectUri
}
&state=
${
state
}
&scope=openid%20profile`
;
// 跳转到 LINE 登录页面
window
.
location
.
href
=
lineLoginUrl
;
}
// 微信授权
登录
// 微信授权
const
loginWechat
=
()
=>
{
const
redirect_url
=
openInfo
.
value
.
redirectUri
||
'https://www.oytour.com/#/login'
const
url
=
`https://open.weixin.qq.com/connect/qrconnect?appid=
${
appId
}
&redirect_uri=
${
encodeURIComponent
(
redirect_url
)}
&response_type=code&scope=snsapi_login&state=
${
1
}
&wechat_redirect=
${
redirect_url
}
`
;
const
redirect_url
=
openInfo
.
value
.
redirectUri
||
'https://www.oytour.com/#/login
/2
'
const
url
=
`https://open.weixin.qq.com/connect/qrconnect?appid=
${
openInfo
.
value
.
appId
}
&redirect_uri=
${
encodeURIComponent
(
redirect_url
)}
&response_type=code&scope=snsapi_login&state=
${
1
}
&wechat_redirect=
${
redirect_url
}
`
;
window
.
location
.
href
=
url
;
}
// 获取
绑定
AppID 域名 重定向页面
// 获取AppID 域名 重定向页面
const
getAppIdRedirectUri
=
async
(
providerType
:
string
)
=>
{
// const { AppID, State, OpenRedirectUri } = openInfo.value;
// let redirect_uri = OpenRedirectUri;
...
...
@@ -267,8 +267,7 @@ const getAppIdRedirectUri = async (providerType: string) => {
const
response
=
await
userStore
.
getUserWechatAppIdAsync
(
systemConfig
.
tenantId
?.
toString
()
||
''
,
providerType
)
if
(
response
.
status
==
'SUCCESS'
)
{
openInfo
.
value
=
response
.
data
[
0
]
if
(
openInfo
.
value
?.
appId
){
console
.
log
(
openInfo
.
value
,
'----------'
)
if
(
openInfo
.
value
.
appId
){
if
(
providerType
==
providerTypeEnum
.
WECHAT
.
value
){
loginWechat
()
}
else
if
(
providerType
==
providerTypeEnum
.
GOOGLE
.
value
){
...
...
@@ -294,10 +293,8 @@ const useWechatBind = async(code:string) => {
Message
.
success
(
t
(
'personal.bindWechatSuccess'
))
getPersonalInfor
()
}
router
.
push
(
'/accountCenter'
)
}
catch
(
error
:
any
)
{
// Message.error(error.message)
router
.
push
(
'/accountCenter'
)
Message
.
error
(
error
.
message
)
}
finally
{
loading
.
value
=
false
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment