Skip to content

Commit

Permalink
Merge pull request #1 from lyy0709/master
Browse files Browse the repository at this point in the history
重写了一下setup页面
  • Loading branch information
gcslaoli authored Apr 16, 2024
2 parents cf1a1d9 + 20ac989 commit 98948ce
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 26 deletions.
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
# 从 builder 镜像中复制应用到当前镜像中
COPY --from=builder /app/main /app/main

# 从 builder 镜像中复制应用到当前镜像中
COPY --from=builder /app/resource /app/resource

# 指定环境变量 TZ,你可以在运行 Docker 容器时通过 -e 参数来覆盖这个值
ENV TZ=Asia/Shanghai

# 指定容器启动时运行的命令
ENTRYPOINT ["/app/main"]
ENTRYPOINT ["/app/main"]
14 changes: 13 additions & 1 deletion api/api.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package api

import "github.com/gogf/gf/v2/frame/g"
import (
"net/http"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
)

func init() {
s := g.Server()
Expand All @@ -24,9 +28,17 @@ func init() {
group.GET("/login", Login)
group.POST("/login", LoginPost)
group.GET("/auth/logout", AuthLogout)
group.ALL("/public-api/referral/invites/*any", NotFound) //禁用邀请
group.POST("/backend-api/accounts/data_export", NotFound) // 禁用导出
group.POST("/backend-api/payments/checkout", NotFound) // 禁用支付

}

// NotFound 404
func NotFound(r *ghttp.Request) {
r.Response.WriteStatus(http.StatusNotFound)
}

// Init initializes the api module.
func Init(ctx g.Ctx) {
g.Log().Info(ctx, "Api module initialized")
Expand Down
4 changes: 4 additions & 0 deletions api/proxyapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ func ProxyApi(r *ghttp.Request) {
header := r.Request.Header
header.Set("Origin", "https://chat.openai.com")
header.Set("Referer", "https://chat.openai.com/")
accessToken := config.GetAccessToken(ctx)
if accessToken != "" {
header.Set("Authorization", "Bearer "+ accessToken)
}
utils.HeaderModify(&r.Request.Header)

proxy.ServeHTTP(r.Response.RawWriter(), r.Request)
Expand Down
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: '3.8'
services:
cockroachai-v2:
image: lyy0709/cockroachai-v2:latest
ports:
- "9000:9315" #左侧为暴露的端口
volumes:
- ./config.yaml:/config.yaml
- ./resource:/app/resource
118 changes: 94 additions & 24 deletions resource/template/setup.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,110 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<title>表单页面</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<style>
body {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
background-color: #f5f5f5;
color: #333;
text-align: center;
padding-top: 100px;
margin: 0;
}
.login-container {
width: 100%;
max-width: 300px;
margin: auto;
background: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0px 0px 10px rgba(0,0,0,0.1);
}
.login-container h2 {
color: #333;
margin-bottom: 20px;
}
.form-field {
position: relative;
margin-bottom: 15px;
}
.password-container {
position: relative;
}

.field-icon {
position: absolute;
right: 10px;
top: 50%;
transform: translateY(-70%);
cursor: pointer;
}
input[type='text'], input[type='password'], textarea {
width: 100%;
box-sizing: border-box;
padding: 10px;
padding-right: 40px; /* 留出眼睛图标的空间 */
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 3px;
}
.btn {
background-color: #0A8852;
color: white;
border: none;
padding: 10px 15px;
text-align: center;
text-decoration: none;
display: block;
font-size: 16px;
margin: 10px 0;
cursor: pointer;
width: 100%;
border-radius: 5px;
}
@media (max-width: 768px) {
body {
padding-top: 50px;
}
}
</style>
</head>
<body>
<div class="container">
<h1 class="text-center mt-4">蟑螂账号管理</h1>
<div class="login-container">
<h2>蟑螂账号管理</h2>
<form action="" method="post">
<div class="form-group">
<label for="refreshCookie">Refresh Cookie</label>
<textarea class="form-control" id="refreshCookie" name="refreshCookie" rows="3"></textarea>
<div class="form-field">
<textarea id="refreshCookie" name="refreshCookie" placeholder="Refresh Cookie" rows="3"></textarea>
</div>
<div class="form-group">
<label for="adminPassword">管理员密码</label>
<input type="password" class="form-control" id="adminPassword" name="adminPassword">
<input type="checkbox" id="showPassword"> 显示密码
<div class="password-container">
<input type="password" id="adminPassword" name="adminPassword" placeholder="管理员密码">
<span id="eyeIcon" toggle="#adminPassword" class="far fa-eye-slash field-icon toggle-password"></span>
</div>
<button type="submit" class="btn btn-primary">确认</button>
<button type="reset" class="btn btn-secondary">清空</button>
<button type="submit" class="btn">确认</button>
<button type="reset" class="btn">清空</button>
</form>
<div id="result" class="mt-4">{{.result}}</div>

</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>

<script>
$(document).ready(function() {
$('#showPassword').change(function() {
if($(this).is(':checked')) {
$('#adminPassword').attr('type', 'text');
} else {
$('#adminPassword').attr('type', 'password');
}
});
function togglePasswordVisibility() {
var passwordInput = document.getElementById('adminPassword');
var eyeIcon = document.getElementById('eyeIcon');
if (passwordInput.type === 'password') {
passwordInput.type = 'text';
eyeIcon.classList.remove('fa-eye-slash');
eyeIcon.classList.add('fa-eye');
} else {
passwordInput.type = 'password';
eyeIcon.classList.remove('fa-eye');
eyeIcon.classList.add('fa-eye-slash');
}
}
document.addEventListener('DOMContentLoaded', function () {
var eyeIcon = document.getElementById('eyeIcon');
eyeIcon.addEventListener('click', togglePasswordVisibility);
});
</script>
</body>
</html>
</html>

0 comments on commit 98948ce

Please sign in to comment.