Commit 31134103 authored by sunguoshu's avatar sunguoshu

unocss

parent db1a2091
This diff is collapsed.
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
"swagger-editor-dist": "^4.10.0", "swagger-editor-dist": "^4.10.0",
"terser": "^5.18.2", "terser": "^5.18.2",
"typescript": "^5.1.5", "typescript": "^5.1.5",
"unocss": "^0.53.6",
"unplugin-auto-import": "^0.16.4", "unplugin-auto-import": "^0.16.4",
"unplugin-vue-components": "^0.25.1", "unplugin-vue-components": "^0.25.1",
"unplugin-vue-macros": "^2.3.6", "unplugin-vue-macros": "^2.3.6",
......
This diff is collapsed.
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
<div> <div>
<router-view /> <router-view />
<TheLock v-if="configStore.isLock" /> <TheLock v-if="configStore.isLock" />
<TheModal />
<TheMagnifierDialogVue /> <TheMagnifierDialogVue />
</div> </div>
</a-config-provider> </a-config-provider>
...@@ -13,7 +12,6 @@ ...@@ -13,7 +12,6 @@
import zhCN from 'ant-design-vue/lib/locale/zh_CN' import zhCN from 'ant-design-vue/lib/locale/zh_CN'
import TheLock from '@/components/TheLock' import TheLock from '@/components/TheLock'
import TheMagnifierDialogVue from '@/components/Magnifier/magnifierDialog.vue' import TheMagnifierDialogVue from '@/components/Magnifier/magnifierDialog.vue'
import TheModal from '@/components/TheModal/index.vue'
import { useConfigStore } from '@/store/modules' import { useConfigStore } from '@/store/modules'
const configStore = useConfigStore() const configStore = useConfigStore()
......
<template>
<div>
<a-modal :title="title" :visible="visible" @ok="handleOk" @cancel="handleCancel">
<p>{{ message }}</p>
</a-modal>
</div>
</template>
<script>
export default {
name: 'TheModal',
data() {
return {
title: 'title',
visible: false,
message: '内容',
handleOk: () => {}
}
},
methods: {
handleCancel() {
this.visible = false
}
},
created() {
this.$bus.$on('openModel', ({ title, message, ok }) => {
this.visible = true
this.title = title || ''
this.message = message || ''
this.handleOk = ok
? () => {
ok()
this.handleCancel()
}
: () => {
this.handleCancel()
}
})
},
mounted() {}
}
</script>
<style lang="less" scoped>
/deep/.ant-modal {
top: calc(50% - 100px);
max-height: 200px;
}
/deep/.ant-modal-body {
padding: 12px;
& > p {
max-height: 80px;
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
margin: unset;
text-align: center;
}
}
</style>
...@@ -106,11 +106,11 @@ export default { ...@@ -106,11 +106,11 @@ export default {
this.$message.error('系统开始接入时间不能大于系统关闭接入时间', 5) this.$message.error('系统开始接入时间不能大于系统关闭接入时间', 5)
return return
} }
if (firstHour == sedHour && firstMin > sedMin) { if (firstHour === sedHour && firstMin > sedMin) {
this.$message.error('系统开始接入时间不能大于系统关闭接入时间', 5) this.$message.error('系统开始接入时间不能大于系统关闭接入时间', 5)
return return
} }
if (firstHour == sedHour && firstMin == sedMin && firstSeconds > sedSeconds) { if (firstHour === sedHour && firstMin === sedMin && firstSeconds > sedSeconds) {
this.$message.error('系统开始接入时间不能大于系统关闭接入时间', 5) this.$message.error('系统开始接入时间不能大于系统关闭接入时间', 5)
return return
} }
......
...@@ -42,10 +42,10 @@ export default { ...@@ -42,10 +42,10 @@ export default {
methods: { methods: {
closeItem() { closeItem() {
let menuList = this.menuStore.visitedMenu let menuList = this.menuStore.visitedMenu
if (menuList[this.menuIndex].name == 'home') { if (menuList[this.menuIndex].name === 'home') {
return return
} }
if (this.menuStore.selectedMenu == menuList[this.menuIndex].name) { if (this.menuStore.selectedMenu === menuList[this.menuIndex].name) {
this.$router.push(menuList[this.menuIndex - 1].path) this.$router.push(menuList[this.menuIndex - 1].path)
} }
this.menuStore.removeVisitedMenu('index', this.menuIndex) this.menuStore.removeVisitedMenu('index', this.menuIndex)
...@@ -59,7 +59,7 @@ export default { ...@@ -59,7 +59,7 @@ export default {
}, },
closeRight() { closeRight() {
let menuList = this.menuStore.visitedMenu let menuList = this.menuStore.visitedMenu
if (this.menuIndex == menuList.length - 1) { if (this.menuIndex === menuList.length - 1) {
return return
} }
if (this.$route.name !== menuList[this.menuIndex].name) { if (this.$route.name !== menuList[this.menuIndex].name) {
......
<template> <template>
<div> <div>
<ul class="tabBox"> <ul class="tabBox">
<li v-for="(menu, index) in menuList" :key="index"> <li v-for="(menu, index) in menuStore.visitedMenu" :key="index">
<span <span
:class="{ active: selectedMenu == menu.name }" :class="{ active: selectedMenu === menu.name }"
@contextmenu.prevent="showCloseMenu(index, menuList, $event)" @contextmenu.prevent="showCloseMenu(index, menuStore.visitedMenu, $event)"
> >
<i @click="goPath(menu)"> <i @click="goPath(menu)">
{{ menu.meta.title }} {{ menu.meta.title }}
...@@ -27,7 +27,6 @@ import Close from './Close.vue' ...@@ -27,7 +27,6 @@ import Close from './Close.vue'
const router = useRouter() const router = useRouter()
const menuStore = useMenuStore() const menuStore = useMenuStore()
let menuList = ref(menuStore.visitedMenu)
let left = ref('') let left = ref('')
let menuIndex = ref('') let menuIndex = ref('')
...@@ -41,8 +40,8 @@ function goPath(menu) { ...@@ -41,8 +40,8 @@ function goPath(menu) {
router.push(menu.path) router.push(menu.path)
} }
function closeMenu(index) { function closeMenu(index) {
if (menuStore.selectedMenu == menuList.value[index].name) { if (menuStore.selectedMenu === menuStore.visitedMenu[index].name) {
router.push(menuList.value[index - 1].path) router.push(menuStore.visitedMenu[index - 1].path)
} }
menuStore.removeVisitedMenu('index', index) menuStore.removeVisitedMenu('index', index)
} }
......
...@@ -42,7 +42,7 @@ export const TheMenu = defineComponent({ ...@@ -42,7 +42,7 @@ export const TheMenu = defineComponent({
return ( return (
<a-menu-item <a-menu-item
key={item.name} key={item.name}
class={menuStore.selectedMenu == item.name ? `${prefixCls}-selected` : ''} class={menuStore.selectedMenu === item.name ? `${prefixCls}-selected` : ''}
> >
<MenuLink item={item} /> <MenuLink item={item} />
</a-menu-item> </a-menu-item>
...@@ -82,7 +82,9 @@ const SubMenu = defineComponent({ ...@@ -82,7 +82,9 @@ const SubMenu = defineComponent({
return <SubMenu key={item.name} item={item} /> return <SubMenu key={item.name} item={item} />
} }
return ( return (
<a-menu-item class={menuStore.selectedMenu == item.name ? `${prefixCls}-selected` : ''}> <a-menu-item
class={menuStore.selectedMenu === item.name ? `${prefixCls}-selected` : ''}
>
<MenuLink item={item} /> <MenuLink item={item} />
</a-menu-item> </a-menu-item>
) )
......
<template> <template>
<div class="Notify"> <div class="Notify">
<ul v-if="type == '1'"> <ul v-if="type === '1'">
<li v-for="(li, index) in list" :key="index"> <li v-for="(li, index) in list" :key="index">
<div class="left"> <div class="left">
<!-- <img :src="li.userPic" alt="" /> --> <!-- <img :src="li.userPic" alt="" /> -->
<span v-if="li.noticeType == 0"> <span v-if="li.noticeType === 0">
<img src="../../../assets/img/systemIcon.png" alt="" /> <img src="@/assets/img/systemIcon.png" alt="" />
</span> </span>
<svg <svg
v-else v-else
...@@ -120,26 +120,26 @@ ...@@ -120,26 +120,26 @@
</div> </div>
</li> </li>
</ul> </ul>
<ul v-if="type == '2'"> <ul v-if="type === '2'">
<li v-for="(li, index) in list" :key="index"> <li v-for="(li, index) in list" :key="index">
<div class="left"> <div class="left">
<img :src="getUrl(li.type)" alt="" /> <img :src="getUrl(li.type)" alt="" />
</div> </div>
<div class="right"> <div class="right">
<h6 v-if="li.isFinish == true">{{ li.title }}</h6> <h6 v-if="li.isFinish === true">{{ li.title }}</h6>
<h6 v-else> <h6 v-else>
<del> {{ li.title }}</del> <del> {{ li.title }}</del>
</h6> </h6>
<div class="time"> <div class="time">
<span v-if="li.isFinish == true">{{ li.datetime }}</span> <span v-if="li.isFinish === true">{{ li.datetime }}</span>
<del v-else>{{ li.datetime }}</del> <del v-else>{{ li.datetime }}</del>
<span @click.stop="goDetail(li, index)"> 详情 </span> <span @click.stop="goDetail(li, index)"> 详情 </span>
</div> </div>
</div> </div>
</li> </li>
</ul> </ul>
<ul v-if="type == '3'" class="waitDone"> <ul v-if="type === '3'" class="waitDone">
<li v-for="(li, index) in list" :key="index"> <li v-for="(li, index) in list" :key="index">
<div class="right"> <div class="right">
<div class="title" style="display: flex; justify-content: space-between"> <div class="title" style="display: flex; justify-content: space-between">
...@@ -248,10 +248,6 @@ export default { ...@@ -248,10 +248,6 @@ export default {
text-overflow: ellipsis; text-overflow: ellipsis;
// 只要超过宽度就换行,不论中文还是英文 // 只要超过宽度就换行,不论中文还是英文
word-break: break-all; word-break: break-all;
//最多展示两行
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
//根据样式设置 //根据样式设置
line-height: 1.2em; line-height: 1.2em;
max-height: 2.4em; max-height: 2.4em;
...@@ -287,13 +283,7 @@ export default { ...@@ -287,13 +283,7 @@ export default {
-webkit-line-clamp: 2; -webkit-line-clamp: 2;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
// 只要超过宽度就换行,不论中文还是英文
word-break: break-all; word-break: break-all;
//最多展示两行
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
//根据样式设置
line-height: 1.2em; line-height: 1.2em;
max-height: 2.4em; max-height: 2.4em;
} }
......
...@@ -10,6 +10,7 @@ import { createHead, HeadVuePlugin } from '@vueuse/head' ...@@ -10,6 +10,7 @@ import { createHead, HeadVuePlugin } from '@vueuse/head'
import router from './router' import router from './router'
import './directives' import './directives'
import { useAppStore } from '@/store/modules' import { useAppStore } from '@/store/modules'
import 'virtual:uno.css'
import VXETable from 'vxe-table' import VXETable from 'vxe-table'
import 'vxe-table/lib/style.css' import 'vxe-table/lib/style.css'
...@@ -19,7 +20,6 @@ import Step from '@/components/Step' ...@@ -19,7 +20,6 @@ import Step from '@/components/Step'
import magnifier from '@/components/Magnifier/magnifier.vue' import magnifier from '@/components/Magnifier/magnifier.vue'
import { post } from '@/utils/remote/remote' import { post } from '@/utils/remote/remote'
import api from '@/utils/remote' import api from '@/utils/remote'
import queryEnum from '@/utils/remote/queryEnum'
import dayjs from 'dayjs' import dayjs from 'dayjs'
dayjs.locale('zh-cn') dayjs.locale('zh-cn')
...@@ -34,11 +34,9 @@ Vue.component('magnifier', magnifier) ...@@ -34,11 +34,9 @@ Vue.component('magnifier', magnifier)
// ********** 方法 ********** // ********** 方法 **********
const bus = new Vue() const bus = new Vue()
Vue.prototype.$bus = bus // 事件总线 Vue.prototype.$bus = bus // 事件总线
Vue.prototype.$Modal = (data: any) => bus.$emit('openModel', data)
Vue.prototype.$moment = moment Vue.prototype.$moment = moment
Vue.prototype.$remote = post Vue.prototype.$remote = post
Vue.prototype.$api = api Vue.prototype.$api = api
Vue.prototype.$queryEnum = queryEnum
Vue.prototype.$getTableFiled = (table: string, filed: string, index: string) => Vue.prototype.$getTableFiled = (table: string, filed: string, index: string) =>
table + '[' + index + ']' + '.' + filed table + '[' + index + ']' + '.' + filed
// ********** 插件 ********** // ********** 插件 **********
......
...@@ -5,17 +5,21 @@ import { postQueryMenu } from '@/apis' ...@@ -5,17 +5,21 @@ import { postQueryMenu } from '@/apis'
import { useMenuStore, useConfigStore } from '@/store/modules' import { useMenuStore, useConfigStore } from '@/store/modules'
export const useAppStore = defineStore('app', () => { export const useAppStore = defineStore('app', () => {
const userId = ref(localStorage.getItem('userId')) const route = location.hash.slice(1)
const userId = localStorage.getItem('userId')
const loading = ref(true) const loading = ref(true)
const menuStore = useMenuStore() const menuStore = useMenuStore()
const configStore = useConfigStore() const configStore = useConfigStore()
if (!userId.value) { if (!userId) {
location.hash = '#/login' location.hash = '#/login'
} }
router.addRoutes(setupLayouts(generatedRoutes))
let authRoutes: string[] = [] // 权限路由
let currentMenu: any // 当前路由菜单
// 递归转换菜单
function transformToMenu(item: Menu[]): any[] { function transformToMenu(item: Menu[]): any[] {
return item.map((i) => { return item.map((i) => {
let obj = { let obj = {
...@@ -26,7 +30,12 @@ export const useAppStore = defineStore('app', () => { ...@@ -26,7 +30,12 @@ export const useAppStore = defineStore('app', () => {
} }
} }
if (i.type === 'menu') { if (i.type === 'menu') {
return { ...obj, path: i.path } authRoutes.push(i.path!)
const menu = { ...obj, path: i.path }
if (i.path === route) {
currentMenu = menu
}
return menu
} }
return { return {
...obj, ...obj,
...@@ -35,15 +44,34 @@ export const useAppStore = defineStore('app', () => { ...@@ -35,15 +44,34 @@ export const useAppStore = defineStore('app', () => {
}) })
} }
function setMenu(data: any[]) {
const menu = transformToMenu(data)
menuStore.setMenu(menu)
console.log(menu)
}
function setRoutes() {
const routes = generatedRoutes.filter((r) => authRoutes.includes(r.path))
router.addRoutes(setupLayouts(routes))
}
function setState() {
if (currentMenu) {
menuStore.setSelectedMenu(currentMenu.name)
}
}
postQueryMenu().then((r) => { postQueryMenu().then((r) => {
if (r.data) { if (r.data) {
const menu = transformToMenu(r.data) setMenu(r.data)
menuStore.setMenu(menu) setRoutes()
setState()
loading.value = false loading.value = false
} }
}) })
function logout() { function logout() {
menuStore.clear()
configStore.clear() configStore.clear()
localStorage.removeItem('userId') localStorage.removeItem('userId')
location.hash = '#/login' location.hash = '#/login'
......
export const useMenuStore = defineStore('menu', { export const useMenuStore = defineStore('menu', {
state: () => ({ state: () => ({
menuRoute: [] as any[],
menu: [] as any[], menu: [] as any[],
selectedMenu: '', selectedMenu: '',
openedMenu: [] as string[], openedMenu: [] as string[],
visitedMenu: [] as any[] visitedMenu: [
{
name: 'Home',
path: '/home',
meta: {
title: '首页',
icon: 'material-symbols:home'
}
}
] as any[]
}), }),
actions: { actions: {
setMenuRoute(menuRoute: any[]) {
this.menuRoute = menuRoute
},
setMenu(menu: any[]): void { setMenu(menu: any[]): void {
this.menu = menu this.menu = menu
}, },
...@@ -20,7 +25,7 @@ export const useMenuStore = defineStore('menu', { ...@@ -20,7 +25,7 @@ export const useMenuStore = defineStore('menu', {
this.openedMenu = menu this.openedMenu = menu
}, },
addVisitedMenu(menu: any): void { addVisitedMenu(menu: any): void {
if (menu.meta.title && !this.visitedMenu.some((item) => item?.name === this.selectedMenu)) { if (menu.meta.title && !this.visitedMenu.some((item) => item?.name === menu.name)) {
this.visitedMenu.push(menu) this.visitedMenu.push(menu)
} }
}, },
...@@ -41,7 +46,9 @@ export const useMenuStore = defineStore('menu', { ...@@ -41,7 +46,9 @@ export const useMenuStore = defineStore('menu', {
} }
}, },
clear() { clear() {
localStorage.removeItem('menu') this.selectedMenu = ''
this.openedMenu = []
this.visitedMenu = []
} }
} }
}) })
import { post } from '@/utils/remote'
export default function queryEnum(params) {
return post('/sso/resource/getOptions', params, undefined, undefined, {
headers: {
'Content-Type': 'application/json;'
}
})
}
<template> <template>
<div> <div class="w-100 h-25 bg-violet">
<h1>首页</h1> <h1 class="text-3xl font-bold underline">Hello world!</h1>
</div> </div>
</template> </template>
......
<template> <template>
<h1>1001</h1> <div class="w-24 h-24 bg-slate-100">
<h1>1001</h1>
</div>
</template> </template>
<script setup lang="ts"></script> <script>
export default {
name: '1001',
data() {
return {}
},
methods: {},
created() {},
mounted() {}
}
</script>
<style scoped lang="less"></style> <style scoped lang="less"></style>
...@@ -12,6 +12,7 @@ import antdvFix from 'vite-plugin-antdv-fix' ...@@ -12,6 +12,7 @@ import antdvFix from 'vite-plugin-antdv-fix'
import mockDevServerPlugin from 'vite-plugin-mock-dev-server' import mockDevServerPlugin from 'vite-plugin-mock-dev-server'
import Pages from 'vite-plugin-pages' import Pages from 'vite-plugin-pages'
import Layouts from 'vite-plugin-vue-layouts' import Layouts from 'vite-plugin-vue-layouts'
import UnoCSS from 'unocss/vite'
import postcssImport from 'postcss-import' import postcssImport from 'postcss-import'
import autoprefixer from 'autoprefixer' import autoprefixer from 'autoprefixer'
...@@ -83,6 +84,7 @@ export default defineConfig(({ mode }) => { ...@@ -83,6 +84,7 @@ export default defineConfig(({ mode }) => {
components({ components({
dirs: ['src/components'] dirs: ['src/components']
}), }),
UnoCSS(),
antdvFix(), antdvFix(),
Pages({ Pages({
dirs: 'src/views', dirs: 'src/views',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment