页面调整

dev
truthhun 1 year ago
parent 4f5ca624f6
commit 0664e582d5

@ -52,6 +52,7 @@ message ConfigSystem {
string copyright_start_year = 10;
string register_background = 11;
string login_background = 12;
repeated string recommend_words = 13;
}
//

@ -3,6 +3,7 @@ package model
import (
"moredoc/util/captcha"
"strconv"
"strings"
"time"
jsoniter "github.com/json-iterator/go"
@ -52,7 +53,6 @@ func (Config) TableName() string {
}
// CreateConfig 创建Config
// TODO: 创建成功之后,注意相关表统计字段数值的增减
func (m *DBModel) CreateConfig(config *Config) (err error) {
err = m.db.Create(config).Error
if err != nil {
@ -156,7 +156,6 @@ func (m *DBModel) GetConfigList(opt *OptionGetConfigList) (configList []Config,
}
// DeleteConfig 删除数据
// TODO: 删除数据之后,存在 config_id 的关联表,需要删除对应数据,同时相关表的统计数值,也要随着减少
func (m *DBModel) DeleteConfig(ids []interface{}) (err error) {
err = m.db.Where("id in (?)", ids).Delete(&Config{}).Error
if err != nil {
@ -185,6 +184,7 @@ const (
ConfigSystemTitle = "title"
ConfigSystemDescription = "description"
ConfigSystemKeywords = "keywords"
ConfigSystemRecommendWords = "recommend_words"
ConfigSystemLogo = "logo"
ConfigSystemFavicon = "favicon"
ConfigSystemLoginBackground = "login_background"
@ -195,18 +195,19 @@ const (
)
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"` // 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"` // 版权年
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"` // 版权年
RecommendWords []string `json:"recommend_words"` // 推荐词,首页收缩推荐词
}
const (
@ -413,7 +414,19 @@ func (m *DBModel) GetConfigOfSystem() (config ConfigSystem) {
var data = make(map[string]interface{})
for _, cfg := range confgis {
data[cfg.Name] = cfg.Value
if cfg.Name == ConfigSystemRecommendWords {
words := strings.Split(cfg.Value, ",")
iwords := make([]string, 0)
for _, word := range words {
word = strings.TrimSpace(word)
if word != "" {
iwords = append(iwords, word)
}
}
data[cfg.Name] = iwords
} else {
data[cfg.Name] = cfg.Value
}
}
bytes, _ := json.Marshal(data)
@ -512,6 +525,7 @@ func (m *DBModel) initConfig() (err error) {
{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: ConfigSystemRecommendWords, Label: "首页搜索推荐词", Value: "", Placeholder: "网站首页搜索推荐关键字,多个关键字用英文逗号分隔", InputType: "text", Sort: 50, 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: ""},

@ -101,7 +101,7 @@ export default {
.doc-cover {
.el-image {
width: 100%;
border: 3px solid #efefef;
border: 2px solid #efefef;
border-radius: 5px;
&:hover img {
transform: scale(1.2);

@ -32,13 +32,17 @@
></el-button>
</el-input>
</el-form-item>
<el-form-item>
<el-form-item v-if="settings.system.recommend_words">
<span>大家在搜:</span>
<a href="#"><el-tag size="small">Java教程</el-tag></a>
<a href="#"><el-tag size="small">PHP教程</el-tag></a>
<a href="#"><el-tag size="small">GPTChat</el-tag></a>
<a href="#"><el-tag size="small">开源中国</el-tag></a>
<a href="#"><el-tag size="small">小学语文</el-tag></a>
<nuxt-link
v-for="word in settings.system.recommend_words"
:key="'kw-' + word"
:to="{
path: '/search',
query: { wd: word },
}"
><el-tag size="small">{{ word }}</el-tag></nuxt-link
>
</el-form-item>
</el-form>
</div>
@ -304,6 +308,7 @@ export default {
computed: {
...mapGetters('category', ['categoryTrees']),
...mapGetters('user', ['user']),
...mapGetters('setting', ['settings']),
},
async created() {
await Promise.all([
@ -547,6 +552,7 @@ export default {
border: 2px solid #efefef;
border-radius: 5px;
height: 160px;
width: 115px;
img {
width: 100%;
transition: transform 0.3s ease 0s;

@ -31,7 +31,7 @@
<nuxt-link to="/" :title="settings.system.sitename"
><img
:src="settings.system.logo"
style="height: 56px; max-width: 100%"
style="max-width: 100%"
:alt="settings.system.sitename"
/></nuxt-link>
</el-col>

@ -240,7 +240,7 @@
</template>
<script>
import { mapGetters } from 'vuex'
import { mapActions, mapGetters } from 'vuex'
import { formatBytes } from '~/utils/utils'
import { createDocument } from '~/api/document'
import { canIUploadDocument } from '~/api/user'
@ -307,6 +307,7 @@ export default {
},
methods: {
formatBytes,
...mapActions('user', ['getUser']),
handleChange(file) {
const name = file.name.toLowerCase()
const ext = file.name.substring(file.name.lastIndexOf('.')).toLowerCase()
@ -402,6 +403,7 @@ export default {
overwrite: false,
}
this.$refs.upload.clearFiles()
this.getUser()
} else {
console.log(res)
this.$message.error(res.data.message || '上传失败')

Loading…
Cancel
Save