完成注册和登录页面设计

dev
truthhun 1 year ago
parent 26789e423b
commit 057cd495bb

@ -1,6 +1,6 @@
# moredoc - 魔文库
# moredoc - 魔文库
moredoc - 魔文库,由 深圳市摩枫网络科技(https://mnt.ltd) 基于golang开发的类似百度文库的开源文库系统支持TXT、PDF、EPUB、office等格式文档的在线预览与管理`dochub文库`( [github](https://github.com/truthhun/dochub), [gitee](https://gitee.com/truthhun/DocHub) )的重构版本。
moredoc - 魔文库,由 深圳市摩枫网络科技(https://mnt.ltd) 基于golang开发的类似百度文库的开源文库系统支持TXT、PDF、EPUB、office等格式文档的在线预览与管理`dochub文库`( [github](https://github.com/truthhun/dochub), [gitee](https://gitee.com/truthhun/DocHub) )的重构版本。
## 特性

@ -50,6 +50,8 @@ message ConfigSystem {
string analytics = 8;
string sitename = 9;
string copyright_start_year = 10;
string register_background = 11;
string login_background = 12;
}
//

@ -176,29 +176,33 @@ type ConfigCaptcha struct {
}
const (
ConfigSystemSitename = "sitename"
ConfigSystemDomain = "domain"
ConfigSystemTitle = "title"
ConfigSystemDescription = "description"
ConfigSystemKeywords = "keywords"
ConfigSystemLogo = "logo"
ConfigSystemFavicon = "favicon"
ConfigSystemIcp = "icp"
ConfigSystemAnalytics = "analytics"
ConfigSystemCopyrightStartYear = "copyright_start_year"
ConfigSystemSitename = "sitename"
ConfigSystemDomain = "domain"
ConfigSystemTitle = "title"
ConfigSystemDescription = "description"
ConfigSystemKeywords = "keywords"
ConfigSystemLogo = "logo"
ConfigSystemFavicon = "favicon"
ConfigSystemLoginBackground = "login_background"
ConfigSystemRegistrerBackground = "register_background"
ConfigSystemIcp = "icp"
ConfigSystemAnalytics = "analytics"
ConfigSystemCopyrightStartYear = "copyright_start_year"
)
type ConfigSystem struct {
Sitename string `json:"sitename"` // 网站名称
Domain string `json:"domain"` // 站点域名,不带 HTTPS:// 和 HTTP://
Title string `json:"title"` // 网站首页标题
Keywords string `json:"keywords"` // 系统关键字
Description string `json:"description"` // 系统描述
Logo string `json:"logo"` // logo
Favicon string `json:"favicon"` // logo
ICP string `json:"icp"` // 网站备案
Analytics string `json:"analytics"` // 统计代码
CopyrightStartYear string `json:"copyright_start_year"` // 版权年
Sitename string `json:"sitename"` // 网站名称
Domain string `json:"domain"` // 站点域名,不带 HTTPS:// 和 HTTP://
Title string `json:"title"` // 网站首页标题
Keywords string `json:"keywords"` // 系统关键字
Description string `json:"description"` // 系统描述
Logo string `json:"logo"` // logo
Favicon string `json:"favicon"` // favicon
ConfigSystemRegistrerBackground string `json:"register_background"` // 注册页面背景图
ConfigSystemLoginBackground string `json:"login_background"` // 登录页面背景图
ICP string `json:"icp"` // 网站备案
Analytics string `json:"analytics"` // 统计代码
CopyrightStartYear string `json:"copyright_start_year"` // 版权年
}
const (
@ -392,16 +396,18 @@ func (m *DBModel) initConfig() (err error) {
// 初始化配置项
cfgs := []Config{
// 系统配置项
{Category: ConfigCategorySystem, Name: ConfigSystemSitename, Label: "网站名称", Value: "魔刀文库", Placeholder: "请输入您网站的名称,如:魔刀文库", InputType: "text", Sort: 1, Options: ""},
{Category: ConfigCategorySystem, Name: ConfigSystemTitle, Label: "首页标题", Value: "MOREDOC · 魔刀文库", Placeholder: "请输入您网站的首页标题,如:魔刀文库,强大、专业的文库系统", InputType: "text", Sort: 2, Options: ""},
{Category: ConfigCategorySystem, Name: ConfigSystemKeywords, Label: "网站关键字", Value: "MOREDOC · 魔刀文库", Placeholder: "请输入您网站的关键字", InputType: "text", Sort: 3, Options: ""},
{Category: ConfigCategorySystem, Name: ConfigSystemDescription, Label: "网站描述", Value: "MOREDOC · 魔刀文库", Placeholder: "请输入您网站的描述", InputType: "textarea", Sort: 4, Options: ""},
{Category: ConfigCategorySystem, Name: ConfigSystemLogo, Label: "网站Logo", Value: "", Placeholder: "请输入您网站的Logo路径", InputType: "image", Sort: 6, Options: ""},
{Category: ConfigCategorySystem, Name: ConfigSystemFavicon, Label: "网站Favicon", Value: "", Placeholder: "请输入您网站的Favicon路径", InputType: "image", Sort: 6, Options: ""},
{Category: ConfigCategorySystem, Name: ConfigSystemIcp, Label: "网站备案号", Value: "", Placeholder: "请输入您网站的备案号", InputType: "text", Sort: 6, Options: ""},
{Category: ConfigCategorySystem, Name: ConfigSystemDomain, Label: "网站域名", Value: "https://moredoc.mnt.ltd", Placeholder: "请输入您网站的域名访问地址,如 https://moredoc.mnt.ltd用以生成网站地图sitemap", InputType: "text", Sort: 7, Options: ""},
{Category: ConfigCategorySystem, Name: ConfigSystemCopyrightStartYear, Label: "版权起始年", Value: "2019", Placeholder: "请输入您网站版权起始年2019则前台会显示如 ©2019 - 2022 的字样", InputType: "text", Sort: 8, Options: ""},
{Category: ConfigCategorySystem, Name: ConfigSystemAnalytics, Label: "网站统计代码", Value: "", Placeholder: "请输入您网站的统计代码", InputType: "textarea", Sort: 9, Options: ""},
{Category: ConfigCategorySystem, Name: ConfigSystemSitename, Label: "网站名称", Value: "魔豆文库", Placeholder: "请输入您网站的名称,如:魔豆文库", InputType: "text", Sort: 10, Options: ""},
{Category: ConfigCategorySystem, Name: ConfigSystemTitle, Label: "首页标题", Value: "MOREDOC · 魔豆文库", Placeholder: "请输入您网站的首页标题,如:魔豆文库,强大、专业的文库系统", InputType: "text", Sort: 20, Options: ""},
{Category: ConfigCategorySystem, Name: ConfigSystemKeywords, Label: "网站关键字", Value: "MOREDOC · 魔豆文库", Placeholder: "请输入您网站的关键字", InputType: "text", Sort: 30, Options: ""},
{Category: ConfigCategorySystem, Name: ConfigSystemDescription, Label: "网站描述", Value: "MOREDOC · 魔豆文库", Placeholder: "请输入您网站的描述", InputType: "textarea", Sort: 40, Options: ""},
{Category: ConfigCategorySystem, Name: ConfigSystemLogo, Label: "网站Logo", Value: "", Placeholder: "请上传一张图片作为网站Logo", InputType: "image", Sort: 60, Options: ""},
{Category: ConfigCategorySystem, Name: ConfigSystemFavicon, Label: "网站Favicon", Value: "", Placeholder: "请上传一张 .ico 图标作为网站favicon", InputType: "image", Sort: 61, Options: ""},
{Category: ConfigCategorySystem, Name: ConfigSystemRegistrerBackground, Label: "注册页背景图", Value: "", Placeholder: "请上传一张图片作为注册页背景图", InputType: "image", Sort: 62, Options: ""},
{Category: ConfigCategorySystem, Name: ConfigSystemLoginBackground, Label: "登录页背景图", Value: "", Placeholder: "请上传一张图片作为登录页背景图", InputType: "image", Sort: 63, Options: ""},
{Category: ConfigCategorySystem, Name: ConfigSystemIcp, Label: "网站备案号", Value: "", Placeholder: "请输入您网站的备案号", InputType: "text", Sort: 69, Options: ""},
{Category: ConfigCategorySystem, Name: ConfigSystemDomain, Label: "网站域名", Value: "https://moredoc.mnt.ltd", Placeholder: "请输入您网站的域名访问地址,如 https://moredoc.mnt.ltd用以生成网站地图sitemap", InputType: "text", Sort: 70, Options: ""},
{Category: ConfigCategorySystem, Name: ConfigSystemCopyrightStartYear, Label: "版权起始年", Value: "2019", Placeholder: "请输入您网站版权起始年2019则前台会显示如 ©2019 - 2022 的字样", InputType: "text", Sort: 80, Options: ""},
{Category: ConfigCategorySystem, Name: ConfigSystemAnalytics, Label: "网站统计代码", Value: "", Placeholder: "请输入您网站的统计代码", InputType: "textarea", Sort: 90, Options: ""},
// 验证码配置项
{Category: ConfigCategoryCaptcha, Name: ConfigCaptchaHeight, Label: "验证码高度", Value: "60", Placeholder: "请输入验证码高度默认为60", InputType: "number", Sort: 13, Options: ""},

@ -10,7 +10,7 @@ var (
store = base64Captcha.DefaultMemStore
width = 240
height = 60
sourceChinese = strings.Join(strings.Split("欢迎使用由深圳市摩枫网络科技有限公司基于阿帕奇开源协议的魔文库系统", ""), ",")
sourceChinese = strings.Join(strings.Split("欢迎使用由深圳市摩枫网络科技有限公司基于阿帕奇开源协议的魔文库系统", ""), ",")
sourceString = "1234567890qwertyuioplkjhgfdsazxcvbnm"
CaptchaTypeOptions = "string:字符串\nmath:算术\nchinese:中文\ndigit:数字\naudio:语音"
)

@ -25,7 +25,7 @@ export default {
},
head() {
return {
title: 'MOREDOC · 魔文库,开源文库系统',
title: 'MOREDOC · 魔文库,开源文库系统',
}
},
async created() {},

@ -47,6 +47,18 @@
@click="execLogin"
>立即登录</el-button
>
<nuxt-link
to="/findpassword"
title="找回密码"
class="el-link el-link--default"
>找回密码</nuxt-link
>
<nuxt-link
to="/register"
title="注册账户"
class="el-link el-link--default float-right"
>注册账户</nuxt-link
>
</el-form-item>
</el-form>
</div>

@ -0,0 +1,197 @@
<template>
<div class="com-form-register">
<el-form
ref="formRegister"
label-position="top"
label-width="80px"
:model="user"
>
<el-form-item
label="用户名"
prop="username"
:rules="[
{
required: true,
message: '请输入您用于登录的用户名',
trigger: 'blur',
},
]"
>
<el-input
v-model="user.username"
placeholder="请输入您用于登录的用户名"
></el-input>
</el-form-item>
<el-form-item
label="密码"
prop="password"
:rules="[
{
required: true,
message: '请输入您的登录密码',
trigger: 'blur',
},
]"
>
<el-input
v-model="user.password"
placeholder="请输入您的登录密码"
type="password"
></el-input>
</el-form-item>
<el-form-item
label="确认密码"
prop="repeat_password"
:rules="[
{
required: true,
message: '请再次输入您的登录密码',
trigger: 'blur',
},
]"
>
<el-input
v-model="user.repeat_password"
placeholder="请再次输入您的登录密码"
type="password"
></el-input>
</el-form-item>
<el-form-item
v-if="captcha.enable"
label="验证码"
prop="captcha"
:rules="[
{
required: true,
message: '请输入验证码',
trigger: 'blur',
},
]"
>
<div v-if="captcha.type == 'audio'">
<el-row :gutter="15">
<el-col :span="20">
<audio controls="controls" :src="captcha.captcha"></audio>
</el-col>
<el-col :span="4">
<el-tooltip placement="top" content="刷新语音验证码">
<el-button
icon="el-icon-refresh"
class="btn-audio-refresh"
@click="loadCaptcha"
></el-button>
</el-tooltip>
</el-col>
</el-row>
</div>
<div v-else>
<el-tooltip placement="right" content="点击可刷新验证码">
<img :src="captcha.captcha" class="pointer" @click="loadCaptcha" />
</el-tooltip>
</div>
<el-input v-model="user.captcha" placeholder="请输入验证码"></el-input>
</el-form-item>
<el-form-item class="register">
<el-button
type="primary"
class="btn-block btn-register"
icon="el-icon-check"
@click="execRegister"
>立即注册</el-button
>
<nuxt-link to="/findpassword" class="el-link el-link--default"
>找回密码</nuxt-link
>
<nuxt-link to="/login" class="el-link el-link--default float-right"
>马上登录</nuxt-link
>
</el-form-item>
</el-form>
</div>
</template>
<script>
import { mapActions } from 'vuex'
import { getUserCaptcha, register } from '~/api/user'
export default {
name: 'FormRegister',
props: {
redirect: {
type: String,
default: '',
},
},
data() {
return {
activeTab: 'student',
user: {
group_id: 3,
username: '',
password: '',
repeat_password: '',
captcha: '',
captcha_id: '',
},
captcha: {
enable: false,
},
}
},
created() {
this.loadCaptcha()
},
methods: {
...mapActions('user', ['register']),
execRegister() {
this.$refs.formRegister.validate(async (valid) => {
if (valid) {
const user = { ...this.user }
if (user.password !== user.repeat_password) {
this.$message.error('两次输入的密码不一致')
return
}
delete user.repeat_password
const res = await this.register(user)
if (res.status === 200) {
this.$message.success('注册成功')
if (this.redirect) {
this.$router.replace(this.redirect)
} else {
this.$router.replace({ name: 'index' })
}
}
}
})
},
async loadCaptcha() {
const res = await getUserCaptcha({ type: 'register', t: Date.now() })
if (res.data.enable) {
//
this.user = {
...this.user,
captcha_id: res.data.id,
}
this.captcha = res.data
}
},
tabClick(tab) {
this.activeTab = tab.name
if (tab.name === 'company') {
this.user.group_id = 2
} else {
this.user.group_id = 3
}
//
this.$refs.formRegister.clearValidate()
},
},
}
</script>
<style lang="scss" scoped>
.com-form-register {
.btn-audio-refresh {
vertical-align: -webkit-baseline-middle;
}
}
</style>

@ -83,7 +83,7 @@ export default {
},
head() {
return {
title: 'MOREDOC · 魔文库,开源文库系统',
title: 'MOREDOC · 魔文库,开源文库系统',
}
},
async created() {},

@ -224,7 +224,7 @@ export default {
},
head() {
return {
title: 'MOREDOC · 魔文库,开源文库系统',
title: 'MOREDOC · 魔文库,开源文库系统',
}
},
methods: {

@ -157,7 +157,7 @@ export default {
},
head() {
return {
title: 'MOREDOC · 魔文库,开源文库系统',
title: 'MOREDOC · 魔文库,开源文库系统',
}
},
methods: {

@ -220,7 +220,7 @@ export default {
},
head() {
return {
title: 'MOREDOC · 魔文库,开源文库系统',
title: 'MOREDOC · 魔文库,开源文库系统',
}
},
methods: {

@ -6,7 +6,7 @@
>
<div class="logo" @click="gohome">
<img src="/static/images/default-logo-icon.png" alt="" />
<span>文库系统</span>
<span>文库系统</span>
</div>
<transition
:duration="{ enter: 800, leave: 800 }"
@ -195,7 +195,7 @@ export default {
title:
this.settings.system.title ||
this.settings.system.sitename ||
'魔文库',
'魔文库',
link: [
{
rel: 'icon',

@ -34,7 +34,7 @@
<nuxt />
</el-main>
<el-footer>
<div class="footer-friendlink">
<div v-if="$route.path === '/'" class="footer-friendlink">
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<strong>友情链接</strong>
@ -98,7 +98,7 @@
v-if="settings.system.domain"
:underline="false"
type="white"
title="魔文库"
title="魔文库"
:href="settings.system.domain"
>
{{ settings.system.sitename }}
@ -165,7 +165,7 @@ export default {
title:
this.settings.system.title ||
this.settings.system.sitename ||
'魔文库',
'魔文库',
keywords: this.settings.system.keywords,
description: this.settings.system.description,
// favicon

@ -19,7 +19,7 @@ export default {
},
head() {
return {
title: '404 - Not Found - MOREDOC · 魔文库',
title: '404 - Not Found - MOREDOC · 魔文库',
meta: [
{
hid: 'keywords',

@ -9,7 +9,7 @@ export default {
layout: 'admin',
head() {
return {
title: `面板 - MOREDOC · 魔文库`,
title: `面板 - MOREDOC · 魔文库`,
}
},
}

@ -69,7 +69,7 @@ export default {
},
head() {
return {
title: 'MOREDOC · 魔文库,开源文库系统',
title: 'MOREDOC · 魔文库,开源文库系统',
}
},
async created() {

@ -137,7 +137,7 @@ export default {
},
head() {
return {
title: 'MOREDOC · 魔文库,开源文库系统',
title: 'MOREDOC · 魔文库,开源文库系统',
}
},
computed: {

@ -273,7 +273,7 @@ export default {
},
head() {
return {
title: 'MOREDOC · 魔文库,开源文库系统',
title: 'MOREDOC · 魔文库,开源文库系统',
}
},
computed: {

@ -12,7 +12,7 @@ export default {
},
head() {
return {
title: 'MOREDOC · 魔文库,开源文库系统',
title: 'MOREDOC · 魔文库,开源文库系统',
}
},
async created() {},

@ -227,7 +227,7 @@ export default {
},
head() {
return {
// title: 'MOREDOC · ',
// title: 'MOREDOC · ',
script: [],
}
},

@ -1,27 +1,69 @@
<template>
<div class="page page-login">
<el-card shadow="never">
<div slot="header" class="clearfix">
<span>用户登录</span>
</div>
<form-login :redirect="'/admin'"></form-login>
</el-card>
<div
class="page page-login"
:style="
settings.system.login_background
? 'background:url(' +
settings.system.login_background +
') no-repeat center center'
: ''
"
>
<div>
<el-card shadow="never">
<div slot="header" class="clearfix">
<span>用户登录</span>
</div>
<form-login></form-login>
</el-card>
</div>
</div>
</template>
<script>
import { mapGetters } from 'vuex'
export default {
head() {
return {
title: `用户登录 - MOREDOC · 魔刀文库`,
title: `用户登录 - ${this.settings.system.sitename}`,
meta: [
{
hid: 'keywords',
name: 'keywords',
content: `用户登录,${this.settings.system.sitename},${this.settings.system.keywords}`,
},
{
hid: 'description',
name: 'description',
content: `${this.settings.system.description}`,
},
],
}
},
computed: {
...mapGetters('setting', ['settings']),
...mapGetters('user', ['user']),
},
created() {
//
if (this.user.id && this.user.id > 0) {
this.$router.replace({ name: 'user-id', params: { id: this.user.id } })
}
},
}
</script>
<style lang="scss">
.page-login {
width: 100%;
margin-top: -20px;
margin-bottom: -20px;
background-size: cover !important;
& > div {
width: $default-width;
margin: 0 auto;
}
.el-card {
width: 450px;
width: 520px;
max-width: 100%;
margin: 100px auto;
margin-right: 0;

@ -1,21 +1,80 @@
<template>
<div class="page-index">
{{ $route.name }}
<div
class="page page-register"
:style="
settings.system.register_background
? 'background:url(' +
settings.system.register_background +
') no-repeat center center'
: ''
"
>
<div>
<el-card shadow="never">
<div slot="header" class="clearfix">
<span>用户注册</span>
</div>
<form-register></form-register>
</el-card>
</div>
</div>
</template>
<script>
import { mapGetters } from 'vuex'
export default {
name: 'IndexPage',
name: 'RegisterPage',
data() {
return {}
},
head() {
return {
title: 'MOREDOC · 魔刀文库,开源文库系统',
title: `用户注册 - ${this.settings.system.sitename}`,
meta: [
{
hid: 'keywords',
name: 'keywords',
content: `用户注册,${this.settings.system.sitename},${this.settings.system.keywords}`,
},
{
hid: 'description',
name: 'description',
content: `${this.settings.system.description}`,
},
],
}
},
computed: {
...mapGetters('setting', ['settings']),
...mapGetters('user', ['user']),
},
created() {
//
if (this.user.id && this.user.id > 0) {
this.$router.replace({ name: 'user-id', params: { id: this.user.id } })
}
},
async created() {},
methods: {},
}
</script>
<style lang="scss">
.page-register {
width: 100%;
margin-top: -20px;
margin-bottom: -20px;
background-size: cover !important;
& > div {
width: $default-width;
margin: 0 auto;
}
.el-card {
width: 520px;
max-width: 100%;
margin: 100px auto;
margin-right: 0;
.el-card__body {
padding-bottom: 0;
}
}
}
</style>

@ -223,7 +223,7 @@ export default {
bodyAttrs: {
class: 'search-page',
},
title: 'MOREDOC · 魔文库,开源文库系统',
title: 'MOREDOC · 魔文库,开源文库系统',
}
},
async created() {},

@ -287,7 +287,7 @@ export default {
},
head() {
return {
title: 'MOREDOC · 魔文库,开源文库系统',
title: 'MOREDOC · 魔文库,开源文库系统',
}
},
computed: {

@ -64,7 +64,7 @@ export default {
},
head() {
return {
title: 'MOREDOC · 魔文库,开源文库系统',
title: 'MOREDOC · 魔文库,开源文库系统',
}
},
async created() {},

Loading…
Cancel
Save