| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- <script lang="ts" setup>
- import { isDark } from '@/utils/is'
- import { useAppStore } from '@/store/modules/app'
- import { useDesign } from '@/hooks/web/useDesign'
- import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
- import routerSearch from '@/components/RouterSearch/index.vue'
- import { useAutoLogout } from './composable/useAutoLogout'
- import { leftAsideStore } from '@/export'
- // import demo from '/svgs/demo.svg?raw'
- const electrical_modules_files = import.meta.glob('./assets/svgs/electrical/**.svg', {
- eager: true,
- as: 'raw'
- })
- const electrical_stroke_modules_files = import.meta.glob('./assets/svgs/electrical/stroke/**.svg', {
- eager: true,
- as: 'raw'
- })
- const process_demo_image_files = import.meta.glob('./assets/images/process-demo/**', {
- eager: true,
- query: '?url',
- import: 'default'
- })
- const materials_files = import.meta.glob('./assets/images/materials/**', {
- eager: true,
- query: '?url',
- import: 'default'
- })
- const electrical_register_config: any = []
- for (const key in electrical_modules_files) {
- //根据路径获取svg文件名
- const name = key.split('/').pop()!.split('.')[0]
- electrical_register_config.push({
- id: name,
- title: name,
- type: 'svg',
- thumbnail: 'data:image/svg+xml;utf8,' + encodeURIComponent(electrical_modules_files[key]),
- svg: electrical_modules_files[key],
- props: {
- fill: {
- type: 'color',
- val: '#FF0000',
- title: '填充色'
- }
- }
- })
- }
- for (const key in electrical_stroke_modules_files) {
- //根据路径获取svg文件名
- const name = key.split('/').pop()!.split('.')[0]
- electrical_register_config.push({
- id: name,
- title: name,
- type: 'svg',
- thumbnail:
- 'data:image/svg+xml;utf8,' + encodeURIComponent(electrical_stroke_modules_files[key]),
- svg: electrical_stroke_modules_files[key],
- props: {
- stroke: {
- type: 'color',
- val: '#00ff00',
- title: '边框色'
- }
- }
- })
- }
- leftAsideStore.registerConfig('电气符号', electrical_register_config)
- const process_demo_register_config: any[] = Object.entries(process_demo_image_files).map(
- ([key, url]) => {
- const name = key.split('/').pop()!.split('.')[0]
- return {
- id: name,
- title: name,
- type: 'img',
- thumbnail: url,
- props: {}
- }
- }
- )
- leftAsideStore.registerConfig('工艺流程图', process_demo_register_config)
- const materials_register_config: any[] = Object.entries(materials_files).map(([key, url]) => {
- const name = key.split('/').pop()!.split('.')[0]
- return {
- id: name,
- title: name,
- type: 'img',
- thumbnail: url,
- props: {}
- }
- })
- leftAsideStore.registerConfig('素材', materials_register_config)
- const route = useRoute()
- const { addListeners, removeListeners } = useAutoLogout()
- const whiteList = [
- '/login',
- '/social-login',
- '/auth-redirect',
- '/bind',
- '/register',
- '/oauthLogin/gitee',
- '/dingding',
- '/deepoil',
- '/oli-connection/monitoring-board'
- ]
- watch(
- () => route.path,
- (newPath) => {
- if (whiteList.includes(newPath)) {
- console.log('进入白名单页面,移除超时检测')
- removeListeners()
- } else {
- console.log('进入受控页面,开启超时检测')
- addListeners()
- }
- },
- { immediate: true } // 初始化时立即执行一次
- )
- defineOptions({ name: 'APP' })
- const { getPrefixCls } = useDesign()
- const prefixCls = getPrefixCls('app')
- const appStore = useAppStore()
- const currentSize = computed(() => appStore.getCurrentSize)
- const greyMode = computed(() => appStore.getGreyMode)
- const { wsCache } = useCache()
- // 根据浏览器当前主题设置系统主题色
- const setDefaultTheme = () => {
- let isDarkTheme = wsCache.get(CACHE_KEY.IS_DARK)
- if (isDarkTheme === null) {
- isDarkTheme = isDark()
- }
- appStore.setIsDark(isDarkTheme)
- }
- setDefaultTheme()
- </script>
- <template>
- <ConfigGlobal :size="currentSize">
- <RouterView :class="greyMode ? `${prefixCls}-grey-mode` : ''" />
- <routerSearch />
- </ConfigGlobal>
- </template>
- <style lang="scss">
- $prefix-cls: #{$namespace}-app;
- .size {
- width: 100%;
- height: 100%;
- }
- html,
- body {
- @extend .size;
- padding: 0 !important;
- margin: 0;
- overflow: hidden;
- #app {
- @extend .size;
- }
- }
- .#{$prefix-cls}-grey-mode {
- filter: grayscale(100%);
- }
- </style>
|