改进 前端

This commit is contained in:
Twilight 2024-03-28 14:08:17 +08:00
parent 09d4f39ef2
commit b822becbbf
15 changed files with 311 additions and 219 deletions

View File

@ -0,0 +1,69 @@
{
"globals": {
"Component": true,
"ComponentPublicInstance": true,
"ComputedRef": true,
"EffectScope": true,
"ExtractDefaultPropTypes": true,
"ExtractPropTypes": true,
"ExtractPublicPropTypes": true,
"InjectionKey": true,
"PropType": true,
"Ref": true,
"VNode": true,
"WritableComputedRef": true,
"computed": true,
"createApp": true,
"customRef": true,
"defineAsyncComponent": true,
"defineComponent": true,
"effectScope": true,
"getCurrentInstance": true,
"getCurrentScope": true,
"h": true,
"inject": true,
"isProxy": true,
"isReactive": true,
"isReadonly": true,
"isRef": true,
"markRaw": true,
"nextTick": true,
"onActivated": true,
"onBeforeMount": true,
"onBeforeUnmount": true,
"onBeforeUpdate": true,
"onDeactivated": true,
"onErrorCaptured": true,
"onMounted": true,
"onRenderTracked": true,
"onRenderTriggered": true,
"onScopeDispose": true,
"onServerPrefetch": true,
"onUnmounted": true,
"onUpdated": true,
"provide": true,
"reactive": true,
"readonly": true,
"ref": true,
"resolveComponent": true,
"shallowReactive": true,
"shallowReadonly": true,
"shallowRef": true,
"toRaw": true,
"toRef": true,
"toRefs": true,
"toValue": true,
"triggerRef": true,
"unref": true,
"useAttrs": true,
"useCssModule": true,
"useCssVars": true,
"useRoute": true,
"useRouter": true,
"useSlots": true,
"watch": true,
"watchEffect": true,
"watchPostEffect": true,
"watchSyncEffect": true
}
}

View File

@ -1,11 +1,7 @@
<template>
<v-app>
<v-main>
<router-view />
</v-main>
</v-app>
<Default />
</template>
<script lang="ts" setup>
//
import Default from './layouts/default/Default.vue';
</script>

18
src/auto-imports.d.ts vendored
View File

@ -55,8 +55,8 @@ declare global {
const useCssModule: typeof import('vue')['useCssModule']
const useCssVars: typeof import('vue')['useCssVars']
const useLink: typeof import('vue-router')['useLink']
const useRoute: typeof import('vue-router')['useRoute']
const useRouter: typeof import('vue-router')['useRouter']
const useRoute: typeof import('vue-router/auto')['useRoute']
const useRouter: typeof import('vue-router/auto')['useRouter']
const useSlots: typeof import('vue')['useSlots']
const watch: typeof import('vue')['watch']
const watchEffect: typeof import('vue')['watchEffect']
@ -93,8 +93,6 @@ declare module 'vue' {
readonly nextTick: UnwrapRef<typeof import('vue')['nextTick']>
readonly onActivated: UnwrapRef<typeof import('vue')['onActivated']>
readonly onBeforeMount: UnwrapRef<typeof import('vue')['onBeforeMount']>
readonly onBeforeRouteLeave: UnwrapRef<typeof import('vue-router')['onBeforeRouteLeave']>
readonly onBeforeRouteUpdate: UnwrapRef<typeof import('vue-router')['onBeforeRouteUpdate']>
readonly onBeforeUnmount: UnwrapRef<typeof import('vue')['onBeforeUnmount']>
readonly onBeforeUpdate: UnwrapRef<typeof import('vue')['onBeforeUpdate']>
readonly onDeactivated: UnwrapRef<typeof import('vue')['onDeactivated']>
@ -123,9 +121,8 @@ declare module 'vue' {
readonly useAttrs: UnwrapRef<typeof import('vue')['useAttrs']>
readonly useCssModule: UnwrapRef<typeof import('vue')['useCssModule']>
readonly useCssVars: UnwrapRef<typeof import('vue')['useCssVars']>
readonly useLink: UnwrapRef<typeof import('vue-router')['useLink']>
readonly useRoute: UnwrapRef<typeof import('vue-router')['useRoute']>
readonly useRouter: UnwrapRef<typeof import('vue-router')['useRouter']>
readonly useRoute: UnwrapRef<typeof import('vue-router/auto')['useRoute']>
readonly useRouter: UnwrapRef<typeof import('vue-router/auto')['useRouter']>
readonly useSlots: UnwrapRef<typeof import('vue')['useSlots']>
readonly watch: UnwrapRef<typeof import('vue')['watch']>
readonly watchEffect: UnwrapRef<typeof import('vue')['watchEffect']>
@ -155,8 +152,6 @@ declare module '@vue/runtime-core' {
readonly nextTick: UnwrapRef<typeof import('vue')['nextTick']>
readonly onActivated: UnwrapRef<typeof import('vue')['onActivated']>
readonly onBeforeMount: UnwrapRef<typeof import('vue')['onBeforeMount']>
readonly onBeforeRouteLeave: UnwrapRef<typeof import('vue-router')['onBeforeRouteLeave']>
readonly onBeforeRouteUpdate: UnwrapRef<typeof import('vue-router')['onBeforeRouteUpdate']>
readonly onBeforeUnmount: UnwrapRef<typeof import('vue')['onBeforeUnmount']>
readonly onBeforeUpdate: UnwrapRef<typeof import('vue')['onBeforeUpdate']>
readonly onDeactivated: UnwrapRef<typeof import('vue')['onDeactivated']>
@ -185,9 +180,8 @@ declare module '@vue/runtime-core' {
readonly useAttrs: UnwrapRef<typeof import('vue')['useAttrs']>
readonly useCssModule: UnwrapRef<typeof import('vue')['useCssModule']>
readonly useCssVars: UnwrapRef<typeof import('vue')['useCssVars']>
readonly useLink: UnwrapRef<typeof import('vue-router')['useLink']>
readonly useRoute: UnwrapRef<typeof import('vue-router')['useRoute']>
readonly useRouter: UnwrapRef<typeof import('vue-router')['useRouter']>
readonly useRoute: UnwrapRef<typeof import('vue-router/auto')['useRoute']>
readonly useRouter: UnwrapRef<typeof import('vue-router/auto')['useRouter']>
readonly useSlots: UnwrapRef<typeof import('vue')['useSlots']>
readonly watch: UnwrapRef<typeof import('vue')['watch']>
readonly watchEffect: UnwrapRef<typeof import('vue')['watchEffect']>

3
src/components.d.ts vendored
View File

@ -7,7 +7,8 @@ export {}
declare module 'vue' {
export interface GlobalComponents {
HelloWorld: typeof import('./src/components/HelloWorld.vue')['default']
AppFooter: typeof import('./components/AppFooter.vue')['default']
HelloWorld: typeof import('./components/HelloWorld.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
}

View File

@ -1,157 +1,5 @@
<template>
<v-container class="fill-height">
<v-responsive
class="align-centerfill-height mx-auto"
max-width="900"
>
<v-img
class="mb-4"
height="150"
src="@/assets/logo.png"
/>
<h1>欢迎使用 资料库</h1>
<div class="text-center">
<div class="text-body-2 font-weight-light mb-n1">Welcome to</div>
<h1 class="text-h2 font-weight-bold">Vuetify</h1>
</div>
<div class="py-4" />
<v-row>
<v-col cols="12">
<v-card
class="py-4"
color="surface-variant"
image="https://cdn.vuetifyjs.com/docs/images/one/create/feature.png"
prepend-icon="mdi-rocket-launch-outline"
rounded="lg"
variant="outlined"
>
<template #image>
<v-img position="top right" />
</template>
<template #title>
<h2 class="text-h5 font-weight-bold">Get started</h2>
</template>
<template #subtitle>
<div class="text-subtitle-1">
Replace this page by removing <v-kbd>{{ `<HelloWorld />` }}</v-kbd> in <v-kbd>pages/index.vue</v-kbd>.
</div>
</template>
<v-overlay
opacity=".12"
scrim="primary"
contained
model-value
persistent
/>
</v-card>
</v-col>
<v-col cols="6">
<v-card
append-icon="mdi-open-in-new"
class="py-4"
color="surface-variant"
href="https://vuetifyjs.com/"
prepend-icon="mdi-text-box-outline"
rel="noopener noreferrer"
rounded="lg"
subtitle="Learn about all things Vuetify in our documentation."
target="_blank"
title="Documentation"
variant="text"
>
<v-overlay
opacity=".06"
scrim="primary"
contained
model-value
persistent
/>
</v-card>
</v-col>
<v-col cols="6">
<v-card
append-icon="mdi-open-in-new"
class="py-4"
color="surface-variant"
href="https://vuetifyjs.com/introduction/why-vuetify/#feature-guides"
prepend-icon="mdi-star-circle-outline"
rel="noopener noreferrer"
rounded="lg"
subtitle="Explore available framework Features."
target="_blank"
title="Features"
variant="text"
>
<v-overlay
opacity=".06"
scrim="primary"
contained
model-value
persistent
/>
</v-card>
</v-col>
<v-col cols="6">
<v-card
append-icon="mdi-open-in-new"
class="py-4"
color="surface-variant"
href="https://vuetifyjs.com/components/all"
prepend-icon="mdi-widgets-outline"
rel="noopener noreferrer"
rounded="lg"
subtitle="Discover components in the API Explorer."
target="_blank"
title="Components"
variant="text"
>
<v-overlay
opacity=".06"
scrim="primary"
contained
model-value
persistent
/>
</v-card>
</v-col>
<v-col cols="6">
<v-card
append-icon="mdi-open-in-new"
class="py-4"
color="surface-variant"
href="https://discord.vuetifyjs.com"
prepend-icon="mdi-account-group-outline"
rel="noopener noreferrer"
rounded="lg"
subtitle="Connect with Vuetify developers."
target="_blank"
title="Community"
variant="text"
>
<v-overlay
opacity=".06"
scrim="primary"
contained
model-value
persistent
/>
</v-card>
</v-col>
</v-row>
</v-responsive>
</v-container>
<p>目前还在开发中</p>
</template>
<script setup lang="ts">
//
</script>

View File

@ -1,5 +0,0 @@
# Layouts
Layouts are reusable components that wrap around pages. They are used to provide a consistent look and feel across multiple pages.
Full documentation for this feature can be found in the Official [vite-plugin-vue-layouts](https://github.com/JohnCampionJr/vite-plugin-vue-layouts) repository.

View File

@ -0,0 +1,55 @@
<template>
<!-- <v-app id="nav"> -->
<v-navigation-drawer v-model="drawer">
<div class="pa-2">
<v-btn
density="default"
icon="mdi-close"
@click="drawer = !drawer"
></v-btn>
</div>
<!-- <v-divider></v-divider> -->
<v-list density="compact" nav>
<template v-for="item in items">
<v-list-item
rounded="lg"
:prepend-icon="item.icon"
:title="item.text"
:value="item.text"
:to="item.to"
></v-list-item>
</template>
<!-- <v-list-item
prepend-icon="mdi-forum"
title="About"
value="about"
></v-list-item> -->
</v-list>
</v-navigation-drawer>
<v-app-bar>
<v-app-bar-nav-icon @click="drawer = !drawer"></v-app-bar-nav-icon>
<v-app-bar-title>{{ configStore.appName }}</v-app-bar-title>
</v-app-bar>
<!-- </v-app> -->
</template>
<script lang="ts" setup>
import { ref } from "vue";
import { useConfigStore } from "@/stores/config";
const configStore = useConfigStore();
const drawer = ref(false);
const items = [
{ icon: "mdi-home", text: "首页", to: { name: "home" } },
// { icon: "mdi-content-copy", text: "", to: { name: "libraries" } },
// // { icon: "mdi-history", text: "Frequently contacted", to: "/documents" },
// { icon: "mdi-account", text: "", to: { name: "login" } },
];
</script>

View File

@ -0,0 +1,28 @@
<template>
<v-app id="d">
<default-bar />
<default-view />
</v-app>
</template>
<script lang="ts" setup>
import DefaultBar from "./AppBar.vue";
import DefaultView from "./View.vue";
import { useTheme } from "vuetify";
const theme = useTheme();
//
function updateTheme() {
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
theme.global.name.value = prefersDark ? "dark" : "light";
}
updateTheme();
window
.matchMedia("(prefers-color-scheme: dark)")
.addEventListener("change", updateTheme);
</script>

View File

@ -1,13 +1,11 @@
<template>
<v-app>
<v-main>
<v-main>
<v-container>
<router-view />
</v-main>
<AppFooter />
</v-app>
</v-container>
</v-main>
</template>
<script lang="ts" setup>
//
//
</script>

22
src/plugins/api.ts Normal file
View File

@ -0,0 +1,22 @@
import { Configuration } from "../api";
// import axios from "axios";
// import router from "@/router";
// import {useUserStore} from "@/store/user";
// import { useConfigStore } from "@/store/config";
//
//
// const userStore = useUserStore()
// const configStore = useConfigStore()
//
// const conf = new Configuration
// conf.basePath = configStore.apiServer
//
// conf.apiKey = "Bearer " + userStore.jwt_token
// const document = new DocumentsApi(conf);
// const library = new LibrariesApi(conf);
//
//
// export {
// document, library, conf
// }

8
src/plugins/getTheme.ts Normal file
View File

@ -0,0 +1,8 @@
let matchResult = window.matchMedia('(prefers-color-scheme: dark)');
function getTheme() {
return matchResult.matches ? 'dark' : 'light'
}
export default getTheme()

View File

@ -1,16 +1,57 @@
/**
* router/index.ts
*
* Automatic routes for `./src/pages/*.vue`
*/
// Composables
import { createRouter, createWebHistory } from 'vue-router/auto'
import { setupLayouts } from 'virtual:generated-layouts'
import { createRouter, createWebHistory } from "vue-router";
// import { useUserStore } from "@/stores/user";
// import { useConfigStore } from "@/stores/config";
const routes = [
{
path: "/",
name: "home",
meta: {
auth: true,
},
// route level code-splitting
// this generates a separate chunk (Home-[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import("@/views/Home.vue"),
},
];
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
extendRoutes: setupLayouts,
})
history: createWebHistory(process.env.BASE_URL),
routes,
});
export default router
// router.beforeEach((to, from) => {
//
// // get route name
// console.log(from.name, from.fullPath)
//
// const userStore = useUserStore();
// const configStore = useConfigStore();
//
// // if (to.matched.length === 0) {
// // return router.push({ name: "errors.404" });
// // }
//
// if (to.meta.title) {
// document.title = to.meta.title + " - " + configStore.getAppName();
// } else {
// document.title = configStore.getAppName();
// }
//
// if (to.meta.auth == true) {
// // validate login state
// if (userStore.jwt_token == null) {
// router.push({ name: "login" });
// }
// } else {
// document.title = configStore.getAppName();
// }
//
// return true;
//
// });
export default router;

27
src/stores/config.ts Normal file
View File

@ -0,0 +1,27 @@
import {defineStore} from 'pinia'
// import axios from "axios";
export const useConfigStore = defineStore('app', {
state: () => ({
appName: "资料库",
description: "Leaf Library",
accountServer: "https://oauth.leaflow.cn",
apiServer: "https://document-api.leaflow.cn/api",
// apiServer: "http://localhost:8080/api",
}),
actions: {
getAppName(): string {
return this.appName !== null ? this.appName : "Leaf Library"
},
getRefreshUrl(): string {
return this.accountServer + "/public/auth_request/refresh"
},
getLoginUrl(): string {
let url = new URL(this.accountServer + "/public/auth_request")
url.searchParams.append("description", this.description)
// url.searchParams.append("callback_uri", window.location.href)
url.searchParams.append("attributes[app]", "todo")
return url.toString()
}
},
})

10
src/views/Home.vue Normal file
View File

@ -0,0 +1,10 @@
<template>
<div>
<HelloWorld />
</div>
</template>
<script lang="ts" setup>
import HelloWorld from '@/components/HelloWorld.vue'
</script>

View File

@ -1,32 +1,32 @@
{
"compilerOptions": {
"target": "ESNext",
"jsx": "preserve",
"lib": ["DOM", "ESNext"],
"baseUrl": ".",
"module": "ESNext",
"target": "esnext",
"useDefineForClassFields": true,
"allowSyntheticDefaultImports": true,
"composite": true,
"module": "esnext",
"moduleResolution": "node",
"strict": true,
"jsx": "preserve",
"sourceMap": false,
"resolveJsonModule": true,
"esModuleInterop": true,
"lib": ["esnext", "dom"],
"types": [
"node",
"vuetify"
],
"paths": {
"@/*": ["src/*"]
},
"resolveJsonModule": true,
"types": [
"vite/client",
"vite-plugin-vue-layouts/client",
"unplugin-vue-router/client"
],
"allowJs": true,
"strict": true,
"strictNullChecks": true,
"noUnusedLocals": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"skipLibCheck": true
"allowJs": true
},
"include": [
"./src/typed-router.d.ts"
],
"exclude": ["dist", "node_modules", "cypress"],
"references": [{ "path": "./tsconfig.node.json" }],
"src/**/*.ts",
"src/**/*.d.ts",
"src/**/*.tsx",
"src/**/*.vue",
"vite.config.ts"
]
}