|
1 | 1 | <template> |
2 | 2 | <div class="console" id="particles"> |
3 | | - <div class="card"> |
4 | | - <v-stepper v-model="step"> |
5 | | - <v-stepper-content step="1" class="fn__clear"> |
6 | | - <h1>Pipe {{ $t(account === 'pipe' ? 'init' : 'guide', $store.state.locale) }}</h1> |
7 | | - <div class="ft__center login__content" v-if="account===''"> |
8 | | - <div class="fn__pointer" @click="loginGitHub"> |
9 | | - {{ $t('useGitHub', $store.state.locale) }}{{ $t('login', $store.state.locale) }} |
10 | | - <div class="login__github"></div> |
11 | | - <img class="fn__none" src="~assets/images/github.gif"/> |
12 | | - </div> |
13 | | - </div> |
14 | | - <div v-if="account==='pipe'"> |
15 | | - <br> |
16 | | - <v-form ref="accountForm" @submit.prevent="init"> |
17 | | - <v-text-field |
18 | | - :label="$t('userName', $store.state.locale)" |
19 | | - v-model="userName" |
20 | | - :counter="16" |
21 | | - :rules="requiredRules" |
22 | | - required |
23 | | - ></v-text-field> |
24 | | - <v-text-field |
25 | | - :label="$t('password', $store.state.locale)" |
26 | | - v-model="userPassword" |
27 | | - :counter="16" |
28 | | - :rules="requiredRules" |
29 | | - required |
30 | | - type="password" |
31 | | - @keyup.13="localInit" |
32 | | - ></v-text-field> |
33 | | - </v-form> |
34 | | - <div class="alert alert--danger" v-show="registerError"> |
35 | | - <v-icon>danger</v-icon> |
36 | | - <span>{{ registerErrorMsg }}</span> |
37 | | - </div> |
38 | | - </div> |
39 | | - <div class="fn__right"> |
40 | | - <v-btn v-if="account === 'pipe'" |
41 | | - class="btn--info" @click="account = ''">{{ $t('preStep', $store.state.locale) }}</v-btn> |
42 | | - <v-btn |
43 | | - v-if="account === 'pipe'" |
44 | | - class="btn--success btn--space" |
45 | | - @click="localInit">{{ $t('init', $store.state.locale) }} |
46 | | - </v-btn> |
47 | | - </div> |
48 | | - </v-stepper-content> |
49 | | - |
50 | | - <v-stepper-content step="2" class="fn__clear"> |
51 | | - <h1> |
52 | | - {{ $t('useHacpaiInit', $store.state.locale) }} |
53 | | - {{ $store.state.name }} |
54 | | - {{ $t('init', $store.state.locale) }} |
55 | | - </h1> |
56 | | - <div class="ft__center login__content fn__clear"> |
57 | | - <img class="avatar login__image card init__image--step2" |
58 | | - :src="`${$store.state.avatarURL}?imageView2/1/w/128/h/128/interlace/1/q/100`"/> |
59 | | - <v-form ref="form" class="fn__flex" @submit.prevent="init"> |
60 | | - <v-text-field |
61 | | - class="fn__flex-1" |
62 | | - label="B3log Key" |
63 | | - v-model="b3key" |
64 | | - :counter="20" |
65 | | - :rules="b3keyRules" |
66 | | - required |
67 | | - @keyup.13="init" |
68 | | - ></v-text-field> |
69 | | - <a |
70 | | - class="init__help" |
71 | | - href="https://hacpai.com/settings/b3" |
72 | | - target="_blank">{{ $t('check', $store.state.locale) }}/{{ $t('setting', $store.state.locale) }} B3log Key</a> |
73 | | - </v-form> |
74 | | - <div class="alert alert--danger" v-show="postInitError"> |
75 | | - <v-icon>danger</v-icon> |
76 | | - <span>{{ postInitErrorMsg }}</span> |
77 | | - </div> |
78 | | - </div> |
79 | | - <div class="fn__right"> |
80 | | - <v-btn class="btn--info" @click="step = 1">{{ $t('preStep', $store.state.locale) }}</v-btn> |
81 | | - <v-btn class="btn--success btn--space" @click="init">{{ $t('init', $store.state.locale) }}</v-btn> |
82 | | - </div> |
83 | | - </v-stepper-content> |
84 | | - |
85 | | - <v-stepper-content step="3" class="fn__clear"> |
86 | | - <h1>{{ $t('welcome', $store.state.locale) }} Pipe</h1> |
87 | | - <div class="ft__center login__content fn__clear"> |
88 | | - <a href="https://github.com/b3log/pipe" |
89 | | - target="_blank" |
90 | | - :aria-label="$t('openPipeTravel', $store.state.locale)" |
91 | | - class="card login__image init__image--step3 pipe-tooltipped pipe-tooltipped--n"> |
92 | | - <img src="~assets/images/logo.png"/> |
93 | | - </a> |
94 | | - <div class="init__text">{{$t('starIsMotivation', $store.state.locale)}}</div> |
95 | | - <iframe src="https://ghbtns.com/github-btn.html?user=b3log&repo=pipe&type=star&count=true&size=large" |
96 | | - frameborder="0" scrolling="0" width="160px" height="30px"></iframe> |
97 | | - </div> |
98 | | - </v-stepper-content> |
99 | | - </v-stepper> |
| 3 | + <div class="card" ref="content"> |
| 4 | + <div class="login__content"> |
| 5 | + <div class="fn__pointer" @click="loginGitHub"> |
| 6 | + {{ $t('useGitHub', $store.state.locale) }}{{ $t('startToUse', $store.state.locale) }} |
| 7 | + <div class="login__github"></div> |
| 8 | + <img class="fn__none" src="~assets/images/github.gif"/> |
| 9 | + </div> |
| 10 | + </div> |
100 | 11 | </div> |
101 | 12 | </div> |
102 | 13 | </template> |
103 | 14 |
|
104 | 15 | <script> |
105 | | - import Vue from 'vue' |
106 | 16 | import 'particles.js' |
107 | | - import sha512crypt from 'sha512crypt-node' |
108 | | - import {initParticlesJS} from '~/plugins/utils' |
109 | | - import { required, maxSize } from '~/plugins/validate' |
| 17 | + import { initParticlesJS } from '~/plugins/utils' |
110 | 18 |
|
111 | 19 | export default { |
112 | 20 | data () { |
113 | 21 | return { |
114 | 22 | clickedGitHub: false, |
115 | | - userName: '', |
116 | | - userPassword: '', |
117 | | - account: '', |
118 | | - step: 4, |
119 | | - postInitError: false, |
120 | | - postInitErrorMsg: '', |
121 | | - registerError: false, |
122 | | - registerErrorMsg: '', |
123 | | - b3key: '', |
124 | | - b3keyRules: [ |
125 | | - (v) => required.call(this, v), |
126 | | - (v) => maxSize.call(this, v, 20) |
127 | | - ], |
128 | | - requiredRules: [ |
129 | | - (v) => required.call(this, v), |
130 | | - (v) => maxSize.call(this, v, 16) |
131 | | - ] |
132 | 23 | } |
133 | 24 | }, |
134 | 25 | head () { |
135 | 26 | return { |
136 | | - title: this.$t('welcome', this.$store.state.locale) + ' - Pipe' |
| 27 | + title: this.$t('welcome', this.$store.state.locale) + ' - Pipe', |
137 | 28 | } |
138 | 29 | }, |
139 | 30 | methods: { |
140 | 31 | loginGitHub () { |
141 | 32 | this.$store.commit('setSnackBar', { |
142 | 33 | snackBar: true, |
143 | 34 | snackMsg: 'Loading...', |
144 | | - snackModify: 'success' |
| 35 | + snackModify: 'success', |
145 | 36 | }) |
146 | 37 | if (!this.clickedGitHub) { |
147 | 38 | window.location.href = `${process.env.AxiosBaseURL}/oauth/github/redirect` |
148 | 39 | this.$set(this, 'clickedGitHub', true) |
149 | 40 | } |
150 | 41 | }, |
151 | | - hacpaiInit () { |
152 | | - if (this.$store.state.name !== '') { |
153 | | - this.$set(this, 'step', 2) |
154 | | - } else { |
155 | | - window.open('https://hacpai.com/login') |
156 | | - } |
157 | | - }, |
158 | | - async localInit () { |
159 | | - if (!this.$refs.accountForm.validate()) { |
160 | | - return |
161 | | - } |
162 | | - const responseData = await this.axios.post('/init/local', { |
163 | | - name: this.userName, |
164 | | - password: sha512crypt.sha512crypt(this.userPassword, `$6$5000$${Math.random().toString(36)}`) |
165 | | - }) |
166 | | - if (responseData.code === 0) { |
167 | | - this.$set(this, 'step', 3) |
168 | | - this.$set(this, 'registerError', false) |
169 | | - this.$set(this, 'registerErrorMsg', '') |
170 | | - this.$store.commit('setIsInit', true) |
171 | | - const stateResponseData = await this.axios.get('/status') |
172 | | - if (stateResponseData) { |
173 | | - this.$store.commit('setStatus', stateResponseData) |
174 | | - } |
175 | | - } else { |
176 | | - this.$set(this, 'registerError', true) |
177 | | - this.$set(this, 'registerErrorMsg', responseData.msg) |
178 | | - } |
179 | | - }, |
180 | | - async init () { |
181 | | - if (!this.$refs.form.validate()) { |
182 | | - return |
183 | | - } |
184 | | -
|
185 | | - const responseData = await this.axios.post('/init', { |
186 | | - b3key: this.b3key |
187 | | - }) |
188 | | - if (responseData.code === 0) { |
189 | | - this.$set(this, 'step', 3) |
190 | | - this.$set(this, 'postInitError', false) |
191 | | - this.$set(this, 'postInitErrorMsg', '') |
192 | | - this.$store.commit('setIsInit', true) |
193 | | - } else { |
194 | | - this.$set(this, 'postInitError', true) |
195 | | - this.$set(this, 'postInitErrorMsg', responseData.msg) |
196 | | - } |
197 | | - } |
198 | 42 | }, |
199 | 43 | mounted () { |
200 | 44 | initParticlesJS('particles') |
201 | | - Vue.nextTick(() => { |
202 | | - this.$set(this, 'step', this.$store.state.name === '' ? 1 : 2) |
203 | | - }) |
204 | | - } |
| 45 | + }, |
205 | 46 | } |
206 | 47 | </script> |
207 | | - |
208 | | -<style lang="sass"> |
209 | | - @import '~assets/scss/_variables' |
210 | | - .init |
211 | | - &__help |
212 | | - padding: 34px 0 0 20px |
213 | | - &__image |
214 | | - &--step2.card |
215 | | - margin: 20px auto 0 |
216 | | - &--step3.card |
217 | | - margin: 30px auto 36px |
218 | | - &__text |
219 | | - margin-bottom: 30px |
220 | | -</style> |
0 commit comments