feat: 新增页面布局

This commit is contained in:
duanshuwen
2025-12-01 22:16:34 +08:00
parent edd8b939d3
commit ae19c6c551
13 changed files with 174 additions and 16 deletions

View File

@@ -0,0 +1,30 @@
<template>
<div class="w-[80px] h-full box-border pt-[12px] pb-[12px] flex flex-col items-center justify-center">
<div :class="['flex flex-col gap-[16px]', {'mt-auto mb-[8px] shrink-1': item.id === 7}]" v-for="(item) in menus" :key="item.id">
<div :class="['cursor-pointer flex flex-col items-center justify-center']" @click="handleClick(item)">
<div :class="['box-border rounded-[16px] p-[8px]', {'bg-white': item.id === currentId}]">
<component :is="item.icon" :color="item.id === currentId ? item.activeColor : item.color" :class="['w-[32px] h-[32px]']" />
</div>
<div :class="['text-[14px] mt-[4px] mb-[8px]', item.id === currentId ? item.activeColor : item.color]">
{{ item.name }}
</div>
</div>
</div>
<div class="w-[48px] h-[48px] rounded-full overflow-hidden">
<img class="w-full h-full object-cover" src="https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg" />
</div>
</div>
</template>
<script setup lang="ts">
import {ref} from 'vue'
import { menus } from '@/constant/menus'
const currentId = ref(null)
const handleClick = (item: any) => {
currentId.value = item.id
}
</script>
<style></style>

View File

@@ -0,0 +1,9 @@
<template>
<div class="task-list w-[392px] h-full rounded-[16px] bg-white">
</div>
</template>
<script setup lang="ts"></script>
<style></style>

View File

@@ -0,0 +1,62 @@
import { RiHomeLine, RiFileListLine, RiHotelLine, RiChatQuoteLine, RiBarChartBoxAiLine, RiMoreLine, RiSettingsLine } from '@remixicon/vue'
// 菜单列表申明
export interface MenuItem {
id: number
name: string
icon: any
color: string
activeColor: string
}
export const menus: MenuItem[] = [
{
id: 1,
name: '首页',
icon: RiHomeLine,
color: '#525866',
activeColor: 'text-[#2B7FFF]',
},
{
id: 2,
name: '订单',
icon: RiFileListLine,
color: '#525866',
activeColor: 'text-[#2B7FFF]',
},
{
id: 3,
name: '库存',
icon: RiHotelLine,
color: '#525866',
activeColor: 'text-[#2B7FFF]',
},
{
id: 4,
name: '评价',
icon: RiChatQuoteLine,
color: '#525866',
activeColor: 'text-[#2B7FFF]',
},
{
id: 5,
name: '数据看板',
icon: RiBarChartBoxAiLine,
color: '#525866',
activeColor: 'text-[#2B7FFF]',
},
{
id: 6,
name: '更多',
icon: RiMoreLine,
color: '#525866',
activeColor: 'text-[#2B7FFF]',
},
{
id: 7,
name: '设置',
icon: RiSettingsLine,
color: '#525866',
activeColor: 'text-[#2B7FFF]',
},
]

View File

@@ -6,3 +6,7 @@ body {
margin: 0;
padding: 0;
}
.bg {
background: linear-gradient( 180deg, #EFF6FF 0%, #F5F7FA 40%);
}

View File

@@ -0,0 +1,17 @@
<template>
<div class="bg box-border w-full h-screen flex pt-[8px] pb-[8px]">
<div class="w-[952px] h-full">
<slot></slot>
</div>
<TaskList />
<Menus />
</div>
</template>
<script setup lang="ts">
import TaskList from '@/components/TaskList/index.vue'
import Menus from '@/components/Menus/index.vue'
</script>

View File

@@ -3,6 +3,7 @@ import { createApp } from "vue";
import { createPinia } from "pinia";
import router from "./router";
import App from "./App.vue";
import Layout from "./layout/index.vue";
// 创建 Vue 应用实例
const app = createApp(App);
@@ -10,6 +11,9 @@ const app = createApp(App);
// 使用 Pinia 状态管理
app.use(createPinia());
// 注册 Layout 组件
app.component('Layout', Layout);
// 使用 Vue Router
app.use(router);

View File

@@ -12,6 +12,12 @@ const routes = [
component: () => import("@/views/browser/BrowserLayout.vue"),
meta: { requiresAuth: true },
},
{
path: "/home",
name: "Home",
component: () => import("@/views/home/index.vue"),
meta: { requiresAuth: true },
},
{
path: "/about",
name: "About",
@@ -30,10 +36,12 @@ router.beforeEach((to, _from, next) => {
next({ path: "/login" });
return;
}
if (token && to.path !== "/browser") {
next({ path: "/browser" });
if (token && to.path !== "/home") {
next({ path: "/home" });
return;
}
next();
});

View File

View File

@@ -1,18 +1,11 @@
<template>
<div class="home">
<h2 class="text-2xl font-bold mb-4">欢迎使用智念科技 AI</h2>
<div class="bg-white p-6">
<button
class="bg-blue-300 hover:bg-blue-500 text-white px-4 py-2 rounded mr-2"
@click="openBaidu"
>
打开百度
</button>
</div>
</div>
<Layout>
</Layout>
</template>
<script setup lang="ts">
const openBaidu = () => {
(window as any).ipcAPI?.openBaidu()

View File

@@ -41,6 +41,19 @@
/>
</div>
<p v-if="errors.password" class="mt-1 text-xs text-red-500">{{ errors.password }}</p>
<!-- 验证码 -->
<div class="font-[14px] text-gray-700 mb-[8px] mt-[12px]">验证码</div>
<div class="flex items-center gap-2 border rounded-[10px] box-border px-[12px] py-[10px]">
<input
class="flex-1 focus-visible:outline-none"
type="text"
v-model.trim="form.code"
placeholder="请输入验证码"
@keyup.enter="onSubmit"
/>
<img class="w-[80px] h-[40px]" src="" />
</div>
<p v-if="errors.code" class="mt-1 text-xs text-red-500">{{ errors.code }}</p>
<!-- 记住密码|忘记密码 -->
<div class="flex items-center justify-between mb-[24px] mt-[24px]">
@@ -94,8 +107,8 @@ import { login as apiLogin } from "@/renderer/api/login";
import { RiUser3Fill , RiKey2Fill} from '@remixicon/vue'
const router = useRouter();
const form = reactive({ account: "", password: "", agreement: "" });
const errors = reactive<{ account?: string; password?: string }>({});
const form = reactive({ account: "", password: "", agreement: "", code: "" });
const errors = reactive<{ account?: string; password?: string; code?: string }>({});
const loading = ref(false);
const showPwd = ref(false);
@@ -118,7 +131,7 @@ const onSubmit = async () => {
// const token = res && (res.token || res.data?.token || res.access_token);
// if (!token) throw new Error("登录失败");
// localStorage.setItem("token", token);
await (window as any).ipcAPI.app.setFrameless('/browser')
await (window as any).ipcAPI.app.setFrameless('/home')
} finally {
// loading.value = false;
}