LoginView.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. <div class="flex items-center justify-center min-h-screen bg-gray-200">
  3. <div class="bg-gray-100 p-8 rounded-lg shadow-md w-96">
  4. <h2 class="text-2xl font-bold text-gray-700 mb-6 text-center">User Stories Generator</h2>
  5. <form @submit.prevent="login">
  6. <div class="mb-4">
  7. <label for="username" class="block text-gray-700 text-sm font-bold mb-2">用户名</label>
  8. <input
  9. v-model="username"
  10. type="text"
  11. id="username"
  12. placeholder="请输入用户名"
  13. class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
  14. />
  15. </div>
  16. <div class="mb-4">
  17. <label for="password" class="block text-gray-700 text-sm font-bold mb-2">密码</label>
  18. <input
  19. v-model="password"
  20. type="password"
  21. id="password"
  22. placeholder="请输入密码"
  23. class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
  24. />
  25. </div>
  26. <div class="mb-4">
  27. <label class="inline-flex items-center">
  28. <input
  29. v-model="rememberMe"
  30. type="checkbox"
  31. class="form-checkbox h-4 w-4 text-indigo-600 transition duration-150 ease-in-out"
  32. />
  33. <span class="ml-2 text-gray-700 text-sm">忘记我</span>
  34. </label>
  35. </div>
  36. <div class="flex items-center justify-between">
  37. <button
  38. type="submit"
  39. class="bg-indigo-500 hover:bg-indigo-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline"
  40. >
  41. 登录
  42. </button>
  43. </div>
  44. </form>
  45. </div>
  46. </div>
  47. </template>
  48. <script setup>
  49. import { ref } from 'vue'
  50. import { useRouter } from 'vue-router'
  51. const router = useRouter()
  52. const username = ref('')
  53. const password = ref('')
  54. const rememberMe = ref(false)
  55. const login = () => {
  56. // Simple validation for demonstration purposes
  57. if (username.value && password.value) {
  58. // Redirect to home page on successful login
  59. router.push({ name: 'home' })
  60. } else {
  61. alert('请输入用户名和密码')
  62. }
  63. }
  64. </script>
  65. <style scoped>
  66. /* Additional styles can be added here if needed */
  67. </style>