index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <div class="go-login-box">
  3. <div class="go-login-box-bg"></div>
  4. <n-divider class="go-login-box-header" />
  5. <div class="go-login">
  6. <div class="go-login-carousel">
  7. <n-carousel autoplay>
  8. <img
  9. v-for="(e, i) in imgList"
  10. :key="i"
  11. class="go-login-carousel-img"
  12. :src="e"
  13. alt="展示图片"
  14. />
  15. </n-carousel>
  16. </div>
  17. <div class="login-account">
  18. <div class="login-account-container">
  19. <n-collapse-transition :appear="true" :show="show">
  20. <n-card class="login-account-card" title="登录 GoView">
  21. <div class="login-account-top">
  22. <img
  23. class="login-account-top-logo"
  24. src="~@/assets/images/logo.png"
  25. alt="logo"
  26. />
  27. </div>
  28. <n-form
  29. ref="formRef"
  30. label-placement="left"
  31. size="large"
  32. :model="formInline"
  33. :rules="rules"
  34. >
  35. <n-form-item path="username">
  36. <n-input
  37. v-model:value="formInline.username"
  38. placeholder="请输入用户名"
  39. >
  40. <template #prefix>
  41. <n-icon size="18">
  42. <PersonOutline />
  43. </n-icon>
  44. </template>
  45. </n-input>
  46. </n-form-item>
  47. <n-form-item path="password">
  48. <n-input
  49. v-model:value="formInline.password"
  50. type="password"
  51. show-password-toggle
  52. placeholder="请输入密码"
  53. >
  54. <template #prefix>
  55. <n-icon size="18">
  56. <LockClosedOutline />
  57. </n-icon>
  58. </template>
  59. </n-input>
  60. </n-form-item>
  61. <n-form-item>
  62. <div class="flex justify-between">
  63. <div class="flex-initial">
  64. <n-checkbox v-model:checked="autoLogin">
  65. 自动登录
  66. </n-checkbox>
  67. </div>
  68. </div>
  69. </n-form-item>
  70. <n-form-item>
  71. <n-button
  72. type="primary"
  73. @click="handleSubmit"
  74. size="large"
  75. :loading="loading"
  76. block
  77. >
  78. 登录
  79. </n-button>
  80. </n-form-item>
  81. </n-form>
  82. </n-card>
  83. </n-collapse-transition>
  84. </div>
  85. </div>
  86. </div>
  87. <div class="go-login-box-footer">
  88. 文档地址: http://www.mtruning.club/
  89. </div>
  90. </div>
  91. </template>
  92. <script lang="ts" setup>
  93. import { reactive, ref, onMounted } from 'vue'
  94. import { useRoute, useRouter } from 'vue-router'
  95. import { useMessage } from 'naive-ui'
  96. import { PersonOutline, LockClosedOutline } from '@vicons/ionicons5'
  97. import imgOne from '@/assets/images/login/one.png'
  98. import imgTwo from '@/assets/images/login/two.png'
  99. import imgThree from '@/assets/images/login/three.png'
  100. interface FormState {
  101. username: string
  102. password: string
  103. }
  104. const formRef = ref()
  105. const message = useMessage()
  106. const loading = ref(false)
  107. const autoLogin = ref(true)
  108. const show = ref(false)
  109. onMounted(() => {
  110. setTimeout(() => {
  111. show.value = true
  112. }, 100)
  113. })
  114. const formInline = reactive({
  115. username: 'admin',
  116. password: '123456'
  117. })
  118. const rules = {
  119. username: { required: true, message: '请输入用户名', trigger: 'blur' },
  120. password: { required: true, message: '请输入密码', trigger: 'blur' }
  121. }
  122. const imgList = [imgOne, imgTwo, imgThree]
  123. const router = useRouter()
  124. const route = useRoute()
  125. const handleSubmit = (e: Event) => {
  126. e.preventDefault()
  127. formRef.value.validate(async (errors: any) => {
  128. if (!errors) {
  129. const { username, password } = formInline
  130. loading.value = true
  131. message.success('登录成功!')
  132. router.replace('/')
  133. } else {
  134. message.error('请填写完整信息,并且进行验证码校验')
  135. }
  136. })
  137. }
  138. </script>
  139. <style lang="scss" scoped>
  140. $width: 450px;
  141. $account-img-height: 270px;
  142. $footer-height: 50px;
  143. $account-height: calc(100vh - $footer-height);
  144. $--filter-color-base-login: rgba(51, 55, 61, 0.3);
  145. * {
  146. box-sizing: border-box;
  147. }
  148. @include go(login-box) {
  149. height: 100vh;
  150. overflow: hidden;
  151. background-image: linear-gradient(120deg, $--color-bg-1 0%, $--color-bg-2 100%);
  152. &-header {
  153. margin: 0px;
  154. padding-top: $--header-height;
  155. }
  156. @include go(login) {
  157. display: flex;
  158. justify-content: space-evenly;
  159. align-items: center;
  160. margin-top: -$--header-height;
  161. padding-top: $--header-height;
  162. &-carousel {
  163. width: 50%;
  164. &-img {
  165. height: 70vh;
  166. }
  167. }
  168. .login-account {
  169. z-index: 1;
  170. display: flex;
  171. flex-direction: column;
  172. height: $account-height;
  173. &-container {
  174. flex: 1;
  175. padding: 32px 0;
  176. width: $width;
  177. margin: 0 auto;
  178. margin-top: 100px;
  179. }
  180. &-card {
  181. @extend .go-background-filter;
  182. background-color: $--filter-color-base-login;
  183. }
  184. &-top {
  185. padding-top: 10px;
  186. text-align: center;
  187. height: $account-img-height;
  188. margin-bottom: 20px;
  189. }
  190. }
  191. }
  192. &-footer {
  193. height: $footer-height;
  194. margin-top: -$--header-height;
  195. text-align: center;
  196. line-height: $footer-height;
  197. color: $--color-text-2;
  198. }
  199. &-bg {
  200. z-index: 0;
  201. position: fixed;
  202. width: 100vw;
  203. height: 100vh;
  204. background: url('@/assets/images/login/login-bg.png') no-repeat 750px -120px;
  205. }
  206. @media (min-width: 768px) {
  207. .login-account {
  208. background-repeat: no-repeat;
  209. background-position: 50%;
  210. background-size: 100%;
  211. }
  212. .page-account-container {
  213. padding: 32px 0 24px 0;
  214. }
  215. }
  216. }
  217. </style>