Commit 0ab54fbd authored by guxukai's avatar guxukai

chore: 登录portal

parent f90a2f55
...@@ -25,9 +25,9 @@ const routes = [ ...@@ -25,9 +25,9 @@ const routes = [
children: [...CROPPED_ROUTES, ...LOOKUP_ROUTES], children: [...CROPPED_ROUTES, ...LOOKUP_ROUTES],
}, },
{ {
path: '/login-proxy', path: '/proxy',
name: 'login-proxy', name: 'proxy',
component: () => import('@account/views/fixed/login-proxy/index.vue'), component: () => import('@account/views/fixed/proxy/index.vue'),
}, },
...FIXED_ROUTES, ...FIXED_ROUTES,
...SYSTEM_ROUTES, ...SYSTEM_ROUTES,
......
<template>
<div></div>
</template>
<script lang="ts" setup>
import { useRouter } from 'vue-router'
const $router = useRouter()
$router.push({ name: 'home' })
</script>
<template>
<el-config-provider :locale="zhCn">
<router-view />
</el-config-provider>
</template>
<script setup>
import zhCn from 'element-plus/lib/locale/lang/zh-cn'
import { useSplash } from '@shared/hooks/useSplash'
useSplash()
</script>
<style></style>
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
import { createApp } from 'vue'
import App from './App.vue'
import { router } from './router'
import { store } from '@shared/store'
import { createMockServer } from '@shared/mock'
import 'tailwindcss/tailwind.css'
import ElementPlus from 'element-plus'
import Components from '@shared/components/global/index'
import '@shared/assets/sass/index.scss'
import '@assets/icons'
import '@assets/font/font.css'
import '@assets/css/tailwind.css'
createMockServer()
const app = createApp(App)
app.use(store).use(router).use(ElementPlus).use(Components).mount('#app')
import { createRouter, createWebHistory } from 'vue-router'
import { SYSTEM_ROUTES } from '@shared/router/constants'
const FIXED_ROUTES = [
{
path: '/login',
name: 'login',
component: () => import('@entry/views/fixed/login/index.vue'),
},
{
path: '/proxy',
name: 'proxy',
component: () => import('@entry/views/fixed/proxy/index.vue'),
},
{
path: '/retrieve',
name: 'retrieve',
component: () => import('@entry/views/fixed/retrieve/index.vue'),
},
{
path: '/register',
name: 'register',
component: () => import('@entry/views/fixed/register/index.vue'),
},
]
const routes = [...FIXED_ROUTES, ...SYSTEM_ROUTES]
export const router = createRouter({
history: createWebHistory('/entry'),
routes,
})
<template>
<div class="flex flex-row justify-center items-center h-screen w-screen">
<img src="@/assets/icons/svg/401.svg" class="w-[120px]" />
<div class="ml-12">
<p class="mb-6 text-gray-700 text-4xl">抱歉 , 你没有权限 !</p>
<el-button type="info" class="px-12" @click="back">返回</el-button>
</div>
</div>
</template>
<script setup>
import { getCurrentInstance } from 'vue'
let { proxy } = getCurrentInstance()
const back = function () {
proxy.$router.back()
}
</script>
This diff is collapsed.
<template>
<div class="flex flex-row justify-center items-center h-screen w-screen">
<i class="font-404 !text-[120px] text-red-100" />
<div class="ml-12">
<p class="mb-6 text-gray-700 text-4xl">抱歉 , 页面丢失了 .</p>
<el-button type="info" class="px-12" @click="back">返回</el-button>
</div>
</div>
</template>
<script setup>
import { getCurrentInstance } from 'vue'
let { proxy } = getCurrentInstance()
const back = function () {
proxy.$router.back()
}
</script>
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
import useVuelidate from '@vuelidate/core' import useVuelidate from '@vuelidate/core'
import { AuthLogin, AuthLoginPostReq } from '@shared/models/gateway/AuthLogin' import { AuthLogin, AuthLoginPostReq } from '@shared/models/gateway/AuthLogin'
import { reactive, ref } from 'vue' import { reactive, ref } from 'vue'
import { useRouter } from 'vue-router' import { useRoute, useRouter } from 'vue-router'
import { helpers, required } from '@vuelidate/validators' import { helpers, required } from '@vuelidate/validators'
import { useRequest } from 'vue-request' import { useRequest } from 'vue-request'
import { MessageUtils } from '@shared/utils/message-utils' import { MessageUtils } from '@shared/utils/message-utils'
...@@ -66,6 +66,7 @@ import { AuthRegisterStatus } from '@shared/models/gateway/AuthRegisterStatus' ...@@ -66,6 +66,7 @@ import { AuthRegisterStatus } from '@shared/models/gateway/AuthRegisterStatus'
import { AuthLicenseStatus } from '@shared/models/gateway/AuthLicenseStatus' import { AuthLicenseStatus } from '@shared/models/gateway/AuthLicenseStatus'
import { useAuth } from '@shared/store/modules/auth' import { useAuth } from '@shared/store/modules/auth'
import { useLayout } from '@shared/store/modules/layout' import { useLayout } from '@shared/store/modules/layout'
const $route = useRoute()
const authStore = useAuth() const authStore = useAuth()
const layoutStore = useLayout() const layoutStore = useLayout()
const $router = useRouter() const $router = useRouter()
...@@ -105,7 +106,7 @@ const handleSubmitForm = async () => { ...@@ -105,7 +106,7 @@ const handleSubmitForm = async () => {
authStore.$patch({ authStore.$patch({
loginInfo: res.data, loginInfo: res.data,
}) })
await $router.push({ name: 'login-proxy' }) $router.push({ name: 'proxy' })
} else { } else {
MessageUtils.warning(res?.message) MessageUtils.warning(res?.message)
} }
......
...@@ -2,14 +2,16 @@ ...@@ -2,14 +2,16 @@
<div></div> <div></div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { UserToken } from '@shared/models/user-service/UserToken'
import { useAuth } from '@shared/store/modules/auth' import { useAuth } from '@shared/store/modules/auth'
import { useRequest } from 'vue-request' import { useRouter } from 'vue-router'
import { useUser } from '@shared/store/modules/user' import { useUser } from '@shared/store/modules/user'
import { useRequest } from 'vue-request'
import { UserToken } from '@shared/models/user-service/UserToken'
import { GATEWAY_CODE } from '@shared/http/constants' import { GATEWAY_CODE } from '@shared/http/constants'
import { useRouter } from 'vue-router'
const $router = useRouter()
const authStore = useAuth() const authStore = useAuth()
const $router = useRouter()
const userStore = useUser() const userStore = useUser()
const { const {
data: userData, data: userData,
...@@ -22,13 +24,20 @@ const { ...@@ -22,13 +24,20 @@ const {
}).then(res => { }).then(res => {
if (res.code === GATEWAY_CODE.success) { if (res.code === GATEWAY_CODE.success) {
userStore.$patch({ userInfo: res.data }) userStore.$patch({ userInfo: res.data })
authStore.$patch({ //超管跳转
consoleInfo: { if (authStore.loginInfo.id === 10000000) {
consoleObjectId: '0', authStore.$patch({
consoleName: '个人控制台', consoleInfo: {
}, consoleName: '超管',
}) consoleObjectId: '1',
$router.push({ name: 'home' }) consoleTypeId: '1',
},
})
window.location.replace(`${origin}/super/proxy`)
return
}
//其余跳转
window.location.replace(`${origin}/account/proxy`)
} }
return res return res
}), }),
......
...@@ -25,7 +25,11 @@ const routes = [ ...@@ -25,7 +25,11 @@ const routes = [
component: () => import('@shared/layouts/default-layout.vue'), component: () => import('@shared/layouts/default-layout.vue'),
children: [...CROPPED_ROUTES, ...LOOKUP_ROUTES], children: [...CROPPED_ROUTES, ...LOOKUP_ROUTES],
}, },
...FIXED_ROUTES, {
path: '/proxy',
name: 'proxy',
component: () => import('@account/views/fixed/proxy/index.vue'),
},
...SYSTEM_ROUTES, ...SYSTEM_ROUTES,
] ]
export const router = createRouter({ export const router = createRouter({
......
<template>
<div></div>
</template>
<script lang="ts" setup>
import { useRouter } from 'vue-router'
const $router = useRouter()
$router.push({ name: 'home' })
</script>
...@@ -25,7 +25,11 @@ const routes = [ ...@@ -25,7 +25,11 @@ const routes = [
component: () => import('@shared/layouts/default-layout.vue'), component: () => import('@shared/layouts/default-layout.vue'),
children: [...CROPPED_ROUTES, ...LOOKUP_ROUTES], children: [...CROPPED_ROUTES, ...LOOKUP_ROUTES],
}, },
...FIXED_ROUTES, {
path: '/proxy',
name: 'proxy',
component: () => import('@account/views/fixed/proxy/index.vue'),
},
...SYSTEM_ROUTES, ...SYSTEM_ROUTES,
] ]
export const router = createRouter({ export const router = createRouter({
......
<template>
<div></div>
</template>
<script lang="ts" setup>
import { useRouter } from 'vue-router'
const $router = useRouter()
$router.push({ name: 'home' })
</script>
...@@ -25,7 +25,11 @@ const routes = [ ...@@ -25,7 +25,11 @@ const routes = [
component: () => import('@shared/layouts/default-layout.vue'), component: () => import('@shared/layouts/default-layout.vue'),
children: [...CROPPED_ROUTES, ...LOOKUP_ROUTES], children: [...CROPPED_ROUTES, ...LOOKUP_ROUTES],
}, },
...FIXED_ROUTES, {
path: '/proxy',
name: 'proxy',
component: () => import('@account/views/fixed/proxy/index.vue'),
},
...SYSTEM_ROUTES, ...SYSTEM_ROUTES,
] ]
export const router = createRouter({ export const router = createRouter({
......
<template>
<div></div>
</template>
<script lang="ts" setup>
import { useRouter } from 'vue-router'
const $router = useRouter()
$router.push({ name: 'home' })
</script>
<template>
<div></div>
</template>
<script lang="ts" setup>
import { useRouter } from 'vue-router'
const $router = useRouter()
$router.push({ name: 'home' })
</script>
...@@ -4,9 +4,11 @@ ...@@ -4,9 +4,11 @@
{{ consoleName }} {{ consoleName }}
</div> </div>
<el-dropdown v-else class="toggle-menu" placement="bottom-start" trigger="click" @command="handleToggleConsole"> <el-dropdown v-else class="toggle-menu" placement="bottom-start" trigger="click" @command="handleToggleConsole">
<span class="el-dropdown-link flex items-center gap-1"> <span class="el-dropdown-link">
<span>{{ consoleName }}</span> <span>{{ consoleName }}</span>
<g-icon name="ArrowDown" /> <el-icon class="el-icon--right">
<g-icon name="ArrowDown" />
</el-icon>
</span> </span>
<template #dropdown> <template #dropdown>
<el-dropdown-menu> <el-dropdown-menu>
...@@ -21,7 +23,7 @@ ...@@ -21,7 +23,7 @@
:key="child.id" :key="child.id"
class="text-overflow" class="text-overflow"
:class="{ 'is-active': consoleObjectId === child.id }" :class="{ 'is-active': consoleObjectId === child.id }"
:command="child.id" :command="{ parent: item, child }"
> >
<span class="auth-name">{{ child.name }}</span> <span class="auth-name">{{ child.name }}</span>
</el-dropdown-item> </el-dropdown-item>
...@@ -42,12 +44,15 @@ import { GATEWAY_CODE } from '@shared/http/constants' ...@@ -42,12 +44,15 @@ import { GATEWAY_CODE } from '@shared/http/constants'
import { computed } from 'vue' import { computed } from 'vue'
import { useUser } from '@shared/store/modules/user' import { useUser } from '@shared/store/modules/user'
import { useAuth } from '@shared/store/modules/auth' import { useAuth } from '@shared/store/modules/auth'
import { useRoute, useRouter } from 'vue-router'
const $router = useRouter()
const $route = useRoute()
const userStore = useUser() const userStore = useUser()
const authStore = useAuth() const authStore = useAuth()
const consoleList = computed(() => authStore.consoleList) const consoleList = computed(() => authStore.consoleList)
const consoleName = computed(() => authStore.consoleInfo.consoleName) const consoleName = computed(() => authStore.consoleInfo.consoleName)
const consoleObjectId = computed(() => authStore.consoleInfo.consoleObjectId) const consoleObjectId = computed(() => authStore.consoleInfo.consoleObjectId)
const isSuperAdmin = computed(() => userStore.userInfo.id === '1000000') const isSuperAdmin = computed(() => userStore.userInfo.id === '10000000')
const onlyPersonal = computed( const onlyPersonal = computed(
() => () =>
!authStore.consoleList.some(item => { !authStore.consoleList.some(item => {
...@@ -73,7 +78,25 @@ const { ...@@ -73,7 +78,25 @@ const {
ready: computed(() => Boolean(userStore.userInfo.id)), ready: computed(() => Boolean(userStore.userInfo.id)),
}, },
) )
const handleToggleConsole = () => {} // 切换控制台
const handleToggleConsole = ({ parent, child }) => {
if (child.id === authStore.consoleInfo.consoleObjectId) return
authStore.$patch({
consoleInfo: {
consoleName: child.name,
consoleObjectId: child.id,
consoleTypeId: parent.id,
},
})
const reference = {
0: 'account',
1: 'system',
2: 'federation',
3: 'organization',
}
userStore.$reset()
window.location.replace(`${window.location.origin}/${reference[parent.id]}/proxy`)
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import '@/assets/styles/variables.scss'; @import '@/assets/styles/variables.scss';
......
export const FIXED_ROUTES = [ export const FIXED_ROUTES: any[] = []
{
path: '/login',
name: 'login',
component: () => import('@shared/pages/fixed/login/index.vue'),
},
{
path: '/retrieve',
name: 'retrieve',
component: () => import('@shared/pages/fixed/retrieve/index.vue'),
},
{
path: '/register',
name: 'register',
component: () => import('@shared/pages/fixed/register/index.vue'),
},
]
export const SYSTEM_ROUTES = [ export const SYSTEM_ROUTES = [
{ {
path: '/401', path: '/401',
......
...@@ -37,8 +37,7 @@ export const zookeeper = (router: Router): void => { ...@@ -37,8 +37,7 @@ export const zookeeper = (router: Router): void => {
if (isInWhiteList) { if (isInWhiteList) {
next() next()
} else { } else {
// 未登录 window.location.replace(window.location.origin + '/entry/login')
next({ name: 'login' })
} }
} }
}) })
......
...@@ -9,13 +9,14 @@ export const useAuth = defineStore('auth', { ...@@ -9,13 +9,14 @@ export const useAuth = defineStore('auth', {
consoleInfo: { consoleInfo: {
consoleObjectId: '0', consoleObjectId: '0',
consoleName: '个人控制台', consoleName: '个人控制台',
consoleTypeId: '0',
}, },
}), }),
actions: {}, actions: {},
persist: { persist: {
key: 'auth', key: 'auth',
storage: window.sessionStorage, storage: window.sessionStorage,
paths: ['loginInfo', 'consoleList'], paths: ['loginInfo', 'consoleList', 'consoleInfo'],
overwrite: true, overwrite: true,
}, },
}) })
......
...@@ -9,4 +9,5 @@ export type AuthType = { ...@@ -9,4 +9,5 @@ export type AuthType = {
export type ConsoleInfo = { export type ConsoleInfo = {
consoleObjectId: string consoleObjectId: string
consoleName: string consoleName: string
consoleTypeId: string
} }
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
"@organization/*": ["src/organization/*"], "@organization/*": ["src/organization/*"],
"@super/*": ["src/super/*"], "@super/*": ["src/super/*"],
"@system/*": ["src/system/*"], "@system/*": ["src/system/*"],
"@entry/*": ["src/entry/*"],
}, },
"lib": [ "lib": [
"esnext", "esnext",
......
...@@ -112,6 +112,7 @@ module.exports = defineConfig({ ...@@ -112,6 +112,7 @@ module.exports = defineConfig({
.set('@organization', resolve('src/pages/organization')) .set('@organization', resolve('src/pages/organization'))
.set('@super', resolve('src/pages/super')) .set('@super', resolve('src/pages/super'))
.set('@system', resolve('src/pages/system')) .set('@system', resolve('src/pages/system'))
.set('@entry', resolve('src/pages/entry'))
config.plugins.delete('named-chunks') config.plugins.delete('named-chunks')
config.store.set('devtool', 'eval-source-map') config.store.set('devtool', 'eval-source-map')
isProduction && chainProd(config) isProduction && chainProd(config)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment