art: 格式化代码
This commit is contained in:
parent
3cb34c8554
commit
526bfa65b5
@ -29,13 +29,18 @@
|
||||
import SubMenu from './sub-menu.vue'
|
||||
import XEUtils from 'xe-utils'
|
||||
import { fliteredMenuTree } from './menu'
|
||||
import { useRoute } from 'vue-router'
|
||||
|
||||
const app = useAppStore()
|
||||
|
||||
// const router = useRouter()
|
||||
|
||||
const theme = computed(() => {
|
||||
return app.layout.navTheme === 'light' ? 'light' : 'dark'
|
||||
})
|
||||
const menuTree = computed(() => {
|
||||
// 重新去计算路由的菜单
|
||||
// router.currentRoute();
|
||||
return fliteredMenuTree()
|
||||
})
|
||||
const route = useRoute()
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { createRouter, createWebHashHistory } from 'vue-router'
|
||||
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
|
||||
import UserLayout from '@/layout/user-layout.vue'
|
||||
import AdminLayout from '@/layout/admin-layout.vue'
|
||||
import BlankLayout from '@/layout/blank-layout.vue'
|
||||
|
||||
export const routes = [
|
||||
export const routes: Array<RouteRecordRaw> = [
|
||||
{
|
||||
path: '/admin/acl', // 系统管理
|
||||
name: 'ACL',
|
||||
@ -99,43 +99,49 @@ export const routes = [
|
||||
},
|
||||
]
|
||||
|
||||
export default createRouter({
|
||||
history: createWebHashHistory(),
|
||||
routes: [
|
||||
{
|
||||
path: '/',
|
||||
name: 'Index',
|
||||
redirect: '/login',
|
||||
},
|
||||
{
|
||||
path: '/login',
|
||||
name: 'Login',
|
||||
redirect: '/login/user',
|
||||
component: UserLayout,
|
||||
children: [
|
||||
{
|
||||
path: 'user',
|
||||
name: 'LoginPage',
|
||||
component: () => import('../views/login/user-login.vue'),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '/admin',
|
||||
name: 'Admin',
|
||||
redirect: '/admin/dashboard',
|
||||
component: AdminLayout,
|
||||
meta: { title: 'menus.index', icon: 'icon-home' },
|
||||
children: routes,
|
||||
},
|
||||
{
|
||||
path: '/:catchAll(.*)',
|
||||
redirect: '/message',
|
||||
},
|
||||
{
|
||||
path: '/message',
|
||||
name: 'Message',
|
||||
component: () => import('@/views/message/message-page.vue'),
|
||||
},
|
||||
],
|
||||
})
|
||||
const getNewRouter = () => {
|
||||
// TODO 用户store判断是否登录,登录就返回过滤的,没有登录就返回全量
|
||||
|
||||
return createRouter({
|
||||
history: createWebHashHistory(),
|
||||
routes: [
|
||||
{
|
||||
path: '/',
|
||||
name: 'Index',
|
||||
redirect: '/login',
|
||||
},
|
||||
{
|
||||
path: '/login',
|
||||
name: 'Login',
|
||||
redirect: '/login/user',
|
||||
component: UserLayout,
|
||||
children: [
|
||||
{
|
||||
path: 'user',
|
||||
name: 'LoginPage',
|
||||
component: () => import('../views/login/user-login.vue'),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '/admin',
|
||||
name: 'Admin',
|
||||
redirect: '/admin/dashboard',
|
||||
component: AdminLayout,
|
||||
meta: { title: 'menus.index', icon: 'icon-home' },
|
||||
children: routes,
|
||||
},
|
||||
{
|
||||
path: '/:catchAll(.*)',
|
||||
redirect: '/message',
|
||||
},
|
||||
{
|
||||
path: '/message',
|
||||
name: 'Message',
|
||||
component: () => import('@/views/message/message-page.vue'),
|
||||
},
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
export default getNewRouter()
|
||||
|
@ -25,6 +25,9 @@ export const useUserStore = defineStore('user', {
|
||||
},
|
||||
userLogin(user: auth.AuthUser) {
|
||||
Object.assign(this, user)
|
||||
// 过了路由的地址
|
||||
// router.addRoute
|
||||
|
||||
router.push({ path: '/admin/acl/users' }) // 登录后跳转到用户列表页面
|
||||
},
|
||||
logout() {
|
||||
|
@ -3,7 +3,7 @@
|
||||
<a-flex gap="middle" horizontal>
|
||||
<span class="ant-form-text">请输入打印的条码数量:</span>
|
||||
<a-form-item name="input-number" no-style>
|
||||
<a-input-number v-model:value="inputRef" :min="1" :max="30" @change="fetchAndPrintBarcodes(inputRef)" />
|
||||
<a-input-number v-model:value="inputRef" :min="1" :max="30" />
|
||||
</a-form-item>
|
||||
|
||||
<button @click="printCode">打印条形码</button>
|
||||
@ -30,6 +30,10 @@
|
||||
|
||||
const inputRef = ref(1)
|
||||
|
||||
watch(inputRef, (newVal) => {
|
||||
fetchAndPrintBarcodes(newVal)
|
||||
})
|
||||
|
||||
const printCode = () => {
|
||||
const container = document.getElementById('barcodes-container')
|
||||
if (!container) {
|
||||
@ -48,20 +52,20 @@
|
||||
honorMarginPadding: false,
|
||||
targetStyles: ['*'],
|
||||
style: `
|
||||
@page {
|
||||
size: ${widthInches}in ${heightInches}in;
|
||||
margin: 0;
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 6px;
|
||||
}
|
||||
#barcodes-container canvas {
|
||||
display: block;
|
||||
margin-bottom: 2mm; /* 调整条形码之间的间距 */
|
||||
}
|
||||
`,
|
||||
@page {
|
||||
size: ${widthInches}in ${heightInches}in;
|
||||
margin: 0;
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 6px;
|
||||
}
|
||||
#barcodes-container canvas {
|
||||
display: block;
|
||||
margin-bottom: 2mm; /* 调整条形码之间的间距 */
|
||||
}
|
||||
`,
|
||||
onLoadingStart: () => console.log('开始加载'),
|
||||
onLoadingEnd: () => console.log('加载完成'),
|
||||
// onError: (err: Error) => console.error('打印出错:', err),
|
||||
@ -75,7 +79,7 @@
|
||||
}
|
||||
|
||||
// 定义一个函数来从后端获取条形码字符串并打印
|
||||
const fetchAndPrintBarcodes = async (count: number) => {
|
||||
const fetchAndPrintBarcodes = (count: number) => {
|
||||
// 清空之前的条形码容器
|
||||
const container = document.getElementById('barcodes-container')
|
||||
if (!container) throw new Error('条形码容器未找到')
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user