Login.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <div
  3. :class="prefixCls"
  4. class="relative h-[100%] lt-md:px-10px lt-sm:px-10px lt-xl:px-10px lt-xl:px-10px"
  5. >
  6. <div class="relative mx-auto h-full flex">
  7. <div
  8. :class="`${prefixCls}__left flex-1 bg-gray-500 bg-opacity-20 relative p-30px lt-xl:hidden overflow-x-hidden overflow-y-auto`"
  9. >
  10. <!-- 左上角的 logo + 系统标题 -->
  11. <div class="relative flex items-center text-white">
  12. <img alt="" class="mr-10px h-48px w-48px" src="@/assets/imgs/logo.png" />
  13. <span class="text-20px font-bold">{{ underlineToHump(appStore.getTitle) }}</span>
  14. </div>
  15. <!-- 左边的背景图 + 欢迎语 -->
  16. <div class="h-[calc(100%-60px)] flex items-center justify-center">
  17. <TransitionGroup
  18. appear
  19. enter-active-class="animate__animated animate__bounceInLeft"
  20. tag="div"
  21. >
  22. <!-- <img key="1" alt="" class="w-350px" src="@/assets/svgs/login-box-bg.svg" />-->
  23. <!-- <img key="1" alt="" class="w-350px" src="@/assets/imgs/yf.jpg" />-->
  24. <!-- <div key="2" class="text-3xl text-white">{{ t('login.welcome') }}</div>-->
  25. <div key="3" class="mt-5 text-14px font-normal text-white">
  26. {{ t('login.message') }}
  27. </div>
  28. </TransitionGroup>
  29. </div>
  30. </div>
  31. <div
  32. class="relative flex-1 p-30px dark:bg-[var(--login-bg-color)] lt-sm:p-10px overflow-x-hidden overflow-y-auto"
  33. >
  34. <!-- 右上角的主题、语言选择 -->
  35. <div
  36. class="flex items-center justify-between at-2xl:justify-end at-xl:justify-end"
  37. style="color: var(--el-text-color-primary)"
  38. >
  39. <div class="flex items-center at-2xl:hidden at-xl:hidden">
  40. <img alt="" class="mr-10px h-48px w-48px" src="@/assets/imgs/logo.png" />
  41. <span class="text-20px font-bold">{{ underlineToHump(appStore.getTitle) }}</span>
  42. </div>
  43. <div class="flex items-center justify-end space-x-10px h-48px">
  44. <ThemeSwitch />
  45. <LocaleDropdown />
  46. </div>
  47. </div>
  48. <!-- 右边的登录界面 -->
  49. <Transition appear enter-active-class="animate__animated animate__bounceInRight">
  50. <div
  51. class="m-auto h-[calc(100%-60px)] w-[100%] flex items-center at-2xl:max-w-500px at-lg:max-w-500px at-md:max-w-500px at-xl:max-w-500px"
  52. >
  53. <!-- 账号登录 -->
  54. <LoginForm class="m-auto h-auto p-20px lt-xl:(rounded-3xl light:bg-white)" />
  55. <!-- 手机登录 -->
  56. <!-- <MobileForm class="m-auto h-auto p-20px lt-xl:(rounded-3xl light:bg-white)" />-->
  57. <!-- 二维码登录 -->
  58. <QrCodeForm class="m-auto h-auto p-20px lt-xl:(rounded-3xl light:bg-white)" />
  59. <!-- 注册 -->
  60. <RegisterForm class="m-auto h-auto p-20px lt-xl:(rounded-3xl light:bg-white)" />
  61. <!-- 三方登录 -->
  62. <!-- <SSOLoginVue class="m-auto h-auto p-20px lt-xl:(rounded-3xl light:bg-white)" />-->
  63. <!-- 忘记密码 -->
  64. <ForgetPasswordForm class="m-auto h-auto p-20px lt-xl:(rounded-3xl light:bg-white)" />
  65. </div>
  66. </Transition>
  67. </div>
  68. </div>
  69. </div>
  70. </template>
  71. <script lang="ts" setup>
  72. import { underlineToHump } from '@/utils'
  73. import { useDesign } from '@/hooks/web/useDesign'
  74. import { useAppStore } from '@/store/modules/app'
  75. import { ThemeSwitch } from '@/layout/components/ThemeSwitch'
  76. import { LocaleDropdown } from '@/layout/components/LocaleDropdown'
  77. import * as dd from 'dingtalk-jsapi'
  78. import { LoginForm, QrCodeForm, RegisterForm, ForgetPasswordForm } from './components'
  79. import { dingTalkLogin } from '../../api/login'
  80. defineOptions({ name: 'Login' })
  81. const { t } = useI18n()
  82. const appStore = useAppStore()
  83. const { getPrefixCls } = useDesign()
  84. const prefixCls = getPrefixCls('login')
  85. function loginWithDingTalk() {
  86. const ddCorpId = import.meta.env.VITE_DD_CORPID
  87. const ddClientId = import.meta.env.VITE_DD_CLIENTID
  88. if (!ddCorpId || !ddClientId) return
  89. dd.requestAuthCode({
  90. corpId: ddCorpId,
  91. clientId: ddClientId,
  92. success: (res: any) => {
  93. const { code } = res
  94. dingTalkLogin({ code, type: 10, state: new Date().getTime() }).then((res) => {
  95. console.log('res :>> ', res)
  96. })
  97. },
  98. fail: (err: any) => {
  99. console.log('err :>> ', err)
  100. }
  101. })
  102. }
  103. function dingTalkAutoLogin() {
  104. const url = window.location.href
  105. console.log('url :>> ', url)
  106. if (!url.includes('/deepoli')) return
  107. const ua = window.navigator.userAgent.toLowerCase()
  108. console.log('ua :>> ', ua)
  109. if (!ua.includes('dingtalk') && !ua.includes('dingtalkwork')) return
  110. loginWithDingTalk()
  111. }
  112. onMounted(() => {
  113. dingTalkAutoLogin()
  114. })
  115. </script>
  116. <style lang="scss" scoped>
  117. $prefix-cls: #{$namespace}-login;
  118. .#{$prefix-cls} {
  119. overflow: auto;
  120. &__left {
  121. &::before {
  122. position: absolute;
  123. top: 0;
  124. left: 0;
  125. z-index: -1;
  126. width: 100%;
  127. height: 100%;
  128. background-image: url('@/assets/imgs/yf.png');
  129. background-position: center;
  130. background-repeat: no-repeat;
  131. background-size: cover; /* 关键:图片覆盖整个容器 */
  132. content: '';
  133. }
  134. }
  135. }
  136. </style>
  137. <style lang="scss">
  138. .dark .login-form {
  139. .el-divider__text {
  140. background-color: var(--login-bg-color);
  141. }
  142. .el-card {
  143. background-color: var(--login-bg-color);
  144. }
  145. }
  146. </style>
  147. <!--<template>-->
  148. <!-- <div-->
  149. <!-- :class="prefixCls"-->
  150. <!-- class="relative h-[100%] lt-md:px-10px lt-sm:px-10px lt-xl:px-10px lt-xl:px-10px"-->
  151. <!-- >-->
  152. <!-- <div class="relative mx-auto h-full flex">-->
  153. <!-- <div-->
  154. <!-- :class="`${prefixCls}__left flex-1 bg-gray-500 bg-opacity-20 relative p-30px lt-xl:hidden overflow-x-hidden overflow-y-auto`"-->
  155. <!-- >-->
  156. <!-- &lt;!&ndash; 左上角的 logo + 系统标题 &ndash;&gt;-->
  157. <!-- <div class="relative flex items-center text-white">-->
  158. <!-- <img alt="" class="mr-10px h-48px w-48px" src="@/assets/imgs/logo.png" />-->
  159. <!-- <span class="text-20px font-bold">{{ underlineToHump(appStore.getTitle) }}</span>-->
  160. <!-- </div>-->
  161. <!-- &lt;!&ndash; 左边的背景图 + 欢迎语 &ndash;&gt;-->
  162. <!-- <div class="h-[calc(100%-60px)] flex items-center justify-center">-->
  163. <!-- <TransitionGroup-->
  164. <!-- appear-->
  165. <!-- enter-active-class="animate__animated animate__bounceInLeft"-->
  166. <!-- tag="div"-->
  167. <!-- >-->
  168. <!-- <img key="1" alt="" class="w-350px" src="@/assets/svgs/login-box-bg.svg" />-->
  169. <!-- <div key="2" class="text-3xl text-white">{{ t('login.welcome') }}</div>-->
  170. <!-- <div key="3" class="mt-5 text-14px font-normal text-white">-->
  171. <!-- {{ t('login.message') }}-->
  172. <!-- </div>-->
  173. <!-- </TransitionGroup>-->
  174. <!-- </div>-->
  175. <!-- </div>-->
  176. <!-- <div-->
  177. <!-- class="relative flex-1 p-30px dark:bg-[var(&#45;&#45;login-bg-color)] lt-sm:p-10px overflow-x-hidden overflow-y-auto"-->
  178. <!-- >-->
  179. <!-- &lt;!&ndash; 右上角的主题、语言选择 &ndash;&gt;-->
  180. <!-- <div-->
  181. <!-- class="flex items-center justify-between at-2xl:justify-end at-xl:justify-end"-->
  182. <!-- style="color: var(&#45;&#45;el-text-color-primary);"-->
  183. <!-- >-->
  184. <!-- <div class="flex items-center at-2xl:hidden at-xl:hidden">-->
  185. <!-- <img alt="" class="mr-10px h-48px w-48px" src="@/assets/imgs/logo.png" />-->
  186. <!-- <span class="text-20px font-bold" >{{ underlineToHump(appStore.getTitle) }}</span>-->
  187. <!-- </div>-->
  188. <!-- <div class="flex items-center justify-end space-x-10px h-48px">-->
  189. <!-- <ThemeSwitch />-->
  190. <!-- <LocaleDropdown />-->
  191. <!-- </div>-->
  192. <!-- </div>-->
  193. <!-- &lt;!&ndash; 右边的登录界面 &ndash;&gt;-->
  194. <!-- <Transition appear enter-active-class="animate__animated animate__bounceInRight">-->
  195. <!-- <div-->
  196. <!-- class="m-auto h-[calc(100%-60px)] w-[100%] flex items-center at-2xl:max-w-500px at-lg:max-w-500px at-md:max-w-500px at-xl:max-w-500px"-->
  197. <!-- >-->
  198. <!-- &lt;!&ndash; 账号登录 &ndash;&gt;-->
  199. <!-- <LoginForm class="m-auto h-auto p-20px lt-xl:(rounded-3xl light:bg-white)" />-->
  200. <!-- &lt;!&ndash; 手机登录 &ndash;&gt;-->
  201. <!-- <MobileForm class="m-auto h-auto p-20px lt-xl:(rounded-3xl light:bg-white)" />-->
  202. <!-- &lt;!&ndash; 二维码登录 &ndash;&gt;-->
  203. <!-- <QrCodeForm class="m-auto h-auto p-20px lt-xl:(rounded-3xl light:bg-white)" />-->
  204. <!-- &lt;!&ndash; 注册 &ndash;&gt;-->
  205. <!-- <RegisterForm class="m-auto h-auto p-20px lt-xl:(rounded-3xl light:bg-white)" />-->
  206. <!-- &lt;!&ndash; 三方登录 &ndash;&gt;-->
  207. <!-- <SSOLoginVue class="m-auto h-auto p-20px lt-xl:(rounded-3xl light:bg-white)" />-->
  208. <!-- &lt;!&ndash; 忘记密码 &ndash;&gt;-->
  209. <!-- <ForgetPasswordForm class="m-auto h-auto p-20px lt-xl:(rounded-3xl light:bg-white)" />-->
  210. <!-- </div>-->
  211. <!-- </Transition>-->
  212. <!-- </div>-->
  213. <!-- </div>-->
  214. <!-- </div>-->
  215. <!--</template>-->
  216. <!--<script lang="ts" setup>-->
  217. <!--import { underlineToHump } from '@/utils'-->
  218. <!--import { useDesign } from '@/hooks/web/useDesign'-->
  219. <!--import { useAppStore } from '@/store/modules/app'-->
  220. <!--import { ThemeSwitch } from '@/layout/components/ThemeSwitch'-->
  221. <!--import { LocaleDropdown } from '@/layout/components/LocaleDropdown'-->
  222. <!--import { LoginForm, MobileForm, QrCodeForm, RegisterForm, SSOLoginVue, ForgetPasswordForm } from './components'-->
  223. <!--defineOptions({ name: 'Login' })-->
  224. <!--const { t } = useI18n()-->
  225. <!--const appStore = useAppStore()-->
  226. <!--const { getPrefixCls } = useDesign()-->
  227. <!--const prefixCls = getPrefixCls('login')-->
  228. <!--</script>-->
  229. <!--<style lang="scss" scoped>-->
  230. <!--$prefix-cls: #{$namespace}-login;-->
  231. <!--.#{$prefix-cls} {-->
  232. <!-- overflow: auto;-->
  233. <!-- &__left {-->
  234. <!-- &::before {-->
  235. <!-- position: absolute;-->
  236. <!-- top: 0;-->
  237. <!-- left: 0;-->
  238. <!-- z-index: -1;-->
  239. <!-- width: 100%;-->
  240. <!-- height: 100%;-->
  241. <!-- background-image: url('@/assets/svgs/login-bg.svg');-->
  242. <!-- background-position: center;-->
  243. <!-- background-repeat: no-repeat;-->
  244. <!-- content: '';-->
  245. <!-- }-->
  246. <!-- }-->
  247. <!--}-->
  248. <!--</style>-->
  249. <!--<style lang="scss">-->
  250. <!--.dark .login-form {-->
  251. <!-- .el-divider__text {-->
  252. <!-- background-color: var(&#45;&#45;login-bg-color);-->
  253. <!-- }-->
  254. <!-- .el-card {-->
  255. <!-- background-color: var(&#45;&#45;login-bg-color);-->
  256. <!-- }-->
  257. <!--}-->
  258. <!--</style>-->