Browse Source

init

master
nelson 2 years ago
commit
4c0bfdf48a
  1. 24
      .gitignore
  2. 23
      README.md
  3. 13
      index.html
  4. 23
      package.json
  5. BIN
      public/favicon.ico
  6. 19
      src/App.vue
  7. BIN
      src/assets/logo.png
  8. 52
      src/components/HelloWorld.vue
  9. 8
      src/env.d.ts
  10. 9
      src/main.ts
  11. 23
      src/router/index.js
  12. 10
      src/store/index.js
  13. 18
      src/utils/request.js
  14. 14
      src/views/tst/About.vue
  15. 14
      src/views/tst/Home.vue
  16. 17
      tsconfig.json
  17. 8
      tsconfig.node.json
  18. 7
      vite.config.ts

24
.gitignore

@ -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?

23
README.md

@ -0,0 +1,23 @@
# 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=johnsoncodehk.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).
npm install vue-router save
npm install vuex save
npm install axios save

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.ts"></script>
</body>
</html>

23
package.json

@ -0,0 +1,23 @@
{
"name": "stock-web",
"private": true,
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"preview": "vite preview"
},
"dependencies": {
"axios": "^0.26.1",
"save": "^2.4.0",
"vue": "^3.2.25",
"vue-router": "^4.0.14",
"vuex": "^4.0.2"
},
"devDependencies": {
"@vitejs/plugin-vue": "^2.3.1",
"typescript": "^4.5.4",
"vite": "^2.9.2",
"vue-tsc": "^0.29.8"
}
}

BIN
public/favicon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

19
src/App.vue

@ -0,0 +1,19 @@
<script setup lang="ts">
</script>
<template>
<img alt="Vue logo" src="./assets/logo.png"/>
<router-view/>
</template>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>

BIN
src/assets/logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

52
src/components/HelloWorld.vue

@ -0,0 +1,52 @@
<script setup lang="ts">
import { ref } from 'vue'
defineProps<{ msg: string }>()
const count = ref(0)
</script>
<template>
<h1>{{ msg }}</h1>
<p>
Recommended IDE setup:
<a href="https://code.visualstudio.com/" target="_blank">VS Code</a>
+
<a href="https://github.com/johnsoncodehk/volar" target="_blank">Volar</a>
</p>
<p>See <code>README.md</code> for more information.</p>
<p>
<a href="https://vitejs.dev/guide/features.html" target="_blank">
Vite Docs
</a>
|
<a href="https://v3.vuejs.org/" target="_blank">Vue 3 Docs</a>
</p>
<button type="button" @click="count++">count is: {{ count }}</button>
<p>
Edit
<code>components/HelloWorld.vue</code> to test hot module replacement.
</p>
</template>
<style scoped>
a {
color: #42b983;
}
label {
margin: 0 0.5em;
font-weight: bold;
}
code {
background-color: #eee;
padding: 2px 4px;
border-radius: 4px;
color: #304455;
}
</style>

8
src/env.d.ts

@ -0,0 +1,8 @@
/// <reference types="vite/client" />
declare module '*.vue' {
import type { DefineComponent } from 'vue'
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
const component: DefineComponent<{}, {}, any>
export default component
}

9
src/main.ts

@ -0,0 +1,9 @@
import { createApp } from 'vue'
import App from './App.vue'
// @ts-ignore
import router from './router/index'
// @ts-ignore
import store from './store/index'
createApp(App).use(router).use(store).mount('#app')

23
src/router/index.js

@ -0,0 +1,23 @@
import {createRouter,createWebHashHistory} from 'vue-router'
import Home from '../views/tst/Home.vue'
const routes = [
{
path: '/',
name: 'Home',
component: Home
},
{
path: '/about',
name: 'About',
component: () => import('../views/tst/About.vue')
}
]
const router = createRouter({
history: createWebHashHistory(),
routes
})
export default router

10
src/store/index.js

@ -0,0 +1,10 @@
import {createStore} from 'vuex'
export default createStore({
state: {
num: 0
},
mutations:{},
actions:{},
modules:{}
})

18
src/utils/request.js

@ -0,0 +1,18 @@
import axios from "axios"
const service = axios.create({
baseURL: 'http://127.0.0.1:8888',
timeout: 10000
})
service.interceptors.request.use(config => {
return config
})
service.interceptors.response.use(response => {
return response
},error => {
return Promise.reject(error)
})
export default service

14
src/views/tst/About.vue

@ -0,0 +1,14 @@
<template>
<div>{{name}}</div>
</template>
<script setup lang="ts">
import {ref} from 'vue'
const name = ref('this is about')
</script>
<style scoped>
</style>

14
src/views/tst/Home.vue

@ -0,0 +1,14 @@
<template>
<div>{{name}}</div>
</template>
<script setup lang="ts">
import {ref} from 'vue'
const name = ref('this is home')
</script>
<style scoped>
</style>

17
tsconfig.json

@ -0,0 +1,17 @@
{
"compilerOptions": {
"target": "esnext",
"useDefineForClassFields": true,
"module": "esnext",
"moduleResolution": "node",
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
"isolatedModules": true,
"esModuleInterop": true,
"lib": ["esnext", "dom"]
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
"references": [{ "path": "./tsconfig.node.json" }]
}

8
tsconfig.node.json

@ -0,0 +1,8 @@
{
"compilerOptions": {
"composite": true,
"module": "esnext",
"moduleResolution": "node"
},
"include": ["vite.config.ts"]
}

7
vite.config.ts

@ -0,0 +1,7 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()]
})
Loading…
Cancel
Save