Compare commits
3 Commits
526bfa65b5
...
566da2e791
Author | SHA1 | Date | |
---|---|---|---|
![]() |
566da2e791 | ||
![]() |
c0b5e0bfd5 | ||
![]() |
9e27d62e0e |
@ -1,18 +1,18 @@
|
|||||||
/**
|
/**
|
||||||
* @desc 当前用户
|
* @desc 当前用户
|
||||||
*/
|
*/
|
||||||
import { defaultSuccess, defaultError, http } from '@/plugins/axios';
|
import { defaultSuccess, defaultError, http } from '@/plugins/axios'
|
||||||
import type { AxiosResponse } from 'axios';
|
import type { AxiosResponse } from 'axios'
|
||||||
export default async function (
|
export default async function (
|
||||||
success: (data: auth.AuthUser) => void = defaultSuccess,
|
success: (data: auth.AuthUser) => void = defaultSuccess,
|
||||||
fail: (error: { code: string; error?: string }) => void = defaultError,
|
fail: (error: { code: string; error?: string }) => void = defaultError,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
return http({
|
return http({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
url: `/auth/current-user`,
|
url: `/auth/current-user`,
|
||||||
})
|
})
|
||||||
.then((data: AxiosResponse<auth.AuthUser, unknown>) => {
|
.then((data: AxiosResponse<auth.AuthUser, unknown>) => {
|
||||||
success(data.data);
|
success(data.data)
|
||||||
})
|
})
|
||||||
.catch((error: { code: string; error?: string }) => fail(error));
|
.catch((error: { code: string; error?: string }) => fail(error))
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,7 @@
|
|||||||
import { config } from '@/settings/application'
|
import { config } from '@/settings/application'
|
||||||
import { MenuInfo } from 'ant-design-vue/es/menu/src/interface'
|
import { MenuInfo } from 'ant-design-vue/es/menu/src/interface'
|
||||||
import { useUserStore } from '@/stores/user'
|
import { useUserStore } from '@/stores/user'
|
||||||
|
import api from '@/api'
|
||||||
const t = useI18n()
|
const t = useI18n()
|
||||||
const user = useUserStore()
|
const user = useUserStore()
|
||||||
|
|
||||||
@ -81,11 +82,13 @@
|
|||||||
}
|
}
|
||||||
const logout = () => {
|
const logout = () => {
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: t.t('layout.user.modal.logout.title'),
|
title: '退出登录',
|
||||||
icon: createVNode(ExclamationCircleOutlined),
|
icon: createVNode(ExclamationCircleOutlined),
|
||||||
content: createVNode('div', { style: 'color:red;' }, t.t('layout.user.modal.logout.content')),
|
content: createVNode('div', { style: 'color:red;' }, '确定退出系统吗?'),
|
||||||
onOk() {
|
onOk() {
|
||||||
console.log(1)
|
api.authApi.auth.logout(() => {
|
||||||
|
user.logout()
|
||||||
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,6 @@ export const routes: Array<RouteRecordRaw> = [
|
|||||||
|
|
||||||
const getNewRouter = () => {
|
const getNewRouter = () => {
|
||||||
// TODO 用户store判断是否登录,登录就返回过滤的,没有登录就返回全量
|
// TODO 用户store判断是否登录,登录就返回过滤的,没有登录就返回全量
|
||||||
|
|
||||||
return createRouter({
|
return createRouter({
|
||||||
history: createWebHashHistory(),
|
history: createWebHashHistory(),
|
||||||
routes: [
|
routes: [
|
||||||
|
@ -18,6 +18,12 @@ export const useUserStore = defineStore('user', {
|
|||||||
isAdmin(state) {
|
isAdmin(state) {
|
||||||
return state.roles.includes('admin')
|
return state.roles.includes('admin')
|
||||||
},
|
},
|
||||||
|
isLogin(state) {
|
||||||
|
return state.token && state.refreshToken
|
||||||
|
},
|
||||||
|
getPermission(state) {
|
||||||
|
return state.permissions
|
||||||
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
refreshUserInfo(user: auth.AuthUser) {
|
refreshUserInfo(user: auth.AuthUser) {
|
||||||
@ -41,6 +47,7 @@ export const useUserStore = defineStore('user', {
|
|||||||
this.sex = 'FEMALE'
|
this.sex = 'FEMALE'
|
||||||
this.token = ''
|
this.token = ''
|
||||||
this.refreshToken = ''
|
this.refreshToken = ''
|
||||||
|
router.push({ path: '/login/user' }) // 退出登录后跳转到登录页面,未实现,要清理缓存?
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
persist: {
|
persist: {
|
||||||
|
@ -52,20 +52,20 @@
|
|||||||
honorMarginPadding: false,
|
honorMarginPadding: false,
|
||||||
targetStyles: ['*'],
|
targetStyles: ['*'],
|
||||||
style: `
|
style: `
|
||||||
@page {
|
@page {
|
||||||
size: ${widthInches}in ${heightInches}in;
|
size: ${widthInches}in ${heightInches}in;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
font-size: 6px;
|
font-size: 6px;
|
||||||
}
|
}
|
||||||
#barcodes-container canvas {
|
#barcodes-container canvas {
|
||||||
display: block;
|
display: block;
|
||||||
margin-bottom: 2mm; /* 调整条形码之间的间距 */
|
margin-bottom: 2mm; /* 调整条形码之间的间距 */
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
onLoadingStart: () => console.log('开始加载'),
|
onLoadingStart: () => console.log('开始加载'),
|
||||||
onLoadingEnd: () => console.log('加载完成'),
|
onLoadingEnd: () => console.log('加载完成'),
|
||||||
// onError: (err: Error) => console.error('打印出错:', err),
|
// onError: (err: Error) => console.error('打印出错:', err),
|
||||||
@ -80,6 +80,7 @@
|
|||||||
|
|
||||||
// 定义一个函数来从后端获取条形码字符串并打印
|
// 定义一个函数来从后端获取条形码字符串并打印
|
||||||
const fetchAndPrintBarcodes = (count: number) => {
|
const fetchAndPrintBarcodes = (count: number) => {
|
||||||
|
if (count <= 0) return
|
||||||
// 清空之前的条形码容器
|
// 清空之前的条形码容器
|
||||||
const container = document.getElementById('barcodes-container')
|
const container = document.getElementById('barcodes-container')
|
||||||
if (!container) throw new Error('条形码容器未找到')
|
if (!container) throw new Error('条形码容器未找到')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user