art: 格式化代码
This commit is contained in:
parent
3cb34c8554
commit
526bfa65b5
@ -29,13 +29,18 @@
|
|||||||
import SubMenu from './sub-menu.vue'
|
import SubMenu from './sub-menu.vue'
|
||||||
import XEUtils from 'xe-utils'
|
import XEUtils from 'xe-utils'
|
||||||
import { fliteredMenuTree } from './menu'
|
import { fliteredMenuTree } from './menu'
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
|
|
||||||
const app = useAppStore()
|
const app = useAppStore()
|
||||||
|
|
||||||
|
// const router = useRouter()
|
||||||
|
|
||||||
const theme = computed(() => {
|
const theme = computed(() => {
|
||||||
return app.layout.navTheme === 'light' ? 'light' : 'dark'
|
return app.layout.navTheme === 'light' ? 'light' : 'dark'
|
||||||
})
|
})
|
||||||
const menuTree = computed(() => {
|
const menuTree = computed(() => {
|
||||||
|
// 重新去计算路由的菜单
|
||||||
|
// router.currentRoute();
|
||||||
return fliteredMenuTree()
|
return fliteredMenuTree()
|
||||||
})
|
})
|
||||||
const route = useRoute()
|
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 UserLayout from '@/layout/user-layout.vue'
|
||||||
import AdminLayout from '@/layout/admin-layout.vue'
|
import AdminLayout from '@/layout/admin-layout.vue'
|
||||||
import BlankLayout from '@/layout/blank-layout.vue'
|
import BlankLayout from '@/layout/blank-layout.vue'
|
||||||
|
|
||||||
export const routes = [
|
export const routes: Array<RouteRecordRaw> = [
|
||||||
{
|
{
|
||||||
path: '/admin/acl', // 系统管理
|
path: '/admin/acl', // 系统管理
|
||||||
name: 'ACL',
|
name: 'ACL',
|
||||||
@ -99,43 +99,49 @@ export const routes = [
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
export default createRouter({
|
const getNewRouter = () => {
|
||||||
history: createWebHashHistory(),
|
// TODO 用户store判断是否登录,登录就返回过滤的,没有登录就返回全量
|
||||||
routes: [
|
|
||||||
{
|
return createRouter({
|
||||||
path: '/',
|
history: createWebHashHistory(),
|
||||||
name: 'Index',
|
routes: [
|
||||||
redirect: '/login',
|
{
|
||||||
},
|
path: '/',
|
||||||
{
|
name: 'Index',
|
||||||
path: '/login',
|
redirect: '/login',
|
||||||
name: 'Login',
|
},
|
||||||
redirect: '/login/user',
|
{
|
||||||
component: UserLayout,
|
path: '/login',
|
||||||
children: [
|
name: 'Login',
|
||||||
{
|
redirect: '/login/user',
|
||||||
path: 'user',
|
component: UserLayout,
|
||||||
name: 'LoginPage',
|
children: [
|
||||||
component: () => import('../views/login/user-login.vue'),
|
{
|
||||||
},
|
path: 'user',
|
||||||
],
|
name: 'LoginPage',
|
||||||
},
|
component: () => import('../views/login/user-login.vue'),
|
||||||
{
|
},
|
||||||
path: '/admin',
|
],
|
||||||
name: 'Admin',
|
},
|
||||||
redirect: '/admin/dashboard',
|
{
|
||||||
component: AdminLayout,
|
path: '/admin',
|
||||||
meta: { title: 'menus.index', icon: 'icon-home' },
|
name: 'Admin',
|
||||||
children: routes,
|
redirect: '/admin/dashboard',
|
||||||
},
|
component: AdminLayout,
|
||||||
{
|
meta: { title: 'menus.index', icon: 'icon-home' },
|
||||||
path: '/:catchAll(.*)',
|
children: routes,
|
||||||
redirect: '/message',
|
},
|
||||||
},
|
{
|
||||||
{
|
path: '/:catchAll(.*)',
|
||||||
path: '/message',
|
redirect: '/message',
|
||||||
name: 'Message',
|
},
|
||||||
component: () => import('@/views/message/message-page.vue'),
|
{
|
||||||
},
|
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) {
|
userLogin(user: auth.AuthUser) {
|
||||||
Object.assign(this, user)
|
Object.assign(this, user)
|
||||||
|
// 过了路由的地址
|
||||||
|
// router.addRoute
|
||||||
|
|
||||||
router.push({ path: '/admin/acl/users' }) // 登录后跳转到用户列表页面
|
router.push({ path: '/admin/acl/users' }) // 登录后跳转到用户列表页面
|
||||||
},
|
},
|
||||||
logout() {
|
logout() {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<a-flex gap="middle" horizontal>
|
<a-flex gap="middle" horizontal>
|
||||||
<span class="ant-form-text">请输入打印的条码数量:</span>
|
<span class="ant-form-text">请输入打印的条码数量:</span>
|
||||||
<a-form-item name="input-number" no-style>
|
<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>
|
</a-form-item>
|
||||||
|
|
||||||
<button @click="printCode">打印条形码</button>
|
<button @click="printCode">打印条形码</button>
|
||||||
@ -30,6 +30,10 @@
|
|||||||
|
|
||||||
const inputRef = ref(1)
|
const inputRef = ref(1)
|
||||||
|
|
||||||
|
watch(inputRef, (newVal) => {
|
||||||
|
fetchAndPrintBarcodes(newVal)
|
||||||
|
})
|
||||||
|
|
||||||
const printCode = () => {
|
const printCode = () => {
|
||||||
const container = document.getElementById('barcodes-container')
|
const container = document.getElementById('barcodes-container')
|
||||||
if (!container) {
|
if (!container) {
|
||||||
@ -48,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),
|
||||||
@ -75,7 +79,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 定义一个函数来从后端获取条形码字符串并打印
|
// 定义一个函数来从后端获取条形码字符串并打印
|
||||||
const fetchAndPrintBarcodes = async (count: number) => {
|
const fetchAndPrintBarcodes = (count: number) => {
|
||||||
// 清空之前的条形码容器
|
// 清空之前的条形码容器
|
||||||
const container = document.getElementById('barcodes-container')
|
const container = document.getElementById('barcodes-container')
|
||||||
if (!container) throw new Error('条形码容器未找到')
|
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