Skip to content

Commit

Permalink
V1.2版本更新
Browse files Browse the repository at this point in the history
  • Loading branch information
nuanxinqing123 committed Nov 21, 2021
1 parent e9404f3 commit ec0ac99
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 78 deletions.
65 changes: 36 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,65 @@
程序的起因是因为家里申请了公网IP,因此购置了一套服务器在家里放着。但是方便操作和记忆,因为写了此导航来可以快速的从内网或者外网访问家里的某些服务

### Docker部署
```dockerfile
# 第一步:创建映射文件夹并进入
```text
// 第一步:创建映射文件夹并进入
mkdir HNconfig && cd HNconfig
# 第二步:下载配置文件
// 第二步:下载配置文件
wget https://ghproxy.com/https://github.com/nuanxinqing123/HomeNavigation/blob/master/conf/config.json
# 第三步:运行Docker image
docker run -itd --name HomeNavigation -v $PWD:/go/src/Gin_HomeNavigation/conf -p 8082:8100 nuanxinqing123/home_navigation:1.1
// 第三步:运行Docker image
docker run -itd --name HomeNavigation -v $PWD:/go/src/Gin_HomeNavigation/conf -p 8082:8100 nuanxinqing123/home_navigation:1.2
```
好了,部署完成。如果需要修改前端的显示内容,直接修改 HNconfig/config.json里面的内容就好了。还有就是启动命令默认是8082端口,大家自行修改一下

**Tips:因为版本更新可能会变动json文件。所以推荐更新之前先把原来的json文件修改名字,下载新的json文件之后把原来的内容再拷贝过去**

### config.json 文件
```json
{
"Config": {
# 网站LOGO(支持相对&绝对路径、支持图床外链)
// 网站LOGO(支持相对&绝对路径、支持图床外链)
"Logo": "img/logo.png",
# 网站ico(支持相对&绝对路径、支持图床外链)
// 网站ico(支持相对&绝对路径、支持图床外链)
"Favicon": "img/favicon.ico",
# 网站标题
// 网站标题
"Title": "Cloud Services",
# 网站底部标题
// 网站底部标题
"FooterTitle": "陕ICP备xxxxxxxx号-1",
# 网站底部标题链接(可空)
// 网站底部标题链接(可空)
"FooterTitleLink": "https://beian.miit.gov.cn/",
# 网站底部版权信息
// 网站底部版权信息
"FooterTextDataOne": "Copyright © 2021",
# 网站底部其他文字(可随意自定义)
// 网站底部其他文字(可随意自定义)
"FooterTextDataTwo": "百度",
# 网站底部其他文字链接(可空)
// 网站底部其他文字链接(可空)
"FooterTextDataTwoLink": "https://www.baidu.com/"
},
"SoftWare": {
# 程序运行端口(修改后重启生效)
// 程序运行端口(修改后重启生效)
"port": "8100"
},
"Data": [
{
# 显示顺序(不可以重复)
// 显示顺序(不可以重复)
"id": 1,
# 图标标题
// 图标标题
"title": "我的博客",
# 图标图片(支持相对&绝对路径、支持图床外链)
// 图标图片(支持相对&绝对路径、支持图床外链)
"ico": "img/png/AppStore.png",
# 外网访问地址(可空)
// 外网访问地址(可空)
"w_link": "https://6b7.org/",
# 内网访问地址(可空)
// 内网访问地址(可空)
"n_link": "https://6b7.org/"
},
{
"id": 2,
"title": "我的网盘",
"ico": "img/png/iCloud-Drive.png",
"w_link": "https://alist.6b7.org/",
"n_link": "https://alist.6b7.org/"
"Style": { // 不懂请勿配置此项
// Web背景图片(推荐图床外链)
"Background": "",
// 链接文字颜色(支持颜色的英文单词和十六进制颜色值)
"AColor": "",
// 链接文字悬浮颜色(支持颜色的英文单词和十六进制颜色值)
"AColorHover": ""
}
]
}
Expand All @@ -80,9 +83,16 @@ docker run -itd --name HomeNavigation -v $PWD:/go/src/Gin_HomeNavigation/conf -p
### 配置文件说明
以上配置文件是整个程序的所有配置项,由于程序采用JSON文件实时读取的方式,所以修改配置过后均可实时生效(除了端口需要重启生效)。

### 前端模板说明
模板经过修改,原版模板来自于:http://www.wdmomo.fun:81/home/

### 版本通知
```text
2021.11.21:V1.2
1、增加空路由提示
2、增加更多可以控制元素(自定义背景图、色)
3、更换新的背景图
2021.11.18:V1.1
1、修复CSS的部分错误
2、目前CSS任然存在问题,推荐添加Web不要超过16个
Expand All @@ -91,7 +101,4 @@ docker run -itd --name HomeNavigation -v $PWD:/go/src/Gin_HomeNavigation/conf -p
2021.11.17:V1.0
1、支持内网外网添加定义
2、JSON文件动态加载全网页
```

### 前端模板说明
模板经过修改,原版模板来自于:http://www.wdmomo.fun:81/home/
```
7 changes: 6 additions & 1 deletion conf/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,10 @@
"w_link": "#",
"n_link": "#"
}
]
],
"Style": {
"Background": "img/bg.jpg",
"AColor": "black",
"AColorHover": "#87CEEB"
}
}
29 changes: 17 additions & 12 deletions controllers/indexControllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,27 @@ import (
"net/http"
)



func Index(ctx *gin.Context){
func Index(ctx *gin.Context) {
// 加载配置
Web := dataSource.LoadConfig()

// 渲染前端
ctx.HTML(http.StatusOK, "index.html", gin.H{
"logo": Web.Config.Logo,
"title": Web.Config.Title,
"favicon": Web.Config.Favicon,
"FooterTitle": Web.Config.FooterTitle,
"FooterTitleLink": Web.Config.FooterTitleLink,
"FooterTextDataOne": Web.Config.FooterTextDataOne,
"FooterTextDataTwo": Web.Config.FooterTextDataTwo,
"logo": Web.Config.Logo,
"title": Web.Config.Title,
"favicon": Web.Config.Favicon,
"FooterTitle": Web.Config.FooterTitle,
"FooterTitleLink": Web.Config.FooterTitleLink,
"FooterTextDataOne": Web.Config.FooterTextDataOne,
"FooterTextDataTwo": Web.Config.FooterTextDataTwo,
"FooterTextDataTwoLink": Web.Config.FooterTextDataTwoLink,
"data": Web.Data,
"data": Web.Data,
"Background": Web.Style.Background,
"AColor": Web.Style.AColor,
"AColorHover": Web.Style.AColorHover,
})
}
}

func NoRouter(ctx *gin.Context) {
ctx.String(http.StatusOK, "The visit address does not exist, please return to the homepage")
}
31 changes: 19 additions & 12 deletions model/Config_Model.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,37 @@ package model

// Config 配置项
type Config struct {
Config conf
Config conf
SoftWare software
Data []Data
Data []Data
Style style
}

type conf struct {
Logo string `json:"logo"`
Title string `json:"title"`
Favicon string `json:"favicon"`
FooterTitle string `json:"FooterTitle"`
FooterTitleLink string `json:"FooterTitleLink"`
FooterTextDataOne string `json:"FooterTextDataOne"`
FooterTextDataTwo string `json:"FooterTextDataTwo"`
Logo string `json:"logo"`
Title string `json:"title"`
Favicon string `json:"favicon"`
FooterTitle string `json:"FooterTitle"`
FooterTitleLink string `json:"FooterTitleLink"`
FooterTextDataOne string `json:"FooterTextDataOne"`
FooterTextDataTwo string `json:"FooterTextDataTwo"`
FooterTextDataTwoLink string `json:"FooterTextDataTwoLink"`
}

type software struct {
Port string `json:"port"`
Port string `json:"port"`
}

type Data struct {
Id int `json:"id"`
Id int `json:"id"`
Title string `json:"title"`
Ico string `json:"ico"`
WLink string `json:"w_link"`
NLink string `json:"n_link"`
}
}

type style struct {
Background string `json:"background"`
AColor string `json:"AColor"`
AColorHover string `json:"AColorHover"`
}
5 changes: 4 additions & 1 deletion router/IndexRouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ import (
func IndexRouter(index *gin.Engine) {
// 首页
index.GET("/", controllers.Index)
}

// 404路由
index.NoRoute(controllers.NoRouter)
}
46 changes: 23 additions & 23 deletions views/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -3446,28 +3446,28 @@ ul {
font-size: 12px
}

a {
color: #fff;
text-decoration: none
}
/*a {*/
/* color: black;*/
/* text-decoration: none*/
/*}*/

@font-face {
font-family: MyriadSetPro-Thin;
src: url(./font/MyriadSetPro-Thin.ttf)
}

body {
height: 100%;
background-color: #ffffff;
background-image: url("../img/overlay.png"), -moz-linear-gradient(60deg, rgba(255, 165, 150, 0.5) 5%, rgba(0, 228, 255, 0.35)), url("../img/bg.jpg");
background-image: url("../img/overlay.png"), -webkit-linear-gradient(60deg, rgba(255, 165, 150, 0.5) 5%, rgba(0, 228, 255, 0.35)), url("../img/bg.jpg");
background-image: url("../img/overlay.png"), -ms-linear-gradient(60deg, rgba(255, 165, 150, 0.5) 5%, rgba(0, 228, 255, 0.35)), url("../img/bg.jpg");
background-image: url("../img/overlay.png"), linear-gradient(60deg, rgba(255, 165, 150, 0.5) 5%, rgba(0, 228, 255, 0.35)), url("../img/bg.jpg");
background-repeat: repeat, no-repeat, no-repeat;
background-size: 100px 100px, cover, cover;
background-position: top left, center center, bottom center;
background-attachment: fixed, fixed, fixed;
}
/*body {*/
/* height: 100%;*/
/* background-color: #ffffff;*/
/* background-image: url("../img/overlay.png"), -moz-linear-gradient(60deg, rgba(255, 165, 150, 0.5) 5%, rgba(0, 228, 255, 0.35)), url("../img/bg.jpg");*/
/* background-image: url("../img/overlay.png"), -webkit-linear-gradient(60deg, rgba(255, 165, 150, 0.5) 5%, rgba(0, 228, 255, 0.35)), url("../img/bg.jpg");*/
/* background-image: url("../img/overlay.png"), -ms-linear-gradient(60deg, rgba(255, 165, 150, 0.5) 5%, rgba(0, 228, 255, 0.35)), url("../img/bg.jpg");*/
/* background-image: url("../img/overlay.png"), linear-gradient(60deg, rgba(255, 165, 150, 0.5) 5%, rgba(0, 228, 255, 0.35)), url("../img/bg.jpg");*/
/* background-repeat: repeat, no-repeat, no-repeat;*/
/* background-size: 100px 100px, cover, cover;*/
/* background-position: top left, center center, bottom center;*/
/* background-attachment: fixed, fixed, fixed;*/
/*}*/

#wrap {
width: 100%;
Expand Down Expand Up @@ -3544,8 +3544,8 @@ ul li a strong {
text-align: right;
font-size: 13px;
font-weight: 400;
color: #fff;
color: rgba(255, 255, 255, .8);
/*color: #fff;*/
/*color: rgba(255, 255, 255, .8);*/
overflow: visible !important;
z-index: 10
}
Expand All @@ -3570,13 +3570,13 @@ ul li a strong {

.footer-contents a, .footer-contents a:active, .footer-contents a:focus {
text-decoration: none;
color: #fff;
color: rgba(255, 255, 255, .8)
/*color: #fff;*/
/*color: rgba(255, 255, 255, .8)*/
}

.footer-contents a:hover {
color: #fff
}
/*.footer-contents a:hover {*/
/* color: #fff*/
/*}*/

.coffee_cup {
width: 20px;
Expand Down
Binary file modified views/img/bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions views/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@
<link rel="shortcut icon" href="{{ .favicon }}">
<link rel="stylesheet" type="text/css" href="css/style.css" />
<title>{{ .title }}</title>
<style>
body{
background: url("{{ .Background }}") no-repeat;
}
.footer-contents a:hover {
color: {{ .AColorHover }}
}
a {
color: {{ .AColor }};
text-decoration: none
}
</style>
</head>
<body>
<div id="wrap">
Expand Down

0 comments on commit ec0ac99

Please sign in to comment.