Skip to content

Commit 80ead6a

Browse files
committed
🎨 b3log#191
1 parent 56f5eda commit 80ead6a

12 files changed

Lines changed: 32 additions & 459 deletions

File tree

‎console/assets/scss/console.scss‎

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,16 @@
2525

2626
// login
2727
.login {
28-
padding: 30px;
2928
&__content {
3029
height: 300px;
31-
}
32-
33-
&__link {
34-
margin: 0 25px;
35-
}
36-
37-
&__image {
38-
&.card {
39-
display: block;
40-
height: 120px;
41-
width: 120px;
42-
margin: 54px auto;
43-
svg {
44-
color: #fff;
45-
height: 100px;
46-
width: 100px;
47-
padding: 10px;
30+
display: flex;
31+
align-items: center;
32+
33+
& > .fn__pointer {
34+
margin: 0 auto;
35+
text-align: center;
36+
&:hover .login__github {
37+
background-image: url("~assets/images/github.gif");
4838
}
4939
}
5040
}
@@ -56,9 +46,6 @@
5646
background-size: cover;
5747
margin: 20px auto;
5848
background-position: center center;
59-
&:hover {
60-
background-image: url("~assets/images/github.gif");
61-
}
6249
}
6350
}
6451

‎console/assets/symbol.js‎

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎console/components/Header.vue‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010
<template v-if="$store.state.role === 0">
1111
<span class="fn__flex-1"> &nbsp;</span>
1212
<span>
13-
<nuxt-link to="/login">{{ $t('login', $store.state.locale)}}</nuxt-link>
14-
<nuxt-link to="/register" class="btn--space btn--success btn btn--small">
15-
{{ $t('register', $store.state.locale)}}
13+
<nuxt-link to="/init" class="btn--space btn--success btn btn--small">
14+
{{ $t('startToUse', $store.state.locale)}}
1615
</nuxt-link>
1716
</span>
1817
</template>
@@ -116,9 +115,8 @@
116115
})
117116
}
118117
},
119-
async logout () {
120-
await this.axios.post('/logout')
121-
window.location.href = '/'
118+
logout () {
119+
this.axios.post('/logout')
122120
}
123121
}
124122
}

‎console/layouts/default.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<v-app :class="$store.state.bodySide" id="pipe">
3-
<pipe-header from="default"/>
3+
<pipe-header from="default"/>
44
<side v-if="$route.path.indexOf('/admin') > -1"/>
55
<div class="main">
66
<div class="content" v-if="$route.path.indexOf('/admin') > -1">

‎console/middleware/authenticated.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
export default function ({redirect, store, route}) {
22
if (!store.state.isInit) {
3+
if (route.path !== '/init') {
4+
return redirect('/init')
5+
}
36
return
47
}
58
const isLogin = store.state.role !== 0
@@ -8,8 +11,6 @@ export default function ({redirect, store, route}) {
811
redirect('/')
912
}
1013
} else if (route.path === '/init') {
11-
redirect('/')
12-
} else if (route.path === '/login' || route.path === '/register') {
1314
if (isLogin) {
1415
redirect('/admin')
1516
}

‎console/middleware/initialized.js‎

Lines changed: 0 additions & 11 deletions
This file was deleted.

‎console/nuxt.config.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ module.exports = {
5353
}
5454
},
5555
router: {
56-
middleware: ['initialized', 'authenticated']
56+
middleware: ['authenticated']
5757
},
5858
modules: ['@nuxtjs/proxy'],
5959
proxy: {

‎console/pages/init.vue‎

Lines changed: 12 additions & 185 deletions
Original file line numberDiff line numberDiff line change
@@ -1,220 +1,47 @@
11
<template>
22
<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>
10011
</div>
10112
</div>
10213
</template>
10314

10415
<script>
105-
import Vue from 'vue'
10616
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'
11018
11119
export default {
11220
data () {
11321
return {
11422
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-
]
13223
}
13324
},
13425
head () {
13526
return {
136-
title: this.$t('welcome', this.$store.state.locale) + ' - Pipe'
27+
title: this.$t('welcome', this.$store.state.locale) + ' - Pipe',
13728
}
13829
},
13930
methods: {
14031
loginGitHub () {
14132
this.$store.commit('setSnackBar', {
14233
snackBar: true,
14334
snackMsg: 'Loading...',
144-
snackModify: 'success'
35+
snackModify: 'success',
14536
})
14637
if (!this.clickedGitHub) {
14738
window.location.href = `${process.env.AxiosBaseURL}/oauth/github/redirect`
14839
this.$set(this, 'clickedGitHub', true)
14940
}
15041
},
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-
}
19842
},
19943
mounted () {
20044
initParticlesJS('particles')
201-
Vue.nextTick(() => {
202-
this.$set(this, 'step', this.$store.state.name === '' ? 1 : 2)
203-
})
204-
}
45+
},
20546
}
20647
</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

Comments
 (0)