mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 05:31:44 +08:00
feat: 优化默认文件
This commit is contained in:
@@ -238,9 +238,6 @@ func (r *websiteRepo) List(page, limit uint) ([]*biz.Website, int64, error) {
|
||||
func (r *websiteRepo) Create(req *request.WebsiteCreate) (*biz.Website, error) {
|
||||
// 初始化nginx配置
|
||||
config := nginx.DefaultConf
|
||||
if app.Locale == "zh_CN" {
|
||||
config = nginx.DefaultConfZh
|
||||
}
|
||||
p, err := nginx.NewParser(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -294,9 +291,12 @@ func (r *websiteRepo) Create(req *request.WebsiteCreate) (*biz.Website, error) {
|
||||
return nil, err
|
||||
}
|
||||
var index []byte
|
||||
if app.Locale == "zh_CN" {
|
||||
index, err = embed.WebsiteFS.ReadFile(filepath.Join("website", "index_zh.html"))
|
||||
} else {
|
||||
switch app.Locale {
|
||||
case "zh_CN":
|
||||
index, err = embed.WebsiteFS.ReadFile(filepath.Join("website", "index_zh_CN.html"))
|
||||
case "zh_TW":
|
||||
index, err = embed.WebsiteFS.ReadFile(filepath.Join("website", "index_zh_TW.html"))
|
||||
default:
|
||||
index, err = embed.WebsiteFS.ReadFile(filepath.Join("website", "index.html"))
|
||||
}
|
||||
if err != nil {
|
||||
@@ -306,9 +306,12 @@ func (r *websiteRepo) Create(req *request.WebsiteCreate) (*biz.Website, error) {
|
||||
return nil, err
|
||||
}
|
||||
var notFound []byte
|
||||
if app.Locale == "zh_CN" {
|
||||
notFound, err = embed.WebsiteFS.ReadFile(filepath.Join("website", "404_zh.html"))
|
||||
} else {
|
||||
switch app.Locale {
|
||||
case "zh_CN":
|
||||
notFound, err = embed.WebsiteFS.ReadFile(filepath.Join("website", "404_zh_CN.html"))
|
||||
case "zh_TW":
|
||||
notFound, err = embed.WebsiteFS.ReadFile(filepath.Join("website", "404_zh_TW.html"))
|
||||
default:
|
||||
notFound, err = embed.WebsiteFS.ReadFile(filepath.Join("website", "404.html"))
|
||||
}
|
||||
if err != nil {
|
||||
@@ -632,9 +635,6 @@ func (r *websiteRepo) ResetConfig(id uint) error {
|
||||
|
||||
// 初始化nginx配置
|
||||
config := nginx.DefaultConf
|
||||
if app.Locale == "zh_CN" {
|
||||
config = nginx.DefaultConfZh
|
||||
}
|
||||
p, err := nginx.NewParser(config)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html lang="zh-Hans">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
@@ -9,7 +9,7 @@
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>Not Found</h1>
|
||||
<p>请求的 URL 在此服务器上未找到。</p>
|
||||
<p>在此服务器上未找到请求的 URL。</p>
|
||||
<p>如果您是手动输入的 URL 请检查拼写并重试。</p>
|
||||
<p><em>由 <a target="_blank" href="https://acepanel.net">AcePanel</a> 强力驱动</em></p>
|
||||
</div>
|
||||
17
pkg/embed/website/404_zh_TW.html
Normal file
17
pkg/embed/website/404_zh_TW.html
Normal file
@@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-Hant">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>404 Not Found</title>
|
||||
<style>body{background:#f2f3f5;margin:0;padding:20px;font-family:system-ui,sans-serif}.container{max-width:600px;margin:3em auto;background:#fff;padding:40px;border-radius:12px;box-shadow:0 4px 12px rgba(0,0,0,.05)}h1{font-size:3em;font-weight:600;margin:0 0 30px;color:#1a1a1a}p{color:#5a5a5a;line-height:1.6}a{text-decoration:none;color:#333;font-weight:600}</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>Not Found</h1>
|
||||
<p>在此伺服器上找不到請求的 URL。</p>
|
||||
<p>如果您是手動輸入的 URL 請檢查拼寫並重試。</p>
|
||||
<p><em>由 <a target="_blank" href="https://acepanel.net">AcePanel</a> 技術支援</em></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<html lang="zh-Hans">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
@@ -10,7 +10,7 @@
|
||||
<div class="container">
|
||||
<h1>AcePanel</h1>
|
||||
<p>这是 AcePanel 的网站默认页面!</p>
|
||||
<p>当您看到此页面,说明您的网站已创建成功。</p>
|
||||
<p>当您看到此页面时,说明您的网站已创建成功。</p>
|
||||
<p><em>由 <a target="_blank" href="https://acepanel.net">AcePanel</a> 强力驱动</em></p>
|
||||
</div>
|
||||
</body>
|
||||
17
pkg/embed/website/index_zh_TW.html
Normal file
17
pkg/embed/website/index_zh_TW.html
Normal file
@@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-Hant">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>AcePanel</title>
|
||||
<style>body{background:#f2f3f5;margin:0;padding:20px;font-family:system-ui,sans-serif}.container{max-width:600px;margin:3em auto;background:#fff;padding:40px;border-radius:12px;box-shadow:0 4px 12px rgba(0,0,0,.05)}h1{font-size:3em;font-weight:600;margin:0 0 30px;color:#1a1a1a}p{color:#5a5a5a;line-height:1.6}a{text-decoration:none;color:#333;font-weight:600}</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>AcePanel</h1>
|
||||
<p>這是 AcePanel 的網站預設頁面!</p>
|
||||
<p>當您看到此頁面時,表示您的網站已成功建立。</p>
|
||||
<p><em>由 <a target="_blank" href="https://acepanel.net">AcePanel</a> 技術支援</em></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -7,12 +7,12 @@ var order = []string{"listen", "server_name", "index", "root",
|
||||
const DefaultConf = `server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
index index.php index.html index.htm;
|
||||
index index.php index.html;
|
||||
root /www/wwwroot/default;
|
||||
# Error page configuration
|
||||
# Error page
|
||||
error_page 404 /404.html;
|
||||
include enable-php-0.conf;
|
||||
# Do not log static files
|
||||
# Browser cache
|
||||
location ~ .*\.(bmp|jpg|jpeg|png|gif|svg|ico|tiff|webp|avif|heif|heic|jxl)$ {
|
||||
expires 30d;
|
||||
access_log /dev/null;
|
||||
@@ -23,35 +23,7 @@ const DefaultConf = `server {
|
||||
access_log /dev/null;
|
||||
error_log /dev/null;
|
||||
}
|
||||
# Deny some sensitive directories
|
||||
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.env) {
|
||||
return 404;
|
||||
}
|
||||
access_log /www/wwwlogs/default.log;
|
||||
error_log /www/wwwlogs/default.log;
|
||||
}
|
||||
`
|
||||
|
||||
const DefaultConfZh = `server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
index index.php index.html index.htm;
|
||||
root /www/wwwroot/default;
|
||||
# 错误页配置
|
||||
error_page 404 /404.html;
|
||||
include enable-php-0.conf;
|
||||
# 不记录静态文件日志
|
||||
location ~ .*\.(bmp|jpg|jpeg|png|gif|svg|ico|tiff|webp|avif|heif|heic|jxl)$ {
|
||||
expires 30d;
|
||||
access_log /dev/null;
|
||||
error_log /dev/null;
|
||||
}
|
||||
location ~ .*\.(js|css|ttf|otf|woff|woff2|eot)$ {
|
||||
expires 6h;
|
||||
access_log /dev/null;
|
||||
error_log /dev/null;
|
||||
}
|
||||
# 禁止部分敏感目录
|
||||
# Deny sensitive files
|
||||
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.env) {
|
||||
return 404;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user