feat: 工作空间.

This commit is contained in:
lijiahangmax
2023-12-05 00:01:18 +08:00
parent f26b90ba34
commit c5120463d9
6 changed files with 99 additions and 26 deletions

View File

@@ -0,0 +1,41 @@
<template>
<a-layout class="host-workspace-layout">
<!-- 页面 -->
<a-layout-content>
<!-- 水印 -->
<a-watermark :grayscale="true"
:alpha=".6"
:z-index="9999"
style="width: 100%; height: 100%;"
:content="userStore.username || ''">
<PageLayout />
</a-watermark>
</a-layout-content>
</a-layout>
</template>
<script lang="ts">
export default {
name: 'hos-workspace-layout'
};
</script>
<script lang="ts" setup>
import { useUserStore } from '@/store';
import PageLayout from './page-layout.vue';
const userStore = useUserStore();
</script>
<style lang="less" scoped>
.host-workspace-layout {
height: 100vh;
width: 100%;
.arco-layout-content {
height: 100%;
width: 100%;
}
}
</style>

View File

@@ -7,28 +7,23 @@ import {
NOT_FOUND_ROUTER_NAME, NOT_FOUND_ROUTER_NAME,
} from '@/router/constants'; } from '@/router/constants';
// 默认布局
export const DEFAULT_LAYOUT = () => import('@/layout/default-layout.vue'); export const DEFAULT_LAYOUT = () => import('@/layout/default-layout.vue');
/** // 根页面
* 根页面
*/
export const ROOT_ROUTER: RouteRecordRaw = { export const ROOT_ROUTER: RouteRecordRaw = {
path: '/', path: '/',
redirect: DEFAULT_ROUTE_FULL_PATH, redirect: DEFAULT_ROUTE_FULL_PATH,
}; };
/** // 登录页面
* 登录页面
*/
export const LOGIN_ROUTER: RouteRecordRaw = { export const LOGIN_ROUTER: RouteRecordRaw = {
path: '/login', path: '/login',
name: LOGIN_ROUTE_NAME, name: LOGIN_ROUTE_NAME,
component: () => import('@/views/authentication/login/index.vue'), component: () => import('@/views/authentication/login/index.vue'),
}; };
/** // 重定向页面
* 重定向页面
*/
export const REDIRECT_ROUTER: RouteRecordRaw = { export const REDIRECT_ROUTER: RouteRecordRaw = {
path: '/redirect', path: '/redirect',
name: 'redirectWrapper', name: 'redirectWrapper',
@@ -49,18 +44,14 @@ export const REDIRECT_ROUTER: RouteRecordRaw = {
], ],
}; };
/** // 403 页面
* 403 页面
*/
export const FORBIDDEN_ROUTE: RouteRecordRaw = { export const FORBIDDEN_ROUTE: RouteRecordRaw = {
path: '/403', path: '/403',
name: FORBIDDEN_ROUTER_NAME, name: FORBIDDEN_ROUTER_NAME,
component: () => import('@/views/base/status/forbidden/index.vue'), component: () => import('@/views/base/status/forbidden/index.vue'),
}; };
/** // 404 页面
* 404 页面
*/
export const NOT_FOUND_ROUTE: RouteRecordRaw = { export const NOT_FOUND_ROUTE: RouteRecordRaw = {
// path: '/:pathMatch(.*)*', // path: '/:pathMatch(.*)*',
path: '/404', path: '/404',

View File

@@ -3,6 +3,10 @@ import type { RouteRecordNormalized } from 'vue-router';
// 应用模块 // 应用模块
const modules = import.meta.glob('./modules/*.ts', { eager: true }); const modules = import.meta.glob('./modules/*.ts', { eager: true });
// 应用路由
export const appRoutes: RouteRecordNormalized[] = formatModules(modules, []);
// 格式化模块
function formatModules(_modules: any, result: RouteRecordNormalized[]) { function formatModules(_modules: any, result: RouteRecordNormalized[]) {
Object.keys(_modules).forEach((key) => { Object.keys(_modules).forEach((key) => {
const defaultModule = _modules[key].default; const defaultModule = _modules[key].default;
@@ -14,8 +18,3 @@ function formatModules(_modules: any, result: RouteRecordNormalized[]) {
}); });
return result; return result;
} }
/**
* 应用路由
*/
export const appRoutes: RouteRecordNormalized[] = formatModules(modules, []);

View File

@@ -0,0 +1,16 @@
import type { AppRouteRecordRaw } from '../types';
const DASHBOARD: AppRouteRecordRaw = {
name: 'hostWorkspace',
path: '/host-workspace',
component: () => import('@/layout/host-workspace-layout.vue'),
children: [
{
name: 'hostTerminal',
path: '/host-workspace/terminal',
component: () => import('@/views/host-workspace/terminal/index.vue'),
},
],
};
export default DASHBOARD;

View File

@@ -0,0 +1,21 @@
<template>
<div>
<div></div>
<div></div>
<div></div>
</div>
</template>
<script lang="ts">
export default {
name: 'index'
};
</script>
<script lang="ts" setup>
</script>
<style lang="less" scoped>
</style>

View File

@@ -236,6 +236,7 @@
} }
} }
} }
cacheStore.reset('menus');
Message.success('删除成功'); Message.success('删除成功');
} catch (e) { } catch (e) {
} finally { } finally {
@@ -245,12 +246,12 @@
// 添加后回调 // 添加后回调
const addedCallback = () => { const addedCallback = () => {
loadMenuData(); loadMenuData(true);
}; };
// 更新后回调 // 更新后回调
const updatedCallback = () => { const updatedCallback = () => {
loadMenuData(); loadMenuData(true);
}; };
defineExpose({ defineExpose({
@@ -258,11 +259,15 @@
}); });
// 加载菜单 // 加载菜单
const loadMenuData = async () => { const loadMenuData = async (all: any = undefined) => {
try { try {
setFetchLoading(true); setFetchLoading(true);
const { data } = await getMenuList(formModel); const { data } = await getMenuList(all === true ? {} : formModel);
tableRenderData.value = data as MenuQueryResponse[]; tableRenderData.value = data as MenuQueryResponse[];
// 重设缓存
if (all) {
cacheStore.set('menus', data);
}
} catch (e) { } catch (e) {
} finally { } finally {
setFetchLoading(false); setFetchLoading(false);
@@ -270,13 +275,13 @@
}; };
onMounted(() => { onMounted(() => {
loadMenuData(); loadMenuData(true);
}); });
// 重置菜单 // 重置菜单
const resetForm = () => { const resetForm = () => {
formRef.value.resetFields(); formRef.value.resetFields();
loadMenuData(); loadMenuData(true);
}; };
// 切换展开/折叠 // 切换展开/折叠