mirror of
https://github.com/nezhahq/nezha.git
synced 2025-02-02 09:38:13 -05:00
fix bug (#328)
* fix bugs 1. 修复default主题mixin.js文件丢失 2. 修复主题默认值为后台设置值 3. default主题样式优化 * 修复前台切换 theme-custom 不生效
This commit is contained in:
parent
e24925b049
commit
ab39782c78
@ -14,7 +14,7 @@ func PreferredTheme(c *gin.Context) {
|
|||||||
if theme, err := c.Cookie("preferred_theme"); err == nil {
|
if theme, err := c.Cookie("preferred_theme"); err == nil {
|
||||||
if _, has := model.Themes[theme]; has {
|
if _, has := model.Themes[theme]; has {
|
||||||
// 检验自定义主题
|
// 检验自定义主题
|
||||||
if theme == "custom" && singleton.Conf.Site.Theme != "custom" && !utils.IsFileExists("resource/template/custom/home.html") {
|
if theme == "custom" && singleton.Conf.Site.Theme != "custom" && !utils.IsFileExists("resource/template/theme-custom/home.html") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.Set(model.CtxKeyPreferredTheme, theme)
|
c.Set(model.CtxKeyPreferredTheme, theme)
|
||||||
|
7
resource/l10n/en-US.toml
vendored
7
resource/l10n/en-US.toml
vendored
@ -398,7 +398,7 @@ other = "Virtualization"
|
|||||||
other = "Swap"
|
other = "Swap"
|
||||||
|
|
||||||
[NetTransfer]
|
[NetTransfer]
|
||||||
other = "Network Transfer"
|
other = "Transfer"
|
||||||
|
|
||||||
[Load]
|
[Load]
|
||||||
other = "Load"
|
other = "Load"
|
||||||
@ -419,7 +419,7 @@ other = "Last Active"
|
|||||||
other = "Version"
|
other = "Version"
|
||||||
|
|
||||||
[NetSpeed]
|
[NetSpeed]
|
||||||
other = "Network Speed"
|
other = "Speed"
|
||||||
|
|
||||||
[Uptime]
|
[Uptime]
|
||||||
other = "Uptime"
|
other = "Uptime"
|
||||||
@ -627,3 +627,6 @@ other = "Feature"
|
|||||||
|
|
||||||
[Template]
|
[Template]
|
||||||
other = "Template"
|
other = "Template"
|
||||||
|
|
||||||
|
[Stat]
|
||||||
|
other = "Stat"
|
||||||
|
3
resource/l10n/es-ES.toml
vendored
3
resource/l10n/es-ES.toml
vendored
@ -627,3 +627,6 @@ other = "Característica"
|
|||||||
|
|
||||||
[Template]
|
[Template]
|
||||||
other = "Plantilla"
|
other = "Plantilla"
|
||||||
|
|
||||||
|
[Stat]
|
||||||
|
other = "Stat"
|
||||||
|
3
resource/l10n/zh-CN.toml
vendored
3
resource/l10n/zh-CN.toml
vendored
@ -627,3 +627,6 @@ other = "功能"
|
|||||||
|
|
||||||
[Template]
|
[Template]
|
||||||
other = "主题"
|
other = "主题"
|
||||||
|
|
||||||
|
[Stat]
|
||||||
|
other = "信息"
|
||||||
|
3
resource/l10n/zh-TW.toml
vendored
3
resource/l10n/zh-TW.toml
vendored
@ -627,3 +627,6 @@ other = "功能"
|
|||||||
|
|
||||||
[Template]
|
[Template]
|
||||||
other = "主題"
|
other = "主題"
|
||||||
|
|
||||||
|
[Stat]
|
||||||
|
other = "信息"
|
||||||
|
23
resource/static/theme-default/css/main.css
vendored
23
resource/static/theme-default/css/main.css
vendored
@ -86,21 +86,35 @@ td {
|
|||||||
margin-right: 0;
|
margin-right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ui.grid {
|
||||||
|
margin-bottom:-0.5em
|
||||||
|
}
|
||||||
|
|
||||||
|
.ui.card>.content>.header:not(.ui), .ui.cards>.card>.content>.header:not(.ui){
|
||||||
|
line-height: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
.status.cards .wide.column {
|
.status.cards .wide.column {
|
||||||
padding-top: 0 !important;
|
padding-top: 0 !important;
|
||||||
padding-bottom: 0 !important;
|
padding-bottom: 0 !important;
|
||||||
height:3.3rem !important;
|
height:2.3rem !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status.cards .wide.column:nth-child(1) {
|
.status.cards .wide.column:nth-child(1) {
|
||||||
margin-top:2rem !important;
|
margin-top:1.2rem !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status.cards .wide.column:nth-child(2) {
|
.status.cards .wide.column:nth-child(2) {
|
||||||
margin-top:2rem !important;
|
margin-top:1.2rem !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status.cards .three.wide.column {
|
||||||
|
text-align: center;
|
||||||
|
width: 22%!important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status.cards .thirteen.wide.column{
|
.status.cards .thirteen.wide.column{
|
||||||
|
width: 78%!important;
|
||||||
padding-left:0;
|
padding-left:0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +138,7 @@ td {
|
|||||||
.closePopup{
|
.closePopup{
|
||||||
color:rgb(10, 148, 242) !important;
|
color:rgb(10, 148, 242) !important;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 10px;
|
top: 7px;
|
||||||
right: 10px;
|
right: 10px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
z-index: 9999;
|
z-index: 9999;
|
||||||
@ -194,6 +208,7 @@ td {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.nezha-secondary-font {
|
.nezha-secondary-font {
|
||||||
|
height: 1em;
|
||||||
color: rgb(10, 148, 242) !important;
|
color: rgb(10, 148, 242) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
56
resource/static/theme-default/js/mixin.js
vendored
Normal file
56
resource/static/theme-default/js/mixin.js
vendored
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
const mixinsVue = {
|
||||||
|
delimiters: ['@#', '#@'],
|
||||||
|
data: {
|
||||||
|
preferredTemplate: null,
|
||||||
|
isMobile: false
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.isMobile = this.checkIsMobile();
|
||||||
|
this.preferredTemplate = this.getCookie('preferred_theme') ? this.getCookie('preferred_theme') : this.$root.defaultTemplate;
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
toggleTemplate(template) {
|
||||||
|
if( template != this.preferredTemplate){
|
||||||
|
this.preferredTemplate = template;
|
||||||
|
this.updateCookie("preferred_theme", template);
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
updateCookie(name, value) {
|
||||||
|
document.cookie = name + "=" + value +"; path=/";
|
||||||
|
},
|
||||||
|
getCookie(name) {
|
||||||
|
const cookies = document.cookie.split(';');
|
||||||
|
let cookieValue = null;
|
||||||
|
for (let i = 0; i < cookies.length; i++) {
|
||||||
|
const cookie = cookies[i].trim();
|
||||||
|
if (cookie.startsWith(name + '=')) {
|
||||||
|
cookieValue = cookie.substring(name.length + 1, cookie.length);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cookieValue;
|
||||||
|
},
|
||||||
|
checkIsMobile() { // 检测设备类型,页面宽度小于768px认为是移动设备
|
||||||
|
return window.innerWidth <= 768;
|
||||||
|
},
|
||||||
|
logOut(id) {
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: '/api/logout',
|
||||||
|
data: JSON.stringify({ id: id }),
|
||||||
|
contentType: 'application/json',
|
||||||
|
success: function (resp) {
|
||||||
|
if (resp.code == 200) {
|
||||||
|
window.location.reload();
|
||||||
|
} else {
|
||||||
|
alert('注销失败(Error ' + resp.code + '): ' + resp.message);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (err) {
|
||||||
|
alert('网络错误: ' + err.responseText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,14 +5,14 @@ const mixinsVue = {
|
|||||||
isSystemTheme: false,
|
isSystemTheme: false,
|
||||||
showGroup: false,
|
showGroup: false,
|
||||||
showGoTop: false,
|
showGoTop: false,
|
||||||
preferredTemplate: 'default',
|
preferredTemplate: null,
|
||||||
isMobile: false
|
isMobile: false
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.isMobile = this.checkIsMobile();
|
this.isMobile = this.checkIsMobile();
|
||||||
this.initTheme();
|
this.initTheme();
|
||||||
this.storedShowGroup();
|
this.storedShowGroup();
|
||||||
this.preferredTemplate = this.getCookie('preferred_theme') ? this.getCookie('preferred_theme') : 'default';
|
this.preferredTemplate = this.getCookie('preferred_theme') ? this.getCookie('preferred_theme') : this.$root.defaultTemplate;
|
||||||
window.addEventListener('scroll', this.handleScroll);
|
window.addEventListener('scroll', this.handleScroll);
|
||||||
},
|
},
|
||||||
destroyed() {
|
destroyed() {
|
||||||
|
4
resource/template/theme-default/header.html
vendored
4
resource/template/theme-default/header.html
vendored
@ -12,14 +12,14 @@
|
|||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.2/font/bootstrap-icons.min.css">
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.2/font/bootstrap-icons.min.css">
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/lipis/flag-icons@7.0.0/css/flag-icons.min.css">
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/lipis/flag-icons@7.0.0/css/flag-icons.min.css">
|
||||||
<link rel="stylesheet" type="text/css" href="/static/semantic-ui-alerts.min.css">
|
<link rel="stylesheet" type="text/css" href="/static/semantic-ui-alerts.min.css">
|
||||||
<link rel="stylesheet" type="text/css" href="/static/theme-default/css/main.css?v20240222">
|
<link rel="stylesheet" type="text/css" href="/static/theme-default/css/main.css?v20240226">
|
||||||
<link rel="shortcut icon" type="image/png" href="/static/logo.svg" />
|
<link rel="shortcut icon" type="image/png" href="/static/logo.svg" />
|
||||||
<script src="https://cdn.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.min.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.1/dist/semantic.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.1/dist/semantic.min.js"></script>
|
||||||
<script src="/static/semantic-ui-alerts.min.js"></script>
|
<script src="/static/semantic-ui-alerts.min.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14"></script>
|
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/echarts@5.5.0/dist/echarts.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/echarts@5.5.0/dist/echarts.min.js"></script>
|
||||||
<script src="/static/theme-server-status/js/mixin.js?v20240225"></script>
|
<script src="/static/theme-default/js/mixin.js?v20240226"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
{{end}}
|
{{end}}
|
7
resource/template/theme-default/home.html
vendored
7
resource/template/theme-default/home.html
vendored
@ -19,7 +19,7 @@
|
|||||||
class="apple icon"></i><i v-else-if='isWindowsPlatform(server.Host.Platform)'
|
class="apple icon"></i><i v-else-if='isWindowsPlatform(server.Host.Platform)'
|
||||||
class="windows icon"></i><i v-else :class="'fl-' + getFontLogoClass(server.Host.Platform)"></i>
|
class="windows icon"></i><i v-else :class="'fl-' + getFontLogoClass(server.Host.Platform)"></i>
|
||||||
@#server.Name + (server.live?'':'[{{tr "Offline"}}]')#@
|
@#server.Name + (server.live?'':'[{{tr "Offline"}}]')#@
|
||||||
<i @click="togglePopup($event, server.ID)" aria-expanded="false" class="nezha-secondary-font info circle icon" style="height: 28px"></i>
|
<i @click="togglePopup($event, server.ID)" aria-expanded="false" class="nezha-secondary-font info circle icon"></i>
|
||||||
<div class="ui content popup" :class="{ 'visible': isActive(server.ID) }" style="margin-bottom: 0;">
|
<div class="ui content popup" :class="{ 'visible': isActive(server.ID) }" style="margin-bottom: 0;">
|
||||||
<i class="closePopup window close icon" @click="closePopup(server.ID)"></i>
|
<i class="closePopup window close icon" @click="closePopup(server.ID)"></i>
|
||||||
{{tr "Platform"}}: @#server.Host.Platform#@-@#server.Host.PlatformVersion#@
|
{{tr "Platform"}}: @#server.Host.Platform#@-@#server.Host.PlatformVersion#@
|
||||||
@ -90,7 +90,7 @@
|
|||||||
<i class="arrow alternate circle up outline icon"></i>
|
<i class="arrow alternate circle up outline icon"></i>
|
||||||
@#formatByteSize(server.State.NetOutSpeed)#@/s
|
@#formatByteSize(server.State.NetOutSpeed)#@/s
|
||||||
</div>
|
</div>
|
||||||
<div class="three wide column">流量</div>
|
<div class="three wide column">{{tr "NetTransfer"}}</div>
|
||||||
<div class="thirteen wide column">
|
<div class="thirteen wide column">
|
||||||
<i class="arrow circle down icon"></i>
|
<i class="arrow circle down icon"></i>
|
||||||
@#formatByteSize(server.State.NetInTransfer)#@
|
@#formatByteSize(server.State.NetInTransfer)#@
|
||||||
@ -98,7 +98,7 @@
|
|||||||
<i class="arrow circle up icon"></i>
|
<i class="arrow circle up icon"></i>
|
||||||
@#formatByteSize(server.State.NetOutTransfer)#@
|
@#formatByteSize(server.State.NetOutTransfer)#@
|
||||||
</div>
|
</div>
|
||||||
<div class="three wide column">信息</div>
|
<div class="three wide column">{{tr "Stat"}}</div>
|
||||||
<div class="thirteen wide column">
|
<div class="thirteen wide column">
|
||||||
<i class="bi bi-cpu-fill" style="font-size: 1.1rem; color: #4a86e8;"></i> @#getCoreAndGHz(server.Host.CPU)#@
|
<i class="bi bi-cpu-fill" style="font-size: 1.1rem; color: #4a86e8;"></i> @#getCoreAndGHz(server.Host.CPU)#@
|
||||||
|
|
||||||
@ -138,6 +138,7 @@
|
|||||||
delimiters: ['@#', '#@'],
|
delimiters: ['@#', '#@'],
|
||||||
data: {
|
data: {
|
||||||
page: 'index',
|
page: 'index',
|
||||||
|
defaultTemplate: {{.Conf.Site.Theme}},
|
||||||
templates: {{.Themes}},
|
templates: {{.Themes}},
|
||||||
data: [],
|
data: [],
|
||||||
groups: [],
|
groups: [],
|
||||||
|
1
resource/template/theme-default/network.html
vendored
1
resource/template/theme-default/network.html
vendored
@ -36,6 +36,7 @@
|
|||||||
delimiters: ['@#', '#@'],
|
delimiters: ['@#', '#@'],
|
||||||
data: {
|
data: {
|
||||||
page: 'network',
|
page: 'network',
|
||||||
|
defaultTemplate: {{.Conf.Site.Theme}},
|
||||||
templates: {{.Themes}},
|
templates: {{.Themes}},
|
||||||
servers: initData,
|
servers: initData,
|
||||||
option: {
|
option: {
|
||||||
|
1
resource/template/theme-default/service.html
vendored
1
resource/template/theme-default/service.html
vendored
@ -87,6 +87,7 @@
|
|||||||
delimiters: ['@#', '#@'],
|
delimiters: ['@#', '#@'],
|
||||||
data: {
|
data: {
|
||||||
page: 'service',
|
page: 'service',
|
||||||
|
defaultTemplate: {{.Conf.Site.Theme}},
|
||||||
templates: {{.Themes}}
|
templates: {{.Themes}}
|
||||||
},
|
},
|
||||||
mixins: [mixinsVue]
|
mixins: [mixinsVue]
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.4.1/dist/js/bootstrap.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.4.1/dist/js/bootstrap.min.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14"></script>
|
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/echarts@5.5.0/dist/echarts.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/echarts@5.5.0/dist/echarts.min.js"></script>
|
||||||
<script src="/static/theme-server-status/js/mixin.js?v20240225"></script>
|
<script src="/static/theme-server-status/js/mixin.js?v20240226"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
{{end}}
|
{{end}}
|
@ -22,6 +22,7 @@
|
|||||||
delimiters: ['@#', '#@'],
|
delimiters: ['@#', '#@'],
|
||||||
data: {
|
data: {
|
||||||
page: 'index',
|
page: 'index',
|
||||||
|
defaultTemplate: {{.Conf.Site.Theme}},
|
||||||
templates: {{.Themes}},
|
templates: {{.Themes}},
|
||||||
nodesTag: [],
|
nodesTag: [],
|
||||||
nodesNoTag: [],
|
nodesNoTag: [],
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
delimiters: ['@#', '#@'],
|
delimiters: ['@#', '#@'],
|
||||||
data: {
|
data: {
|
||||||
page: 'network',
|
page: 'network',
|
||||||
|
defaultTemplate: {{.Conf.Site.Theme}},
|
||||||
templates: {{.Themes}},
|
templates: {{.Themes}},
|
||||||
servers: initData,
|
servers: initData,
|
||||||
option: {
|
option: {
|
||||||
|
@ -78,6 +78,7 @@
|
|||||||
delimiters: ['@#', '#@'],
|
delimiters: ['@#', '#@'],
|
||||||
data: {
|
data: {
|
||||||
page: 'service',
|
page: 'service',
|
||||||
|
defaultTemplate: {{.Conf.Site.Theme}},
|
||||||
templates: {{.Themes}},
|
templates: {{.Themes}},
|
||||||
servicesTag: [],
|
servicesTag: [],
|
||||||
servicesNoTag: [],
|
servicesNoTag: [],
|
||||||
|
Loading…
Reference in New Issue
Block a user