Showing
9 changed files
with
63 additions
and
136 deletions
| @@ -49,13 +49,6 @@ | @@ -49,13 +49,6 @@ | ||
| 49 | return userStore.platInfo?.logo; | 49 | return userStore.platInfo?.logo; |
| 50 | }); | 50 | }); |
| 51 | const getTitle = computed(() => { | 51 | const getTitle = computed(() => { |
| 52 | - // 设置icon | ||
| 53 | - let link = (document.querySelector("link[rel*='icon']") || | ||
| 54 | - document.createElement('link')) as HTMLLinkElement; | ||
| 55 | - link.type = 'image/x-icon'; | ||
| 56 | - link.rel = 'shortcut icon'; | ||
| 57 | - link.href = userStore.platInfo?.icon ?? '/favicon.ico'; | ||
| 58 | - document.getElementsByTagName('head')[0].appendChild(link); | ||
| 59 | return userStore.platInfo?.name ?? title; | 52 | return userStore.platInfo?.name ?? title; |
| 60 | }); | 53 | }); |
| 61 | </script> | 54 | </script> |
| @@ -67,6 +60,7 @@ | @@ -67,6 +60,7 @@ | ||
| 67 | padding-left: 7px; | 60 | padding-left: 7px; |
| 68 | cursor: pointer; | 61 | cursor: pointer; |
| 69 | transition: all 0.2s ease; | 62 | transition: all 0.2s ease; |
| 63 | + | ||
| 70 | &.light { | 64 | &.light { |
| 71 | border-bottom: 1px solid @border-color-base; | 65 | border-bottom: 1px solid @border-color-base; |
| 72 | } | 66 | } |
| @@ -35,6 +35,8 @@ export const APP_SESSION_CACHE_KEY = 'COMMON__SESSION__KEY__'; | @@ -35,6 +35,8 @@ export const APP_SESSION_CACHE_KEY = 'COMMON__SESSION__KEY__'; | ||
| 35 | 35 | ||
| 36 | export const PLATFORM = 'PLATFORM'; | 36 | export const PLATFORM = 'PLATFORM'; |
| 37 | 37 | ||
| 38 | +export const PLATFORM_INFO_CACHE_KEY = 'PLATFORM_INFO'; | ||
| 39 | + | ||
| 38 | export const MENU_LIST = 'MENU_LIST'; | 40 | export const MENU_LIST = 'MENU_LIST'; |
| 39 | export enum CacheTypeEnum { | 41 | export enum CacheTypeEnum { |
| 40 | SESSION, | 42 | SESSION, |
| @@ -71,7 +71,6 @@ | @@ -71,7 +71,6 @@ | ||
| 71 | 71 | ||
| 72 | import { useUserStore } from '/@/store/modules/user'; | 72 | import { useUserStore } from '/@/store/modules/user'; |
| 73 | import { LoginStateEnum, useLoginState, useFormRules, useFormValid } from './useLogin'; | 73 | import { LoginStateEnum, useLoginState, useFormRules, useFormValid } from './useLogin'; |
| 74 | - import { useDesign } from '/@/hooks/web/useDesign'; | ||
| 75 | import { getPlatForm } from '/@/api/oem'; | 74 | import { getPlatForm } from '/@/api/oem'; |
| 76 | import { createLocalStorage } from '/@/utils/cache'; | 75 | import { createLocalStorage } from '/@/utils/cache'; |
| 77 | 76 | ||
| @@ -80,8 +79,7 @@ | @@ -80,8 +79,7 @@ | ||
| 80 | const FormItem = Form.Item; | 79 | const FormItem = Form.Item; |
| 81 | const InputPassword = Input.Password; | 80 | const InputPassword = Input.Password; |
| 82 | const { t } = useI18n(); | 81 | const { t } = useI18n(); |
| 83 | - const { notification, createMessage } = useMessage(); | ||
| 84 | - const { prefixCls } = useDesign('login'); | 82 | + const { notification } = useMessage(); |
| 85 | const userStore = useUserStore(); | 83 | const userStore = useUserStore(); |
| 86 | 84 | ||
| 87 | const { setLoginState, getLoginState } = useLoginState(); | 85 | const { setLoginState, getLoginState } = useLoginState(); |
| @@ -115,7 +113,7 @@ | @@ -115,7 +113,7 @@ | ||
| 115 | username: data.account, | 113 | username: data.account, |
| 116 | mode: 'modal', //不要默认的错误提示 | 114 | mode: 'modal', //不要默认的错误提示 |
| 117 | }) | 115 | }) |
| 118 | - .catch((data) => { | 116 | + .catch(() => { |
| 119 | //登录失败返回的html,所以提示框什么都没有 | 117 | //登录失败返回的html,所以提示框什么都没有 |
| 120 | //去掉提示框 | 118 | //去掉提示框 |
| 121 | // createMessage.error(data.message); | 119 | // createMessage.error(data.message); |
| @@ -129,13 +127,6 @@ | @@ -129,13 +127,6 @@ | ||
| 129 | const res = await getPlatForm(); | 127 | const res = await getPlatForm(); |
| 130 | storage.set('platformInfo', res); | 128 | storage.set('platformInfo', res); |
| 131 | userStore.setPlatInfo(res); | 129 | userStore.setPlatInfo(res); |
| 132 | - // 设置icon | ||
| 133 | - let link = (document.querySelector("link[rel*='icon']") || | ||
| 134 | - document.createElement('link')) as HTMLLinkElement; | ||
| 135 | - link.type = 'image/x-icon'; | ||
| 136 | - link.rel = 'shortcut icon'; | ||
| 137 | - link.href = res.icon ?? '/favicon.ico'; | ||
| 138 | - document.getElementsByTagName('head')[0].appendChild(link); | ||
| 139 | 130 | ||
| 140 | var _hmt = _hmt || []; | 131 | var _hmt = _hmt || []; |
| 141 | (function () { | 132 | (function () { |
| 1 | <template> | 1 | <template> |
| 2 | - <div | ||
| 3 | - style="background-size: 100% 100%" | ||
| 4 | - :style="{ backgroundImage: 'url(' + (logoUrl !== undefined ? logoUrl : '') + ')' }" | ||
| 5 | - :class="prefixCls" | ||
| 6 | - class="relative w-full h-full px-4" | ||
| 7 | - > | 2 | + <div :class="prefixCls" class="relative w-full h-full px-4"> |
| 8 | <AppLocalePicker | 3 | <AppLocalePicker |
| 9 | class="absolute text-white top-4 right-4 enter-x xl:text-gray-600" | 4 | class="absolute text-white top-4 right-4 enter-x xl:text-gray-600" |
| 10 | :showText="false" | 5 | :showText="false" |
| @@ -36,12 +31,8 @@ | @@ -36,12 +31,8 @@ | ||
| 36 | {{ defaultTitle }} | 31 | {{ defaultTitle }} |
| 37 | </div> | 32 | </div> |
| 38 | </div> | 33 | </div> |
| 39 | - <div v-if="ifCustom" class="my-auto"> | ||
| 40 | - <img | ||
| 41 | - :alt="title" | ||
| 42 | - src="../../../assets/svg/thingskit-login-background.svg" | ||
| 43 | - class="w-1/2 -mt-16 -enter-x" | ||
| 44 | - /> | 34 | + <div v-if="show" class="my-auto"> |
| 35 | + <img :alt="title" :src="defaultBackgroundImage" class="w-1/2 -mt-16 -enter-x" /> | ||
| 45 | <div class="mt-10 font-medium text-white -enter-x"> | 36 | <div class="mt-10 font-medium text-white -enter-x"> |
| 46 | <span class="inline-block mt-4 text-3xl"> {{ t('sys.login.signInTitle') }}</span> | 37 | <span class="inline-block mt-4 text-3xl"> {{ t('sys.login.signInTitle') }}</span> |
| 47 | </div> | 38 | </div> |
| @@ -67,7 +58,6 @@ | @@ -67,7 +58,6 @@ | ||
| 67 | </template> | 58 | </template> |
| 68 | <script lang="ts" setup> | 59 | <script lang="ts" setup> |
| 69 | import { ref, onMounted } from 'vue'; | 60 | import { ref, onMounted } from 'vue'; |
| 70 | - // import { AppLogo } from '/@/components/Application'; | ||
| 71 | import { AppLocalePicker, AppDarkModeToggle } from '/@/components/Application'; | 61 | import { AppLocalePicker, AppDarkModeToggle } from '/@/components/Application'; |
| 72 | import LoginForm from './LoginForm.vue'; | 62 | import LoginForm from './LoginForm.vue'; |
| 73 | import ForgetPasswordForm from './ForgetPasswordForm.vue'; | 63 | import ForgetPasswordForm from './ForgetPasswordForm.vue'; |
| @@ -77,13 +67,9 @@ | @@ -77,13 +67,9 @@ | ||
| 77 | import { useI18n } from '/@/hooks/web/useI18n'; | 67 | import { useI18n } from '/@/hooks/web/useI18n'; |
| 78 | import { useDesign } from '/@/hooks/web/useDesign'; | 68 | import { useDesign } from '/@/hooks/web/useDesign'; |
| 79 | import { useLocaleStore } from '/@/store/modules/locale'; | 69 | import { useLocaleStore } from '/@/store/modules/locale'; |
| 80 | - // import { useUserStore } from '/@/store/modules/user'; | ||
| 81 | - import { getPlatForm } from '/@/api/oem/index'; | ||
| 82 | - import defaultShowLogoImg from '/@/assets/svg/login-bg.svg'; | ||
| 83 | - import defaultShowLogoDarkImg from '/@/assets/svg/login-bg-dark.svg'; | ||
| 84 | import { useTitle } from '@vueuse/core'; | 70 | import { useTitle } from '@vueuse/core'; |
| 85 | - import { createLocalStorage } from '/@/utils/cache'; | ||
| 86 | - // import {usePlatform} from '/@/views/system/customize/hook/usePlatformInfo' | 71 | + import defaultBackgroundImage from '/@/assets/svg/thingskit-login-background.svg'; |
| 72 | + import { getPlatFormInfo } from '../../system/customize/hook/usePlatformInfo'; | ||
| 87 | 73 | ||
| 88 | defineProps({ | 74 | defineProps({ |
| 89 | sessionTimeout: { | 75 | sessionTimeout: { |
| @@ -93,88 +79,22 @@ | @@ -93,88 +79,22 @@ | ||
| 93 | const { title } = useGlobSetting(); | 79 | const { title } = useGlobSetting(); |
| 94 | const defaultTitle = ref(''); | 80 | const defaultTitle = ref(''); |
| 95 | const defaultLogo = ref(''); | 81 | const defaultLogo = ref(''); |
| 96 | - const logoUrl = ref(''); | ||
| 97 | - // const userStore = useUserStore(); | ||
| 98 | - const storage = createLocalStorage(); | ||
| 99 | - | ||
| 100 | - onMounted(async () => { | ||
| 101 | - let res = storage.get('platformInfo'); | ||
| 102 | - if (res === '' || res === null) { | ||
| 103 | - res = await getPlatForm(); | ||
| 104 | - } | ||
| 105 | - logoUrl.value = res?.background; | ||
| 106 | - defaultTitle.value = res?.name || title; | ||
| 107 | - defaultLogo.value = res?.logo; | ||
| 108 | - let link = (document.querySelector("link[rel*='icon']") || | ||
| 109 | - document.createElement('link')) as HTMLLinkElement; | ||
| 110 | - link.type = 'image/x-icon'; | ||
| 111 | - link.rel = 'shortcut icon'; | ||
| 112 | - link.href = res?.icon ?? '/favicon.ico'; | ||
| 113 | - document.getElementsByTagName('head')[0].appendChild(link); | ||
| 114 | - let defaultLogoBg = document.createElement('style'); | ||
| 115 | - let defaultLogoDarkBg = document.createElement('style'); | ||
| 116 | - if (logoUrl.value !== undefined) { | ||
| 117 | - //企业自定义 | ||
| 118 | - ifCustom.value = false; | ||
| 119 | - //默认图片 | ||
| 120 | - defaultLogoBg.innerHTML = `.vben-login::before{ | ||
| 121 | - background-image:url(""); | ||
| 122 | - position:absolute; | ||
| 123 | - }`; | ||
| 124 | - //切换黑暗模式图片 | ||
| 125 | - defaultLogoDarkBg.innerHTML = `html[data-theme='dark'] .vben-login::before{ | ||
| 126 | - background-image:url(""); | ||
| 127 | - position:absolute; | ||
| 128 | - }`; | ||
| 129 | - } else { | ||
| 130 | - logoUrl.value = 'url(' + defaultShowLogoImg + ')'; | ||
| 131 | - //默认图片 | ||
| 132 | - defaultLogoBg.innerHTML = `.vben-login::before{ | ||
| 133 | - background-image:url(${defaultShowLogoImg}); | ||
| 134 | - position:absolute; | ||
| 135 | - }`; | ||
| 136 | - //切换黑暗模式图片 | ||
| 137 | - defaultLogoDarkBg.innerHTML = `html[data-theme='dark'] .vben-login::before{ | ||
| 138 | - background-image:url(${defaultShowLogoDarkImg}); | ||
| 139 | - position:absolute; | ||
| 140 | - }`; | ||
| 141 | - } | ||
| 142 | - document.head.appendChild(defaultLogoBg); | ||
| 143 | - document.head.appendChild(defaultLogoDarkBg); | ||
| 144 | - }); | ||
| 145 | 82 | ||
| 146 | - // const userStore = useUserStore(); | ||
| 147 | - | ||
| 148 | - const ifCustom = ref(true); | ||
| 149 | - // const getLogo = computed(() => { | ||
| 150 | - // return userStore.platInfo?.logo; | ||
| 151 | - // }); | ||
| 152 | - // const getTitle = computed(() => { | ||
| 153 | - // // 设置icon | ||
| 154 | - // let link = (document.querySelector("link[rel*='icon']") || | ||
| 155 | - // document.createElement('link')) as HTMLLinkElement; | ||
| 156 | - // link.type = 'image/x-icon'; | ||
| 157 | - // link.rel = 'shortcut icon'; | ||
| 158 | - // link.href = userStore.platInfo?.icon ?? '/favicon.ico'; | ||
| 159 | - // document.getElementsByTagName('head')[0].appendChild(link); | ||
| 160 | - // // logoUrl.value = userStore.platInfo?.background; | ||
| 161 | - // // if (logoUrl.value !== undefined) { | ||
| 162 | - // // ifCustom.value = false; | ||
| 163 | - // // } else { | ||
| 164 | - // // logoUrl.value = 'url(' + defaultShowLogoImg + ')'; | ||
| 165 | - // // } | ||
| 166 | - // return userStore.platInfo?.name ?? title; | ||
| 167 | - // }); | ||
| 168 | - // const globSetting = useGlobSetting(); | ||
| 169 | const { prefixCls } = useDesign('login'); | 83 | const { prefixCls } = useDesign('login'); |
| 170 | const { t } = useI18n(); | 84 | const { t } = useI18n(); |
| 171 | const localeStore = useLocaleStore(); | 85 | const localeStore = useLocaleStore(); |
| 172 | const showLocale = localeStore.getShowPicker; | 86 | const showLocale = localeStore.getShowPicker; |
| 173 | - // const title = computed(() => globSetting?.title ?? ''); | ||
| 174 | 87 | ||
| 175 | onMounted(() => { | 88 | onMounted(() => { |
| 176 | useTitle('ThingsKit 物联网平台'); | 89 | useTitle('ThingsKit 物联网平台'); |
| 177 | }); | 90 | }); |
| 91 | + | ||
| 92 | + const show = ref(false); | ||
| 93 | + | ||
| 94 | + onMounted(() => { | ||
| 95 | + const platform = getPlatFormInfo(); | ||
| 96 | + show.value = !platform.background; | ||
| 97 | + }); | ||
| 178 | </script> | 98 | </script> |
| 179 | <style lang="less"> | 99 | <style lang="less"> |
| 180 | @prefix-cls: ~'@{namespace}-login'; | 100 | @prefix-cls: ~'@{namespace}-login'; |
| @@ -71,7 +71,6 @@ | @@ -71,7 +71,6 @@ | ||
| 71 | 71 | ||
| 72 | import { useUserStore } from '/@/store/modules/user'; | 72 | import { useUserStore } from '/@/store/modules/user'; |
| 73 | import { LoginStateEnum, useLoginState, useFormRules, useFormValid } from './useLogin'; | 73 | import { LoginStateEnum, useLoginState, useFormRules, useFormValid } from './useLogin'; |
| 74 | - import { useDesign } from '/@/hooks/web/useDesign'; | ||
| 75 | import { getPlatForm } from '/@/api/oem'; | 74 | import { getPlatForm } from '/@/api/oem'; |
| 76 | import { createLocalStorage, createSessionStorage } from '/@/utils/cache'; | 75 | import { createLocalStorage, createSessionStorage } from '/@/utils/cache'; |
| 77 | 76 | ||
| @@ -81,7 +80,6 @@ | @@ -81,7 +80,6 @@ | ||
| 81 | const InputPassword = Input.Password; | 80 | const InputPassword = Input.Password; |
| 82 | const { t } = useI18n(); | 81 | const { t } = useI18n(); |
| 83 | const { notification, createMessage } = useMessage(); | 82 | const { notification, createMessage } = useMessage(); |
| 84 | - const { prefixCls } = useDesign('login'); | ||
| 85 | const userStore = useUserStore(); | 83 | const userStore = useUserStore(); |
| 86 | 84 | ||
| 87 | const { setLoginState, getLoginState } = useLoginState(); | 85 | const { setLoginState, getLoginState } = useLoginState(); |
| @@ -137,13 +135,6 @@ | @@ -137,13 +135,6 @@ | ||
| 137 | const res = await getPlatForm(); | 135 | const res = await getPlatForm(); |
| 138 | storage.set('platformInfo', res); | 136 | storage.set('platformInfo', res); |
| 139 | userStore.setPlatInfo(res); | 137 | userStore.setPlatInfo(res); |
| 140 | - // 设置icon | ||
| 141 | - let link = (document.querySelector("link[rel*='icon']") || | ||
| 142 | - document.createElement('link')) as HTMLLinkElement; | ||
| 143 | - link.type = 'image/x-icon'; | ||
| 144 | - link.rel = 'shortcut icon'; | ||
| 145 | - link.href = res.icon ?? '/favicon.ico'; | ||
| 146 | - document.getElementsByTagName('head')[0].appendChild(link); | ||
| 147 | 138 | ||
| 148 | var _hmt = _hmt || []; | 139 | var _hmt = _hmt || []; |
| 149 | (function () { | 140 | (function () { |
| @@ -38,7 +38,7 @@ | @@ -38,7 +38,7 @@ | ||
| 38 | > | 38 | > |
| 39 | </template> | 39 | </template> |
| 40 | <template #uploadText> | 40 | <template #uploadText> |
| 41 | - <div class="box-outline"> 支持.ICON格式,建议尺寸为16*16px </div> | 41 | + <div class="box-outline"> 支持.ICO格式,建议尺寸为16*16px </div> |
| 42 | </template> | 42 | </template> |
| 43 | </ContentUploadText> | 43 | </ContentUploadText> |
| 44 | </template> | 44 | </template> |
| @@ -149,9 +149,10 @@ | @@ -149,9 +149,10 @@ | ||
| 149 | } | 149 | } |
| 150 | } | 150 | } |
| 151 | const beforeUploadIconPic = (file: FileItem) => { | 151 | const beforeUploadIconPic = (file: FileItem) => { |
| 152 | - const isJpgOrPng = file.type === 'image/x-icon'; | 152 | + console.log(file); |
| 153 | + const isJpgOrPng = file.type === 'image/vnd.microsoft.icon'; | ||
| 153 | if (!isJpgOrPng) { | 154 | if (!isJpgOrPng) { |
| 154 | - createMessage.error('只能上传.icon图片文件!'); | 155 | + createMessage.error('只能上传.ico图片文件!'); |
| 155 | } | 156 | } |
| 156 | const isLt2M = (file.size as number) / 1024 < 500; | 157 | const isLt2M = (file.size as number) / 1024 < 500; |
| 157 | if (!isLt2M) { | 158 | if (!isLt2M) { |
| 1 | import { getPlatForm } from '/@/api/oem'; | 1 | import { getPlatForm } from '/@/api/oem'; |
| 2 | -import { createLocalStorage } from '/@/utils/cache'; | 2 | +import lightThemeBgImage from '/@/assets/svg/login-bg.svg'; |
| 3 | +import darkThemeBgImage from '/@/assets/svg/login-bg-dark.svg'; | ||
| 4 | +import { createStorage } from '/@/utils/cache'; | ||
| 5 | +import { Platform } from '/@/api/oem/model'; | ||
| 6 | +import { PLATFORM_INFO_CACHE_KEY } from '/@/enums/cacheEnum'; | ||
| 3 | 7 | ||
| 4 | enum DefaultPlatform { | 8 | enum DefaultPlatform { |
| 5 | LOGO = '/resource/img/logo.png', | 9 | LOGO = '/resource/img/logo.png', |
| @@ -7,19 +11,15 @@ enum DefaultPlatform { | @@ -7,19 +11,15 @@ enum DefaultPlatform { | ||
| 7 | ICO = '/favicon.ico', | 11 | ICO = '/favicon.ico', |
| 8 | } | 12 | } |
| 9 | 13 | ||
| 14 | +const storage = createStorage(); | ||
| 15 | + | ||
| 16 | +export const getPlatFormInfo = () => storage.get(PLATFORM_INFO_CACHE_KEY) as Platform; | ||
| 17 | +export const setPlatFormInfo = (info: Recordable) => storage.set(PLATFORM_INFO_CACHE_KEY, info); | ||
| 18 | + | ||
| 10 | export const usePlatform = async () => { | 19 | export const usePlatform = async () => { |
| 11 | - const platformInfo = await getPlatForm(); | ||
| 12 | - const storage = createLocalStorage(); | ||
| 13 | - if ( | ||
| 14 | - platformInfo === '' || | ||
| 15 | - platformInfo === null || | ||
| 16 | - Object.getOwnPropertyNames(platformInfo).length === 0 | ||
| 17 | - ) { | ||
| 18 | - storage.set('platformInfo', 1234); | ||
| 19 | - } else { | ||
| 20 | - storage.set('platformInfo', platformInfo); | ||
| 21 | - } | 20 | + const platformInfo = (await getPlatForm()) || {}; |
| 22 | 21 | ||
| 22 | + setPlatFormInfo(platformInfo); | ||
| 23 | const createLoadingEffect = () => { | 23 | const createLoadingEffect = () => { |
| 24 | const wrap = document.createElement('div'); | 24 | const wrap = document.createElement('div'); |
| 25 | wrap.setAttribute('class', 'app-loading-wrap'); | 25 | wrap.setAttribute('class', 'app-loading-wrap'); |
| @@ -50,7 +50,7 @@ export const usePlatform = async () => { | @@ -50,7 +50,7 @@ export const usePlatform = async () => { | ||
| 50 | const replaceSiteIco = () => { | 50 | const replaceSiteIco = () => { |
| 51 | const linkEl = document.querySelectorAll('link[rel*="icon"]'); | 51 | const linkEl = document.querySelectorAll('link[rel*="icon"]'); |
| 52 | linkEl.forEach((item) => { | 52 | linkEl.forEach((item) => { |
| 53 | - item.setAttribute('href', platformInfo.logo || DefaultPlatform.ICO); | 53 | + item.setAttribute('href', platformInfo.icon || DefaultPlatform.ICO); |
| 54 | }); | 54 | }); |
| 55 | }; | 55 | }; |
| 56 | 56 | ||
| @@ -60,9 +60,31 @@ export const usePlatform = async () => { | @@ -60,9 +60,31 @@ export const usePlatform = async () => { | ||
| 60 | loadingWrapper?.appendChild(createLoadingEffect()); | 60 | loadingWrapper?.appendChild(createLoadingEffect()); |
| 61 | }; | 61 | }; |
| 62 | 62 | ||
| 63 | + const setBackgroundImage = () => { | ||
| 64 | + const { background } = platformInfo; | ||
| 65 | + const styleEl = document.createElement('style'); | ||
| 66 | + | ||
| 67 | + styleEl.innerHTML = ` | ||
| 68 | + .vben-login::before{ | ||
| 69 | + background-image:url("${background || lightThemeBgImage}"); | ||
| 70 | + position:absolute; | ||
| 71 | + margin-left: ${background ? 0 : '-48%'} !important; | ||
| 72 | + } | ||
| 73 | + html[data-theme='dark'] .vben-login::before{ | ||
| 74 | + background-image:url("${background || darkThemeBgImage}"); | ||
| 75 | + position:absolute; | ||
| 76 | + margin-left: ${background ? 0 : '-48%'} !important; | ||
| 77 | + } | ||
| 78 | + `; | ||
| 79 | + | ||
| 80 | + console.log(styleEl); | ||
| 81 | + document.head.appendChild(styleEl); | ||
| 82 | + }; | ||
| 83 | + | ||
| 63 | const bootstrap = () => { | 84 | const bootstrap = () => { |
| 64 | replaceSiteIco(); | 85 | replaceSiteIco(); |
| 65 | replaceLoadingEffect(); | 86 | replaceLoadingEffect(); |
| 87 | + setBackgroundImage(); | ||
| 66 | }; | 88 | }; |
| 67 | 89 | ||
| 68 | bootstrap(); | 90 | bootstrap(); |
| @@ -27,6 +27,8 @@ | @@ -27,6 +27,8 @@ | ||
| 27 | import { HistoryTrendModal } from './components/HistoryTrendModal'; | 27 | import { HistoryTrendModal } from './components/HistoryTrendModal'; |
| 28 | import { useSocket } from '../packages/hook/useSocket'; | 28 | import { useSocket } from '../packages/hook/useSocket'; |
| 29 | import { watch } from 'vue'; | 29 | import { watch } from 'vue'; |
| 30 | + import { useRootSetting } from '/@/hooks/setting/useRootSetting'; | ||
| 31 | + import { ThemeEnum } from '/@/enums/appEnum'; | ||
| 30 | 32 | ||
| 31 | const props = defineProps<{ | 33 | const props = defineProps<{ |
| 32 | value?: Recordable; | 34 | value?: Recordable; |
| @@ -72,12 +74,15 @@ | @@ -72,12 +74,15 @@ | ||
| 72 | 74 | ||
| 73 | useSocket(dataSource); | 75 | useSocket(dataSource); |
| 74 | 76 | ||
| 77 | + const { getDarkMode } = useRootSetting(); | ||
| 75 | watch( | 78 | watch( |
| 76 | getIsSharePage, | 79 | getIsSharePage, |
| 77 | (value) => { | 80 | (value) => { |
| 78 | if (value) { | 81 | if (value) { |
| 82 | + console.log(unref(getDarkMode)); | ||
| 79 | const root = document.querySelector('#app'); | 83 | const root = document.querySelector('#app'); |
| 80 | - (root as HTMLDivElement).style.backgroundColor = '#F5F5F5'; | 84 | + (root as HTMLDivElement).style.backgroundColor = |
| 85 | + unref(getDarkMode) === ThemeEnum.LIGHT ? '#F5F5F5' : '#1b1b1b'; | ||
| 81 | } | 86 | } |
| 82 | }, | 87 | }, |
| 83 | { immediate: true } | 88 | { immediate: true } |