Commit a3d99ee4 by User

登录模块根据Parameters配置切换登录地址

parent 7d94604c
<!doctype html> <!doctype html>
<html lang="zh-cmn-Hans"> <html lang="zh-cmn-Hans">
<head> <head>
<meta name="buildTime" content="2025-04-08 13:46:49"> <meta name="buildTime" content="2025-04-15 09:32:40">
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<link rel="icon" href="/favicon.svg" /> <link rel="icon" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="color-scheme" content="light dark" /> <meta name="color-scheme" content="light dark" />
<title>VueDashboard</title> <title>VueDashboard</title>
<script type="module" crossorigin src="/Content/VueDashboardUi/VueDashboard1/assets/index-HfdlqkRG.js"></script> <script type="module" crossorigin src="/Content/VueDashboardUi/VueDashboard1/assets/index-DDJd5Man.js"></script>
<link rel="stylesheet" crossorigin href="/Content/VueDashboardUi/VueDashboard1/assets/index-DhhgO4aJ.css"> <link rel="stylesheet" crossorigin href="/Content/VueDashboardUi/VueDashboard1/assets/index-DhhgO4aJ.css">
</head> </head>
<body> <body>
......
import { request } from '../request'; import { request } from '../request';
// 获取登录URL
function getLoginUrl(): Promise<string> {
return new Promise(resolve => {
setTimeout(() => {
try {
const parameters = window.uiGlobalConfig?.Parameters;
if (!parameters) {
resolve('/auth/kivii');
return;
}
const decodedStr = parameters.replace(/&quot;/g, '"');
const parsedParams = JSON.parse(decodedStr);
if (!parsedParams.loginUrl) {
resolve('/auth/kivii');
return;
}
resolve(parsedParams.loginUrl);
} catch (error) {
resolve('/auth/kivii');
}
}, 50);
});
}
/** /**
* Login * Login
* *
...@@ -7,13 +32,15 @@ import { request } from '../request'; ...@@ -7,13 +32,15 @@ import { request } from '../request';
* @param password Password * @param password Password
*/ */
export function fetchLogin(userName: string, password: string) { export function fetchLogin(userName: string, password: string) {
return request<Api.Auth.LoginToken>({ return getLoginUrl().then(loginUrl => {
url: '/auth/kivii', return request<Api.Auth.LoginToken>({
method: 'post', url: loginUrl,
data: { method: 'post',
userName, data: {
password userName,
} password
}
});
}); });
} }
......
...@@ -44,7 +44,7 @@ export const themeSettings: App.Theme.ThemeSetting = { ...@@ -44,7 +44,7 @@ export const themeSettings: App.Theme.ThemeSetting = {
mixChildMenuWidth: 200 mixChildMenuWidth: 200
}, },
footer: { footer: {
visible: true, visible: false,
fixed: false, fixed: false,
height: 48, height: 48,
right: true right: true
......
<script setup lang="ts"> <script setup lang="ts">
import { computed, reactive } from 'vue'; import { computed, reactive } from 'vue';
import { $t } from '@/locales'; import { $t } from '@/locales';
import { loginModuleRecord } from '@/constants/app'; // import { loginModuleRecord } from '@/constants/app';
import { useRouterPush } from '@/hooks/common/router'; import { useRouterPush } from '@/hooks/common/router';
import { useFormRules, useNaiveForm } from '@/hooks/common/form'; import { useFormRules, useNaiveForm } from '@/hooks/common/form';
import { useAuthStore } from '@/store/modules/auth'; import { useAuthStore } from '@/store/modules/auth';
...@@ -39,39 +39,39 @@ async function handleSubmit() { ...@@ -39,39 +39,39 @@ async function handleSubmit() {
await authStore.login(model.userName, model.password); await authStore.login(model.userName, model.password);
} }
type AccountKey = 'super' | 'admin' | 'user'; // type AccountKey = 'super' | 'admin' | 'user';
interface Account { // interface Account {
key: AccountKey; // key: AccountKey;
label: string; // label: string;
userName: string; // userName: string;
password: string; // password: string;
} // }
const accounts = computed<Account[]>(() => [ // const accounts = computed<Account[]>(() => [
{ // {
key: 'super', // key: 'super',
label: $t('page.login.pwdLogin.superAdmin'), // label: $t('page.login.pwdLogin.superAdmin'),
userName: 'Super', // userName: 'Super',
password: '123456' // password: '123456'
}, // },
{ // {
key: 'admin', // key: 'admin',
label: $t('page.login.pwdLogin.admin'), // label: $t('page.login.pwdLogin.admin'),
userName: 'Admin', // userName: 'Admin',
password: '123456' // password: '123456'
}, // },
{ // {
key: 'user', // key: 'user',
label: $t('page.login.pwdLogin.user'), // label: $t('page.login.pwdLogin.user'),
userName: 'User', // userName: 'User',
password: '123456' // password: '123456'
} // }
]); // ]);
async function handleAccountLogin(account: Account) { // async function handleAccountLogin(account: Account) {
await authStore.login(account.userName, account.password); // await authStore.login(account.userName, account.password);
} // }
</script> </script>
<template> <template>
......
<script setup lang="ts"> <script setup lang="ts">
import { onActivated, onDeactivated, computed, watch, ref, onMounted, onUnmounted } from 'vue'; import { computed, onActivated, onDeactivated, onMounted, onUnmounted, ref, watch } from 'vue';
import { useAppStore } from '@/store/modules/app'; import { useAppStore } from '@/store/modules/app';
import { useRouteStore } from '@/store/modules/route'; import { useRouteStore } from '@/store/modules/route';
import IframePage from '@/views/_builtin/iframe-page/[url].vue';
import { getDefaultMenu } from '@/service/api';
import HeaderBanner from './modules/header-banner.vue'; import HeaderBanner from './modules/header-banner.vue';
import CardData from './modules/card-data.vue'; import CardData from './modules/card-data.vue';
import LineChart from './modules/line-chart.vue'; import LineChart from './modules/line-chart.vue';
import PieChart from './modules/pie-chart.vue'; import PieChart from './modules/pie-chart.vue';
import ProjectNews from './modules/project-news.vue'; import ProjectNews from './modules/project-news.vue';
import CreativityBanner from './modules/creativity-banner.vue'; import CreativityBanner from './modules/creativity-banner.vue';
import IframePage from '@/views/_builtin/iframe-page/[url].vue';
import { getDefaultMenu } from '@/service/api';
const appStore = useAppStore(); const appStore = useAppStore();
const routeStore = useRouteStore(); const routeStore = useRouteStore();
...@@ -32,7 +32,7 @@ const isExtjsRootReady = ref(false); ...@@ -32,7 +32,7 @@ const isExtjsRootReady = ref(false);
// 检查 extjs-root 是否存在 // 检查 extjs-root 是否存在
const checkExtjsRoot = () => { const checkExtjsRoot = () => {
const extjsRoot = document.getElementById('extjs-root'); const extjsRoot = document.getElementById('extjs-root');
isExtjsRootReady.value = !!extjsRoot; isExtjsRootReady.value = Boolean(extjsRoot);
if (!extjsRoot) { if (!extjsRoot) {
setTimeout(checkExtjsRoot, 100); // 继续检查 setTimeout(checkExtjsRoot, 100); // 继续检查
} }
...@@ -50,44 +50,49 @@ onDeactivated(() => { ...@@ -50,44 +50,49 @@ onDeactivated(() => {
isActive.value = false; isActive.value = false;
}); });
// 监听 MenuRoot 变化 // 监听 MenuRoot 变化
watch(menuRoot, async (newValue) => { watch(
// console.log('MenuRoot updated:', newValue); menuRoot,
if (newValue) { async newValue => {
const { data } = await getDefaultMenu( if (newValue) {
`/Restful/Kivii.Basic.Entities.Menu/Query.json?ParentKvid=${newValue.Kvid}&isRelateFunction=true` const { data } = await getDefaultMenu(
); `/Restful/Kivii.Basic.Entities.Menu/Query.json?ParentKvid=${newValue.Kvid}&isRelateFunction=true`
// console.log('Menu data:', data); );
if (data?.Results && data?.Results.length > 0) { if (data?.Results && data?.Results.length > 0) {
const autoStartItem = data?.Results.find(item => { const autoStartItem = data?.Results.find(item => {
try { let params: { AutoStartup?: boolean | string } = {};
const params = JSON.parse(item.Parameters || '{}'); try {
return params.AutoStartup === 'true'; if (item.Parameters) {
} catch (error) { params = JSON.parse(item.Parameters);
// console.error('Parameters parse error:', error); }
return false; // 确保 AutoStartup 属性存在
} params.AutoStartup ||= false;
}); return params.AutoStartup === true || params.AutoStartup === 'true';
} catch (error) {
params.AutoStartup = false;
return false;
}
});
if (autoStartItem) { if (autoStartItem) {
// 设置 iframe 属性 const type = autoStartItem.Type || 'Unsupported';
autoStartProps.value = { autoStartProps.value = {
type: autoStartItem.Type, type,
kvid: autoStartItem.Kvid, kvid: autoStartItem.Kvid || '',
url: '' url: ''
}; };
// console.log('autoStartProps:', autoStartProps.value); }
} }
} }
} },
}, { immediate: true }); { immediate: true }
);
const gap = computed(() => (appStore.isMobile ? 0 : 16)); const gap = computed(() => (appStore.isMobile ? 0 : 16));
</script> </script>
<template> <template>
<NSpace vertical :size="16"> <NSpace vertical :size="16">
<HeaderBanner /> <HeaderBanner />
<NGrid :x-gap="gap" :y-gap="16" responsive="screen" item-responsive> <NGrid :x-gap="gap" :y-gap="16" responsive="screen" item-responsive>
<NGi span="24 s:24 m:14"> <NGi span="24 s:24 m:14">
...@@ -100,10 +105,13 @@ const gap = computed(() => (appStore.isMobile ? 0 : 16)); ...@@ -100,10 +105,13 @@ const gap = computed(() => (appStore.isMobile ? 0 : 16));
<!-- 添加 IframePage 组件,增加 isExtjsRootReady 检查 --> <!-- 添加 IframePage 组件,增加 isExtjsRootReady 检查 -->
<template v-if="isExtjsRootReady"> <template v-if="isExtjsRootReady">
<div v-show="isActive" :id="extjsContainerId" style="width: 100%; height: 100%"> <div v-show="isActive" :id="extjsContainerId" style="width: 100%; height: 100%">
<IframePage v-if="autoStartProps.type" :type="autoStartProps.type" :kvid="autoStartProps.kvid" <IframePage
:url="autoStartProps.url" /> v-if="autoStartProps.type"
:type="autoStartProps.type"
:kvid="autoStartProps.kvid"
:url="autoStartProps.url"
/>
</div> </div>
</template> </template>
</NSpace> </NSpace>
</template> </template>
......
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