forked from xizeyoupan/Meting-API
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
151 lines (143 loc) · 6 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import api from './src/service/api.js'
import { handler, docs } from './src/template.js'
import { Hono } from 'hono'
import { logger } from 'hono/logger'
import { cors } from 'hono/cors'
import config from './src/config.js'
import { get_runtime, get_url } from './src/util.js'
const app = new Hono()
app.use('*', cors())
app.use('*', logger())
app.get('/api', api)
app.get('/test', handler)
app.get('/docs', docs)
app.get('/', (c) => {
return c.html(`
<!doctype html>
<html lang="zh-CN" id="htmlid">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>[在线]小关のMeting...</title>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/zui.css">
</head>
<body>
<style>
.tag { padding: 5px; margin: 5px; }
.v-card { padding: 5px; margin: 5px; display: flex; }
.panel { padding: 5px; margin: 10px; height: 100px; width: 550px; }
.style-group { position: fixed; right: 30px; top: 30px }
@media (max-width: 629px) { .style-group { position: fixed; right: auto; top: auto; bottom: 20px; left: 45vw; justify-content: center; } }
</style>
<h1 style="padding: 30px;">Meting API</h1>
<div class="btn-group style-group">
<button class="btn" type="button" onclick="style_light()"><i class="icon icon-sun"></i></button>
<button class="btn" type="button" onclick="style_dark()"><i class="icon icon-moon"></i></button>
<button class="btn active" type="button" onclick="style_auto()"><i class="icon icon-desktop"></i></button>
</div>
<div style="margin: 20px;">
<div style="display: flex;">
<a href="https://github.com/xiaoguan-dot/Meting-API" style="text-decoration: none;"><img alt="Github@xiaoguan-dot/Meting-API Static Badge"
src="https://img.shields.io/badge/Github-Meting-green" class="tag"></a>
<a href="https://github.com/xiaoguan-dot/Meting-API" style="text-decoration: none;"><img alt="Github@xiaoguan-dot/Meting-API forks"
src="https://img.shields.io/github/forks/xiaoguan-dot/Meting-API" class="tag"></a>
<a href="https://github.com/xiaoguan-dot/Meting-API" style="text-decoration: none;"><img alt="Github@xiaoguan-dot/Meting-API Repo stars"
src="https://img.shields.io/github/stars/xiaoguan-dot/Meting-API" class="tag"></a>
</div>
<div class="v-card">
<div class="panel">
<div class="panel-heading">
<div class="panel-title">当前版本</div>
</div>
<div class="panel-body">
<p>1.0.8</p>
</div>
</div>
<div class="panel">
<div class="panel-heading">
<div class="panel-title">当前运行环境</div>
</div>
<div class="panel-body">
<p>${get_runtime()}</p>
</div>
</div>
<div class="panel">
<div class="panel-heading">
<div class="panel-title">当前时间</div>
</div>
<div class="panel-body">
<p>${new Date()}</p>
</div>
</div>
</div>
<div class="v-card">
<div class="panel">
<div class="panel-heading">
<div class="panel-title">内部端口</div>
</div>
<div class="panel-body">
<p>${config.PORT}</p>
</div>
</div>
<div class="panel">
<div class="panel-heading">
<div class="panel-title">部署在大陆</div>
</div>
<div class="panel-body">
<p>${config.OVERSEAS ? 'N O' : 'Y E S'}</p>
</div>
</div>
<div class="panel">
<div class="panel-heading">
<div class="panel-title">当前地址 / 实际地址</div>
</div>
<div class="panel-body">
<a href="${c.req.url}">当前地址 ${c.req.url}</a>
<br>
<a href="${get_url(c)}">实际地址 ${get_url(c)}</a>
</div>
</div>
</div>
<div class="v-card">
<div class="panel">
<div class="panel-heading">
<div class="panel-title">文档地址</div>
</div>
<div class="panel-body">
<a href="${get_url(c) + 'docs'}">${get_url(c) + 'docs'}</a>
</div>
</div>
<div class="panel">
<div class="panel-heading">
<div class="panel-title">测试地址</div>
</div>
<div class="panel-body">
<a href="${get_url(c) + 'test'}">${get_url(c) + 'test'}</a>
</div>
</div>
<div class="panel">
<div class="panel-heading">
<div class="panel-title">api地址</div>
</div>
<div class="panel-body">
<a href="${get_url(c) + 'api'}">${get_url(c) + 'api'}</a>
</div>
</div>
</div>
<script src="https://unpkg.com/[email protected]/dist/zui.js"></script>
</body>
<!-- 暗色主题判断 -->
<script>let isDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches; let element = document.getElementById('htmlid'); element.classList.toggle('dark', isDarkMode); element.classList.toggle('light', !isDarkMode);</script>
<!-- 主题设置 -->
<script>
// 自动
function style_auto() {let isDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches; let element = document.getElementById('htmlid'); element.classList.toggle('dark', isDarkMode); element.classList.toggle('light', !isDarkMode);}
// 暗色
function style_dark() {let element = document.getElementById('htmlid').className = "dark";}
// 亮色
function style_light(){let element = document.getElementById('htmlid').className = "light";}
</script>
</html>`
)
})
export default app