angel-kanade模版增加主题切换功能 (#329)

This commit is contained in:
nap0o 2024-02-27 07:42:56 -05:00 committed by GitHub
parent 8033c6a0b7
commit 8e67d3487e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 129 additions and 109 deletions

View File

@ -1,4 +1,5 @@
{{define "theme-angel-kanade/footer"}} {{define "theme-angel-kanade/footer"}}
</div>
<div class="ui inverted vertical footer segment"> <div class="ui inverted vertical footer segment">
<div class="ui center aligned is-size-7 container"> <div class="ui center aligned is-size-7 container">
<b>&copy; <a style="color: white;" href="/">{{.Conf.Site.Brand}}</a></b> | <b>&copy; <a style="color: white;" href="/">{{.Conf.Site.Brand}}</a></b> |
@ -13,12 +14,12 @@
<script src="/static/semantic-ui-alerts.min.js"></script> <script src="/static/semantic-ui-alerts.min.js"></script>
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/vue/2.6.14/vue.min.js"></script> <script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/vue/2.6.14/vue.min.js"></script>
<script src="/static/main.js?v20240224"></script> <script src="/static/main.js?v20240224"></script>
<script src="/static/theme-default/js/mixin.js?v20240226"></script>
<script> <script>
(function () { (function () {
updateLang({{.LANG }}); updateLang({{.LANG }});
})(); })();
</script> </script>
</body> </body>
</html> </html>
{{end}} {{end}}

View File

@ -4,7 +4,6 @@
{{template "theme-angel-kanade/menu" .}} {{template "theme-angel-kanade/menu" .}}
<div class="nb-container"> <div class="nb-container">
<div class="ui container"> <div class="ui container">
<div id="app">
<div class="ui styled fluid accordion" v-for="group in groups"> <div class="ui styled fluid accordion" v-for="group in groups">
<div class="active title"> <div class="active title">
<i class="dropdown icon"></i> <i class="dropdown icon"></i>
@ -121,7 +120,6 @@
</div> </div>
</div> </div>
</div> </div>
</div>
{{template "theme-angel-kanade/footer" .}} {{template "theme-angel-kanade/footer" .}}
<script> <script>
const initData = JSON.parse('{{.Servers}}').servers; const initData = JSON.parse('{{.Servers}}').servers;
@ -129,10 +127,13 @@
el: '#app', el: '#app',
delimiters: ['@#', '#@'], delimiters: ['@#', '#@'],
data: { data: {
defaultTemplate: {{.Conf.Site.Theme}},
templates: {{.Themes}},
data: initData, data: initData,
groups: [], groups: [],
cache: [], cache: [],
}, },
mixins: [mixinsVue],
created() { created() {
this.group() this.group()
}, },

View File

@ -1,4 +1,5 @@
{{define "theme-angel-kanade/menu"}} {{define "theme-angel-kanade/menu"}}
<div id="app">
<div class="ui large top fixed menu nb-menu"> <div class="ui large top fixed menu nb-menu">
<div class="ui container"> <div class="ui container">
<a class="item" href="/"> <a class="item" href="/">
@ -15,6 +16,14 @@
{{else}} {{else}}
<a class='item{{if eq .MatchedPath "/"}} active{{end}}' href="/"><i class="home icon"></i>{{tr "Home"}}</a> <a class='item{{if eq .MatchedPath "/"}} active{{end}}' href="/"><i class="home icon"></i>{{tr "Home"}}</a>
<a class='item{{if eq .MatchedPath "/service"}} active{{end}}' href="/service"><i class="rss icon"></i>{{tr "Services"}}</a> <a class='item{{if eq .MatchedPath "/service"}} active{{end}}' href="/service"><i class="rss icon"></i>{{tr "Services"}}</a>
<div class="item ui simple dropdown">
<div class="text"><i class="bi bi-incognito icon" style="margin-right:3px;"></i>{{tr "Template" }}<i class="dropdown icon" style="margin-right:0px;"></i></div>
<div class="menu">
<a v-for="(value, key) in templates" :key="key" @click="toggleTemplate(key)" class="item"><i class="th large icon"></i>@#value#@
<i class="check icon" v-if="preferredTemplate === key"></i>
</a>
</div>
</div>
{{end}} {{end}}
<div class="right menu"> <div class="right menu">
<div class="item"> <div class="item">

View File

@ -76,10 +76,20 @@
{{end}} {{end}}
</tbody> </tbody>
</table> </table>
{{end}} {{end}}
</div> </div>
</div> </div>
</div> </div>
{{template "theme-angel-kanade/footer" .}} {{template "theme-angel-kanade/footer" .}}
<script>
new Vue({
el: '#app',
delimiters: ['@#', '#@'],
data: {
defaultTemplate: {{.Conf.Site.Theme}},
templates: {{.Themes}}
},
mixins: [mixinsVue]
})
</script>
{{end}} {{end}}

View File

@ -12,7 +12,7 @@
<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?v2024022601"> <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>

View File

@ -145,7 +145,6 @@
cache: [], cache: [],
chartDataList: [], chartDataList: [],
activePopup: null, activePopup: null,
}, },
mixins: [mixinsVue], mixins: [mixinsVue],
created() { created() {

View File

@ -24,17 +24,18 @@
page: 'index', page: 'index',
defaultTemplate: {{.Conf.Site.Theme}}, defaultTemplate: {{.Conf.Site.Theme}},
templates: {{.Themes}}, templates: {{.Themes}},
servers: [],
nodesTag: [], nodesTag: [],
nodesNoTag: [], nodesNoTag: [],
chartDataList: [] chartDataList: []
}, },
mixins: [mixinsVue], mixins: [mixinsVue],
created() { created() {
initData = JSON.parse('{{.Servers}}').servers; this.servers = JSON.parse('{{.Servers}}').servers;
if(this.showGroup) { if(this.showGroup) {
this.nodesTag = this.groupingData(this.handleNodes(initData),"Tag"); this.nodesTag = this.groupingData(this.handleNodes(this.servers),"Tag");
} else { } else {
this.nodesNoTag = this.handleNodes(initData); this.nodesNoTag = this.handleNodes(this.servers);
} }
}, },
mounted() { mounted() {
@ -367,8 +368,7 @@
chart.setOption(option); chart.setOption(option);
}, },
reloadCharts() { // 重新加载所有图表 reloadCharts() { // 重新加载所有图表
const data = JSON.parse('{{.Servers}}').servers; this.servers.forEach(node => {
data.forEach(node => {
const id = node.ID; const id = node.ID;
const chartData = this.chartDataList[id - 1]; const chartData = this.chartDataList[id - 1];
if (chartData) { if (chartData) {