feat: 完成登录与栅格下载桌面端
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import { NButton, NIcon, NLayoutSider, NMenu } from "naive-ui";
|
||||
import { LogOutOutline, MoonOutline, PersonOutline, SunnyOutline } from "@vicons/ionicons5";
|
||||
import { logout, type UserInfo } from "../features/auth/api";
|
||||
import { isDark, toggleTheme } from "../shared/theme";
|
||||
import { navGroups, type PageKey } from "./navigation";
|
||||
import GridDownloadView from "../features/download/GridDownloadView.vue";
|
||||
import DownloadManagerView from "../features/download/DownloadManagerView.vue";
|
||||
|
||||
const props = defineProps<{ user: UserInfo }>();
|
||||
const emit = defineEmits<{ logout: [] }>();
|
||||
|
||||
const page = ref<PageKey>("grid");
|
||||
const focusId = ref("");
|
||||
|
||||
function onMenu(key: string) {
|
||||
if (key === "grid" || key === "tasks") page.value = key;
|
||||
}
|
||||
|
||||
function onStarted(id: string) {
|
||||
focusId.value = id;
|
||||
page.value = "tasks";
|
||||
}
|
||||
|
||||
async function signOut() {
|
||||
try {
|
||||
await logout();
|
||||
} finally {
|
||||
emit("logout");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="shell">
|
||||
<aside class="sider">
|
||||
<div class="sider-title">NqiTools</div>
|
||||
<n-layout-sider :native-scrollbar="false" :width="220" style="background: transparent; flex: 1">
|
||||
<n-menu :value="page" :options="navGroups" @update:value="onMenu" />
|
||||
</n-layout-sider>
|
||||
<div class="sider-user">
|
||||
<n-icon :size="18"><PersonOutline /></n-icon>
|
||||
<div class="who">
|
||||
<strong>{{ props.user.userName || props.user.loginId }}</strong>
|
||||
<span>{{ props.user.cityName || "已登录" }}</span>
|
||||
</div>
|
||||
<n-button quaternary circle size="small" :aria-label="isDark ? '切换到日间' : '切换到夜间'" @click="toggleTheme">
|
||||
<template #icon><n-icon><MoonOutline v-if="!isDark" /><SunnyOutline v-else /></n-icon></template>
|
||||
</n-button>
|
||||
<n-button quaternary circle size="small" aria-label="退出" @click="signOut">
|
||||
<template #icon><n-icon><LogOutOutline /></n-icon></template>
|
||||
</n-button>
|
||||
</div>
|
||||
</aside>
|
||||
<main class="content">
|
||||
<GridDownloadView v-if="page === 'grid'" @started="onStarted" />
|
||||
<DownloadManagerView v-else :focus-id="focusId" />
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user