feat: 完成梦象虚拟电厂集中门户基础框架搭建
新增登录页、布局、路由、Pinia状态管理、Mock数据等核心模块,配置环境变量、Vite、ESLint、Prettier、CommitLint等开发工具,添加品牌资源与全局样式。
This commit is contained in:
commit
9ddecbdb9a
42 files changed
+10448
No files matched your search
+121
@@ -0,0 +1,121 @@
|
||||
<template>
|
||||
<!-- 全局 SVG 图标库:迁移自原型项目 index.html,供各页面 <use href="#i-xxx"> 引用 -->
|
||||
<svg class="svg-library" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
||||
<symbol id="i-user" viewBox="0 0 24 24">
|
||||
<path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2" />
|
||||
<circle cx="12" cy="7" r="4" />
|
||||
</symbol>
|
||||
<symbol id="i-lock" viewBox="0 0 24 24">
|
||||
<rect width="16" height="12" x="4" y="10" rx="2" />
|
||||
<path d="M8 10V6a4 4 0 0 1 8 0v4" />
|
||||
</symbol>
|
||||
<symbol id="i-eye" viewBox="0 0 24 24">
|
||||
<path
|
||||
d="M2.06 12.35a1 1 0 0 1 0-.7C3.73 7.6 7.7 5 12 5c4.3 0 8.27 2.6 9.94 6.65a1 1 0 0 1 0 .7C20.27 16.4 16.3 19 12 19c-4.3 0-8.27-2.6-9.94-6.65Z"
|
||||
/>
|
||||
<circle cx="12" cy="12" r="3" />
|
||||
</symbol>
|
||||
<symbol id="i-eye-off" viewBox="0 0 24 24">
|
||||
<path d="m2 2 20 20" />
|
||||
<path
|
||||
d="M6.71 6.71C4.95 7.96 3.62 9.76 2.06 11.65a1 1 0 0 0 0 .7C3.73 16.4 7.7 19 12 19c1.57 0 3.07-.3 4.43-.83"
|
||||
/>
|
||||
<path
|
||||
d="M10.73 5.08C11.14 5.03 11.56 5 12 5c4.3 0 8.27 2.6 9.94 6.65a1 1 0 0 1 0 .7c-.56 1.08-1.24 2.09-2.02 3.01"
|
||||
/>
|
||||
<path d="M14.12 14.12a3 3 0 0 1-4.24-4.24" />
|
||||
</symbol>
|
||||
<symbol id="i-arrow-right" viewBox="0 0 24 24">
|
||||
<path d="M5 12h14" />
|
||||
<path d="m13 6 6 6-6 6" />
|
||||
</symbol>
|
||||
<symbol id="i-arrow-left" viewBox="0 0 24 24">
|
||||
<path d="M19 12H5" />
|
||||
<path d="m11 18-6-6 6-6" />
|
||||
</symbol>
|
||||
<symbol id="i-shield-check" viewBox="0 0 24 24">
|
||||
<path d="M20 13c0 5-3.5 7.5-8 9-4.5-1.5-8-4-8-9V5l8-3 8 3v8Z" />
|
||||
<path d="m9 12 2 2 4-4" />
|
||||
</symbol>
|
||||
<symbol id="i-check" viewBox="0 0 24 24"><path d="m5 12 4 4L19 6" /></symbol>
|
||||
<symbol id="i-check-circle" viewBox="0 0 24 24">
|
||||
<circle cx="12" cy="12" r="9" />
|
||||
<path d="m8 12 3 3 5-6" />
|
||||
</symbol>
|
||||
<symbol id="i-alert-circle" viewBox="0 0 24 24">
|
||||
<circle cx="12" cy="12" r="9" />
|
||||
<path d="M12 8v4" />
|
||||
<path d="M12 16h.01" />
|
||||
</symbol>
|
||||
<symbol id="i-search" viewBox="0 0 24 24">
|
||||
<circle cx="11" cy="11" r="7" />
|
||||
<path d="m20 20-4-4" />
|
||||
</symbol>
|
||||
<symbol id="i-map-pin" viewBox="0 0 24 24">
|
||||
<path d="M20 10c0 5-8 12-8 12S4 15 4 10a8 8 0 1 1 16 0Z" />
|
||||
<circle cx="12" cy="10" r="2.5" />
|
||||
</symbol>
|
||||
<symbol id="i-zap" viewBox="0 0 24 24">
|
||||
<path
|
||||
d="M4 14a1 1 0 0 1-.78-1.63l9-11a.5.5 0 0 1 .87.45l-1.58 6.33A1 1 0 0 0 12.48 9H20a1 1 0 0 1 .78 1.63l-9 11a.5.5 0 0 1-.87-.45l1.58-6.33A1 1 0 0 0 11.52 14H4Z"
|
||||
/>
|
||||
</symbol>
|
||||
<symbol id="i-grid" viewBox="0 0 24 24">
|
||||
<rect width="7" height="7" x="3" y="3" rx="1" />
|
||||
<rect width="7" height="7" x="14" y="3" rx="1" />
|
||||
<rect width="7" height="7" x="14" y="14" rx="1" />
|
||||
<rect width="7" height="7" x="3" y="14" rx="1" />
|
||||
</symbol>
|
||||
<symbol id="i-log-out" viewBox="0 0 24 24">
|
||||
<path d="M10 17l5-5-5-5" />
|
||||
<path d="M15 12H3" />
|
||||
<path d="M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4" />
|
||||
</symbol>
|
||||
<symbol id="i-chevron-down" viewBox="0 0 24 24"><path d="m6 9 6 6 6-6" /></symbol>
|
||||
<symbol id="i-help-circle" viewBox="0 0 24 24">
|
||||
<circle cx="12" cy="12" r="9" />
|
||||
<path d="M9.1 9a3 3 0 1 1 5.83 1c0 2-3 2-3 4" />
|
||||
<path d="M12 18h.01" />
|
||||
</symbol>
|
||||
<symbol id="i-x" viewBox="0 0 24 24">
|
||||
<path d="M18 6 6 18" />
|
||||
<path d="m6 6 12 12" />
|
||||
</symbol>
|
||||
<symbol id="i-phone" viewBox="0 0 24 24">
|
||||
<path
|
||||
d="M22 16.92v3a2 2 0 0 1-2.18 2 19.8 19.8 0 0 1-8.63-3.07 19.45 19.45 0 0 1-6-6A19.8 19.8 0 0 1 2.12 4.18 2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72c.13.96.36 1.9.69 2.8a2 2 0 0 1-.45 2.11L8.08 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45c.91.33 1.85.56 2.81.69A2 2 0 0 1 22 16.92Z"
|
||||
/>
|
||||
</symbol>
|
||||
<symbol id="i-building" viewBox="0 0 24 24">
|
||||
<path d="M3 21h18" />
|
||||
<path d="M5 21V7l7-4 7 4v14" />
|
||||
<path d="M9 9h1" />
|
||||
<path d="M14 9h1" />
|
||||
<path d="M9 13h1" />
|
||||
<path d="M14 13h1" />
|
||||
<path d="M10 21v-4h4v4" />
|
||||
</symbol>
|
||||
<symbol id="i-leaf" viewBox="0 0 24 24">
|
||||
<path d="M11 20A7 7 0 0 1 9.8 6.1C15.5 5 17 2 17 2c1 4 4 5 4 11a7 7 0 0 1-7 7Z" />
|
||||
<path d="M2 21c0-3 1.85-5.36 5.08-6.94C9.6 12.86 12 12 16 12" />
|
||||
</symbol>
|
||||
<symbol id="i-headphones" viewBox="0 0 24 24">
|
||||
<path d="M4 14a8 8 0 0 1 16 0" />
|
||||
<path d="M18 19c0 1.1-.9 2-2 2h-3" />
|
||||
<rect width="4" height="7" x="3" y="13" rx="2" />
|
||||
<rect width="4" height="7" x="17" y="13" rx="2" />
|
||||
</symbol>
|
||||
</svg>
|
||||
<router-view />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
// 应用根组件:承载全局 SVG 图标库
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
#app {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,42 @@
|
||||
import { MOCK_USER } from "@/mock";
|
||||
|
||||
/**
|
||||
* 模拟网络延迟
|
||||
*/
|
||||
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
|
||||
/**
|
||||
* 用户登录(模拟)
|
||||
* TODO: 接口就绪后替换为 POST /auth/login { account, password }
|
||||
*/
|
||||
export async function login(params) {
|
||||
await delay(700);
|
||||
const account = String(params?.account ?? "").trim();
|
||||
const password = String(params?.password ?? "");
|
||||
|
||||
if (account !== MOCK_USER.account || password !== MOCK_USER.password) {
|
||||
throw new Error("账号或密码不正确,请使用演示账号登录");
|
||||
}
|
||||
|
||||
const { password: _ignored, ...user } = MOCK_USER;
|
||||
return { code: 0, data: { user, token: "mock-unified-token" } };
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户信息(模拟)
|
||||
* TODO: 接口就绪后替换为 GET /auth/userinfo
|
||||
*/
|
||||
export async function getUserInfo() {
|
||||
await delay(200);
|
||||
const { password: _ignored, ...user } = MOCK_USER;
|
||||
return { code: 0, data: user };
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录(模拟)
|
||||
* TODO: 接口就绪后替换为 POST /auth/logout
|
||||
*/
|
||||
export async function logout() {
|
||||
await delay(200);
|
||||
return { code: 0 };
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { MOCK_PLANTS, sortPlants } from "@/mock";
|
||||
|
||||
/**
|
||||
* 模拟网络延迟
|
||||
*/
|
||||
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
|
||||
/**
|
||||
* 获取已授权虚拟电厂列表(模拟)
|
||||
* 说明:无论后端返回顺序如何,统一将讲解类平台置顶展示。
|
||||
* TODO: 接口就绪后替换为 GET /plants,后端返回的数据同样走 sortPlants 排序。
|
||||
*/
|
||||
export async function fetchPlants() {
|
||||
await delay(350);
|
||||
const sorted = sortPlants(MOCK_PLANTS);
|
||||
return { code: 0, data: sorted.map((plant) => ({ ...plant })) };
|
||||
}
|
||||
|
||||
/**
|
||||
* 进入指定虚拟电厂(模拟)
|
||||
* TODO: 接口就绪后替换为 POST /plants/{id}/enter
|
||||
*/
|
||||
export async function enterPlant(id) {
|
||||
await delay(650);
|
||||
const plant = MOCK_PLANTS.find((item) => item.id === id);
|
||||
if (!plant) {
|
||||
throw new Error("未找到该虚拟电厂,请重新选择");
|
||||
}
|
||||
return { code: 0, data: { plant, accessToken: "mock-plant-token" } };
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 431 KiB |
@@ -0,0 +1,126 @@
|
||||
<template>
|
||||
<el-container class="layout-container">
|
||||
<el-header class="layout-header">
|
||||
<div class="header-left">
|
||||
<h1 class="app-title">梦象虚拟电厂集中门户</h1>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<el-dropdown trigger="click" @command="handleCommand">
|
||||
<span class="user-info">
|
||||
<el-icon><User /></el-icon>
|
||||
<span class="username">{{ userStore.username || "管理员" }}</span>
|
||||
<el-icon><ArrowDown /></el-icon>
|
||||
</span>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item command="logout">退出登录</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
</el-header>
|
||||
|
||||
<el-container class="layout-body">
|
||||
<el-aside :width="isCollapsed ? '64px' : '220px'" class="layout-sidebar">
|
||||
<el-menu :default-active="currentRoute" :collapse="isCollapsed" router class="sidebar-menu">
|
||||
<el-menu-item index="/plants">
|
||||
<el-icon><HomeFilled /></el-icon>
|
||||
<template #title>电厂门户</template>
|
||||
</el-menu-item>
|
||||
<el-menu-item index="/systems">
|
||||
<el-icon><Menu /></el-icon>
|
||||
<template #title>系统管理</template>
|
||||
</el-menu-item>
|
||||
</el-menu>
|
||||
</el-aside>
|
||||
|
||||
<el-main class="layout-main">
|
||||
<router-view v-slot="{ Component }">
|
||||
<transition name="fade" mode="out-in">
|
||||
<component :is="Component" />
|
||||
</transition>
|
||||
</router-view>
|
||||
</el-main>
|
||||
</el-container>
|
||||
</el-container>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { User, ArrowDown, HomeFilled, Menu } from "@element-plus/icons-vue";
|
||||
import { useUserStore } from "@/store/modules/user";
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const userStore = useUserStore();
|
||||
const isCollapsed = ref(false);
|
||||
|
||||
const currentRoute = computed(() => route.path);
|
||||
|
||||
function handleCommand(command) {
|
||||
if (command === "logout") {
|
||||
userStore.logout();
|
||||
router.push({ name: "Login" });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.layout-container {
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.layout-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
height: $header-height;
|
||||
padding: 0 $spacing-lg;
|
||||
background-color: $color-bg-white;
|
||||
border-bottom: 1px solid $color-border;
|
||||
box-shadow: $shadow-sm;
|
||||
}
|
||||
|
||||
.app-title {
|
||||
font-size: $font-size-xl;
|
||||
font-weight: 600;
|
||||
color: $primary;
|
||||
}
|
||||
|
||||
.header-right {
|
||||
.user-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: $spacing-sm;
|
||||
cursor: pointer;
|
||||
color: $color-text-regular;
|
||||
|
||||
.username {
|
||||
font-size: $font-size-md;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.layout-body {
|
||||
height: calc(100vh - #{$header-height});
|
||||
}
|
||||
|
||||
.layout-sidebar {
|
||||
background-color: $color-bg-white;
|
||||
border-right: 1px solid $color-border;
|
||||
transition: width $transition-normal;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.sidebar-menu {
|
||||
height: 100%;
|
||||
border-right: none;
|
||||
}
|
||||
|
||||
.layout-main {
|
||||
background-color: $color-bg;
|
||||
overflow-y: auto;
|
||||
}
|
||||
</style>
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
import { createApp } from "vue";
|
||||
import { createPinia } from "pinia";
|
||||
import ElementPlus from "element-plus";
|
||||
import zhCn from "element-plus/es/locale/lang/zh-cn";
|
||||
import "element-plus/dist/index.css";
|
||||
|
||||
import App from "./App.vue";
|
||||
import router from "./router";
|
||||
import "@/styles/index.scss";
|
||||
|
||||
const app = createApp(App);
|
||||
|
||||
app.use(createPinia());
|
||||
app.use(router);
|
||||
app.use(ElementPlus, { locale: zhCn });
|
||||
|
||||
app.mount("#app");
|
||||
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
* Mock 数据层
|
||||
* 来源:原型项目 mock.js,用于接口未就绪阶段模拟后端响应
|
||||
*/
|
||||
|
||||
export const MOCK_USER = {
|
||||
account: "admin",
|
||||
password: "123456",
|
||||
name: "平台管理员",
|
||||
role: "虚拟电厂运营人员",
|
||||
};
|
||||
|
||||
/**
|
||||
* 讲解类平台的 ID 前缀,用于排序兜底:讲解类数据始终置顶
|
||||
*/
|
||||
const PRESENTATION_IDS = ["csg-jj", "sg-jj"];
|
||||
|
||||
export const MOCK_PLANTS = [
|
||||
{
|
||||
id: "csg-jj",
|
||||
name: "南网讲解",
|
||||
operator: "南网",
|
||||
region: "讲解",
|
||||
code: "NJ",
|
||||
description: "用于南网业务讲解的资源接入与运营演示平台。",
|
||||
capabilities: ["业务演示", "资源聚合"],
|
||||
status: "可访问",
|
||||
type: "讲解演示平台",
|
||||
entryUrl: "http://vpp.test.manabox.cn/#/southernPowerGrid",
|
||||
},
|
||||
{
|
||||
id: "sg-jj",
|
||||
name: "国网讲解",
|
||||
operator: "国网",
|
||||
region: "讲解",
|
||||
code: "GJ",
|
||||
description: "用于国网业务讲解的调度执行与运营演示平台。",
|
||||
capabilities: ["业务演示", "调度执行"],
|
||||
status: "可访问",
|
||||
type: "讲解演示平台",
|
||||
},
|
||||
{
|
||||
id: "sg-sh",
|
||||
name: "国网上海",
|
||||
operator: "国网",
|
||||
region: "上海",
|
||||
code: "SH",
|
||||
description: "面向上海区域的负荷聚合、需求响应与协同调度。",
|
||||
capabilities: ["资源聚合", "调度执行"],
|
||||
status: "可访问",
|
||||
type: "区域虚拟电厂",
|
||||
},
|
||||
{
|
||||
id: "sg-js",
|
||||
name: "国网江苏",
|
||||
operator: "国网",
|
||||
region: "江苏",
|
||||
code: "JS",
|
||||
description: "汇聚省内可调节资源,支撑电力交易与精细运营。",
|
||||
capabilities: ["双网邀约", "计量分润"],
|
||||
status: "可访问",
|
||||
type: "区域虚拟电厂",
|
||||
},
|
||||
{
|
||||
id: "csg-yn",
|
||||
name: "南网云南",
|
||||
operator: "南网",
|
||||
region: "云南",
|
||||
code: "YN",
|
||||
description: "连接云南绿色能源资源,实现统一监测与灵活调度。",
|
||||
capabilities: ["资源聚合", "绿色运力"],
|
||||
status: "可访问",
|
||||
type: "区域虚拟电厂",
|
||||
},
|
||||
{
|
||||
id: "csg-gx",
|
||||
name: "南网广西",
|
||||
operator: "南网",
|
||||
region: "广西",
|
||||
code: "GX",
|
||||
description: "服务广西多元负荷场景,提升资源协同运行效率。",
|
||||
capabilities: ["调度执行", "计量分润"],
|
||||
status: "可访问",
|
||||
type: "区域虚拟电厂",
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* 统一排序函数:讲解类(type 包含"讲解"或 id 在白名单内)置顶,
|
||||
* 其余保持原有相对顺序。
|
||||
*/
|
||||
export function sortPlants(plants) {
|
||||
return [...plants].sort((a, b) => {
|
||||
const aIsPresentation = a.type?.includes("讲解") || PRESENTATION_IDS.includes(a.id);
|
||||
const bIsPresentation = b.type?.includes("讲解") || PRESENTATION_IDS.includes(b.id);
|
||||
if (aIsPresentation !== bIsPresentation) {
|
||||
return aIsPresentation ? -1 : 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
import { createRouter, createWebHistory } from "vue-router";
|
||||
import { useUserStore } from "@/store/modules/user";
|
||||
|
||||
/**
|
||||
* 路由配置
|
||||
* meta 字段说明:
|
||||
* title - 页面标题
|
||||
* requiresAuth - 是否需要登录鉴权(默认 true)
|
||||
* hidden - 是否在菜单中隐藏
|
||||
*/
|
||||
const routes = [
|
||||
{
|
||||
path: "/login",
|
||||
name: "Login",
|
||||
component: () => import("@/views/login/index.vue"),
|
||||
meta: { title: "集中登录 · 梦象虚拟电厂", titleAsIs: true, requiresAuth: false },
|
||||
},
|
||||
{
|
||||
path: "/plants",
|
||||
name: "Plants",
|
||||
component: () => import("@/views/plants/index.vue"),
|
||||
meta: { title: "选择虚拟电厂 · 梦象虚拟电厂", titleAsIs: true },
|
||||
},
|
||||
{
|
||||
path: "/",
|
||||
name: "Layout",
|
||||
component: () => import("@/layout/index.vue"),
|
||||
redirect: "/plants",
|
||||
children: [
|
||||
{
|
||||
path: "systems",
|
||||
name: "Systems",
|
||||
component: () => import("@/views/systems/index.vue"),
|
||||
meta: { title: "系统管理" },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "/:pathMatch(.*)*",
|
||||
name: "NotFound",
|
||||
component: () => import("@/views/error/404.vue"),
|
||||
meta: { title: "页面不存在", requiresAuth: false },
|
||||
},
|
||||
];
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes,
|
||||
});
|
||||
|
||||
/**
|
||||
* 全局前置守卫
|
||||
*/
|
||||
router.beforeEach((to, _from, next) => {
|
||||
const userStore = useUserStore();
|
||||
|
||||
// 设置页面标题
|
||||
if (to.meta?.titleAsIs) {
|
||||
document.title = to.meta.title;
|
||||
} else {
|
||||
document.title = to.meta?.title
|
||||
? `${to.meta.title} - 梦象虚拟电厂集中门户`
|
||||
: "梦象虚拟电厂集中门户";
|
||||
}
|
||||
|
||||
// 判断是否需要鉴权
|
||||
if (to.meta?.requiresAuth !== false) {
|
||||
if (!userStore.token) {
|
||||
next({ name: "Login", query: { redirect: to.fullPath } });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 已登录用户访问登录页时重定向到首页
|
||||
if (to.name === "Login" && userStore.token) {
|
||||
next({ name: "Portal" });
|
||||
return;
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
export default router;
|
||||
@@ -0,0 +1,5 @@
|
||||
import { createPinia } from "pinia";
|
||||
|
||||
const pinia = createPinia();
|
||||
|
||||
export default pinia;
|
||||
@@ -0,0 +1,60 @@
|
||||
import { defineStore } from "pinia";
|
||||
|
||||
/**
|
||||
* 多系统链接管理 Store
|
||||
* 预留:后续用于管理子系统列表、快捷跳转、权限关联等
|
||||
*/
|
||||
export const useSystemStore = defineStore("system", {
|
||||
state: () => ({
|
||||
/** 系统列表 */
|
||||
systemList: [],
|
||||
/** 当前选中的系统 */
|
||||
currentSystem: null,
|
||||
/** 系统分类 */
|
||||
categories: [],
|
||||
/** 加载状态 */
|
||||
loading: false,
|
||||
}),
|
||||
|
||||
getters: {
|
||||
/**
|
||||
* 按分类获取系统列表
|
||||
*/
|
||||
getSystemsByCategory: (state) => (categoryId) => {
|
||||
return state.systemList.filter((s) => s.categoryId === categoryId);
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取收藏的系统
|
||||
*/
|
||||
favoriteSystems: (state) => {
|
||||
return state.systemList.filter((s) => s.isFavorite);
|
||||
},
|
||||
},
|
||||
|
||||
actions: {
|
||||
/**
|
||||
* 设置系统列表
|
||||
*/
|
||||
setSystemList(list) {
|
||||
this.systemList = list;
|
||||
},
|
||||
|
||||
/**
|
||||
* 设置当前系统
|
||||
*/
|
||||
setCurrentSystem(system) {
|
||||
this.currentSystem = system;
|
||||
},
|
||||
|
||||
/**
|
||||
* 重置状态
|
||||
*/
|
||||
reset() {
|
||||
this.systemList = [];
|
||||
this.currentSystem = null;
|
||||
this.categories = [];
|
||||
this.loading = false;
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,66 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { login as loginApi } from "@/api/auth";
|
||||
import {
|
||||
getToken,
|
||||
setToken,
|
||||
removeToken,
|
||||
getStoredUser,
|
||||
setStoredUser,
|
||||
removeStoredUser,
|
||||
} from "@/utils/auth";
|
||||
|
||||
export const useUserStore = defineStore("user", {
|
||||
state: () => ({
|
||||
token: getToken() || "",
|
||||
userInfo: getStoredUser(),
|
||||
}),
|
||||
|
||||
getters: {
|
||||
isLoggedIn: (state) => Boolean(state.token),
|
||||
username: (state) => state.userInfo?.name || "",
|
||||
},
|
||||
|
||||
actions: {
|
||||
/**
|
||||
* 用户登录(当前为模拟接口)
|
||||
*/
|
||||
async login(loginForm) {
|
||||
try {
|
||||
const { data } = await loginApi(loginForm);
|
||||
this.token = data.token;
|
||||
this.userInfo = data.user;
|
||||
setToken(data.token);
|
||||
setStoredUser(data.user);
|
||||
return data;
|
||||
} catch (error) {
|
||||
this.resetState();
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 设置用户信息
|
||||
*/
|
||||
setUserInfo(info) {
|
||||
this.userInfo = info;
|
||||
setStoredUser(info);
|
||||
},
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
*/
|
||||
logout() {
|
||||
this.resetState();
|
||||
removeToken();
|
||||
removeStoredUser();
|
||||
},
|
||||
|
||||
/**
|
||||
* 重置状态
|
||||
*/
|
||||
resetState() {
|
||||
this.token = "";
|
||||
this.userInfo = null;
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,101 @@
|
||||
// ==========================================
|
||||
// 全局样式入口
|
||||
// ==========================================
|
||||
|
||||
@use "./reset";
|
||||
|
||||
// 全局工具类
|
||||
.flex {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.flex-center {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.flex-between {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.text-ellipsis {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.page-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: $spacing-lg;
|
||||
}
|
||||
|
||||
// 滚动条美化
|
||||
::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background-color: rgba(0, 0, 0, 0.15);
|
||||
border-radius: 3px;
|
||||
|
||||
&:hover {
|
||||
background-color: rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
// 过渡动画
|
||||
.fade-enter-active,
|
||||
.fade-leave-active {
|
||||
transition: opacity $transition-normal;
|
||||
}
|
||||
|
||||
.fade-enter-from,
|
||||
.fade-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.slide-fade-enter-active {
|
||||
transition: all $transition-normal;
|
||||
}
|
||||
|
||||
.slide-fade-leave-active {
|
||||
transition: all $transition-fast;
|
||||
}
|
||||
|
||||
.slide-fade-enter-from {
|
||||
transform: translateY(-10px);
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.slide-fade-leave-to {
|
||||
transform: translateY(10px);
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
// 全局 SVG 图标(迁移自原型,配合 App.vue 中的图标库使用)
|
||||
.svg-library {
|
||||
position: absolute;
|
||||
width: 0;
|
||||
height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.icon {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
flex: 0 0 auto;
|
||||
fill: none;
|
||||
stroke: currentColor;
|
||||
stroke-width: 1.8;
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
// ==========================================
|
||||
// CSS Reset
|
||||
// ==========================================
|
||||
@use "./variables" as *;
|
||||
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
font-family: $font-family;
|
||||
font-size: $font-size-md;
|
||||
color: $color-text-primary;
|
||||
background-color: $color-bg;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
a {
|
||||
color: $primary;
|
||||
text-decoration: none;
|
||||
|
||||
&:hover {
|
||||
color: $primary-light;
|
||||
}
|
||||
}
|
||||
|
||||
ul,
|
||||
ol {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
img {
|
||||
max-width: 100%;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
input,
|
||||
button,
|
||||
textarea,
|
||||
select {
|
||||
font: inherit;
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
// ==========================================
|
||||
// 设计 Token(与参考项目保持一致)
|
||||
// ==========================================
|
||||
|
||||
// 主色调
|
||||
$primary: #20a4b8;
|
||||
$primary-light: #3dc5d8;
|
||||
$primary-dark: #178a9a;
|
||||
|
||||
// 功能色
|
||||
$success: #52c41a;
|
||||
$warning: #faad14;
|
||||
$danger: #ff4d4f;
|
||||
$info: #1890ff;
|
||||
|
||||
// 中性色
|
||||
$color-text-primary: #1a1a2e;
|
||||
$color-text-regular: #4a4a5a;
|
||||
$color-text-secondary: #8c8c9a;
|
||||
$color-text-placeholder: #b0b0bc;
|
||||
|
||||
// 背景色
|
||||
$color-bg: #f5f7fa;
|
||||
$color-bg-white: #ffffff;
|
||||
$color-bg-card: #ffffff;
|
||||
$color-bg-hover: #f0f9fb;
|
||||
|
||||
// 边框色
|
||||
$color-border: #e4e7ed;
|
||||
$color-border-light: #ebeef5;
|
||||
|
||||
// 圆角
|
||||
$radius-sm: 4px;
|
||||
$radius-md: 8px;
|
||||
$radius-lg: 12px;
|
||||
$radius-xl: 16px;
|
||||
|
||||
// 阴影
|
||||
$shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
|
||||
$shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||
$shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
|
||||
|
||||
// 字体
|
||||
$font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", sans-serif;
|
||||
$font-size-xs: 12px;
|
||||
$font-size-sm: 13px;
|
||||
$font-size-md: 14px;
|
||||
$font-size-lg: 16px;
|
||||
$font-size-xl: 20px;
|
||||
$font-size-xxl: 24px;
|
||||
|
||||
// 间距
|
||||
$spacing-xs: 4px;
|
||||
$spacing-sm: 8px;
|
||||
$spacing-md: 16px;
|
||||
$spacing-lg: 24px;
|
||||
$spacing-xl: 32px;
|
||||
$spacing-xxl: 48px;
|
||||
|
||||
// 过渡
|
||||
$transition-fast: 0.15s ease;
|
||||
$transition-normal: 0.3s ease;
|
||||
$transition-slow: 0.5s ease;
|
||||
|
||||
// 布局
|
||||
$header-height: 60px;
|
||||
$sidebar-width: 220px;
|
||||
$sidebar-collapsed-width: 64px;
|
||||
|
||||
// Element Plus 主题覆盖
|
||||
$--el-color-primary: $primary;
|
||||
$--el-color-success: $success;
|
||||
$--el-color-warning: $warning;
|
||||
$--el-color-danger: $danger;
|
||||
$--el-color-info: $info;
|
||||
$--el-font-family: $font-family;
|
||||
$--el-font-size-base: $font-size-md;
|
||||
$--el-border-radius-base: $radius-sm;
|
||||
@@ -0,0 +1,126 @@
|
||||
const TOKEN_KEY = "vpp_portal_token";
|
||||
const USER_KEY = "vpp_portal_user";
|
||||
const REMEMBER_KEY = "vpp_portal_account";
|
||||
const PLANT_KEY = "vpp_portal_selected_plant";
|
||||
|
||||
/**
|
||||
* 获取 Token
|
||||
*/
|
||||
export function getToken() {
|
||||
try {
|
||||
return localStorage.getItem(TOKEN_KEY);
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 Token
|
||||
*/
|
||||
export function setToken(token) {
|
||||
try {
|
||||
localStorage.setItem(TOKEN_KEY, token);
|
||||
} catch {
|
||||
// localStorage 不可用时静默处理
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除 Token
|
||||
*/
|
||||
export function removeToken() {
|
||||
try {
|
||||
localStorage.removeItem(TOKEN_KEY);
|
||||
} catch {
|
||||
// localStorage 不可用时静默处理
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取本地缓存的用户信息
|
||||
*/
|
||||
export function getStoredUser() {
|
||||
try {
|
||||
const raw = localStorage.getItem(USER_KEY);
|
||||
return raw ? JSON.parse(raw) : null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存用户信息
|
||||
*/
|
||||
export function setStoredUser(user) {
|
||||
try {
|
||||
localStorage.setItem(USER_KEY, JSON.stringify(user));
|
||||
} catch {
|
||||
// localStorage 不可用时静默处理
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除用户信息
|
||||
*/
|
||||
export function removeStoredUser() {
|
||||
try {
|
||||
localStorage.removeItem(USER_KEY);
|
||||
} catch {
|
||||
// localStorage 不可用时静默处理
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取记住的账号
|
||||
*/
|
||||
export function getRememberedAccount() {
|
||||
try {
|
||||
return localStorage.getItem(REMEMBER_KEY) || "";
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 记住账号
|
||||
*/
|
||||
export function setRememberedAccount(account) {
|
||||
try {
|
||||
localStorage.setItem(REMEMBER_KEY, account);
|
||||
} catch {
|
||||
// localStorage 不可用时静默处理
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除记住的账号
|
||||
*/
|
||||
export function removeRememberedAccount() {
|
||||
try {
|
||||
localStorage.removeItem(REMEMBER_KEY);
|
||||
} catch {
|
||||
// localStorage 不可用时静默处理
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取已选中的虚拟电厂 ID
|
||||
*/
|
||||
export function getSelectedPlant() {
|
||||
try {
|
||||
return localStorage.getItem(PLANT_KEY) || "";
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录选中的虚拟电厂 ID
|
||||
*/
|
||||
export function setSelectedPlant(id) {
|
||||
try {
|
||||
localStorage.setItem(PLANT_KEY, id);
|
||||
} catch {
|
||||
// localStorage 不可用时静默处理
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* 通用工具函数
|
||||
*/
|
||||
|
||||
/**
|
||||
* 防抖
|
||||
*/
|
||||
export function debounce(fn, delay = 300) {
|
||||
let timer = null;
|
||||
return function (...args) {
|
||||
if (timer) clearTimeout(timer);
|
||||
timer = setTimeout(() => fn.apply(this, args), delay);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 节流
|
||||
*/
|
||||
export function throttle(fn, interval = 300) {
|
||||
let last = 0;
|
||||
return function (...args) {
|
||||
const now = Date.now();
|
||||
if (now - last >= interval) {
|
||||
last = now;
|
||||
fn.apply(this, args);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 深拷贝
|
||||
*/
|
||||
export function deepClone(obj) {
|
||||
if (obj === null || typeof obj !== "object") return obj;
|
||||
try {
|
||||
return JSON.parse(JSON.stringify(obj));
|
||||
} catch {
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* HTML 转义(防 XSS)
|
||||
*/
|
||||
export function escapeHTML(str) {
|
||||
if (!str) return "";
|
||||
const map = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" };
|
||||
return str.replace(/[&<>"']/g, (c) => map[c]);
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
import axios from "axios";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { getToken, removeToken } from "@/utils/auth";
|
||||
import router from "@/router";
|
||||
|
||||
/**
|
||||
* 创建 Axios 实例
|
||||
*/
|
||||
const service = axios.create({
|
||||
baseURL: import.meta.env.VITE_API_BASE_URL,
|
||||
timeout: 30000,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* 请求拦截器
|
||||
*/
|
||||
service.interceptors.request.use(
|
||||
(config) => {
|
||||
const token = getToken();
|
||||
if (token) {
|
||||
config.headers.Authorization = `Bearer ${token}`;
|
||||
}
|
||||
return config;
|
||||
},
|
||||
(error) => {
|
||||
return Promise.reject(error);
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
* 响应拦截器
|
||||
*/
|
||||
service.interceptors.response.use(
|
||||
(response) => {
|
||||
const res = response.data;
|
||||
|
||||
// 约定 code === 0 为成功,其他为业务错误
|
||||
if (res.code !== undefined && res.code !== 0) {
|
||||
ElMessage.error(res.message || "请求失败");
|
||||
|
||||
// Token 过期
|
||||
if (res.code === 401) {
|
||||
removeToken();
|
||||
router.push({ name: "Login" });
|
||||
}
|
||||
|
||||
return Promise.reject(new Error(res.message || "请求失败"));
|
||||
}
|
||||
|
||||
return res;
|
||||
},
|
||||
(error) => {
|
||||
const status = error.response?.status;
|
||||
const messages = {
|
||||
400: "请求参数错误",
|
||||
401: "未授权,请重新登录",
|
||||
403: "拒绝访问",
|
||||
404: "请求资源不存在",
|
||||
500: "服务器内部错误",
|
||||
502: "网关错误",
|
||||
503: "服务不可用",
|
||||
};
|
||||
|
||||
const message = messages[status] || `请求失败(${status || "网络异常"})`;
|
||||
ElMessage.error(message);
|
||||
|
||||
if (status === 401) {
|
||||
removeToken();
|
||||
router.push({ name: "Login" });
|
||||
}
|
||||
|
||||
return Promise.reject(error);
|
||||
},
|
||||
);
|
||||
|
||||
export default service;
|
||||
@@ -0,0 +1,42 @@
|
||||
<template>
|
||||
<div class="error-page">
|
||||
<div class="error-content">
|
||||
<h1 class="error-code">404</h1>
|
||||
<p class="error-message">抱歉,您访问的页面不存在</p>
|
||||
<el-button type="primary" @click="$router.push('/portal')"> 返回首页 </el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
// 404 页面
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.error-page {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
background-color: $color-bg;
|
||||
}
|
||||
|
||||
.error-content {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.error-code {
|
||||
font-size: 120px;
|
||||
font-weight: 700;
|
||||
color: $primary;
|
||||
line-height: 1;
|
||||
margin-bottom: $spacing-md;
|
||||
}
|
||||
|
||||
.error-message {
|
||||
font-size: $font-size-lg;
|
||||
color: $color-text-secondary;
|
||||
margin-bottom: $spacing-xl;
|
||||
}
|
||||
</style>
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,85 @@
|
||||
<template>
|
||||
<div class="page-container systems-page">
|
||||
<div class="page-header flex-between">
|
||||
<div>
|
||||
<h2 class="page-title">系统管理</h2>
|
||||
<p class="page-desc">管理和配置所有子系统链接</p>
|
||||
</div>
|
||||
<el-button type="primary" @click="handleAdd"> 添加系统 </el-button>
|
||||
</div>
|
||||
|
||||
<!-- 搜索筛选区域 -->
|
||||
<el-card shadow="never" class="filter-card">
|
||||
<el-form :inline="true" :model="filterForm">
|
||||
<el-form-item label="系统名称">
|
||||
<el-input v-model="filterForm.keyword" placeholder="请输入系统名称" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="系统分类">
|
||||
<el-select v-model="filterForm.category" placeholder="全部分类" clearable>
|
||||
<el-option label="全部" value="" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handleSearch">查询</el-button>
|
||||
<el-button @click="handleReset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<!-- 系统列表区域 -->
|
||||
<el-card shadow="never" class="list-card">
|
||||
<el-empty description="暂无系统数据" />
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive } from "vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
|
||||
const filterForm = reactive({
|
||||
keyword: "",
|
||||
category: "",
|
||||
});
|
||||
|
||||
function handleSearch() {
|
||||
// 预留:查询逻辑
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
filterForm.keyword = "";
|
||||
filterForm.category = "";
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
ElMessage.info("添加系统功能待开发");
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.systems-page {
|
||||
.page-header {
|
||||
margin-bottom: $spacing-lg;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
font-size: $font-size-xxl;
|
||||
font-weight: 600;
|
||||
color: $color-text-primary;
|
||||
margin-bottom: $spacing-xs;
|
||||
}
|
||||
|
||||
.page-desc {
|
||||
font-size: $font-size-md;
|
||||
color: $color-text-secondary;
|
||||
}
|
||||
|
||||
.filter-card {
|
||||
margin-bottom: $spacing-lg;
|
||||
}
|
||||
|
||||
.list-card {
|
||||
margin-bottom: $spacing-lg;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user