init: 基本布局

This commit is contained in:
Rewrite0
2022-07-23 20:59:55 +08:00
commit ce1e6c3752
21 changed files with 1501 additions and 0 deletions

24
.gitignore vendored Normal file
View File

@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

3
.vscode/extensions.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"recommendations": ["Vue.volar"]
}

16
README.md Normal file
View File

@@ -0,0 +1,16 @@
# Vue 3 + TypeScript + Vite
This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
## Recommended IDE Setup
- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar)
## Type Support For `.vue` Imports in TS
Since TypeScript cannot handle type information for `.vue` imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. However, if you wish to get actual prop types in `.vue` imports (for example to get props validation when using manual `h(...)` calls), you can enable Volar's Take Over mode by following these steps:
1. Run `Extensions: Show Built-in Extensions` from VS Code's command palette, look for `TypeScript and JavaScript Language Features`, then right click and select `Disable (Workspace)`. By default, Take Over mode will enable itself if the default TypeScript extension is disabled.
2. Reload the VS Code window by running `Developer: Reload Window` from the command palette.
You can learn more about Take Over mode [here](https://github.com/johnsoncodehk/volar/discussions/471).

5
auto-imports.d.ts vendored Normal file
View File

@@ -0,0 +1,5 @@
// Generated by 'unplugin-auto-import'
export {}
declare global {
}

25
components.d.ts vendored Normal file
View File

@@ -0,0 +1,25 @@
// generated by unplugin-vue-components
// We suggest you to commit this file into source control
// Read more: https://github.com/vuejs/core/pull/3399
import '@vue/runtime-core'
export {}
declare module '@vue/runtime-core' {
export interface GlobalComponents {
ElAside: typeof import('element-plus/es')['ElAside']
ElCol: typeof import('element-plus/es')['ElCol']
ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
ElContainer: typeof import('element-plus/es')['ElContainer']
ElHeader: typeof import('element-plus/es')['ElHeader']
ElIcon: typeof import('element-plus/es')['ElIcon']
ElMain: typeof import('element-plus/es')['ElMain']
ElMenu: typeof import('element-plus/es')['ElMenu']
ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
ElMenuItemGroup: typeof import('element-plus/es')['ElMenuItemGroup']
ElRow: typeof import('element-plus/es')['ElRow']
ElSubMenu: typeof import('element-plus/es')['ElSubMenu']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
}
}

13
index.html Normal file
View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Vue + TS</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>

30
package.json Normal file
View File

@@ -0,0 +1,30 @@
{
"name": "ab-webui",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"preview": "vite preview"
},
"dependencies": {
"element-plus": "^2.2.10",
"modern-normalize": "^1.1.0",
"vue": "^3.2.37",
"vue-global-api": "^0.4.1",
"vue-router": "4"
},
"devDependencies": {
"@types/node": "^18.0.6",
"@vicons/carbon": "^0.12.0",
"@vicons/utils": "^0.1.4",
"@vitejs/plugin-vue": "^3.0.0",
"sass": "^1.54.0",
"typescript": "^4.6.4",
"unplugin-auto-import": "^0.10.0",
"unplugin-vue-components": "^0.21.1",
"vite": "^3.0.0",
"vue-tsc": "^0.38.4"
}
}

1140
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

14
src/App.vue Normal file
View File

@@ -0,0 +1,14 @@
<script setup lang="ts">
import zhCn from 'element-plus/lib/locale/lang/zh-cn'
import { IconConfigProvider } from '@vicons/utils'
</script>
<template>
<Suspense>
<el-config-provider :locale="zhCn">
<icon-config-provider size="18">
<RouterView />
</icon-config-provider>
</el-config-provider>
</Suspense>
</template>

BIN
src/assets/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

14
src/main.ts Normal file
View File

@@ -0,0 +1,14 @@
import { createApp } from 'vue'
import App from './App.vue'
import 'vue-global-api'
import 'modern-normalize/modern-normalize.css'
import router from './router';
import { Icon } from '@vicons/utils'
const app = createApp(App)
app.component('Icon', Icon);
app.use(router)
app.mount('#app')

17
src/pages/YBangumi.vue Normal file
View File

@@ -0,0 +1,17 @@
<script setup lang="ts">
</script>
<template>
<section class="bangumi">
<el-row>
<el-col>
</el-col>
</el-row>
</section>
</template>
<style lang='scss' scope>
</style>

9
src/pages/YDebug.vue Normal file
View File

@@ -0,0 +1,9 @@
<script setup lang="ts">
</script>
<template>
debug
</template>
<style lang='scss' scope>
</style>

48
src/pages/YLayout.vue Normal file
View File

@@ -0,0 +1,48 @@
<script setup lang="ts">
import YMenu from './YMenu.vue';
</script>
<template>
<div class="app-layout">
<el-container>
<el-header class="header">
<img
src="@/assets/logo.png"
alt="logo"
class="logo"
>
</el-header>
<el-container>
<el-aside width="200px">
<YMenu />
</el-aside>
<el-main>
<RouterView />
</el-main>
</el-container>
</el-container>
</div>
</template>
<style lang='scss' scope>
.app-layout {
width: 100%;
height: 100vh;
overflow: hidden;
display: flex;
}
.header {
display: flex;
align-items: center;
justify-content: center;
border-bottom: 1px solid var(--el-border-color);
height: 65px;
.logo {
height: 70%;
}
}
</style>

37
src/pages/YMenu.vue Normal file
View File

@@ -0,0 +1,37 @@
<script setup lang="ts">
import { Home, Debug } from '@vicons/carbon';
</script>
<template>
<ElMenu
default-active="/bangumi"
class="app-menu"
router
>
<ElMenuItem index="/bangumi">
<Icon>
<Home />
</Icon>
<template #title>番剧管理</template>
</ElMenuItem>
<ElMenuItem index="/debug">
<Icon>
<Debug />
</Icon>
<template #title>调试</template>
</ElMenuItem>
</ElMenu>
</template>
<style lang='scss' scope>
.app-menu {
height: 100%;
.xicon{
margin-right: .5em;
}
}
</style>

30
src/router/index.ts Normal file
View File

@@ -0,0 +1,30 @@
import { createRouter, createWebHashHistory } from 'vue-router';
const YLayout = () => import('../pages/YLayout.vue');
const YBangumi = () => import('../pages/YBangumi.vue');
const YDebug = () => import('../pages/YDebug.vue');
const routes = [
{
path: '/',
component: YLayout,
redirect: '/bangumi',
children: [
{
path: 'bangumi',
component: YBangumi
},
{
path: 'debug',
component: YDebug
}
]
},
]
const router = createRouter({
history: createWebHashHistory(),
routes,
})
export default router;

7
src/vite-env.d.ts vendored Normal file
View File

@@ -0,0 +1,7 @@
/// <reference types="vite/client" />
declare module '*.vue' {
import type { DefineComponent } from 'vue'
const component: DefineComponent<{}, {}, any>
export default component
}

26
tsconfig.json Normal file
View File

@@ -0,0 +1,26 @@
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"module": "ESNext",
"moduleResolution": "Node",
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
"isolatedModules": true,
"esModuleInterop": true,
"lib": ["ESNext", "DOM"],
"skipLibCheck": true,
"baseUrl": "./",
"paths": {
"@/*": ["src/*"],
"#/*": ["src/types/*"]
},
"types": [
"element-plus/global"
]
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
"references": [{ "path": "./tsconfig.node.json" }]
}

9
tsconfig.node.json Normal file
View File

@@ -0,0 +1,9 @@
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}

34
vite.config.ts Normal file
View File

@@ -0,0 +1,34 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path';
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
AutoImport({
resolvers: [ElementPlusResolver()],
}),
Components({
resolvers: [ElementPlusResolver()],
}),
],
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
'#': resolve(__dirname, 'types')
}
},
server: {
proxy: {
'/api': {
target: 'http://192.168.0.2',
changeOrigin: true,
rewrite: path => path.replace(/^\/api/, '/api')
}
}
}
})