Skip to content

Commit 49fb2c0

Browse files
author
ssongliu
committed
feat: Add Enterprise Edition redirection logic
1 parent b2501a6 commit 49fb2c0

9 files changed

Lines changed: 58 additions & 42 deletions

File tree

frontend/src/api/interface/auth.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export namespace Login {
4040
panelName: string;
4141
theme: string;
4242
isOffLine: boolean;
43+
isXpackEE: boolean;
4344
needCaptcha: boolean;
4445
passkeySetting: boolean;
4546
}

frontend/src/api/modules/setting.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,24 @@ export const loadLicenseOptions = () => {
4343
export const listNodeOptions = (type: string) => {
4444
return http.post<Array<Setting.NodeItem>>(`/core/nodes/list`, { type: type });
4545
};
46-
export const loadNodeByUser = () => {
47-
return http.get<Array<Setting.NodeItem>>(`/core/xpackee/users/nodes`);
48-
};
49-
5046
export const listAllSimpleNodes = () => {
5147
return http.get<Array<Setting.SimpleNodeItem>>(`/core/nodes/simple/all`);
5248
};
53-
5449
export const getLicenseSmsInfo = () => {
5550
return http.get<Setting.SmsInfo>(`/core/licenses/sms/info`);
5651
};
57-
5852
export const listAppNodes = () => {
5953
return http.get<Array<Setting.NodeAppItem>>(`/core/xpack/nodes/apps/update`, {}, { timeout: TimeoutEnum.T_60S });
6054
};
6155

56+
// xpackee
57+
export const loadNodeByUser = () => {
58+
return http.get<Array<Setting.NodeItem>>(`/core/xpackee/users/nodes`);
59+
};
60+
export const getXpackEELicenseStatus = () => {
61+
return http.get<Setting.LicenseStatus>(`/core/xpackee/licenses/status`);
62+
};
63+
6264
// agent
6365
export const loadBaseDir = () => {
6466
return http.get<string>(`/settings/basedir`);

frontend/src/components/router-button/index.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</template>
2424

2525
<script lang="ts" setup>
26-
import { routerToName, routerToPath } from '@/utils/router';
26+
import { routerToNameWithQuery, routerToPathWithQuery } from '@/utils/router';
2727
import { computed, onMounted, ref } from 'vue';
2828
import { useRouter } from 'vue-router';
2929
@@ -46,8 +46,8 @@ const activeName = ref('');
4646
const handleChange = (label: string) => {
4747
const btn = buttonArray.value.find((btn) => btn.label === label);
4848
if (!btn) return;
49-
if (btn.path) routerToPath(btn.path);
50-
else if (btn.name) routerToName(btn.name);
49+
if (btn.path) routerToPathWithQuery(btn.path, { uncached: 'true' });
50+
else if (btn.name) routerToNameWithQuery(btn.name, { uncached: 'true' });
5151
activeName.value = btn.label;
5252
};
5353

frontend/src/routers/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ router.beforeEach((to, from, next) => {
1111
NProgress.start();
1212
axiosCanceler.removeAllPending();
1313
const globalStore = GlobalStore();
14-
if (!globalStore.isAdmin && to.name === 'Panel') {
14+
if (globalStore.isXpackEE && !globalStore.isAdmin && to.name === 'Panel') {
1515
next({
1616
name: 'Alert',
1717
});

frontend/src/routers/router.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ const xpackEEModules: Record<string, RouteRecordRaw> = import.meta.glob('../xpac
77
modules = { ...modules, ...xpackModules, ...xpackEEModules };
88

99
const homeRouter: RouteRecordRaw = {
10-
path: '/dashboard',
10+
path: '/',
1111
name: 'Home-Menu',
1212
component: Layout,
13-
redirect: '/dashboard',
13+
redirect: '/',
1414
meta: {
1515
keepAlive: true,
1616
title: 'menu.home',
1717
icon: 'p-home',
1818
},
1919
children: [
2020
{
21-
path: '/dashboard',
21+
path: '/',
2222
name: 'home',
2323
component: () => import('@/views/home/index.vue'),
2424
meta: {

frontend/src/store/interface/index.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,37 +27,43 @@ export interface Watermark {
2727
}
2828

2929
export interface GlobalState {
30-
isLoading: boolean;
31-
loadingText: string;
32-
isLogin: boolean;
33-
entrance: string;
3430
language: string; // zh | en | tw
31+
device: DeviceType;
3532
themeConfig: ThemeConfigProp;
33+
// ui
3634
isFullScreen: boolean;
3735
openMenuTabs: boolean;
3836
watermark: Watermark;
3937
watermarkShow: boolean;
40-
isOnRestart: boolean;
38+
isLoading: boolean;
39+
loadingText: string;
40+
// auth
41+
ignoreCaptcha: boolean;
4142
agreeLicense: boolean;
43+
isLogin: boolean;
44+
entrance: string;
45+
// context
4246
hasNewVersion: boolean;
43-
ignoreCaptcha: boolean;
44-
device: DeviceType;
4547
lastFilePath: string;
4648
currentDB: string;
4749
currentPgDB: string;
4850
currentRedisDB: string;
4951
showEntranceWarn: boolean;
5052
defaultNetwork: string;
5153
defaultIO: string;
52-
isFxplay: boolean;
53-
54+
isOnRestart: boolean;
55+
// tags
5456
isAdmin: boolean;
55-
isProductPro: boolean;
57+
isXpackEE: boolean;
5658
isIntl: boolean;
59+
isFxplay: boolean;
60+
isOffLine: boolean;
61+
// license
62+
isProductPro: boolean;
5763
productProExpires: number;
5864
isMasterProductPro: boolean;
59-
isOffLine: boolean;
60-
65+
isXpackEELicensed: boolean;
66+
// multi-node
6167
masterAlias: string;
6268
currentNode: string;
6369
currentNodeAddr: string;

frontend/src/store/modules/global.ts

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,8 @@ import i18n, { setActiveLocale } from '@/lang';
77
const GlobalStore = defineStore({
88
id: 'GlobalState',
99
state: (): GlobalState => ({
10-
isLoading: false,
11-
loadingText: '',
12-
isLogin: false,
13-
entrance: '',
1410
language: '',
11+
device: DeviceType.Desktop,
1512
themeConfig: {
1613
panelName: '',
1714
primary: '#005eeb',
@@ -27,31 +24,40 @@ const GlobalStore = defineStore({
2724
loginBgType: '',
2825
loginBtnLinkColor: '',
2926
},
27+
// ui
28+
isFullScreen: false,
29+
openMenuTabs: false,
3030
watermark: null,
3131
watermarkShow: false,
32-
openMenuTabs: false,
33-
isFullScreen: false,
34-
isOnRestart: false,
32+
isLoading: false,
33+
loadingText: '',
34+
// auth
35+
ignoreCaptcha: true,
3536
agreeLicense: false,
37+
isLogin: false,
38+
entrance: '',
39+
// context
3640
hasNewVersion: false,
37-
ignoreCaptcha: true,
38-
device: DeviceType.Desktop,
3941
lastFilePath: '',
4042
currentDB: '',
4143
currentPgDB: '',
4244
currentRedisDB: '',
4345
showEntranceWarn: true,
4446
defaultNetwork: 'all',
4547
defaultIO: 'all',
46-
isFxplay: false,
47-
48+
isOnRestart: false,
49+
// tags
4850
isAdmin: false,
49-
isProductPro: false,
51+
isXpackEE: false,
5052
isIntl: false,
53+
isFxplay: false,
54+
isOffLine: false,
55+
// license
56+
isProductPro: false,
5157
productProExpires: 0,
5258
isMasterProductPro: false,
53-
isOffLine: false,
54-
59+
isXpackEELicensed: false,
60+
// multi-node
5561
masterAlias: '',
5662
currentNode: 'local',
5763
currentNodeAddr: '',

frontend/src/views/login/components/login-form.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,7 @@ const getSetting = async () => {
586586
isFxplay.value = res.data.isFxplay;
587587
globalStore.isFxplay = isFxplay.value;
588588
globalStore.isOffLine = res.data.isOffLine;
589+
globalStore.isXpackEE = res.data.isXpackEE;
589590
globalStore.ignoreCaptcha = !res.data.needCaptcha;
590591
passkeySetting.value = res.data.passkeySetting;
591592
if (!globalStore.ignoreCaptcha) {

frontend/src/views/setting/index.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<script lang="ts" setup>
1111
import i18n from '@/lang';
1212
import { useGlobalStore } from '@/composables/useGlobalStore';
13-
const { isOffLine, isFxplay, isAdmin } = useGlobalStore();
13+
const { isOffLine, isFxplay, isAdmin, isXpackEE } = useGlobalStore();
1414
1515
const buttons = [
1616
{
@@ -35,7 +35,7 @@ const buttons = [
3535
},
3636
{
3737
label: i18n.global.t('setting.license'),
38-
path: '/settings/license',
38+
path: isXpackEE.value ? '/xpack-ee/license' : '/settings/license',
3939
},
4040
{
4141
label: i18n.global.t('setting.about'),
@@ -50,7 +50,7 @@ onMounted(() => {
5050
if (isFxplay.value) {
5151
buttons.splice(6, 1);
5252
}
53-
if (!isAdmin.value) {
53+
if (isXpackEE.value && !isAdmin.value) {
5454
buttons.splice(0, 1);
5555
buttons.splice(0, 1);
5656
buttons.splice(3, 1);

0 commit comments

Comments
 (0)