feat: layout调整
This commit is contained in:
@ -8,7 +8,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useUserStore } from '@/stores';
|
import { useUserStore } from '@/stores';
|
||||||
import zhCN from '@arco-design/web-vue/es/locale/lang/zh-cn';
|
import zhCN from '@arco-design/web-vue/es/locale/lang/zh-cn';
|
||||||
const store = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
|
||||||
const redTheme = {
|
const redTheme = {
|
||||||
token: {
|
token: {
|
||||||
@ -18,7 +18,7 @@ const redTheme = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const init = () => {
|
const init = () => {
|
||||||
const { isLogin, fetchUserInfo } = store;
|
const { isLogin, fetchUserInfo } = userStore;
|
||||||
if (isLogin) {
|
if (isLogin) {
|
||||||
fetchUserInfo();
|
fetchUserInfo();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
import type { RouteMeta, RouteRecordRaw } from 'vue-router';
|
import type { RouteMeta, RouteRecordRaw } from 'vue-router';
|
||||||
|
|
||||||
import { useAppStore } from '@/stores';
|
import { useAppStore } from '@/stores';
|
||||||
|
import { useSidebarStore } from '@/stores/modules/side-bar';
|
||||||
import { listenerRouteChange } from '@/utils/route-listener';
|
import { listenerRouteChange } from '@/utils/route-listener';
|
||||||
import { openWindow, regexUrl } from '@/utils';
|
import { openWindow, regexUrl } from '@/utils';
|
||||||
import useMenuTree from './use-menu-tree';
|
import useMenuTree from './use-menu-tree';
|
||||||
@ -25,8 +26,8 @@ export default defineComponent({
|
|||||||
const topMenu = computed(() => appStore.topMenu);
|
const topMenu = computed(() => appStore.topMenu);
|
||||||
const openKeys = ref<string[]>([]);
|
const openKeys = ref<string[]>([]);
|
||||||
const selectedKey = ref<string[]>([]);
|
const selectedKey = ref<string[]>([]);
|
||||||
const goto = (item: RouteRecordRaw) => {
|
const sidebarStore = useSidebarStore();
|
||||||
// Open external link
|
const onMenuItemClick = (item: RouteRecordRaw) => {
|
||||||
if (regexUrl.test(item.path)) {
|
if (regexUrl.test(item.path)) {
|
||||||
openWindow(item.path);
|
openWindow(item.path);
|
||||||
selectedKey.value = [item.name as string];
|
selectedKey.value = [item.name as string];
|
||||||
@ -71,6 +72,9 @@ export default defineComponent({
|
|||||||
const keySet = new Set([...menuOpenKeys, ...openKeys.value]);
|
const keySet = new Set([...menuOpenKeys, ...openKeys.value]);
|
||||||
openKeys.value = [...keySet];
|
openKeys.value = [...keySet];
|
||||||
selectedKey.value = [activeMenu || menuOpenKeys[menuOpenKeys.length - 1]];
|
selectedKey.value = [activeMenu || menuOpenKeys[menuOpenKeys.length - 1]];
|
||||||
|
|
||||||
|
// 自动设置 activeMenuId
|
||||||
|
sidebarStore.setActiveMenuIdByRoute(newRoute);
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
const setCollapse = (val: boolean) => {
|
const setCollapse = (val: boolean) => {
|
||||||
@ -83,14 +87,14 @@ export default defineComponent({
|
|||||||
// 跳过没有 name 的菜单项,防止 key 报错
|
// 跳过没有 name 的菜单项,防止 key 报错
|
||||||
if (!element?.name) return;
|
if (!element?.name) return;
|
||||||
|
|
||||||
const icon = element?.meta?.icon ? () => h(element.meta.icon as object) : null;
|
const icon = element?.meta?.icon ? () => h(element?.meta?.icon as object) : null;
|
||||||
if (element.children && element.children.length > 0) {
|
if (element.children && element.children.length > 0) {
|
||||||
nodes.push(
|
nodes.push(
|
||||||
<a-sub-menu
|
<a-sub-menu
|
||||||
key={String(element.name)}
|
key={String(element.name)}
|
||||||
v-slots={{
|
v-slots={{
|
||||||
icon,
|
icon,
|
||||||
title: () => element.meta?.locale || '',
|
title: () => element?.meta?.locale || '',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{travel(element.children)}
|
{travel(element.children)}
|
||||||
@ -98,8 +102,8 @@ export default defineComponent({
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
nodes.push(
|
nodes.push(
|
||||||
<a-menu-item key={String(element.name)} v-slots={{ icon }} onClick={() => goto(element)}>
|
<a-menu-item key={String(element.name)} v-slots={{ icon }} onClick={() => onMenuItemClick(element)}>
|
||||||
{element.meta?.locale || ''}
|
{element?.meta?.locale || ''}
|
||||||
</a-menu-item>,
|
</a-menu-item>,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,17 +4,16 @@
|
|||||||
*/
|
*/
|
||||||
import type { RouteRecordRaw, RouteRecordNormalized } from 'vue-router';
|
import type { RouteRecordRaw, RouteRecordNormalized } from 'vue-router';
|
||||||
|
|
||||||
import { useAppStore } from '@/stores';
|
// import { useAppStore } from '@/stores';
|
||||||
import appClientMenus from '@/router/app-menus';
|
import { appRoutes } from '@/router/routes';
|
||||||
|
import { useSidebarStore } from '@/stores/modules/side-bar';
|
||||||
|
|
||||||
export default function useMenuTree() {
|
export default function useMenuTree() {
|
||||||
const appStore = useAppStore();
|
// const appStore = useAppStore();
|
||||||
|
const sidebarStore = useSidebarStore();
|
||||||
const appRoute = computed(() => {
|
const appRoute = computed(() => {
|
||||||
if (appStore.menuFromServer) {
|
const _filterRoutes = appRoutes.filter((v) => v.meta.id === sidebarStore.activeMenuId);
|
||||||
// return appClientMenus.concat(toRaw(appStore.appAsyncMenus));
|
return _filterRoutes;
|
||||||
return toRaw(appStore.appAsyncMenus);
|
|
||||||
}
|
|
||||||
return appClientMenus;
|
|
||||||
});
|
});
|
||||||
const menuTree = computed(() => {
|
const menuTree = computed(() => {
|
||||||
const copyRouter = cloneDeep(appRoute.value) as RouteRecordNormalized[];
|
const copyRouter = cloneDeep(appRoute.value) as RouteRecordNormalized[];
|
||||||
|
|||||||
@ -4,9 +4,32 @@ import { IconExport, IconFile, IconCaretDown } from '@arco-design/web-vue/es/ico
|
|||||||
import { fetchMenusTree } from '@/api/all';
|
import { fetchMenusTree } from '@/api/all';
|
||||||
import { handleUserLogout } from '@/utils/user';
|
import { handleUserLogout } from '@/utils/user';
|
||||||
import { fetchLogOut } from '@/api/all/login';
|
import { fetchLogOut } from '@/api/all/login';
|
||||||
|
import { useSidebarStore } from '@/stores/modules/side-bar';
|
||||||
|
import { MENU_GROUP_IDS } from '@/router/constants';
|
||||||
|
import router from '@/router';
|
||||||
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
|
interface MenuItem {
|
||||||
|
name: string;
|
||||||
|
id: number;
|
||||||
|
children: Array<{
|
||||||
|
name: string;
|
||||||
|
}>;
|
||||||
|
}
|
||||||
|
|
||||||
|
const lists = ref<MenuItem[]>([]);
|
||||||
|
const sidebarStore = useSidebarStore();
|
||||||
|
const route = useRoute();
|
||||||
|
|
||||||
|
const selectedKey = computed(() => {
|
||||||
|
// 判断是否为工作台页面(假设路由名为 'Home' 或 path 为 '/')
|
||||||
|
if (route.name === 'Home' || route.path === '/') {
|
||||||
|
return [`${MENU_GROUP_IDS.WORK_BENCH_ID}`];
|
||||||
|
}
|
||||||
|
// 其他页面,activeMenuId 作为 key
|
||||||
|
return [String(sidebarStore.activeMenuId)];
|
||||||
|
});
|
||||||
|
|
||||||
const lists = ref([]);
|
|
||||||
const router = useRouter();
|
|
||||||
const clickExit = async () => {
|
const clickExit = async () => {
|
||||||
const { code } = await fetchLogOut();
|
const { code } = await fetchLogOut();
|
||||||
if (code === 200) {
|
if (code === 200) {
|
||||||
@ -29,26 +52,26 @@ const setServerMenu = () => {
|
|||||||
};
|
};
|
||||||
const handleSelect = (index: any) => {
|
const handleSelect = (index: any) => {
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
router.push('/workplace');
|
router.push('/');
|
||||||
} else {
|
} else {
|
||||||
router.push('/dataEngine/hotTranslation');
|
router.push('/dataEngine/hotTranslation');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDopdownClick = (index: any, ind: any) => {
|
const handleDopdownClick = (index: any, ind: any) => {
|
||||||
let children = lists.value[index].children;
|
const { children } = lists.value[index];
|
||||||
let indPath = children[ind];
|
const indPath = children[ind] as any;
|
||||||
if (indPath.name == '行业热门话题洞察') {
|
if (indPath.name === '行业热门话题洞察') {
|
||||||
router.push('/dataEngine/hotTranslation');
|
router.push('/dataEngine/hotTranslation');
|
||||||
} else if (indPath.name == '行业词云') {
|
} else if (indPath.name === '行业词云') {
|
||||||
router.push('/dataEngine/hotCloud');
|
router.push('/dataEngine/hotCloud');
|
||||||
} else if (indPath.name == '行业关键词动向') {
|
} else if (indPath.name === '行业关键词动向') {
|
||||||
router.push('/dataEngine/keyWord');
|
router.push('/dataEngine/keyWord');
|
||||||
} else if (indPath.name == '用户痛点观察') {
|
} else if (indPath.name === '用户痛点观察') {
|
||||||
router.push('/dataEngine/userPainPoints');
|
router.push('/dataEngine/userPainPoints');
|
||||||
} else if (indPath.name == '重点品牌动向') {
|
} else if (indPath.name === '重点品牌动向') {
|
||||||
router.push('/dataEngine/keyBrandMovement');
|
router.push('/dataEngine/keyBrandMovement');
|
||||||
} else if (indPath.name == '用户画像') {
|
} else if (indPath.name === '用户画像') {
|
||||||
router.push('/dataEngine/userPersona');
|
router.push('/dataEngine/userPersona');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -63,11 +86,15 @@ const handleDopdownClick = (index: any, ind: any) => {
|
|||||||
</div>
|
</div>
|
||||||
<div class="center-side">
|
<div class="center-side">
|
||||||
<div class="menu-demo">
|
<div class="menu-demo">
|
||||||
<a-menu mode="horizontal" :default-selected-keys="['1']">
|
<a-menu
|
||||||
<a-menu-item key="1" @click="handleSelect(0)">
|
mode="horizontal"
|
||||||
|
:selected-keys="selectedKey"
|
||||||
|
:default-selected-keys="[`${MENU_GROUP_IDS.WORK_BENCH_ID}`]"
|
||||||
|
>
|
||||||
|
<a-menu-item :key="`${MENU_GROUP_IDS.WORK_BENCH_ID}`" @click="handleSelect(0)">
|
||||||
<view>工作台</view>
|
<view>工作台</view>
|
||||||
</a-menu-item>
|
</a-menu-item>
|
||||||
<a-menu-item v-for="(item, index) in lists" :key="index + 2">
|
<a-menu-item v-for="(item, index) in lists" :key="String(item.id)">
|
||||||
<a-dropdown :popup-max-height="false">
|
<a-dropdown :popup-max-height="false">
|
||||||
<a-button>{{ item.name }}<icon-caret-down /></a-button>
|
<a-button>{{ item.name }}<icon-caret-down /></a-button>
|
||||||
<template #content>
|
<template #content>
|
||||||
|
|||||||
@ -1,6 +1,10 @@
|
|||||||
import { appRoutes, appExternalRoutes } from '../routes';
|
/*
|
||||||
|
* @Author: RenXiaoDong
|
||||||
|
* @Date: 2025-06-19 01:45:53
|
||||||
|
*/
|
||||||
|
import { appRoutes } from '../routes';
|
||||||
|
|
||||||
const mixinRoutes = [...appRoutes, ...appExternalRoutes];
|
const mixinRoutes = [...appRoutes];
|
||||||
|
|
||||||
const appClientMenus = mixinRoutes.map((el) => {
|
const appClientMenus = mixinRoutes.map((el) => {
|
||||||
const { name, path, meta, redirect, children } = el;
|
const { name, path, meta, redirect, children } = el;
|
||||||
|
|||||||
@ -16,3 +16,9 @@ export const DEFAULT_ROUTE = {
|
|||||||
name: DEFAULT_ROUTE_NAME,
|
name: DEFAULT_ROUTE_NAME,
|
||||||
fullPath: '/',
|
fullPath: '/',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const MENU_GROUP_IDS = {
|
||||||
|
DATA_ENGINE_ID: 1,
|
||||||
|
MANAGEMENT_ID: -1,
|
||||||
|
WORK_BENCH_ID: -99,
|
||||||
|
};
|
||||||
|
|||||||
@ -24,8 +24,8 @@ const router = createRouter({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/workplace',
|
path: '/',
|
||||||
name: 'workplace',
|
name: 'Home',
|
||||||
component: () => import('@/views/components/workplace'),
|
component: () => import('@/views/components/workplace'),
|
||||||
meta: {
|
meta: {
|
||||||
hideSidebar: true,
|
hideSidebar: true,
|
||||||
@ -50,8 +50,7 @@ const router = createRouter({
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
name: 'Home',
|
name: '',
|
||||||
redirect: '/dataEngine/hotTranslation',
|
|
||||||
children: [...appRoutes, REDIRECT_MAIN, NOT_FOUND_ROUTE],
|
children: [...appRoutes, REDIRECT_MAIN, NOT_FOUND_ROUTE],
|
||||||
meta: {
|
meta: {
|
||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
import type { RouteRecordNormalized } from 'vue-router';
|
import type { RouteRecordNormalized } from 'vue-router';
|
||||||
|
|
||||||
const modules = import.meta.glob('./modules/*.ts', { eager: true });
|
const modules = import.meta.glob('./modules/*.ts', { eager: true });
|
||||||
const externalModules = import.meta.glob('./externalModules/*.ts', {
|
// const externalModules = import.meta.glob('./externalModules/*.ts', {
|
||||||
eager: true,
|
// eager: true,
|
||||||
});
|
// });
|
||||||
|
|
||||||
function formatModules(_modules: any, result: RouteRecordNormalized[]) {
|
function formatModules(_modules: any, result: RouteRecordNormalized[]) {
|
||||||
Object.keys(_modules).forEach((key) => {
|
Object.keys(_modules).forEach((key) => {
|
||||||
@ -17,4 +17,4 @@ function formatModules(_modules: any, result: RouteRecordNormalized[]) {
|
|||||||
|
|
||||||
export const appRoutes: RouteRecordNormalized[] = formatModules(modules, []);
|
export const appRoutes: RouteRecordNormalized[] = formatModules(modules, []);
|
||||||
|
|
||||||
export const appExternalRoutes: RouteRecordNormalized[] = formatModules(externalModules, []);
|
// export const appExternalRoutes: RouteRecordNormalized[] = formatModules(externalModules, []);
|
||||||
|
|||||||
@ -1,15 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* @Author: RenXiaoDong
|
||||||
|
* @Date: 2025-06-23 06:39:28
|
||||||
|
*/
|
||||||
import { IconBookmark } from '@arco-design/web-vue/es/icon';
|
import { IconBookmark } from '@arco-design/web-vue/es/icon';
|
||||||
import type { AppRouteRecordRaw } from '../types';
|
import type { AppRouteRecordRaw } from '../types';
|
||||||
|
import { MENU_GROUP_IDS } from '@/router/constants';
|
||||||
|
|
||||||
const COMPONENTS: AppRouteRecordRaw = {
|
const COMPONENTS: AppRouteRecordRaw = {
|
||||||
path: 'dataEngine',
|
path: 'dataEngine',
|
||||||
name: 'dataEngine',
|
name: 'dataEngine',
|
||||||
|
redirect: 'dataEngine/hotTranslation',
|
||||||
meta: {
|
meta: {
|
||||||
locale: '全域数据引擎',
|
locale: '全域数据引擎',
|
||||||
icon: IconBookmark,
|
icon: IconBookmark,
|
||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
roles: ['*'],
|
roles: ['*'],
|
||||||
requiresSidebar: true,
|
requiresSidebar: true,
|
||||||
|
id: MENU_GROUP_IDS.DATA_ENGINE_ID,
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -4,16 +4,19 @@
|
|||||||
*/
|
*/
|
||||||
import { IconBookmark } from '@arco-design/web-vue/es/icon';
|
import { IconBookmark } from '@arco-design/web-vue/es/icon';
|
||||||
import type { AppRouteRecordRaw } from '../types';
|
import type { AppRouteRecordRaw } from '../types';
|
||||||
|
import { MENU_GROUP_IDS } from '@/router/constants';
|
||||||
|
|
||||||
const COMPONENTS: AppRouteRecordRaw = {
|
const COMPONENTS: AppRouteRecordRaw = {
|
||||||
path: 'management',
|
path: 'management',
|
||||||
name: 'management',
|
name: 'management',
|
||||||
|
redirect: 'management/person',
|
||||||
meta: {
|
meta: {
|
||||||
locale: '管理中心',
|
locale: '管理中心',
|
||||||
icon: IconBookmark,
|
icon: IconBookmark,
|
||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
roles: ['*'],
|
roles: ['*'],
|
||||||
requiresSidebar: true,
|
requiresSidebar: true,
|
||||||
|
id: MENU_GROUP_IDS.MANAGEMENT_ID,
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,6 +1,11 @@
|
|||||||
|
/*
|
||||||
|
* @Author: RenXiaoDong
|
||||||
|
* @Date: 2025-06-19 01:45:53
|
||||||
|
*/
|
||||||
import type { RouteMeta, NavigationGuard, RouteComponent } from 'vue-router';
|
import type { RouteMeta, NavigationGuard, RouteComponent } from 'vue-router';
|
||||||
|
|
||||||
export interface AppRouteRecordRaw {
|
export interface AppRouteRecordRaw {
|
||||||
|
id?: number;
|
||||||
path: string;
|
path: string;
|
||||||
name?: string | symbol;
|
name?: string | symbol;
|
||||||
meta?: RouteMeta;
|
meta?: RouteMeta;
|
||||||
|
|||||||
56
src/stores/modules/side-bar/index.ts
Normal file
56
src/stores/modules/side-bar/index.ts
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* @Author: RenXiaoDong
|
||||||
|
* @Date: 2025-06-23 22:13:30
|
||||||
|
*/
|
||||||
|
import { defineStore } from 'pinia';
|
||||||
|
import { MENU_GROUP_IDS } from '@/router/constants';
|
||||||
|
import { appRoutes } from '@/router/routes';
|
||||||
|
import type { RouteLocationNormalized } from 'vue-router';
|
||||||
|
|
||||||
|
const { DATA_ENGINE_ID, MANAGEMENT_ID } = MENU_GROUP_IDS;
|
||||||
|
|
||||||
|
interface sidebarState {
|
||||||
|
activeMenuId: number | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useSidebarStore = defineStore('sidebar', {
|
||||||
|
state: (): sidebarState => ({
|
||||||
|
activeMenuId: null,
|
||||||
|
}),
|
||||||
|
actions: {
|
||||||
|
clearActiveMenuId() {
|
||||||
|
this.activeMenuId = DATA_ENGINE_ID;
|
||||||
|
},
|
||||||
|
setActiveMenuId(id: number) {
|
||||||
|
this.activeMenuId = id;
|
||||||
|
},
|
||||||
|
// 根据当前路由自动设置 activeMenuId
|
||||||
|
setActiveMenuIdByRoute(route: RouteLocationNormalized) {
|
||||||
|
// console.log('setActiveMenuIdByRoute ');
|
||||||
|
// 查找当前路由所属的菜单组
|
||||||
|
const findMenuGroup = (routes: any[]): number | null => {
|
||||||
|
for (const routeItem of routes) {
|
||||||
|
// 检查子路由
|
||||||
|
if (routeItem.children && routeItem.children.length > 0) {
|
||||||
|
// 检查当前路由是否是这个父路由的子路由
|
||||||
|
const isChildRoute = routeItem.children.some((child: any) => child.name === route.name);
|
||||||
|
if (isChildRoute) {
|
||||||
|
return routeItem.meta?.id || null;
|
||||||
|
}
|
||||||
|
// 递归检查更深层的子路由
|
||||||
|
const childResult = findMenuGroup(routeItem.children);
|
||||||
|
if (childResult !== null) {
|
||||||
|
return routeItem.meta?.id || childResult;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
const menuId = findMenuGroup(appRoutes);
|
||||||
|
if (menuId !== null) {
|
||||||
|
this.activeMenuId = menuId;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
@ -6,6 +6,7 @@ import router from '@/router';
|
|||||||
|
|
||||||
import { useUserStore } from '@/stores';
|
import { useUserStore } from '@/stores';
|
||||||
import { useEnterpriseStore } from '@/stores/modules/enterprise';
|
import { useEnterpriseStore } from '@/stores/modules/enterprise';
|
||||||
|
import { useSidebarStore } from '@/stores/modules/side-bar';
|
||||||
|
|
||||||
// 登录
|
// 登录
|
||||||
export function goUserLogin(query?: any) {
|
export function goUserLogin(query?: any) {
|
||||||
@ -24,10 +25,12 @@ export function handleUserHome() {
|
|||||||
|
|
||||||
export function handleUserLogout() {
|
export function handleUserLogout() {
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const store = useEnterpriseStore();
|
const enterpriseStore = useEnterpriseStore();
|
||||||
|
const sidebarStore = useSidebarStore();
|
||||||
|
|
||||||
userStore.deleteToken();
|
userStore.deleteToken();
|
||||||
store.clearEnterpriseInfo();
|
enterpriseStore.clearEnterpriseInfo();
|
||||||
|
sidebarStore.clearActiveMenuId();
|
||||||
|
|
||||||
goUserLogin();
|
goUserLogin();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,12 +54,7 @@
|
|||||||
>
|
>
|
||||||
联系客服
|
联系客服
|
||||||
</a-button>
|
</a-button>
|
||||||
<a-popconfirm
|
<a-popconfirm focusLock title="试用产品" content="确定试用该产品吗?" @ok="handleTrial(props.product.id)">
|
||||||
focusLock
|
|
||||||
title="试用产品"
|
|
||||||
content="确定试用该产品吗?"
|
|
||||||
@ok="handleTrial(props.product.id)"
|
|
||||||
>
|
|
||||||
<a-button v-if="props.product.status === Status.Disable" class="outline-button" type="outline">
|
<a-button v-if="props.product.status === Status.Disable" class="outline-button" type="outline">
|
||||||
免费试用7天
|
免费试用7天
|
||||||
</a-button>
|
</a-button>
|
||||||
@ -74,14 +69,14 @@ import { now } from '@vueuse/core';
|
|||||||
import { trialProduct } from '@/api/all';
|
import { trialProduct } from '@/api/all';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import CustomerServiceModal from '@/components/customer-service-modal.vue';
|
import CustomerServiceModal from '@/components/customer-service-modal.vue';
|
||||||
|
import { appRoutes } from '@/router/routes';
|
||||||
|
import { useSidebarStore } from '@/stores/modules/side-bar';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
product: Product;
|
product: Product;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const emit = defineEmits(['refresh']);
|
const emit = defineEmits(['refresh']);
|
||||||
const visible = ref(false);
|
const sidebarStore = useSidebarStore();
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
enum Status {
|
enum Status {
|
||||||
Disable = 0, // 禁用
|
Disable = 0, // 禁用
|
||||||
@ -101,6 +96,9 @@ interface Product {
|
|||||||
expired_at?: number;
|
expired_at?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const visible = ref(false);
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
const handleTrial = async (id: any) => {
|
const handleTrial = async (id: any) => {
|
||||||
await trialProduct(id);
|
await trialProduct(id);
|
||||||
AMessage.success('试用成功!');
|
AMessage.success('试用成功!');
|
||||||
@ -108,7 +106,11 @@ const handleTrial = async (id: any) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const gotoModule = (menuId: number) => {
|
const gotoModule = (menuId: number) => {
|
||||||
router.push({ name: 'dataEngine' });
|
const _target = appRoutes.find((v) => v.meta.id === menuId);
|
||||||
|
if (_target) {
|
||||||
|
console.log({ _target });
|
||||||
|
router.push({ name: _target.name });
|
||||||
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
|
|||||||
Reference in New Issue
Block a user