Install.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <div class="login-form">
  3. <div class="project-title">
  4. <h1>Nginx UI</h1>
  5. </div>
  6. <a-form
  7. id="components-form-install"
  8. :form="form"
  9. class="login-form"
  10. @submit="handleSubmit"
  11. >
  12. <a-form-item>
  13. <a-input
  14. v-decorator="[
  15. 'email',
  16. { rules: [{
  17. type: 'email',
  18. message: $gettext('Invalid E-mail!'),
  19. },
  20. {
  21. required: true,
  22. message: $gettext('Please input your E-mail!'),
  23. },] },
  24. ]"
  25. :placeholder="$gettext('Email (*)')"
  26. >
  27. <a-icon slot="prefix" type="mail" style="color: rgba(0,0,0,.25)"/>
  28. </a-input>
  29. </a-form-item>
  30. <a-form-item>
  31. <a-input
  32. v-decorator="[
  33. 'username',
  34. { rules: [{ required: true, message: $gettext('Please input your username!') }] },
  35. ]"
  36. :placeholder="$gettext('Username (*)')"
  37. >
  38. <a-icon slot="prefix" type="user" style="color: rgba(0,0,0,.25)"/>
  39. </a-input>
  40. </a-form-item>
  41. <a-form-item>
  42. <a-input
  43. v-decorator="[
  44. 'password',
  45. { rules: [{ required: true, message: $gettext('Please input your password!') }] },
  46. ]"
  47. type="password"
  48. :placeholder="$gettext('Password (*)')"
  49. >
  50. <a-icon slot="prefix" type="lock" style="color: rgba(0,0,0,.25)"/>
  51. </a-input>
  52. </a-form-item>
  53. <a-form-item>
  54. <a-input
  55. v-decorator="[
  56. 'database',
  57. { rules: [{ pattern: /^[^\\/:*?\x22<>|]{1,120}$/,
  58. message: $gettextInterpolate(
  59. $gettext('The filename cannot contain the following characters: %{c}'),
  60. {c: '& &quot; ? < > # {} % ~ / \\'}
  61. )}] },
  62. ]"
  63. :placeholder="$gettext('Database (Optional, default: database)')"
  64. >
  65. <a-icon slot="prefix" type="database" style="color: rgba(0,0,0,.25)"/>
  66. </a-input>
  67. </a-form-item>
  68. <a-form-item>
  69. <a-button type="primary" :block="true" html-type="submit" :loading="loading">
  70. <translate>Install</translate>
  71. </a-button>
  72. </a-form-item>
  73. </a-form>
  74. <footer>
  75. Copyright © 2020 - {{ thisYear }} Nginx UI | Language <set-language class="set_lang" style="display: inline"/>
  76. </footer>
  77. </div>
  78. </template>
  79. <script>
  80. import SetLanguage from "@/components/SetLanguage/SetLanguage";
  81. export default {
  82. name: 'Login',
  83. components: {SetLanguage},
  84. data() {
  85. return {
  86. form: {},
  87. lock: true,
  88. thisYear: new Date().getFullYear(),
  89. loading: false
  90. }
  91. },
  92. created() {
  93. this.form = this.$form.createForm(this)
  94. },
  95. mounted() {
  96. this.$api.install.get_lock().then(r => {
  97. if (r.lock) {
  98. this.$router.push('/login')
  99. }
  100. })
  101. },
  102. methods: {
  103. handleSubmit: async function (e) {
  104. e.preventDefault()
  105. this.loading = true
  106. await this.form.validateFields(async (err, values) => {
  107. if (!err) {
  108. this.$api.install.install_nginx_ui(values).then(() => {
  109. this.$router.push('/login')
  110. })
  111. }
  112. this.loading = false
  113. })
  114. },
  115. },
  116. }
  117. </script>
  118. <style lang="less">
  119. .project-title {
  120. margin: 50px;
  121. h1 {
  122. font-size: 50px;
  123. font-weight: 100;
  124. text-align: center;
  125. }
  126. }
  127. .login-form {
  128. max-width: 500px;
  129. margin: 0 auto;
  130. }
  131. .login-form-button {
  132. }
  133. footer {
  134. padding: 30px;
  135. text-align: center;
  136. }
  137. </style>