This commit is contained in:
jxxghp
2023-06-26 07:23:21 +08:00
parent 4d8f63c223
commit c1815e9266
12 changed files with 47 additions and 74 deletions

12
components.d.ts vendored
View File

@@ -9,13 +9,13 @@ export {}
declare module '@vue/runtime-core' {
export interface GlobalComponents {
CardStatisticsHorizontal: typeof import('./src/@core/components/cards/CardStatisticsHorizontal.vue')['default']
CardStatisticsVertical: typeof import('./src/@core/components/cards/CardStatisticsVertical.vue')['default']
CardStatisticsWithImages: typeof import('./src/@core/components/cards/CardStatisticsWithImages.vue')['default']
ErrorHeader: typeof import('./src/@core/components/ErrorHeader.vue')['default']
MoreBtn: typeof import('./src/@core/components/MoreBtn.vue')['default']
CardStatisticsHorizontal: typeof import('./src/components/cards/CardStatisticsHorizontal.vue')['default']
CardStatisticsVertical: typeof import('./src/components/cards/CardStatisticsVertical.vue')['default']
CardStatisticsWithImages: typeof import('./src/components/cards/CardStatisticsWithImages.vue')['default']
ErrorHeader: typeof import('./src/@components/ErrorHeader.vue')['default']
MoreBtn: typeof import('./src/@components/MoreBtn.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
ThemeSwitcher: typeof import('./src/@core/components/ThemeSwitcher.vue')['default']
ThemeSwitcher: typeof import('./src/@components/ThemeSwitcher.vue')['default']
}
}

View File

@@ -1,8 +1,8 @@
<script setup lang="ts">
interface Props {
errorCode: string
errorTitle: string
errorDescription: string
errorCode?: string
errorTitle?: string
errorDescription?: string
}
const props = defineProps<Props>()
@@ -11,13 +11,19 @@ const props = defineProps<Props>()
<template>
<div class="text-center mb-4">
<!-- 👉 Title and subtitle -->
<h1 class="text-h1">
<h1
v-if="props.errorCode"
class="text-h1 font-weight-medium"
>
{{ props.errorCode }}
</h1>
<h5 class="text-h5 mb-1">
<h5
v-if="props.errorTitle"
class="text-h5 font-weight-medium mb-3"
>
{{ props.errorTitle }}
</h5>
<p class="text-sm">
<p v-if="props.errorDescription">
{{ props.errorDescription }}
</p>
</div>

View File

@@ -1,9 +1,6 @@
import router from '@/router';
import axios from 'axios';
import { useStore } from 'vuex';
// Vuex Store
const store = useStore();
import router from '@/router'
import store from '@/store'
import axios from 'axios'
// 创建axios实例
const api = axios.create({

View File

@@ -1,30 +0,0 @@
<script setup lang="ts">
interface Props {
errorCode?: string
errorTitle?: string
errorDescription?: string
}
const props = defineProps<Props>()
</script>
<template>
<div class="text-center mb-4">
<!-- 👉 Title and subtitle -->
<h1
v-if="props.errorCode"
class="text-h1 font-weight-medium"
>
{{ props.errorCode }}
</h1>
<h5
v-if="props.errorTitle"
class="text-h5 font-weight-medium mb-3"
>
{{ props.errorTitle }}
</h5>
<p v-if="props.errorDescription">
{{ props.errorDescription }}
</p>
</div>
</template>

View File

@@ -15,10 +15,9 @@ loadFonts()
// Create vue app
const app = createApp(App)
// Use plugins
app.use(vuetify)
app.use(store)
app.use(router)
// Mount vue app
app.mount('#app')
// Use plugins Mount vue app
app
.use(vuetify)
.use(router)
.use(store)
.mount('#app')

View File

@@ -8,7 +8,7 @@ import AnalyticsTotalProfitLineCharts from '@/views/dashboard/AnalyticsTotalProf
import AnalyticsTransactions from '@/views/dashboard/AnalyticsTransactions.vue'
import AnalyticsUserTable from '@/views/dashboard/AnalyticsUserTable.vue'
import AnalyticsWeeklyOverview from '@/views/dashboard/AnalyticsWeeklyOverview.vue'
import CardStatisticsVertical from '@core/components/cards/CardStatisticsVertical.vue'
import CardStatisticsVertical from '@components/cards/CardStatisticsVertical.vue'
const totalProfit = {
title: 'Total Profit',

View File

@@ -1,11 +1,11 @@
<script setup lang="ts">
import api from '@/api';
import router from '@/router';
import logo from '@images/logo.svg?raw';
import { useStore } from 'vuex';
import { useStore } from 'vuex'
import api from '@/api'
import router from '@/router'
import logo from '@images/logo.svg?raw'
// Vuex Store
const store = useStore();
const store = useStore()
// 表单
const form = ref({
@@ -59,11 +59,11 @@ const login = () => {
})
.then((response: any) => {
// 获取token
const token = response.access_token;
const token = response.access_token
// 更新token和remember状态到Vuex Store
store.dispatch('auth/updateToken', token);
store.dispatch('auth/updateRemember', form.value.remember);
store.dispatch('auth/updateToken', token)
store.dispatch('auth/updateRemember', form.value.remember)
// 跳转到首页
router.push('/')
@@ -90,8 +90,8 @@ const login = () => {
// 自动登录
onMounted(() => {
// 从Vuex Store中获取token和remember状态
const token = store.state.auth.token;
const remember = store.state.auth.remember;
const token = store.state.auth.token
const remember = store.state.auth.remember
// 如果token存在且保持登录状态为true则跳转到首页
if (token && remember) {

View File

@@ -1,5 +1,5 @@
import store from '@/store';
import { createRouter, createWebHistory } from 'vue-router';
import { createRouter, createWebHistory } from 'vue-router'
import store from '@/store'
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
@@ -105,13 +105,14 @@ const router = createRouter({
// 导航守卫
router.beforeEach((to, from, next) => {
// 通过 Vuex Store 检查用户是否已登录
const isAuthenticated = store.state.auth.token !== null;
const isAuthenticated = store.state.auth.token !== null
if (to.meta.requiresAuth && !isAuthenticated) {
// 如果路由需要登录权限且用户未登录,则跳转到登录页面
next('/login');
} else {
next('/login')
}
else {
// 否则,允许继续进行路由导航
next();
next()
}
})

View File

@@ -1,6 +1,6 @@
import { fileURLToPath } from 'node:url'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { fileURLToPath } from 'node:url'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { defineConfig } from 'vite'
@@ -20,7 +20,7 @@ export default defineConfig({
},
}),
Components({
dirs: ['src/@core/components'],
dirs: ['src/@components'],
dts: true,
}),
AutoImport({