index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <div class="init_page">
  3. <div class="init_page_panle">
  4. <div v-if="hello < 2" id="hello" :class="[hello < 1 ? 'slide-in-fwd-top' : 'slide-out-right']" class="hello ">
  5. <div>
  6. <div class="hello_title">GIN-VUE-ADMIN</div>
  7. <p class="in-two a-fadeinT">初始化须知</p>
  8. <p class="init_p">1.您需有用一定的VUE和golang基础</p>
  9. <p class="init_p">2.请您确认是否已经阅读过官方文档</p>
  10. <p class="init_p">3.请您确认是否了解后续的配置流程</p>
  11. <p class="init_p">注:开发组不为文档中书写过的内容提供无偿服务</p>
  12. <p class="init_btn">
  13. <el-button type="primary" @click="goDoc">
  14. 阅读文档
  15. </el-button>
  16. <el-button type="primary" @click="showNext">
  17. 我已确认
  18. </el-button>
  19. </p>
  20. </div>
  21. </div>
  22. <div v-if="hello > 0 " :class="[(hello > 0 && !out)? 'slide-in-left' : '' , out ? 'slide-out-right' : '']" class=" form">
  23. <el-form ref="form" :model="form" label-width="100px">
  24. <el-form-item label="数据库类型">
  25. <el-select v-model="form.sqlType" disabled placeholder="请选择">
  26. <el-option key="mysql" label="mysql(目前只支持mysql)" value="mysql" />
  27. </el-select>
  28. </el-form-item>
  29. <el-form-item label="host">
  30. <el-input v-model="form.host" placeholder="请输入数据库链接" />
  31. </el-form-item>
  32. <el-form-item label="port">
  33. <el-input v-model="form.port" placeholder="请输入数据库端口" />
  34. </el-form-item>
  35. <el-form-item label="userName">
  36. <el-input v-model="form.userName" placeholder="请输入数据库用户名" />
  37. </el-form-item>
  38. <el-form-item label="password">
  39. <el-input
  40. v-model="form.password"
  41. placeholder="请输入数据库密码(没有则为空)"
  42. />
  43. </el-form-item>
  44. <el-form-item label="dbName">
  45. <el-input v-model="form.dbName" placeholder="请输入数据库名称" />
  46. </el-form-item>
  47. <el-form-item>
  48. <div style="text-align: right">
  49. <el-button type="primary" @click="onSubmit">立即初始化</el-button>
  50. </div>
  51. </el-form-item>
  52. </el-form>
  53. </div>
  54. </div>
  55. </div>
  56. </template>
  57. <script>
  58. import { initDB } from '@/api/initdb'
  59. export default {
  60. name: 'Init',
  61. data() {
  62. return {
  63. hello: 0,
  64. out: false,
  65. form: {
  66. sqlType: 'mysql',
  67. host: '127.0.0.1',
  68. port: '3306',
  69. userName: 'root',
  70. password: '',
  71. dbName: 'gva'
  72. }
  73. }
  74. },
  75. created() {
  76. // setInterval(() => {
  77. // if (this.hello < 3) {
  78. // this.hello = this.hello + 1
  79. // }
  80. // }, 2000)
  81. },
  82. methods: {
  83. showNext() {
  84. this.hello = this.hello + 1
  85. },
  86. goDoc() {
  87. window.open('https://www.gin-vue-admin.com/docs/first_master#3-init')
  88. },
  89. async onSubmit() {
  90. const loading = this.$loading({
  91. lock: true,
  92. text: '正在初始化数据库,请稍候',
  93. spinner: 'el-icon-loading',
  94. background: 'rgba(0, 0, 0, 0.7)'
  95. })
  96. try {
  97. const res = await initDB(this.form)
  98. if (res.code === 0) {
  99. this.out = true
  100. this.$message({
  101. type: 'success',
  102. message: res.msg
  103. })
  104. this.$router.push({ name: 'Login' })
  105. }
  106. loading.close()
  107. } catch (err) {
  108. loading.close()
  109. }
  110. }
  111. }
  112. }
  113. </script>
  114. <style lang="scss" scoped>
  115. .init_page{
  116. margin: 0;
  117. padding: 0;
  118. background-image: url("~@/assets/login_background.svg");
  119. background-size: cover;
  120. width: 100%;
  121. height: 100%;
  122. position: relative;
  123. .init_page_panle{
  124. position: absolute;
  125. top: 3vh;
  126. left: 2vw;
  127. width: 96vw;
  128. height: 94vh;
  129. background-color: rgba(255,255,255,.8);
  130. backdrop-filter: blur(5px);
  131. border-radius: 10px;
  132. display: flex;
  133. align-items: center;
  134. justify-content: space-evenly;
  135. .hello{
  136. position: absolute;
  137. z-index: 2;
  138. text-align: center;
  139. width: 100%;
  140. height: 100%;
  141. display: flex;
  142. align-items: center;
  143. justify-content: center;
  144. cursor: pointer;
  145. .hello_title{
  146. font-size: 32px;
  147. line-height: 98px;
  148. }
  149. .in-two{
  150. font-size: 22px;
  151. }
  152. .init_p{
  153. margin-top: 20px;
  154. color: #777777;
  155. }
  156. .init_btn{
  157. margin-top: 20px;
  158. }
  159. }
  160. .form{
  161. position: absolute;
  162. z-index: 3;
  163. margin-top: 60px;
  164. width: 600px;
  165. height: auto;
  166. padding: 20px;
  167. border-radius: 6px;
  168. }
  169. }
  170. }
  171. .slide-in-fwd-top {
  172. -webkit-animation: slide-in-fwd-top 0.4s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
  173. animation: slide-in-fwd-top 0.4s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
  174. }
  175. .slide-out-right {
  176. -webkit-animation: slide-out-right 0.5s cubic-bezier(0.550, 0.085, 0.680, 0.530) both;
  177. animation: slide-out-right 0.5s cubic-bezier(0.550, 0.085, 0.680, 0.530) both;
  178. }
  179. .slide-in-left {
  180. -webkit-animation: slide-in-left 0.5s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
  181. animation: slide-in-left 0.5s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
  182. }
  183. @-webkit-keyframes slide-in-fwd-top {
  184. 0% {
  185. -webkit-transform: translateZ(-1400px) translateY(-800px);
  186. transform: translateZ(-1400px) translateY(-800px);
  187. opacity: 0;
  188. }
  189. 100% {
  190. -webkit-transform: translateZ(0) translateY(0);
  191. transform: translateZ(0) translateY(0);
  192. opacity: 1;
  193. }
  194. }
  195. @keyframes slide-in-fwd-top {
  196. 0% {
  197. -webkit-transform: translateZ(-1400px) translateY(-800px);
  198. transform: translateZ(-1400px) translateY(-800px);
  199. opacity: 0;
  200. }
  201. 100% {
  202. -webkit-transform: translateZ(0) translateY(0);
  203. transform: translateZ(0) translateY(0);
  204. opacity: 1;
  205. }
  206. }
  207. @-webkit-keyframes slide-out-right {
  208. 0% {
  209. -webkit-transform: translateX(0);
  210. transform: translateX(0);
  211. opacity: 1;
  212. }
  213. 100% {
  214. -webkit-transform: translateX(1000px);
  215. transform: translateX(1000px);
  216. opacity: 0;
  217. }
  218. }
  219. @keyframes slide-out-right {
  220. 0% {
  221. -webkit-transform: translateX(0);
  222. transform: translateX(0);
  223. opacity: 1;
  224. }
  225. 100% {
  226. -webkit-transform: translateX(1000px);
  227. transform: translateX(1000px);
  228. opacity: 0;
  229. }
  230. }
  231. @-webkit-keyframes slide-in-left {
  232. 0% {
  233. -webkit-transform: translateX(-1000px);
  234. transform: translateX(-1000px);
  235. opacity: 0;
  236. }
  237. 100% {
  238. -webkit-transform: translateX(0);
  239. transform: translateX(0);
  240. opacity: 1;
  241. }
  242. }
  243. @keyframes slide-in-left {
  244. 0% {
  245. -webkit-transform: translateX(-1000px);
  246. transform: translateX(-1000px);
  247. opacity: 0;
  248. }
  249. 100% {
  250. -webkit-transform: translateX(0);
  251. transform: translateX(0);
  252. opacity: 1;
  253. }
  254. }
  255. @media (max-width: 750px) {
  256. .form{
  257. width: 94vw !important;
  258. padding: 0;
  259. }
  260. }
  261. </style>