art: 格式化代码
All checks were successful
Release / lint (push) Successful in 29s
Release / Release (push) Successful in 1m22s

This commit is contained in:
my_ong 2024-12-14 11:22:41 +08:00
parent 3cb34c8554
commit 526bfa65b5
5 changed files with 170 additions and 148 deletions

View File

@ -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()

View File

@ -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()

View File

@ -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() {

View File

@ -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