Browse Source

init template

master
wally 4 years ago
commit
52b8226ca2
  1. 5
      .gitignore
  2. 1
      .npmrc
  3. 3
      .vscode/extensions.json
  4. 6
      .vscode/settings.json
  5. 7
      README.md
  6. 13
      index.html
  7. 5142
      package-lock.json
  8. 22
      package.json
  9. BIN
      public/favicon.ico
  10. 10
      src/App.vue
  11. BIN
      src/assets/logo.png
  12. 3
      src/components/navbar.vue
  13. 11
      src/main.js
  14. 14
      src/routers/index.js
  15. 8
      src/views/network-config.vue
  16. 28
      vite.config.js

5
.gitignore

@ -0,0 +1,5 @@
node_modules
.DS_Store
dist
dist-ssr
*.local

1
.npmrc

@ -0,0 +1 @@
registry=https://registry.npm.taobao.org

3
.vscode/extensions.json

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

6
.vscode/settings.json

@ -0,0 +1,6 @@
{
"cSpell.words": [
"windi",
"windicss"
]
}

7
README.md

@ -0,0 +1,7 @@
# Vue 3 + Vite
This template should help get you started developing with Vue 3 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
- [VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar)

13
index.html

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

5142
package-lock.json

File diff suppressed because it is too large

22
package.json

@ -0,0 +1,22 @@
{
"name": "vue3-vite-template",
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vite build",
"serve": "vite preview"
},
"dependencies": {
"element-plus": "^1.1.0-beta.21",
"unplugin-vue-components": "^0.15.6",
"vite-plugin-windicss": "^1.4.11",
"vue": "^3.2.16",
"vue-router": "^4.0.12",
"windicss": "^3.1.9"
},
"devDependencies": {
"@vitejs/plugin-vue": "^1.9.3",
"vite": "^2.6.4",
"vite-plugin-linter": "^1.0.1"
}
}

BIN
public/favicon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

10
src/App.vue

@ -0,0 +1,10 @@
<script setup>
import Navbar from 'components/navbar.vue';
</script>
<template>
<Navbar />
<div class="p-4">
<router-view></router-view>
</div>
</template>

BIN
src/assets/logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

3
src/components/navbar.vue

@ -0,0 +1,3 @@
<template>
<h1 class="text-lg font-medium py-3 px-6 shadow">{{ $route.meta.title || '智能大气腐蚀检测平台' }}</h1>
</template>

11
src/main.js

@ -0,0 +1,11 @@
import 'virtual:windi.css'
import App from './App.vue'
import { createApp } from 'vue'
import router from './routers/index';
const app = createApp(App);
app
.use(router)
.mount('#app')

14
src/routers/index.js

@ -0,0 +1,14 @@
import { createRouter, createWebHistory } from 'vue-router'
// 还有 createWebHashHistory 和 createMemoryHistory
const routes = [
{ path: '/', redirect: '/network-config'},
{ path: '/network-config', name: 'network-config', meta: { title: '网络参数配置' }, component: () => import('@/views/network-config.vue')}
];
const router = createRouter({
history: createWebHistory(),
routes,
})
export default router

8
src/views/network-config.vue

@ -0,0 +1,8 @@
<template>
<el-row :gutter="20">
<el-col :span="6"><div class="bg-gray-400">1</div></el-col>
<el-col :span="6"><div class="bg-gray-400">2</div></el-col>
<el-col :span="6"><div class="bg-gray-400">3</div></el-col>
<el-col :span="6"><div class="bg-gray-400">4</div></el-col>
</el-row>
</template>

28
vite.config.js

@ -0,0 +1,28 @@
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import WindiCSS from 'vite-plugin-windicss';
import { defineConfig } from 'vite'
import path from 'path';
import vue from '@vitejs/plugin-vue'
const resolve = dir => path.join(__dirname, dir);
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
WindiCSS(),
Components({
resolvers: [ElementPlusResolver()],
}),
],
resolve: {
alias: {
'~': __dirname,
'@': resolve('src'),
'views': resolve('src/views'),
'components': resolve('src/components'),
'assets': resolve('src/assets'),
}
}
})
Loading…
Cancel
Save