duqing2026 commited on
Commit
10e0072
·
1 Parent(s): 847febc

feat: enhance functionality with reset button, better defaults and gunicorn

Browse files
Files changed (4) hide show
  1. .gitignore +5 -0
  2. Dockerfile +1 -1
  3. static/js/app.js +12 -3
  4. templates/index.html +8 -5
.gitignore ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ __pycache__/
2
+ *.pyc
3
+ .DS_Store
4
+ .env
5
+ venv/
Dockerfile CHANGED
@@ -16,4 +16,4 @@ ENV HOME=/home/user \
16
 
17
  EXPOSE 7860
18
 
19
- CMD ["python", "app.py"]
 
16
 
17
  EXPOSE 7860
18
 
19
+ CMD ["gunicorn", "-b", "0.0.0.0:7860", "app:app"]
static/js/app.js CHANGED
@@ -12,7 +12,7 @@ const app = createApp({
12
  { id: 'performance', name: '性能优化', icon: 'fa-solid fa-gauge-high' }
13
  ];
14
 
15
- const config = ref({
16
  port: 80,
17
  serverName: 'example.com',
18
  root: '/var/www/html',
@@ -29,7 +29,15 @@ const app = createApp({
29
  { path: '/', proxyPass: '', websocket: false, tryFiles: '$uri $uri/ /index.html' },
30
  { path: '/api', proxyPass: 'http://localhost:3000', websocket: false, tryFiles: '' }
31
  ]
32
- });
 
 
 
 
 
 
 
 
33
 
34
  const addLocation = () => {
35
  config.value.locations.push({ path: '/new-path', proxyPass: 'http://localhost:8080', websocket: false, tryFiles: '' });
@@ -151,7 +159,8 @@ const app = createApp({
151
  removeLocation,
152
  generatedConfig,
153
  copyConfig,
154
- downloadConfig
 
155
  };
156
  }
157
  });
 
12
  { id: 'performance', name: '性能优化', icon: 'fa-solid fa-gauge-high' }
13
  ];
14
 
15
+ const defaultConfig = {
16
  port: 80,
17
  serverName: 'example.com',
18
  root: '/var/www/html',
 
29
  { path: '/', proxyPass: '', websocket: false, tryFiles: '$uri $uri/ /index.html' },
30
  { path: '/api', proxyPass: 'http://localhost:3000', websocket: false, tryFiles: '' }
31
  ]
32
+ };
33
+
34
+ const config = ref(JSON.parse(JSON.stringify(defaultConfig)));
35
+
36
+ const resetConfig = () => {
37
+ if(confirm('确定要重置配置吗?')) {
38
+ config.value = JSON.parse(JSON.stringify(defaultConfig));
39
+ }
40
+ };
41
 
42
  const addLocation = () => {
43
  config.value.locations.push({ path: '/new-path', proxyPass: 'http://localhost:8080', websocket: false, tryFiles: '' });
 
159
  removeLocation,
160
  generatedConfig,
161
  copyConfig,
162
+ downloadConfig,
163
+ resetConfig
164
  };
165
  }
166
  });
templates/index.html CHANGED
@@ -4,12 +4,12 @@
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Nginx 配置大师 | Nginx Config Studio</title>
7
- <script src="https://lib.baomitu.com/vue/3.3.4/vue.global.prod.min.js"></script>
8
  <script src="https://cdn.tailwindcss.com"></script>
9
- <link href="https://lib.baomitu.com/prism/1.29.0/themes/prism-tomorrow.min.css" rel="stylesheet" />
10
- <script src="https://lib.baomitu.com/prism/1.29.0/prism.min.js"></script>
11
- <script src="https://lib.baomitu.com/prism/1.29.0/components/prism-nginx.min.js"></script>
12
- <link href="https://lib.baomitu.com/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
13
  <style>
14
  body { font-family: 'Inter', system-ui, -apple-system, sans-serif; }
15
  .code-preview { max-height: calc(100vh - 200px); overflow-y: auto; }
@@ -25,6 +25,9 @@
25
  <h1 class="text-xl font-bold tracking-wide">Nginx Config Studio <span class="text-xs bg-green-900 text-green-300 px-2 py-0.5 rounded ml-2">v1.0</span></h1>
26
  </div>
27
  <div class="flex items-center gap-4">
 
 
 
28
  <button @click="copyConfig" class="bg-gray-700 hover:bg-gray-600 text-white px-4 py-2 rounded-lg text-sm transition flex items-center gap-2">
29
  <i class="fa-solid fa-copy"></i> 复制配置
30
  </button>
 
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Nginx 配置大师 | Nginx Config Studio</title>
7
+ <script src="https://cdn.jsdelivr.net/npm/vue@3/dist/vue.global.prod.js"></script>
8
  <script src="https://cdn.tailwindcss.com"></script>
9
+ <link href="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/themes/prism-tomorrow.min.css" rel="stylesheet" />
10
+ <script src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/prism.min.js"></script>
11
+ <script src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/components/prism-nginx.min.js"></script>
12
+ <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
13
  <style>
14
  body { font-family: 'Inter', system-ui, -apple-system, sans-serif; }
15
  .code-preview { max-height: calc(100vh - 200px); overflow-y: auto; }
 
25
  <h1 class="text-xl font-bold tracking-wide">Nginx Config Studio <span class="text-xs bg-green-900 text-green-300 px-2 py-0.5 rounded ml-2">v1.0</span></h1>
26
  </div>
27
  <div class="flex items-center gap-4">
28
+ <button @click="resetConfig" class="bg-red-600 hover:bg-red-500 text-white px-4 py-2 rounded-lg text-sm transition flex items-center gap-2">
29
+ <i class="fa-solid fa-rotate-left"></i> 重置
30
+ </button>
31
  <button @click="copyConfig" class="bg-gray-700 hover:bg-gray-600 text-white px-4 py-2 rounded-lg text-sm transition flex items-center gap-2">
32
  <i class="fa-solid fa-copy"></i> 复制配置
33
  </button>