add
This commit is contained in:
24
frontend/.gitignore
vendored
Normal file
24
frontend/.gitignore
vendored
Normal 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?
|
||||
5
frontend/README.md
Normal file
5
frontend/README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# 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.
|
||||
|
||||
Learn more about IDE Support for Vue in the [Vue Docs Scaling up Guide](https://vuejs.org/guide/scaling-up/tooling.html#ide-support).
|
||||
13
frontend/index.html
Normal file
13
frontend/index.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>frontend</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
1684
frontend/package-lock.json
generated
Normal file
1684
frontend/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
23
frontend/package.json
Normal file
23
frontend/package.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "frontend",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@arco-design/web-vue": "^2.56.3",
|
||||
"axios": "^1.7.9",
|
||||
"dayjs": "^1.11.11",
|
||||
"pinia": "^2.2.4",
|
||||
"vue": "^3.5.24",
|
||||
"vue-router": "^4.4.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^5.1.4",
|
||||
"vite": "^5.4.10"
|
||||
}
|
||||
}
|
||||
1
frontend/public/vite.svg
Normal file
1
frontend/public/vite.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
82
frontend/src/App.vue
Normal file
82
frontend/src/App.vue
Normal file
@@ -0,0 +1,82 @@
|
||||
<template>
|
||||
<a-layout class="layout">
|
||||
<a-layout-header class="header">
|
||||
<div class="logo">车智租车</div>
|
||||
<a-menu mode="horizontal" :selected-keys="[active]">
|
||||
<a-menu-item key="/">
|
||||
<router-link to="/">租车大厅</router-link>
|
||||
</a-menu-item>
|
||||
<a-menu-item key="/favorites">
|
||||
<router-link to="/favorites">收藏夹</router-link>
|
||||
</a-menu-item>
|
||||
<a-menu-item key="/orders">
|
||||
<router-link to="/orders">我的订单</router-link>
|
||||
</a-menu-item>
|
||||
<a-menu-item key="/profile">
|
||||
<router-link to="/profile">个人中心</router-link>
|
||||
</a-menu-item>
|
||||
<a-sub-menu v-if="auth.role === 'ADMIN'" key="admin" title="管理后台">
|
||||
<a-menu-item key="/admin/cars">
|
||||
<router-link to="/admin/cars">车辆管理</router-link>
|
||||
</a-menu-item>
|
||||
<a-menu-item key="/admin/users">
|
||||
<router-link to="/admin/users">用户管理</router-link>
|
||||
</a-menu-item>
|
||||
<a-menu-item key="/admin/orders">
|
||||
<router-link to="/admin/orders">订单管理</router-link>
|
||||
</a-menu-item>
|
||||
<a-menu-item key="/admin/stats">
|
||||
<router-link to="/admin/stats">数据统计</router-link>
|
||||
</a-menu-item>
|
||||
</a-sub-menu>
|
||||
</a-menu>
|
||||
<div class="user-actions">
|
||||
<template v-if="auth.token">
|
||||
<a-tag color="arcoblue">{{ auth.user?.username || auth.role }}</a-tag>
|
||||
<a-button type="text" @click="logout">退出</a-button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<router-link to="/login">登录</router-link>
|
||||
<span class="divider">|</span>
|
||||
<router-link to="/register">注册</router-link>
|
||||
</template>
|
||||
</div>
|
||||
</a-layout-header>
|
||||
<a-layout-content class="content">
|
||||
<router-view />
|
||||
</a-layout-content>
|
||||
</a-layout>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, onMounted } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { useAuthStore } from './store/auth'
|
||||
import http from './api/http'
|
||||
|
||||
const auth = useAuthStore()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const active = computed(() => route.path)
|
||||
|
||||
const loadMe = async () => {
|
||||
if (!auth.token) return
|
||||
try {
|
||||
const user = await http.get('/api/user/me')
|
||||
auth.setUser(user)
|
||||
} catch (e) {
|
||||
auth.clear()
|
||||
}
|
||||
}
|
||||
|
||||
const logout = async () => {
|
||||
try {
|
||||
await http.post('/api/auth/logout')
|
||||
} finally {
|
||||
auth.clear()
|
||||
router.push('/login')
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadMe)
|
||||
</script>
|
||||
28
frontend/src/api/http.js
Normal file
28
frontend/src/api/http.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import axios from 'axios'
|
||||
import { useAuthStore } from '../store/auth'
|
||||
|
||||
const http = axios.create({
|
||||
baseURL: 'http://localhost:8080',
|
||||
timeout: 15000
|
||||
})
|
||||
|
||||
http.interceptors.request.use((config) => {
|
||||
const store = useAuthStore()
|
||||
if (store.token) {
|
||||
config.headers.Authorization = `Bearer ${store.token}`
|
||||
}
|
||||
return config
|
||||
})
|
||||
|
||||
http.interceptors.response.use(
|
||||
(response) => {
|
||||
const res = response.data
|
||||
if (res.code !== 0) {
|
||||
return Promise.reject(new Error(res.message || '请求失败'))
|
||||
}
|
||||
return res.data
|
||||
},
|
||||
(error) => Promise.reject(error)
|
||||
)
|
||||
|
||||
export default http
|
||||
1
frontend/src/assets/vue.svg
Normal file
1
frontend/src/assets/vue.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="37.07" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 198"><path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z"></path><path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z"></path><path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 496 B |
43
frontend/src/components/HelloWorld.vue
Normal file
43
frontend/src/components/HelloWorld.vue
Normal file
@@ -0,0 +1,43 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
|
||||
defineProps({
|
||||
msg: String,
|
||||
})
|
||||
|
||||
const count = ref(0)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<h1>{{ msg }}</h1>
|
||||
|
||||
<div class="card">
|
||||
<button type="button" @click="count++">count is {{ count }}</button>
|
||||
<p>
|
||||
Edit
|
||||
<code>components/HelloWorld.vue</code> to test HMR
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
Check out
|
||||
<a href="https://vuejs.org/guide/quick-start.html#local" target="_blank"
|
||||
>create-vue</a
|
||||
>, the official Vue + Vite starter
|
||||
</p>
|
||||
<p>
|
||||
Learn more about IDE Support for Vue in the
|
||||
<a
|
||||
href="https://vuejs.org/guide/scaling-up/tooling.html#ide-support"
|
||||
target="_blank"
|
||||
>Vue Docs Scaling up Guide</a
|
||||
>.
|
||||
</p>
|
||||
<p class="read-the-docs">Click on the Vite and Vue logos to learn more</p>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.read-the-docs {
|
||||
color: #888;
|
||||
}
|
||||
</style>
|
||||
13
frontend/src/main.js
Normal file
13
frontend/src/main.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import { createApp } from 'vue'
|
||||
import { createPinia } from 'pinia'
|
||||
import ArcoVue from '@arco-design/web-vue'
|
||||
import '@arco-design/web-vue/dist/arco.css'
|
||||
import './style.css'
|
||||
import App from './App.vue'
|
||||
import router from './router'
|
||||
|
||||
const app = createApp(App)
|
||||
app.use(createPinia())
|
||||
app.use(router)
|
||||
app.use(ArcoVue)
|
||||
app.mount('#app')
|
||||
46
frontend/src/router/index.js
Normal file
46
frontend/src/router/index.js
Normal file
@@ -0,0 +1,46 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import { useAuthStore } from '../store/auth'
|
||||
import Home from '../views/Home.vue'
|
||||
import Login from '../views/Login.vue'
|
||||
import Register from '../views/Register.vue'
|
||||
import CarDetail from '../views/CarDetail.vue'
|
||||
import Favorites from '../views/Favorites.vue'
|
||||
import Orders from '../views/Orders.vue'
|
||||
import Profile from '../views/Profile.vue'
|
||||
import AdminCars from '../views/admin/AdminCars.vue'
|
||||
import AdminUsers from '../views/admin/AdminUsers.vue'
|
||||
import AdminOrders from '../views/admin/AdminOrders.vue'
|
||||
import AdminStats from '../views/admin/AdminStats.vue'
|
||||
|
||||
const routes = [
|
||||
{ path: '/', component: Home },
|
||||
{ path: '/login', component: Login },
|
||||
{ path: '/register', component: Register },
|
||||
{ path: '/cars/:id', component: CarDetail },
|
||||
{ path: '/favorites', component: Favorites },
|
||||
{ path: '/orders', component: Orders },
|
||||
{ path: '/profile', component: Profile },
|
||||
{ path: '/admin/cars', component: AdminCars },
|
||||
{ path: '/admin/users', component: AdminUsers },
|
||||
{ path: '/admin/orders', component: AdminOrders },
|
||||
{ path: '/admin/stats', component: AdminStats }
|
||||
]
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes
|
||||
})
|
||||
|
||||
router.beforeEach((to) => {
|
||||
const store = useAuthStore()
|
||||
const requiresAuth = ['/favorites', '/orders', '/profile', '/admin/cars', '/admin/users', '/admin/orders', '/admin/stats']
|
||||
if (requiresAuth.includes(to.path) && !store.token) {
|
||||
return '/login'
|
||||
}
|
||||
if (to.path.startsWith('/admin') && store.role !== 'ADMIN') {
|
||||
return '/'
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
export default router
|
||||
27
frontend/src/store/auth.js
Normal file
27
frontend/src/store/auth.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export const useAuthStore = defineStore('auth', {
|
||||
state: () => ({
|
||||
token: localStorage.getItem('token') || '',
|
||||
role: localStorage.getItem('role') || '',
|
||||
user: null
|
||||
}),
|
||||
actions: {
|
||||
setAuth(token, role) {
|
||||
this.token = token
|
||||
this.role = role
|
||||
localStorage.setItem('token', token)
|
||||
localStorage.setItem('role', role)
|
||||
},
|
||||
clear() {
|
||||
this.token = ''
|
||||
this.role = ''
|
||||
this.user = null
|
||||
localStorage.removeItem('token')
|
||||
localStorage.removeItem('role')
|
||||
},
|
||||
setUser(user) {
|
||||
this.user = user
|
||||
}
|
||||
}
|
||||
})
|
||||
60
frontend/src/style.css
Normal file
60
frontend/src/style.css
Normal file
@@ -0,0 +1,60 @@
|
||||
body {
|
||||
margin: 0;
|
||||
background: #f5f7fa;
|
||||
color: #1d2129;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
|
||||
}
|
||||
|
||||
a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.layout {
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 24px;
|
||||
background: #ffffff;
|
||||
border-bottom: 1px solid #e5e6eb;
|
||||
}
|
||||
|
||||
.logo {
|
||||
font-weight: 600;
|
||||
font-size: 18px;
|
||||
padding: 0 16px;
|
||||
}
|
||||
|
||||
.user-actions {
|
||||
margin-left: auto;
|
||||
padding-right: 16px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.divider {
|
||||
color: #c9cdd4;
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 24px;
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.card-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
97
frontend/src/views/CarDetail.vue
Normal file
97
frontend/src/views/CarDetail.vue
Normal file
@@ -0,0 +1,97 @@
|
||||
<template>
|
||||
<div>
|
||||
<a-card v-if="car" :title="car.brand + ' ' + car.model">
|
||||
<p>车牌:{{ car.plateNo }}</p>
|
||||
<p>日租金:¥{{ car.pricePerDay }}</p>
|
||||
<p>押金:¥{{ car.deposit }}</p>
|
||||
<p>座位:{{ car.seats }} | 变速箱:{{ car.transmission }} | 油耗类型:{{ car.fuelType }}</p>
|
||||
<p>里程:{{ car.mileage }} km</p>
|
||||
<p>{{ car.description }}</p>
|
||||
<a-tag v-if="car.isSpecial" color="red">特价</a-tag>
|
||||
<a-tag v-if="car.status !== 'AVAILABLE'" color="orange">不可租</a-tag>
|
||||
<div style="margin-top: 12px; display: flex; gap: 12px;">
|
||||
<a-button type="primary" @click="toggleFavorite">
|
||||
{{ isFavorite ? '取消收藏' : '加入收藏' }}
|
||||
</a-button>
|
||||
</div>
|
||||
</a-card>
|
||||
|
||||
<div style="height: 16px"></div>
|
||||
<a-card>
|
||||
<div class="section-title">租车下单</div>
|
||||
<a-form :model="orderForm" layout="inline">
|
||||
<a-form-item label="租期">
|
||||
<a-range-picker v-model="orderForm.range" />
|
||||
</a-form-item>
|
||||
<a-form-item>
|
||||
<a-button type="primary" @click="createOrder">提交订单</a-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { Message } from '@arco-design/web-vue'
|
||||
import http from '../api/http'
|
||||
import { useAuthStore } from '../store/auth'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const auth = useAuthStore()
|
||||
const car = ref(null)
|
||||
const isFavorite = ref(false)
|
||||
const orderForm = ref({ range: [] })
|
||||
|
||||
const loadCar = async () => {
|
||||
car.value = await http.get(`/api/cars/${route.params.id}`)
|
||||
}
|
||||
|
||||
const loadFavorite = async () => {
|
||||
if (!auth.token) return
|
||||
const favorites = await http.get('/api/user/favorite')
|
||||
isFavorite.value = favorites.some((item) => item.carId === Number(route.params.id))
|
||||
}
|
||||
|
||||
const toggleFavorite = async () => {
|
||||
if (!auth.token) {
|
||||
router.push('/login')
|
||||
return
|
||||
}
|
||||
if (isFavorite.value) {
|
||||
await http.delete(`/api/user/favorite/${route.params.id}`)
|
||||
isFavorite.value = false
|
||||
Message.success('已取消收藏')
|
||||
} else {
|
||||
await http.post(`/api/user/favorite/${route.params.id}`)
|
||||
isFavorite.value = true
|
||||
Message.success('已收藏')
|
||||
}
|
||||
}
|
||||
|
||||
const createOrder = async () => {
|
||||
if (!auth.token) {
|
||||
router.push('/login')
|
||||
return
|
||||
}
|
||||
if (!orderForm.value.range || orderForm.value.range.length !== 2) {
|
||||
Message.warning('请选择租期')
|
||||
return
|
||||
}
|
||||
const [startDate, endDate] = orderForm.value.range
|
||||
await http.post('/api/user/order', {
|
||||
carId: car.value.id,
|
||||
startDate,
|
||||
endDate
|
||||
})
|
||||
Message.success('订单创建成功,请前往我的订单支付')
|
||||
router.push('/orders')
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadCar()
|
||||
loadFavorite()
|
||||
})
|
||||
</script>
|
||||
45
frontend/src/views/Favorites.vue
Normal file
45
frontend/src/views/Favorites.vue
Normal file
@@ -0,0 +1,45 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="section-title">我的收藏</div>
|
||||
<div class="card-grid">
|
||||
<a-card v-for="item in favorites" :key="item.id" :title="item.car.brand + ' ' + item.car.model">
|
||||
<p>车牌:{{ item.car.plateNo }}</p>
|
||||
<p>日租金:¥{{ item.car.pricePerDay }}</p>
|
||||
<a-button type="primary" @click="goDetail(item.car.id)">查看详情</a-button>
|
||||
<a-button type="text" status="danger" @click="remove(item.car.id)">移除</a-button>
|
||||
</a-card>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { Message } from '@arco-design/web-vue'
|
||||
import http from '../api/http'
|
||||
|
||||
const router = useRouter()
|
||||
const favorites = ref([])
|
||||
|
||||
const load = async () => {
|
||||
const list = await http.get('/api/user/favorite')
|
||||
const cars = await http.get('/api/cars')
|
||||
const map = new Map(cars.map((car) => [car.id, car]))
|
||||
favorites.value = list.map((fav) => ({
|
||||
...fav,
|
||||
car: map.get(fav.carId) || {}
|
||||
}))
|
||||
}
|
||||
|
||||
const remove = async (carId) => {
|
||||
await http.delete(`/api/user/favorite/${carId}`)
|
||||
Message.success('已移除')
|
||||
load()
|
||||
}
|
||||
|
||||
const goDetail = (id) => {
|
||||
router.push(`/cars/${id}`)
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
</script>
|
||||
58
frontend/src/views/Home.vue
Normal file
58
frontend/src/views/Home.vue
Normal file
@@ -0,0 +1,58 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="section-title">可租车辆</div>
|
||||
<a-card>
|
||||
<a-form layout="inline" :model="query">
|
||||
<a-form-item label="关键词">
|
||||
<a-input v-model="query.keyword" placeholder="品牌/车型/车牌" allow-clear />
|
||||
</a-form-item>
|
||||
<a-form-item label="特价车">
|
||||
<a-select v-model="query.isSpecial" style="width: 140px">
|
||||
<a-option :value="null">全部</a-option>
|
||||
<a-option :value="true">是</a-option>
|
||||
<a-option :value="false">否</a-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item>
|
||||
<a-button type="primary" @click="loadCars">查询</a-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-card>
|
||||
|
||||
<div style="height: 16px"></div>
|
||||
<div class="card-grid">
|
||||
<a-card v-for="car in cars" :key="car.id" :title="car.brand + ' ' + car.model">
|
||||
<p>车牌:{{ car.plateNo }}</p>
|
||||
<p>日租金:¥{{ car.pricePerDay }}</p>
|
||||
<p>押金:¥{{ car.deposit }}</p>
|
||||
<a-tag v-if="car.isSpecial" color="red">特价</a-tag>
|
||||
<a-tag v-if="car.status !== 'AVAILABLE'" color="orange">不可租</a-tag>
|
||||
<div style="margin-top: 12px">
|
||||
<router-link :to="`/cars/${car.id}`">
|
||||
<a-button type="primary">查看详情</a-button>
|
||||
</router-link>
|
||||
</div>
|
||||
</a-card>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import http from '../api/http'
|
||||
|
||||
const cars = ref([])
|
||||
const query = ref({
|
||||
keyword: '',
|
||||
isSpecial: null
|
||||
})
|
||||
|
||||
const loadCars = async () => {
|
||||
const params = {}
|
||||
if (query.value.keyword) params.keyword = query.value.keyword
|
||||
if (query.value.isSpecial !== null) params.isSpecial = query.value.isSpecial
|
||||
cars.value = await http.get('/api/cars', { params })
|
||||
}
|
||||
|
||||
loadCars()
|
||||
</script>
|
||||
43
frontend/src/views/Login.vue
Normal file
43
frontend/src/views/Login.vue
Normal file
@@ -0,0 +1,43 @@
|
||||
<template>
|
||||
<a-card title="用户登录" style="max-width: 420px; margin: 0 auto;">
|
||||
<a-form :model="form">
|
||||
<a-form-item label="用户名">
|
||||
<a-input v-model="form.username" />
|
||||
</a-form-item>
|
||||
<a-form-item label="密码">
|
||||
<a-input-password v-model="form.password" />
|
||||
</a-form-item>
|
||||
<a-form-item>
|
||||
<a-button type="primary" @click="login" long>登录</a-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-card>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { Message } from '@arco-design/web-vue'
|
||||
import http from '../api/http'
|
||||
import { useAuthStore } from '../store/auth'
|
||||
|
||||
const router = useRouter()
|
||||
const auth = useAuthStore()
|
||||
const form = reactive({
|
||||
username: '',
|
||||
password: ''
|
||||
})
|
||||
|
||||
const login = async () => {
|
||||
try {
|
||||
const res = await http.post('/api/auth/login', form)
|
||||
auth.setAuth(res.token, res.role)
|
||||
const user = await http.get('/api/user/me')
|
||||
auth.setUser(user)
|
||||
Message.success('登录成功')
|
||||
router.push('/')
|
||||
} catch (e) {
|
||||
Message.error(e.message || '登录失败')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
76
frontend/src/views/Orders.vue
Normal file
76
frontend/src/views/Orders.vue
Normal file
@@ -0,0 +1,76 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="section-title">我的订单</div>
|
||||
<a-card>
|
||||
<a-form layout="inline" :model="query">
|
||||
<a-form-item label="状态">
|
||||
<a-select v-model="query.status" style="width: 160px">
|
||||
<a-option value="">全部</a-option>
|
||||
<a-option value="PENDING_PAY">待支付</a-option>
|
||||
<a-option value="RENTING">租用中</a-option>
|
||||
<a-option value="RETURNED">已归还</a-option>
|
||||
<a-option value="CANCELLED">已取消</a-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item>
|
||||
<a-button type="primary" @click="loadOrders">查询</a-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-card>
|
||||
|
||||
<div style="height: 16px"></div>
|
||||
<a-table :columns="columns" :data="orders" row-key="id">
|
||||
<template #actions="{ record }">
|
||||
<a-button v-if="record.status === 'PENDING_PAY'" type="primary" @click="pay(record)">余额支付</a-button>
|
||||
<a-button v-if="record.status === 'PENDING_PAY'" type="text" status="danger" @click="cancel(record)">取消</a-button>
|
||||
<a-button v-if="record.status === 'RENTING'" type="primary" @click="returnCar(record)">归还</a-button>
|
||||
</template>
|
||||
</a-table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { Message } from '@arco-design/web-vue'
|
||||
import http from '../api/http'
|
||||
|
||||
const orders = ref([])
|
||||
const query = ref({ status: '' })
|
||||
|
||||
const columns = [
|
||||
{ title: '订单号', dataIndex: 'orderNo' },
|
||||
{ title: '车辆ID', dataIndex: 'carId' },
|
||||
{ title: '起始日期', dataIndex: 'startDate' },
|
||||
{ title: '结束日期', dataIndex: 'endDate' },
|
||||
{ title: '天数', dataIndex: 'days' },
|
||||
{ title: '总金额', dataIndex: 'totalAmount' },
|
||||
{ title: '状态', dataIndex: 'status' },
|
||||
{ title: '操作', slotName: 'actions' }
|
||||
]
|
||||
|
||||
const loadOrders = async () => {
|
||||
const params = {}
|
||||
if (query.value.status) params.status = query.value.status
|
||||
orders.value = await http.get('/api/user/order', { params })
|
||||
}
|
||||
|
||||
const pay = async (record) => {
|
||||
await http.post('/api/user/order/pay', { orderId: record.id, payType: 'BALANCE' })
|
||||
Message.success('支付成功')
|
||||
loadOrders()
|
||||
}
|
||||
|
||||
const cancel = async (record) => {
|
||||
await http.post(`/api/user/order/${record.id}/cancel`)
|
||||
Message.success('已取消')
|
||||
loadOrders()
|
||||
}
|
||||
|
||||
const returnCar = async (record) => {
|
||||
await http.post(`/api/user/order/${record.id}/return`)
|
||||
Message.success('已归还')
|
||||
loadOrders()
|
||||
}
|
||||
|
||||
loadOrders()
|
||||
</script>
|
||||
91
frontend/src/views/Profile.vue
Normal file
91
frontend/src/views/Profile.vue
Normal file
@@ -0,0 +1,91 @@
|
||||
<template>
|
||||
<div>
|
||||
<a-card>
|
||||
<div class="section-title">个人信息</div>
|
||||
<a-descriptions :data="desc" bordered />
|
||||
</a-card>
|
||||
|
||||
<div style="height: 16px"></div>
|
||||
<a-card>
|
||||
<div class="section-title">余额充值(模拟)</div>
|
||||
<a-form layout="inline">
|
||||
<a-form-item label="充值金额">
|
||||
<a-input-number v-model="balance" :min="1" />
|
||||
</a-form-item>
|
||||
<a-form-item>
|
||||
<a-button type="primary" @click="addBalance">充值</a-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-card>
|
||||
|
||||
<div style="height: 16px"></div>
|
||||
<a-card>
|
||||
<div class="section-title">实名认证</div>
|
||||
<a-form :model="realName">
|
||||
<a-form-item label="真实姓名">
|
||||
<a-input v-model="realName.realName" />
|
||||
</a-form-item>
|
||||
<a-form-item label="身份证号">
|
||||
<a-input v-model="realName.idNumber" />
|
||||
</a-form-item>
|
||||
<a-form-item label="身份证正面">
|
||||
<a-input v-model="realName.idFront" placeholder="图片URL" />
|
||||
</a-form-item>
|
||||
<a-form-item label="身份证反面">
|
||||
<a-input v-model="realName.idBack" placeholder="图片URL" />
|
||||
</a-form-item>
|
||||
<a-form-item>
|
||||
<a-button type="primary" @click="submitRealName">提交审核</a-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { Message } from '@arco-design/web-vue'
|
||||
import http from '../api/http'
|
||||
import { useAuthStore } from '../store/auth'
|
||||
|
||||
const auth = useAuthStore()
|
||||
const user = ref(null)
|
||||
const balance = ref(100)
|
||||
const realName = ref({
|
||||
realName: '',
|
||||
idNumber: '',
|
||||
idFront: '',
|
||||
idBack: ''
|
||||
})
|
||||
|
||||
const desc = computed(() => {
|
||||
if (!user.value) return []
|
||||
return [
|
||||
{ label: '用户名', value: user.value.username },
|
||||
{ label: '手机号', value: user.value.phone || '-' },
|
||||
{ label: '邮箱', value: user.value.email || '-' },
|
||||
{ label: '余额', value: `¥${user.value.balance}` },
|
||||
{ label: '实名认证状态', value: user.value.realNameStatus }
|
||||
]
|
||||
})
|
||||
|
||||
const load = async () => {
|
||||
const res = await http.get('/api/user/me')
|
||||
user.value = res
|
||||
auth.setUser(res)
|
||||
}
|
||||
|
||||
const addBalance = async () => {
|
||||
await http.post('/api/user/balance', { amount: balance.value })
|
||||
Message.success('充值成功')
|
||||
load()
|
||||
}
|
||||
|
||||
const submitRealName = async () => {
|
||||
await http.post('/api/user/real-name', realName.value)
|
||||
Message.success('已提交审核')
|
||||
load()
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
</script>
|
||||
46
frontend/src/views/Register.vue
Normal file
46
frontend/src/views/Register.vue
Normal file
@@ -0,0 +1,46 @@
|
||||
<template>
|
||||
<a-card title="用户注册" style="max-width: 420px; margin: 0 auto;">
|
||||
<a-form :model="form">
|
||||
<a-form-item label="用户名">
|
||||
<a-input v-model="form.username" />
|
||||
</a-form-item>
|
||||
<a-form-item label="密码">
|
||||
<a-input-password v-model="form.password" />
|
||||
</a-form-item>
|
||||
<a-form-item label="手机号">
|
||||
<a-input v-model="form.phone" />
|
||||
</a-form-item>
|
||||
<a-form-item label="邮箱">
|
||||
<a-input v-model="form.email" />
|
||||
</a-form-item>
|
||||
<a-form-item>
|
||||
<a-button type="primary" @click="register" long>注册</a-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-card>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { Message } from '@arco-design/web-vue'
|
||||
import http from '../api/http'
|
||||
|
||||
const router = useRouter()
|
||||
const form = reactive({
|
||||
username: '',
|
||||
password: '',
|
||||
phone: '',
|
||||
email: ''
|
||||
})
|
||||
|
||||
const register = async () => {
|
||||
try {
|
||||
await http.post('/api/auth/register', form)
|
||||
Message.success('注册成功,请登录')
|
||||
router.push('/login')
|
||||
} catch (e) {
|
||||
Message.error(e.message || '注册失败')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
133
frontend/src/views/admin/AdminCars.vue
Normal file
133
frontend/src/views/admin/AdminCars.vue
Normal file
@@ -0,0 +1,133 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="section-title">车辆管理</div>
|
||||
<a-card>
|
||||
<a-form layout="inline" :model="query">
|
||||
<a-form-item label="关键词">
|
||||
<a-input v-model="query.keyword" allow-clear />
|
||||
</a-form-item>
|
||||
<a-form-item label="特价">
|
||||
<a-select v-model="query.isSpecial" style="width: 140px">
|
||||
<a-option :value="null">全部</a-option>
|
||||
<a-option :value="true">是</a-option>
|
||||
<a-option :value="false">否</a-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item>
|
||||
<a-button type="primary" @click="loadCars">查询</a-button>
|
||||
</a-form-item>
|
||||
<a-form-item>
|
||||
<a-button type="primary" status="success" @click="openEdit()">新增</a-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-card>
|
||||
<div style="height: 16px"></div>
|
||||
<a-table :columns="columns" :data="cars" row-key="id">
|
||||
<template #actions="{ record }">
|
||||
<a-button type="text" @click="openEdit(record)">编辑</a-button>
|
||||
<a-button type="text" status="danger" @click="remove(record.id)">删除</a-button>
|
||||
</template>
|
||||
</a-table>
|
||||
|
||||
<a-modal v-model:visible="visible" title="车辆信息" @ok="save">
|
||||
<a-form :model="form">
|
||||
<a-form-item label="品牌">
|
||||
<a-input v-model="form.brand" />
|
||||
</a-form-item>
|
||||
<a-form-item label="车型">
|
||||
<a-input v-model="form.model" />
|
||||
</a-form-item>
|
||||
<a-form-item label="车牌">
|
||||
<a-input v-model="form.plateNo" />
|
||||
</a-form-item>
|
||||
<a-form-item label="日租金">
|
||||
<a-input-number v-model="form.pricePerDay" :min="0" />
|
||||
</a-form-item>
|
||||
<a-form-item label="押金">
|
||||
<a-input-number v-model="form.deposit" :min="0" />
|
||||
</a-form-item>
|
||||
<a-form-item label="座位">
|
||||
<a-input-number v-model="form.seats" :min="2" />
|
||||
</a-form-item>
|
||||
<a-form-item label="变速箱">
|
||||
<a-select v-model="form.transmission">
|
||||
<a-option value="AT">AT</a-option>
|
||||
<a-option value="MT">MT</a-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item label="燃油">
|
||||
<a-input v-model="form.fuelType" />
|
||||
</a-form-item>
|
||||
<a-form-item label="里程">
|
||||
<a-input-number v-model="form.mileage" :min="0" />
|
||||
</a-form-item>
|
||||
<a-form-item label="特价">
|
||||
<a-switch v-model="form.isSpecial" />
|
||||
</a-form-item>
|
||||
<a-form-item label="状态">
|
||||
<a-select v-model="form.status">
|
||||
<a-option value="AVAILABLE">可租</a-option>
|
||||
<a-option value="RENTED">出租中</a-option>
|
||||
<a-option value="MAINTENANCE">维护中</a-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item label="描述">
|
||||
<a-textarea v-model="form.description" />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { Message } from '@arco-design/web-vue'
|
||||
import http from '../../api/http'
|
||||
|
||||
const cars = ref([])
|
||||
const query = ref({ keyword: '', isSpecial: null })
|
||||
const visible = ref(false)
|
||||
const form = ref({})
|
||||
|
||||
const columns = [
|
||||
{ title: 'ID', dataIndex: 'id' },
|
||||
{ title: '品牌', dataIndex: 'brand' },
|
||||
{ title: '车型', dataIndex: 'model' },
|
||||
{ title: '车牌', dataIndex: 'plateNo' },
|
||||
{ title: '日租金', dataIndex: 'pricePerDay' },
|
||||
{ title: '状态', dataIndex: 'status' },
|
||||
{ title: '特价', dataIndex: 'isSpecial' },
|
||||
{ title: '操作', slotName: 'actions' }
|
||||
]
|
||||
|
||||
const loadCars = async () => {
|
||||
const params = {}
|
||||
if (query.value.keyword) params.keyword = query.value.keyword
|
||||
if (query.value.isSpecial !== null) params.isSpecial = query.value.isSpecial
|
||||
cars.value = await http.get('/api/admin/cars', { params })
|
||||
}
|
||||
|
||||
const openEdit = (record) => {
|
||||
form.value = record ? { ...record } : { status: 'AVAILABLE', isSpecial: false }
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
const save = async () => {
|
||||
if (form.value.id) {
|
||||
await http.put('/api/admin/cars', form.value)
|
||||
} else {
|
||||
await http.post('/api/admin/cars', form.value)
|
||||
}
|
||||
Message.success('保存成功')
|
||||
visible.value = false
|
||||
loadCars()
|
||||
}
|
||||
|
||||
const remove = async (id) => {
|
||||
await http.delete(`/api/admin/cars/${id}`)
|
||||
Message.success('已删除')
|
||||
loadCars()
|
||||
}
|
||||
|
||||
loadCars()
|
||||
</script>
|
||||
50
frontend/src/views/admin/AdminOrders.vue
Normal file
50
frontend/src/views/admin/AdminOrders.vue
Normal file
@@ -0,0 +1,50 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="section-title">订单管理</div>
|
||||
<a-card>
|
||||
<a-form layout="inline" :model="query">
|
||||
<a-form-item label="状态">
|
||||
<a-select v-model="query.status" style="width: 160px">
|
||||
<a-option value="">全部</a-option>
|
||||
<a-option value="PENDING_PAY">待支付</a-option>
|
||||
<a-option value="RENTING">租用中</a-option>
|
||||
<a-option value="RETURNED">已归还</a-option>
|
||||
<a-option value="CANCELLED">已取消</a-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item>
|
||||
<a-button type="primary" @click="loadOrders">查询</a-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-card>
|
||||
<div style="height: 16px"></div>
|
||||
<a-table :columns="columns" :data="orders" row-key="id" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import http from '../../api/http'
|
||||
|
||||
const orders = ref([])
|
||||
const query = ref({ status: '' })
|
||||
|
||||
const columns = [
|
||||
{ title: '订单号', dataIndex: 'orderNo' },
|
||||
{ title: '用户ID', dataIndex: 'userId' },
|
||||
{ title: '车辆ID', dataIndex: 'carId' },
|
||||
{ title: '起始日期', dataIndex: 'startDate' },
|
||||
{ title: '结束日期', dataIndex: 'endDate' },
|
||||
{ title: '天数', dataIndex: 'days' },
|
||||
{ title: '总金额', dataIndex: 'totalAmount' },
|
||||
{ title: '状态', dataIndex: 'status' }
|
||||
]
|
||||
|
||||
const loadOrders = async () => {
|
||||
const params = {}
|
||||
if (query.value.status) params.status = query.value.status
|
||||
orders.value = await http.get('/api/admin/orders', { params })
|
||||
}
|
||||
|
||||
loadOrders()
|
||||
</script>
|
||||
40
frontend/src/views/admin/AdminStats.vue
Normal file
40
frontend/src/views/admin/AdminStats.vue
Normal file
@@ -0,0 +1,40 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="section-title">数据统计</div>
|
||||
<a-card>
|
||||
<a-descriptions :data="orderStatsDesc" bordered />
|
||||
</a-card>
|
||||
<div style="height: 16px"></div>
|
||||
<a-card>
|
||||
<a-descriptions :data="financeDesc" bordered />
|
||||
</a-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, computed } from 'vue'
|
||||
import http from '../../api/http'
|
||||
|
||||
const orderStats = ref({})
|
||||
const financeStats = ref({})
|
||||
|
||||
const orderStatsDesc = computed(() => [
|
||||
{ label: '订单总数', value: orderStats.value.total || 0 },
|
||||
{ label: '租用中', value: orderStats.value.renting || 0 },
|
||||
{ label: '已归还', value: orderStats.value.returned || 0 },
|
||||
{ label: '待支付', value: orderStats.value.pendingPay || 0 }
|
||||
])
|
||||
|
||||
const financeDesc = computed(() => [
|
||||
{ label: '累计收入', value: `¥${financeStats.value.income || 0}` },
|
||||
{ label: '累计押金', value: `¥${financeStats.value.deposit || 0}` },
|
||||
{ label: '订单数', value: financeStats.value.orderCount || 0 }
|
||||
])
|
||||
|
||||
const load = async () => {
|
||||
orderStats.value = await http.get('/api/admin/stats/orders')
|
||||
financeStats.value = await http.get('/api/admin/stats/finance')
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
</script>
|
||||
76
frontend/src/views/admin/AdminUsers.vue
Normal file
76
frontend/src/views/admin/AdminUsers.vue
Normal file
@@ -0,0 +1,76 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="section-title">用户管理</div>
|
||||
<a-card>
|
||||
<a-form layout="inline" :model="query">
|
||||
<a-form-item label="关键词">
|
||||
<a-input v-model="query.keyword" allow-clear />
|
||||
</a-form-item>
|
||||
<a-form-item>
|
||||
<a-button type="primary" @click="loadUsers">查询</a-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-card>
|
||||
<div style="height: 16px"></div>
|
||||
<a-table :columns="columns" :data="users" row-key="id">
|
||||
<template #actions="{ record }">
|
||||
<a-button v-if="record.realNameStatus === 'PENDING'" type="primary" @click="approve(record.id)">通过实名</a-button>
|
||||
<a-button v-if="record.realNameStatus === 'PENDING'" type="text" status="danger" @click="reject(record.id)">驳回实名</a-button>
|
||||
<a-button v-if="record.status === 'ACTIVE'" type="text" status="danger" @click="disable(record.id)">禁用</a-button>
|
||||
<a-button v-else type="text" @click="enable(record.id)">启用</a-button>
|
||||
</template>
|
||||
</a-table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { Message } from '@arco-design/web-vue'
|
||||
import http from '../../api/http'
|
||||
|
||||
const users = ref([])
|
||||
const query = ref({ keyword: '' })
|
||||
|
||||
const columns = [
|
||||
{ title: 'ID', dataIndex: 'id' },
|
||||
{ title: '用户名', dataIndex: 'username' },
|
||||
{ title: '手机号', dataIndex: 'phone' },
|
||||
{ title: '邮箱', dataIndex: 'email' },
|
||||
{ title: '角色', dataIndex: 'role' },
|
||||
{ title: '状态', dataIndex: 'status' },
|
||||
{ title: '实名状态', dataIndex: 'realNameStatus' },
|
||||
{ title: '操作', slotName: 'actions' }
|
||||
]
|
||||
|
||||
const loadUsers = async () => {
|
||||
const params = {}
|
||||
if (query.value.keyword) params.keyword = query.value.keyword
|
||||
users.value = await http.get('/api/admin/users', { params })
|
||||
}
|
||||
|
||||
const approve = async (id) => {
|
||||
await http.post(`/api/admin/real-name/${id}/approve`)
|
||||
Message.success('已通过')
|
||||
loadUsers()
|
||||
}
|
||||
|
||||
const reject = async (id) => {
|
||||
await http.post(`/api/admin/real-name/${id}/reject`)
|
||||
Message.success('已驳回')
|
||||
loadUsers()
|
||||
}
|
||||
|
||||
const disable = async (id) => {
|
||||
await http.post(`/api/admin/users/${id}/status`, null, { params: { status: 'DISABLED' } })
|
||||
Message.success('已禁用')
|
||||
loadUsers()
|
||||
}
|
||||
|
||||
const enable = async (id) => {
|
||||
await http.post(`/api/admin/users/${id}/status`, null, { params: { status: 'ACTIVE' } })
|
||||
Message.success('已启用')
|
||||
loadUsers()
|
||||
}
|
||||
|
||||
loadUsers()
|
||||
</script>
|
||||
7
frontend/vite.config.js
Normal file
7
frontend/vite.config.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [vue()],
|
||||
})
|
||||
Reference in New Issue
Block a user