飞书授权添加系统码 及登录进入页面路由
This commit is contained in:
@@ -20,8 +20,11 @@
|
||||
const params = new URLSearchParams(window.location.search)
|
||||
const companyid = params.get('corp_id')
|
||||
const companyabbr = params.get('corp_abbr')
|
||||
const systemid = params.get('system_id')
|
||||
const system_code = params.get('system_code')
|
||||
if (companyid) {
|
||||
userStore.setCompany(companyid, companyabbr || '')
|
||||
userStore.setSystems(systemid || '', system_code || '')
|
||||
// 你也可以加 localStorage/sessionStorage 备份
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ export class UserService {
|
||||
})
|
||||
}
|
||||
//获取 飞书信息
|
||||
static getfeishuAppList(params: { corp_id: string }) {
|
||||
static getfeishuAppList(params: any) {
|
||||
return request.get<Api.Brand.BrandInfo>({
|
||||
url: '/common/preset/feishu/app',
|
||||
params
|
||||
|
||||
@@ -138,7 +138,8 @@ export const useUserStore = defineStore(
|
||||
// 清空所有本地缓存
|
||||
localStorage.clear()
|
||||
sessionStorage.clear()
|
||||
|
||||
systemsabbr.value = ''
|
||||
systemsid.value = ''
|
||||
companyabbr.value = ''
|
||||
companyid.value = ''
|
||||
info.value = {}
|
||||
|
||||
@@ -35,7 +35,8 @@ onMounted(async () => {
|
||||
const userInfo = await UserService.getUserInfo()
|
||||
userStore.setUserInfo(userInfo)
|
||||
userStore.setLoginStatus(true)
|
||||
router.replace('/')
|
||||
router.push(data.home_url)
|
||||
// router.replace('/')
|
||||
} catch (e: any) {
|
||||
error.value = e?.response?.data?.message || '登录失败,请重试'
|
||||
router.replace('/')
|
||||
|
||||
@@ -36,11 +36,11 @@
|
||||
<div class="form">
|
||||
<!-- 登录方式切换 tab -->
|
||||
<div class="login-type-tabs">
|
||||
<span
|
||||
<!-- <span
|
||||
:class="{ active: activeLoginType === 'password' }"
|
||||
@click="activeLoginType = 'password'"
|
||||
>账号密码登录</span
|
||||
>
|
||||
> -->
|
||||
<span
|
||||
:class="{ active: activeLoginType === 'qrcode' }"
|
||||
@click="activeLoginType = 'qrcode'"
|
||||
@@ -255,7 +255,10 @@
|
||||
}
|
||||
|
||||
const getfeishuAppList = async () => {
|
||||
feishuresponse.value = await UserService.getfeishuAppList({ corp_id: companyid.value })
|
||||
feishuresponse.value = await UserService.getfeishuAppList({
|
||||
corp_id: companyid.value,
|
||||
system_id: systemsid.value
|
||||
})
|
||||
if (activeLoginType.value == 'qrcode') {
|
||||
feishulogin()
|
||||
}
|
||||
@@ -265,6 +268,9 @@
|
||||
const systemsdata = systemsList.value.find((c: any) => c.id === systems)
|
||||
systemsid.value = systems
|
||||
userStore.setSystems(systems, systemsdata?.code)
|
||||
if (companyid.value && systemsid.value) {
|
||||
getfeishuAppList()
|
||||
}
|
||||
}
|
||||
//切换公司
|
||||
|
||||
@@ -274,8 +280,10 @@
|
||||
companyid.value = company
|
||||
iscompany.value = company
|
||||
userStore.setCompany(company, companyt?.abbr)
|
||||
if (companyid.value && systemsid.value) {
|
||||
getfeishuAppList()
|
||||
}
|
||||
}
|
||||
if (companyabbr != '') {
|
||||
iscompany.value = true
|
||||
getfeishuAppList()
|
||||
@@ -327,7 +335,7 @@
|
||||
}
|
||||
}
|
||||
watch(
|
||||
(activeLoginType as import('vue').Ref<string>),
|
||||
activeLoginType as import('vue').Ref<string>,
|
||||
async (val) => {
|
||||
if (val === 'qrcode') {
|
||||
userStore.setLoginType('feishu')
|
||||
@@ -390,7 +398,7 @@
|
||||
|
||||
// 登录成功处理
|
||||
showLoginSuccessNotice()
|
||||
router.push(HOME_PAGE)
|
||||
router.push(data.home_url)
|
||||
} catch (error) {
|
||||
// 处理 HttpError
|
||||
if (error instanceof HttpError) {
|
||||
@@ -435,10 +443,24 @@
|
||||
const companyabbr = Array.isArray(route.query.corp_abbr)
|
||||
? route.query.corp_abbr[0]
|
||||
: route.query.corp_abbr
|
||||
const system_id = Array.isArray(route.query.system_id)
|
||||
? route.query.system_id[0]
|
||||
: route.query.system_id
|
||||
const system_code = Array.isArray(route.query.system_code)
|
||||
? route.query.system_code[0]
|
||||
: route.query.system_code
|
||||
if (companyid) {
|
||||
userStore.setCompany(companyid as string, (companyabbr as string) || '')
|
||||
formData.company = Number(companyid)
|
||||
}
|
||||
if (system_id) {
|
||||
userStore.setSystems(companyid as string, (system_code as string) || '')
|
||||
formData.systems = Number(system_id)
|
||||
}
|
||||
// 只有两个 id 都有值时才调用
|
||||
if (companyid && systemsid.value) {
|
||||
getfeishuAppList()
|
||||
}
|
||||
})
|
||||
|
||||
// 切换主题
|
||||
|
||||
Reference in New Issue
Block a user