后端管理模块部署
This commit is contained in:
@@ -77,13 +77,13 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useAdminStore } from '@/stores/admin'
|
||||
import { Fold, Expand } from '@element-plus/icons-vue'
|
||||
import { menuConfig } from '@/config/menu'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
// const router = useRouter()
|
||||
const adminStore = useAdminStore()
|
||||
|
||||
const isCollapse = ref(false)
|
||||
|
||||
@@ -72,12 +72,12 @@ const routes: RouteRecordRaw[] = [
|
||||
]
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
history: createWebHistory('/emotion-museum-admin/'),
|
||||
routes
|
||||
})
|
||||
|
||||
// 路由守卫
|
||||
router.beforeEach((to, from, next) => {
|
||||
router.beforeEach((to, _from, next) => {
|
||||
const token = localStorage.getItem('adminToken')
|
||||
|
||||
if (to.path === '/login') {
|
||||
|
||||
@@ -13,12 +13,13 @@ export const useAdminStore = defineStore('admin', () => {
|
||||
const login = async (loginForm: AdminLoginRequest) => {
|
||||
try {
|
||||
const res = await loginApi(loginForm)
|
||||
token.value = res.data.accessToken
|
||||
adminInfo.value = res.data.adminInfo
|
||||
const authData = res.data as any
|
||||
token.value = authData.accessToken
|
||||
adminInfo.value = authData.adminInfo
|
||||
|
||||
localStorage.setItem('adminToken', res.data.accessToken)
|
||||
localStorage.setItem('adminRefreshToken', res.data.refreshToken)
|
||||
localStorage.setItem('adminInfo', JSON.stringify(res.data.adminInfo))
|
||||
localStorage.setItem('adminToken', authData.accessToken)
|
||||
localStorage.setItem('adminRefreshToken', authData.refreshToken)
|
||||
localStorage.setItem('adminInfo', JSON.stringify(authData.adminInfo))
|
||||
|
||||
ElMessage.success('登录成功')
|
||||
router.push('/')
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'
|
||||
import axios, { AxiosInstance, AxiosResponse } from 'axios'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import router from '@/router'
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// 表单验证规则
|
||||
|
||||
export const validateAccount = (rule: any, value: string, callback: any) => {
|
||||
export const validateAccount = (_rule: any, value: string, callback: any) => {
|
||||
if (!value) {
|
||||
callback(new Error('请输入账号'))
|
||||
} else if (value.length < 3 || value.length > 50) {
|
||||
@@ -10,7 +10,7 @@ export const validateAccount = (rule: any, value: string, callback: any) => {
|
||||
}
|
||||
}
|
||||
|
||||
export const validatePassword = (rule: any, value: string, callback: any) => {
|
||||
export const validatePassword = (_rule: any, value: string, callback: any) => {
|
||||
if (!value) {
|
||||
callback(new Error('请输入密码'))
|
||||
} else if (value.length < 6 || value.length > 20) {
|
||||
@@ -20,7 +20,7 @@ export const validatePassword = (rule: any, value: string, callback: any) => {
|
||||
}
|
||||
}
|
||||
|
||||
export const validateEmail = (rule: any, value: string, callback: any) => {
|
||||
export const validateEmail = (_rule: any, value: string, callback: any) => {
|
||||
if (!value) {
|
||||
callback()
|
||||
} else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
|
||||
@@ -30,7 +30,7 @@ export const validateEmail = (rule: any, value: string, callback: any) => {
|
||||
}
|
||||
}
|
||||
|
||||
export const validatePhone = (rule: any, value: string, callback: any) => {
|
||||
export const validatePhone = (_rule: any, value: string, callback: any) => {
|
||||
if (!value) {
|
||||
callback()
|
||||
} else if (!/^1[3-9]\d{9}$/.test(value)) {
|
||||
|
||||
@@ -45,10 +45,6 @@
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<div class="login-footer">
|
||||
<p>默认账号: admin / admin123</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -190,8 +190,9 @@ const fetchData = async () => {
|
||||
size: pagination.size
|
||||
}
|
||||
const res = await getAdminPage(params)
|
||||
tableData.value = res.data.records
|
||||
pagination.total = res.data.total
|
||||
const pageData = res.data as any
|
||||
tableData.value = pageData.records
|
||||
pagination.total = pageData.total
|
||||
} catch (error) {
|
||||
console.error('获取管理员列表失败:', error)
|
||||
} finally {
|
||||
|
||||
@@ -1181,7 +1181,7 @@ const handleTestRequest = async () => {
|
||||
}
|
||||
|
||||
// 检查是否为流式请求
|
||||
const isStreamRequest = body.stream === true
|
||||
const isStreamRequest = (body as any).stream === true
|
||||
|
||||
if (isStreamRequest) {
|
||||
// 处理流式请求
|
||||
|
||||
@@ -131,8 +131,9 @@ const fetchData = async () => {
|
||||
size: pagination.size
|
||||
}
|
||||
const res = await getUserPage(params)
|
||||
tableData.value = res.data.records
|
||||
pagination.total = res.data.total
|
||||
const pageData = res.data as any
|
||||
tableData.value = pageData.records
|
||||
pagination.total = pageData.total
|
||||
} catch (error) {
|
||||
console.error('获取用户列表失败:', error)
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user