forked from UzTech/Vue3-typescript-demo
init
This commit is contained in:
@@ -4,12 +4,12 @@
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"serve": "vue-cli-service serve --open --mode=development",
|
||||
"start": "vue-cli-service serve --open --mode=development",
|
||||
"build": "vue-cli-service build",
|
||||
"lint": "vue-cli-service lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.21.4",
|
||||
"qs": "^6.10.1",
|
||||
"vue": "^3.2.11",
|
||||
"vue-router": "^4.0.11",
|
||||
"vuex": "^4.0.2",
|
||||
@@ -31,7 +31,6 @@
|
||||
"eslint-plugin-vue": "^7.0.0",
|
||||
"less": "^3.0.4",
|
||||
"less-loader": "^5.0.0",
|
||||
"postcss-px-to-viewport": "^1.1.1",
|
||||
"typescript": "~4.1.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
module.exports = {
|
||||
plugins: {
|
||||
'postcss-px-to-viewport': {
|
||||
viewportWidth: 375
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
19
src/App.vue
19
src/App.vue
@@ -4,34 +4,15 @@
|
||||
<component :is="Component"></component>
|
||||
</keep-alive>
|
||||
</router-view>
|
||||
|
||||
<div>
|
||||
<router-link :to="{name:'Home'}">Home</router-link>
|
||||
|
|
||||
<router-link :to="{name:'User'}">User</router-link>
|
||||
|
|
||||
<router-link :to="{name:'AuthLogin'}">Login</router-link>
|
||||
|
|
||||
<router-link :to="{name:'AuthRegister'}">Register</router-link>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { INVITE_CODE } from '@/store'
|
||||
import qs from 'qs'
|
||||
import { ref, watch } from 'vue'
|
||||
import { RouteLocationNormalizedLoaded, useRoute } from 'vue-router'
|
||||
|
||||
const includeList = ref<string[]>([])
|
||||
const route = useRoute()
|
||||
|
||||
const { search } = location
|
||||
|
||||
if (search && search.indexOf('?') !== -1) {
|
||||
const { invite } = qs.parse(location.search.slice(1))
|
||||
invite && localStorage.setItem(INVITE_CODE, invite as string)
|
||||
}
|
||||
|
||||
watch(route, (to: RouteLocationNormalizedLoaded) => {
|
||||
if (to.meta?.keepAlive && includeList.value.indexOf(to.name as string) === -1) {
|
||||
includeList.value.push(to.name as string)
|
||||
|
||||
@@ -7,7 +7,6 @@ import auth, { AuthState } from './modules/auth'
|
||||
import refresh, { RefreshState } from './modules/refresh'
|
||||
|
||||
export const PERSISTED_KEY = process.env.VUE_APP_VUEX_KEY
|
||||
export const INVITE_CODE = 'invite_code'
|
||||
|
||||
export const key: InjectionKey<Store<State>> = Symbol()
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
<template>
|
||||
注册
|
||||
|
||||
<h2>邀请码: {{ invite }}</h2>
|
||||
|
||||
<button @click="onRegister">注册一个号</button>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { INVITE_CODE, useStore } from '@/store'
|
||||
import { useStore } from '@/store'
|
||||
import type { AuthData } from '@/types/auth'
|
||||
import { ref } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
@@ -15,7 +13,6 @@ import { useRoute, useRouter } from 'vue-router'
|
||||
const store = useStore()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const invite = localStorage.getItem(INVITE_CODE)
|
||||
const loading = ref<boolean>(false)
|
||||
|
||||
const onRegister = (e: AuthData) => {
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
<template>
|
||||
<div class="home">
|
||||
<h1>{{ info.user_id }}</h1>
|
||||
<h2>{{ info.nickname }}</h2>
|
||||
<h3>{{ info.username }}</h3>
|
||||
<img :src="info.avatar" width="80" alt="">
|
||||
我是首页
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
35
yarn.lock
35
yarn.lock
@@ -6270,7 +6270,7 @@ oauth-sign@~0.9.0:
|
||||
resolved "https://registry.nlark.com/oauth-sign/download/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455"
|
||||
integrity sha1-R6ewFrqmi1+g7PPe4IqFxnmsZFU=
|
||||
|
||||
object-assign@>=4.0.1, object-assign@^4.0.1, object-assign@^4.1.0, object-assign@^4.1.1:
|
||||
object-assign@^4.0.1, object-assign@^4.1.0, object-assign@^4.1.1:
|
||||
version "4.1.1"
|
||||
resolved "https://registry.nlark.com/object-assign/download/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
|
||||
integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=
|
||||
@@ -7039,14 +7039,6 @@ postcss-ordered-values@^4.1.2:
|
||||
postcss "^7.0.0"
|
||||
postcss-value-parser "^3.0.0"
|
||||
|
||||
postcss-px-to-viewport@^1.1.1:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/postcss-px-to-viewport/-/postcss-px-to-viewport-1.1.1.tgz#a25ca410b553c9892cc8b525cc710da47bf1aa55"
|
||||
integrity sha512-2x9oGnBms+e0cYtBJOZdlwrFg/mLR4P1g2IFu7jYKvnqnH/HLhoKyareW2Q/x4sg0BgklHlP1qeWo2oCyPm8FQ==
|
||||
dependencies:
|
||||
object-assign ">=4.0.1"
|
||||
postcss ">=5.0.2"
|
||||
|
||||
postcss-reduce-initial@^4.0.3:
|
||||
version "4.0.3"
|
||||
resolved "https://registry.nlark.com/postcss-reduce-initial/download/postcss-reduce-initial-4.0.3.tgz#7fd42ebea5e9c814609639e2c2e84ae270ba48df"
|
||||
@@ -7112,15 +7104,6 @@ postcss-value-parser@^4.0.2, postcss-value-parser@^4.1.0:
|
||||
resolved "https://registry.nlark.com/postcss-value-parser/download/postcss-value-parser-4.1.0.tgz#443f6a20ced6481a2bda4fa8532a6e55d789a2cb"
|
||||
integrity sha1-RD9qIM7WSBor2k+oUypuVdeJoss=
|
||||
|
||||
postcss@>=5.0.2, postcss@^8.1.10:
|
||||
version "8.3.6"
|
||||
resolved "https://registry.nlark.com/postcss/download/postcss-8.3.6.tgz?cache=0&sync_timestamp=1626882858066&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fpostcss%2Fdownload%2Fpostcss-8.3.6.tgz#2730dd76a97969f37f53b9a6096197be311cc4ea"
|
||||
integrity sha1-JzDddql5afN/U7mmCWGXvjEcxOo=
|
||||
dependencies:
|
||||
colorette "^1.2.2"
|
||||
nanoid "^3.1.23"
|
||||
source-map-js "^0.6.2"
|
||||
|
||||
postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.14, postcss@^7.0.27, postcss@^7.0.32, postcss@^7.0.36, postcss@^7.0.5, postcss@^7.0.6:
|
||||
version "7.0.36"
|
||||
resolved "https://registry.nlark.com/postcss/download/postcss-7.0.36.tgz?cache=0&sync_timestamp=1626882858066&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fpostcss%2Fdownload%2Fpostcss-7.0.36.tgz#056f8cffa939662a8f5905950c07d5285644dfcb"
|
||||
@@ -7130,6 +7113,15 @@ postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.14, postcss@^7.0.27, postcss@^7.0.3
|
||||
source-map "^0.6.1"
|
||||
supports-color "^6.1.0"
|
||||
|
||||
postcss@^8.1.10:
|
||||
version "8.3.6"
|
||||
resolved "https://registry.nlark.com/postcss/download/postcss-8.3.6.tgz?cache=0&sync_timestamp=1626882858066&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fpostcss%2Fdownload%2Fpostcss-8.3.6.tgz#2730dd76a97969f37f53b9a6096197be311cc4ea"
|
||||
integrity sha1-JzDddql5afN/U7mmCWGXvjEcxOo=
|
||||
dependencies:
|
||||
colorette "^1.2.2"
|
||||
nanoid "^3.1.23"
|
||||
source-map-js "^0.6.2"
|
||||
|
||||
prelude-ls@~1.1.2:
|
||||
version "1.1.2"
|
||||
resolved "https://registry.nlark.com/prelude-ls/download/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
|
||||
@@ -7258,13 +7250,6 @@ qs@6.7.0:
|
||||
resolved "https://registry.nlark.com/qs/download/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc"
|
||||
integrity sha1-QdwaAV49WB8WIXdr4xr7KHapsbw=
|
||||
|
||||
qs@^6.10.1:
|
||||
version "6.10.1"
|
||||
resolved "https://registry.yarnpkg.com/qs/-/qs-6.10.1.tgz#4931482fa8d647a5aab799c5271d2133b981fb6a"
|
||||
integrity sha512-M528Hph6wsSVOBiYUnGf+K/7w0hNshs/duGsNXPUCLH5XAqjEtiPGwNONLV0tBH8NoGb0mvD5JubnUTrujKDTg==
|
||||
dependencies:
|
||||
side-channel "^1.0.4"
|
||||
|
||||
qs@~6.5.2:
|
||||
version "6.5.2"
|
||||
resolved "https://registry.nlark.com/qs/download/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36"
|
||||
|
||||
Reference in New Issue
Block a user