Commit a3d99ee4 by User

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

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