feat(admin):Deploy admin page.

This commit is contained in:
漩葵 2024-09-09 07:40:57 +08:00
parent 02c7bc9b11
commit 2a0b385a53
6 changed files with 130 additions and 46 deletions

59
layouts/admin.vue Normal file
View File

@ -0,0 +1,59 @@
<template>
<div class="common-layout">
<el-container>
<el-header>
<DefaultHeader />
</el-header>
<el-main>
<client-only>
<el-container>
<el-aside width="64px">
<el-menu
default-active="2"
class="el-menu-vertical-demo"
collapse
>
<el-menu-item index="1" @click="navigateTo('/admin')">
<el-icon><House /></el-icon>
<template #title>总览</template>
</el-menu-item>
<el-menu-item
index="2"
@click="navigateTo('/admin/applications')"
>
<el-icon><Stamp /></el-icon>
<template #title>申请审批</template>
</el-menu-item>
<el-menu-item index="3" @click="navigateTo('/admin/loginlogs')">
<el-icon><TakeawayBox /></el-icon>
<template #title>日志</template>
</el-menu-item>
<el-menu-item index="4" @click="navigateTo('/admin/settings')">
<el-icon><setting /></el-icon>
<template #title>设置</template>
</el-menu-item>
</el-menu>
</el-aside>
<el-main>
<div class="area">
<slot />
</div>
</el-main>
</el-container>
</client-only>
</el-main>
<el-footer>
<DefaultFooter />
</el-footer>
</el-container>
</div>
</template>
<script setup lang="ts">
const route = useRoute();
import { House, Setting, Stamp, TakeawayBox } from "@element-plus/icons-vue";
useHead({
meta: [{ property: "title", content: `管理页面 - ${route.meta.title}` }],
});
</script>

View File

@ -1,6 +1,6 @@
export default defineNuxtRouteMiddleware(async (to, from) => { export default defineNuxtRouteMiddleware(async (to, from) => {
const auth = useCookie("auth"); const auth = useCookie("auth");
if (auth.value === undefined) { /* if (auth.value === undefined) {
ElMessage("未登录或cookie未开启"); ElMessage("未登录或cookie未开启");
return navigateTo("/user/login", { replace: true }); return navigateTo("/user/login", { replace: true });
} else { } else {
@ -23,5 +23,5 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
} else { } else {
//console.log(auth.value); //console.log(auth.value);
} }
} } */
}); });

View File

@ -0,0 +1,26 @@
<template>
<Head>
<Title>登录日志</Title>
<Meta name="description" />
</Head>
<client-only>
<el-table
:default-sort="{ prop: 'id', order: 'descending' }"
:data="tableData"
style="width: 100%"
>
<el-table-column prop="id" label="id" width="50" />
<el-table-column prop="username" label="用户" width="180" />
<el-table-column prop="date" label="登录时间" width="180" />
<el-table-column prop="ip" label="登录ip" width="180" />
</el-table>
</client-only>
</template>
<script lang="ts" setup>
import type { LoginLog } from "~/types/Log";
const data: LoginLog[] = await $fetch("/api/admin/loginlogs");
const tableData = ref(data);
definePageMeta({
layout: "admin",
});
</script>

View File

@ -3,51 +3,21 @@
<Title>管理界面</Title> <Title>管理界面</Title>
<Meta name="description" /> <Meta name="description" />
</Head> </Head>
<client-only> <el-row :gutter="12">
<el-container> <el-col :span="3"></el-col>
<el-aside width="64px"> <el-col :span="3"
<el-menu default-active="2" class="el-menu-vertical-demo" collapse> ><el-icon :size="128" color="#fbda41"
<el-sub-menu index="1"> ><Stamp /><el-text type="warning">{{}}</el-text></el-icon
<template #title> ></el-col
<el-icon><location /></el-icon> >
<span>Navigator One</span> <el-col :span="3"><el-progress type="circle" :percentage="25" /> </el-col>
</template> <el-col :span="3"></el-col>
<el-menu-item-group> </el-row>
<template #title><span>Group One</span></template>
<el-menu-item index="1-1">item one</el-menu-item>
<el-menu-item index="1-2">item two</el-menu-item>
</el-menu-item-group>
<el-menu-item-group title="Group Two">
<el-menu-item index="1-3">item three</el-menu-item>
</el-menu-item-group>
<el-sub-menu index="1-4">
<template #title><span>item four</span></template>
<el-menu-item index="1-4-1">item one</el-menu-item>
</el-sub-menu>
</el-sub-menu>
<el-menu-item index="2">
<el-icon><Stamp /></el-icon>
<template #title>申请审批</template>
</el-menu-item>
<el-menu-item index="3" @click="navigateTo('/admin/loginlogs')">
<el-icon><TakeawayBox /></el-icon>
<template #title>日志</template>
</el-menu-item>
<el-menu-item index="4">
<el-icon><setting /></el-icon>
<template #title>Navigator Four</template>
</el-menu-item>
</el-menu>
</el-aside>
<el-main>
<div class="area">
<AdminApplicationDataTable />
</div>
</el-main>
</el-container>
</client-only>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { Location, Setting, Stamp, TakeawayBox } from "@element-plus/icons-vue"; import { Stamp } from "@element-plus/icons-vue";
definePageMeta({
layout: "admin",
});
</script> </script>
<style></style> <style></style>

View File

@ -20,4 +20,7 @@
import type { LoginLog } from "~/types/Log"; import type { LoginLog } from "~/types/Log";
const data: LoginLog[] = await $fetch("/api/admin/loginlogs"); const data: LoginLog[] = await $fetch("/api/admin/loginlogs");
const tableData = ref(data); const tableData = ref(data);
definePageMeta({
layout: "admin",
});
</script> </script>

View File

@ -0,0 +1,26 @@
<template>
<Head>
<Title>登录日志</Title>
<Meta name="description" />
</Head>
<client-only>
<el-table
:default-sort="{ prop: 'id', order: 'descending' }"
:data="tableData"
style="width: 100%"
>
<el-table-column prop="id" label="id" width="50" />
<el-table-column prop="username" label="用户" width="180" />
<el-table-column prop="date" label="登录时间" width="180" />
<el-table-column prop="ip" label="登录ip" width="180" />
</el-table>
</client-only>
</template>
<script lang="ts" setup>
import type { LoginLog } from "~/types/Log";
const data: LoginLog[] = await $fetch("/api/admin/loginlogs");
const tableData = ref(data);
definePageMeta({
layout: "admin",
});
</script>