2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 03:07:20 +08:00

feat: 去掉nginx高亮,优化登录界面,解决时区和cookie问题

This commit is contained in:
耗子
2024-09-29 01:12:43 +08:00
parent e5f36df4bf
commit d4feba17d0
16 changed files with 45 additions and 328 deletions

View File

@@ -18,6 +18,7 @@ package main
import (
"github.com/TheTNB/panel/internal/bootstrap"
_ "time/tzdata"
)
func main() {

View File

@@ -16,7 +16,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package main
import "github.com/TheTNB/panel/internal/bootstrap"
import (
"github.com/TheTNB/panel/internal/bootstrap"
_ "time/tzdata"
)
// @title 耗子面板 API
// @version 2

View File

@@ -1,12 +1,17 @@
# 警告:未经指导私自修改此配置文件可能导致严重后果
# Warning: Modifying this configuration file without guidance may cause serious consequences
app:
key: "a-long-string-with-32-characters"
locale: "zh_CN"
timezone: "Asia/Shanghai"
version: "2.3.0"
root: "/www"
http:
debug: true
debug: false
address: ":3000"
entrance: "/"
ssl: false
database:
debug: true
debug: false

2
go.mod
View File

@@ -15,7 +15,7 @@ require (
github.com/go-playground/validator/v10 v10.22.1
github.com/go-rat/chix v1.1.3
github.com/go-rat/gormstore v1.0.6
github.com/go-rat/sessions v1.0.9
github.com/go-rat/sessions v1.0.11
github.com/go-rat/utils v1.0.3
github.com/go-resty/resty/v2 v2.15.3
github.com/go-sql-driver/mysql v1.8.1

4
go.sum
View File

@@ -116,8 +116,8 @@ github.com/go-rat/gormstore v1.0.6 h1:YxmaY6n3JoTk6o9RXoZ1+cQ6HQL+ayf/6d8D76ydCA
github.com/go-rat/gormstore v1.0.6/go.mod h1:xG/n+Du8baWf7ptiafiHLWBZWVXrYIPC42CsoEbfr4M=
github.com/go-rat/securecookie v1.0.1 h1:HW0fpKmB+FjJzXTw8ABOwBJ+XrPmRBSZqHhmrv86lBo=
github.com/go-rat/securecookie v1.0.1/go.mod h1:tP/ObWYyjmcpabQ7WTon/i2lBSip/Aolliw2llXuPDU=
github.com/go-rat/sessions v1.0.9 h1:zysrHceTFqyc0qUWn5giLGdbfr/DYHXvFECDBSyv9Gk=
github.com/go-rat/sessions v1.0.9/go.mod h1:Ray/GCbuhm4U9xpjFFSCfOTCEn91puEhAXX5creHE9g=
github.com/go-rat/sessions v1.0.11 h1:2eTUvhEBtymrAtwv71LlGHNylz+Ad2SgY3jg/sSUboA=
github.com/go-rat/sessions v1.0.11/go.mod h1:Ray/GCbuhm4U9xpjFFSCfOTCEn91puEhAXX5creHE9g=
github.com/go-rat/utils v1.0.3 h1:SqH/O0KYq4SBv8naSAjJA4hC45/d8NLNrTCONfqjbFM=
github.com/go-rat/utils v1.0.3/go.mod h1:4WNPlrF57KmeGZN3HOeBgdBVLJL3xgba4QRP/t6pKrE=
github.com/go-resty/resty/v2 v2.15.3 h1:bqff+hcqAflpiF591hhJzNdkRsFhlB96CYfBwSFvql8=

View File

@@ -2,6 +2,7 @@ package bootstrap
import (
"fmt"
"time"
"github.com/golang-module/carbon/v2"
"github.com/knadh/koanf/parsers/yaml"
@@ -22,6 +23,13 @@ func initGlobal() {
panel.Root = panel.Conf.MustString("app.root")
panel.Version = panel.Conf.MustString("app.version")
panel.Locale = panel.Conf.MustString("app.locale")
// 初始化时区
loc, err := time.LoadLocation(panel.Conf.MustString("app.timezone"))
if err != nil {
panic(fmt.Sprintf("failed to load timezone: %v", err))
}
time.Local = loc
carbon.SetDefault(carbon.Default{
Layout: carbon.DateTimeLayout,
Timezone: carbon.PRC,

View File

@@ -3,6 +3,7 @@ package route
import (
"io/fs"
"net/http"
"strings"
"time"
"github.com/go-chi/chi/v5"
@@ -269,7 +270,7 @@ func Http(r chi.Router) {
r.With(middleware.MustLogin).Mount("/swagger", httpSwagger.Handler())
r.NotFound(func(writer http.ResponseWriter, request *http.Request) {
// /api 开头的返回 404
if request.URL.Path[:4] == "/api" {
if strings.HasPrefix(request.URL.Path, "/api") {
http.NotFound(writer, request)
return
}

View File

@@ -30,7 +30,6 @@
"echarts": "^5.5.1",
"install": "^0.13.0",
"lodash-es": "^4.17.21",
"monaco-editor-nginx": "^2.0.2",
"pinia": "^2.2.2",
"vue": "^3.5.5",
"vue-echarts": "^7.0.3",

86
web/pnpm-lock.yaml generated
View File

@@ -38,9 +38,6 @@ importers:
lodash-es:
specifier: ^4.17.21
version: 4.17.21
monaco-editor-nginx:
specifier: ^2.0.2
version: 2.0.2(@babel/runtime@7.25.6)(@nginx/reference-lib@1.1.2)(monaco-editor@0.52.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
pinia:
specifier: ^2.2.2
version: 2.2.2(typescript@5.6.2)(vue@3.5.10(typescript@5.6.2))
@@ -173,10 +170,6 @@ packages:
engines: {node: '>=6.0.0'}
hasBin: true
'@babel/runtime@7.25.6':
resolution: {integrity: sha512-VBj9MYyDb9tuLq7yzqjgzt6Q+IBQLrGZfdjOekyEirZPHxXWoTSGUTMrpsfi58Up73d13NfYLv8HT9vmznjzhQ==}
engines: {node: '>=6.9.0'}
'@babel/types@7.25.6':
resolution: {integrity: sha512-/l42B1qxpG6RdfYf343Uw1vmDjeNhneUXtzhojE7pDgfpEypmRhI6j1kr17XCVv4Cgl9HdAiQY2x0GwKm7rWCw==}
engines: {node: '>=6.9.0'}
@@ -572,9 +565,6 @@ packages:
peerDependencies:
monaco-editor: '>= 0.21.0 < 1'
'@nginx/reference-lib@1.1.2':
resolution: {integrity: sha512-d8HeRHsIOPfVFOpDOi1XjiGxfYyyRmdPd+a+V9vDpyjBWGHVwSSOwzvuPGJtc4V4KK6ZfYHm15FD1etiKYS6vQ==}
'@nodelib/fs.scandir@2.1.5':
resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==}
engines: {node: '>= 8'}
@@ -631,46 +621,55 @@ packages:
resolution: {integrity: sha512-j63YtCIRAzbO+gC2L9dWXRh5BFetsv0j0va0Wi9epXDgU/XUi5dJKo4USTttVyK7fGw2nPWK0PbAvyliz50SCQ==}
cpu: [arm]
os: [linux]
libc: [glibc]
'@rollup/rollup-linux-arm-musleabihf@4.22.4':
resolution: {integrity: sha512-dJnWUgwWBX1YBRsuKKMOlXCzh2Wu1mlHzv20TpqEsfdZLb3WoJW2kIEsGwLkroYf24IrPAvOT/ZQ2OYMV6vlrg==}
cpu: [arm]
os: [linux]
libc: [musl]
'@rollup/rollup-linux-arm64-gnu@4.22.4':
resolution: {integrity: sha512-AdPRoNi3NKVLolCN/Sp4F4N1d98c4SBnHMKoLuiG6RXgoZ4sllseuGioszumnPGmPM2O7qaAX/IJdeDU8f26Aw==}
cpu: [arm64]
os: [linux]
libc: [glibc]
'@rollup/rollup-linux-arm64-musl@4.22.4':
resolution: {integrity: sha512-Gl0AxBtDg8uoAn5CCqQDMqAx22Wx22pjDOjBdmG0VIWX3qUBHzYmOKh8KXHL4UpogfJ14G4wk16EQogF+v8hmA==}
cpu: [arm64]
os: [linux]
libc: [musl]
'@rollup/rollup-linux-powerpc64le-gnu@4.22.4':
resolution: {integrity: sha512-3aVCK9xfWW1oGQpTsYJJPF6bfpWfhbRnhdlyhak2ZiyFLDaayz0EP5j9V1RVLAAxlmWKTDfS9wyRyY3hvhPoOg==}
cpu: [ppc64]
os: [linux]
libc: [glibc]
'@rollup/rollup-linux-riscv64-gnu@4.22.4':
resolution: {integrity: sha512-ePYIir6VYnhgv2C5Xe9u+ico4t8sZWXschR6fMgoPUK31yQu7hTEJb7bCqivHECwIClJfKgE7zYsh1qTP3WHUA==}
cpu: [riscv64]
os: [linux]
libc: [glibc]
'@rollup/rollup-linux-s390x-gnu@4.22.4':
resolution: {integrity: sha512-GqFJ9wLlbB9daxhVlrTe61vJtEY99/xB3C8e4ULVsVfflcpmR6c8UZXjtkMA6FhNONhj2eA5Tk9uAVw5orEs4Q==}
cpu: [s390x]
os: [linux]
libc: [glibc]
'@rollup/rollup-linux-x64-gnu@4.22.4':
resolution: {integrity: sha512-87v0ol2sH9GE3cLQLNEy0K/R0pz1nvg76o8M5nhMR0+Q+BBGLnb35P0fVz4CQxHYXaAOhE8HhlkaZfsdUOlHwg==}
cpu: [x64]
os: [linux]
libc: [glibc]
'@rollup/rollup-linux-x64-musl@4.22.4':
resolution: {integrity: sha512-UV6FZMUgePDZrFjrNGIWzDo/vABebuXBhJEqrHxrGiU6HikPy0Z3LfdtciIttEUQfuDdCn8fqh7wiFJjCNwO+g==}
cpu: [x64]
os: [linux]
libc: [musl]
'@rollup/rollup-win32-arm64-msvc@4.22.4':
resolution: {integrity: sha512-BjI+NVVEGAXjGWYHz/vv0pBqfGoUH0IGZ0cICTn7kB9PyjrATSkX+8WkguNjWoj2qSr1im/+tTGRaY+4/PdcQw==}
@@ -1594,9 +1593,6 @@ packages:
resolution: {integrity: sha512-CJ7e7Abb779OTRv3lomfp7Mns/Sy1+U4pcAx5VbjxCZD5ZM/VJaXPpPjNKjtSvWQy/H86E49REXR34dl1JEz9w==}
hasBin: true
js-tokens@4.0.0:
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
js-tokens@9.0.0:
resolution: {integrity: sha512-WriZw1luRMlmV3LGJaR6QOJjWwgLUTf89OwT2lUOyjX2dJGBwgmIkbcz+7WFZjrZM635JOIR517++e/67CP9dQ==}
@@ -1651,10 +1647,6 @@ packages:
lodash@4.17.21:
resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==}
loose-envify@1.4.0:
resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==}
hasBin: true
lower-case@2.0.2:
resolution: {integrity: sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==}
@@ -1702,15 +1694,6 @@ packages:
resolution: {integrity: sha512-eQsKcWzIaZzEZ07NuEyO4Nw65g0hdWAyurVol1IPl1gahRwY+svqzfgfey8U8dahLwG44d6/RwEzuK52rSa/JQ==}
hasBin: true
monaco-editor-nginx@2.0.2:
resolution: {integrity: sha512-F/qejb0w0hxIyxbu2JMCe+MhnOV7bxGbUynnyMXk7Cy25Na5fD99u5QqRr7WfRhIn0xcdhBEkJ/jikQsxVnEOA==}
peerDependencies:
'@babel/runtime': '>=7.10.0'
'@nginx/reference-lib': '>=1.1.0'
monaco-editor: '>=0.22.3'
react: '>=16.9.0'
react-dom: '>=16.9.0'
monaco-editor@0.52.0:
resolution: {integrity: sha512-OeWhNpABLCeTqubfqLMXGsqf6OmPU6pHM85kF3dhy6kq5hnhuVS1p3VrEW/XhWHc71P2tHyS5JFySD8mgs1crw==}
@@ -1901,15 +1884,6 @@ packages:
queue-microtask@1.2.3:
resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==}
react-dom@18.3.1:
resolution: {integrity: sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==}
peerDependencies:
react: ^18.3.1
react@18.3.1:
resolution: {integrity: sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==}
engines: {node: '>=0.10.0'}
read-package-json-fast@3.0.2:
resolution: {integrity: sha512-0J+Msgym3vrLOUB3hzQCuZHII0xkNGCtz/HJH9xZshwv9DbDwkw1KaE3gx/e2J5rpEY5rtOy6cyhKOPrkP7FZw==}
engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0}
@@ -1922,9 +1896,6 @@ packages:
resolution: {integrity: sha512-GkMg9uOTpIWWKbSsgwb5fA4EavTR+SG/PMPoAY8hkhHfEEY0/vqljY+XHqtDf2cr2IJtoNRDbrrEpZUiZCkYRw==}
engines: {node: '>= 14.16.0'}
regenerator-runtime@0.14.1:
resolution: {integrity: sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==}
relateurl@0.2.7:
resolution: {integrity: sha512-G08Dxvm4iDN3MLM0EsP62EDV9IuhXPR6blNz6Utcp7zyV3tr4HVNINt6MpaRWbxoOHT3Q7YN2P+jaHX8vUbgog==}
engines: {node: '>= 0.10'}
@@ -1972,9 +1943,6 @@ packages:
engines: {node: '>=14.0.0'}
hasBin: true
scheduler@0.23.2:
resolution: {integrity: sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==}
scule@1.3.0:
resolution: {integrity: sha512-6FtHJEvt+pVMIB9IBY+IcCJ6Z5f1iQnytgyfKMhDKgmzYG+TeH/wx1y3l27rshSbLiSanrR9ffZDrEsmjlQF2g==}
@@ -2400,10 +2368,6 @@ snapshots:
dependencies:
'@babel/types': 7.25.6
'@babel/runtime@7.25.6':
dependencies:
regenerator-runtime: 0.14.1
'@babel/types@7.25.6':
dependencies:
'@babel/helper-string-parser': 7.24.8
@@ -2668,8 +2632,6 @@ snapshots:
monaco-editor: 0.52.0
state-local: 1.0.7
'@nginx/reference-lib@1.1.2': {}
'@nodelib/fs.scandir@2.1.5':
dependencies:
'@nodelib/fs.stat': 2.0.5
@@ -3839,8 +3801,6 @@ snapshots:
jiti@2.0.0: {}
js-tokens@4.0.0: {}
js-tokens@9.0.0: {}
js-yaml@4.1.0:
@@ -3889,10 +3849,6 @@ snapshots:
lodash@4.17.21: {}
loose-envify@1.4.0:
dependencies:
js-tokens: 4.0.0
lower-case@2.0.2:
dependencies:
tslib: 2.7.0
@@ -3941,14 +3897,6 @@ snapshots:
dependencies:
commander: 12.1.0
monaco-editor-nginx@2.0.2(@babel/runtime@7.25.6)(@nginx/reference-lib@1.1.2)(monaco-editor@0.52.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1):
dependencies:
'@babel/runtime': 7.25.6
'@nginx/reference-lib': 1.1.2
monaco-editor: 0.52.0
react: 18.3.1
react-dom: 18.3.1(react@18.3.1)
monaco-editor@0.52.0: {}
mrmime@2.0.0: {}
@@ -4136,16 +4084,6 @@ snapshots:
queue-microtask@1.2.3: {}
react-dom@18.3.1(react@18.3.1):
dependencies:
loose-envify: 1.4.0
react: 18.3.1
scheduler: 0.23.2
react@18.3.1:
dependencies:
loose-envify: 1.4.0
read-package-json-fast@3.0.2:
dependencies:
json-parse-even-better-errors: 3.0.2
@@ -4157,8 +4095,6 @@ snapshots:
readdirp@4.0.1: {}
regenerator-runtime@0.14.1: {}
relateurl@0.2.7: {}
require-directory@2.1.1: {}
@@ -4214,10 +4150,6 @@ snapshots:
immutable: 4.3.7
source-map-js: 1.2.1
scheduler@0.23.2:
dependencies:
loose-envify: 1.4.0
scule@1.3.0: {}
seemly@0.3.8: {}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 406 KiB

View File

@@ -1,8 +1,5 @@
<script setup lang="ts">
import Editor from '@guolao/vue-monaco-editor'
import { themeConfig, themeDarkConfig, tokenConf } from 'monaco-editor-nginx/cjs/conf'
import suggestions from 'monaco-editor-nginx/cjs/suggestions'
import { directives } from 'monaco-editor-nginx/cjs/directives'
import file from '@/api/panel/file'
import { languageByPath } from '@/utils/file'
@@ -35,58 +32,6 @@ const save = async () => {
window.$message.success('保存成功')
}
const editorOnBeforeMount = (monaco: any) => {
monaco.languages.register({
id: 'nginx'
})
monaco.languages.setMonarchTokensProvider('nginx', tokenConf)
monaco.editor.defineTheme('nginx-theme', themeConfig)
monaco.editor.defineTheme('nginx-theme-dark', themeDarkConfig)
monaco.languages.registerCompletionItemProvider('nginx', {
provideCompletionItems: (model: any, position: any) => {
const word = model.getWordUntilPosition(position)
const range = {
startLineNumber: position.lineNumber,
endLineNumber: position.lineNumber,
startColumn: word.startColumn,
endColumn: word.endColumn
}
return { suggestions: suggestions(range) }
}
})
monaco.languages.registerHoverProvider('nginx', {
provideHover: (model: any, position: any) => {
const word = model.getWordAtPosition(position)
if (!word) return
const data = directives.find((item) => item.n === word.word || item.n === `$${word.word}`)
if (!data) return
const range = {
startLineNumber: position.lineNumber,
endLineNumber: position.lineNumber,
startColumn: word.startColumn,
endColumn: word.endColumn
}
const contents = [{ value: `**\`${data.n}\`** | ${data.m} | ${data.c || ''}` }]
if (data.s) {
contents.push({ value: `**syntax:** ${data.s || ''}` })
}
if (data.v) {
contents.push({ value: `**default:** ${data.v || ''}` })
}
if (data.d) {
contents.push({ value: `${data.d}` })
}
return {
contents: [...contents],
range: range
}
}
})
}
onMounted(() => {
get()
})
@@ -103,7 +48,6 @@ defineExpose({
:language="languageByPath(props.path!)"
theme="vs-dark"
height="60vh"
@before-mount="editorOnBeforeMount"
:options="{
automaticLayout: true,
formatOnType: true,

View File

@@ -80,10 +80,6 @@ const getIconByExt = (ext: string) => {
}
const languageByPath = (path: string) => {
if (path.startsWith('/www/server/openresty/')) {
return 'nginx'
}
const ext = getExt(path)
switch (ext) {
case 'abap':
@@ -148,6 +144,7 @@ const languageByPath = (path: string) => {
case 'htm': // html 扩展名
return 'html'
case 'ini':
case 'conf':
return 'ini'
case 'java':
return 'java'
@@ -272,7 +269,7 @@ const languageByPath = (path: string) => {
case 'yml': // yaml 扩展名
return 'yaml'
default:
return ''
return 'plaintext'
}
}

View File

@@ -3,9 +3,6 @@ import { NButton, NDataTable, NPopconfirm } from 'naive-ui'
import openresty from '@/api/apps/openresty'
import service from '@/api/panel/system/service'
import Editor from '@guolao/vue-monaco-editor'
import { themeConfig, themeDarkConfig, tokenConf } from 'monaco-editor-nginx/cjs/conf'
import suggestions from 'monaco-editor-nginx/cjs/suggestions'
import { directives } from 'monaco-editor-nginx/cjs/directives'
const currentTab = ref('status')
const status = ref(false)
@@ -103,58 +100,6 @@ const handleReload = async () => {
await getStatus()
}
const editorOnBeforeMount = (monaco: any) => {
monaco.languages.register({
id: 'nginx'
})
monaco.languages.setMonarchTokensProvider('nginx', tokenConf)
monaco.editor.defineTheme('nginx-theme', themeConfig)
monaco.editor.defineTheme('nginx-theme-dark', themeDarkConfig)
monaco.languages.registerCompletionItemProvider('nginx', {
provideCompletionItems: (model: any, position: any) => {
const word = model.getWordUntilPosition(position)
const range = {
startLineNumber: position.lineNumber,
endLineNumber: position.lineNumber,
startColumn: word.startColumn,
endColumn: word.endColumn
}
return { suggestions: suggestions(range) }
}
})
monaco.languages.registerHoverProvider('nginx', {
provideHover: (model: any, position: any) => {
const word = model.getWordAtPosition(position)
if (!word) return
const data = directives.find((item) => item.n === word.word || item.n === `$${word.word}`)
if (!data) return
const range = {
startLineNumber: position.lineNumber,
endLineNumber: position.lineNumber,
startColumn: word.startColumn,
endColumn: word.endColumn
}
const contents = [{ value: `**\`${data.n}\`** | ${data.m} | ${data.c || ''}` }]
if (data.s) {
contents.push({ value: `**syntax:** ${data.s || ''}` })
}
if (data.v) {
contents.push({ value: `**default:** ${data.v || ''}` })
}
if (data.d) {
contents.push({ value: `${data.d}` })
}
return {
contents: [...contents],
range: range
}
}
})
}
onMounted(() => {
getStatus()
getIsEnabled()
@@ -242,11 +187,10 @@ onMounted(() => {
</n-alert>
<Editor
v-model:value="config"
language="nginx"
theme="nginx-theme-dark"
language="ini"
theme="vs-dark"
height="60vh"
mt-8
@before-mount="editorOnBeforeMount"
:options="{
automaticLayout: true,
formatOnType: true,

View File

@@ -2,9 +2,6 @@
import { NButton } from 'naive-ui'
import phpmyadmin from '@/api/apps/phpmyadmin'
import Editor from '@guolao/vue-monaco-editor'
import { themeConfig, themeDarkConfig, tokenConf } from 'monaco-editor-nginx/cjs/conf'
import suggestions from 'monaco-editor-nginx/cjs/suggestions'
import { directives } from 'monaco-editor-nginx/cjs/directives'
const currentTab = ref('status')
const hostname = ref(window.location.hostname)
@@ -40,58 +37,6 @@ const handleSaveConfig = async () => {
window.$message.success('保存成功')
}
const editorOnBeforeMount = (monaco: any) => {
monaco.languages.register({
id: 'nginx'
})
monaco.languages.setMonarchTokensProvider('nginx', tokenConf)
monaco.editor.defineTheme('nginx-theme', themeConfig)
monaco.editor.defineTheme('nginx-theme-dark', themeDarkConfig)
monaco.languages.registerCompletionItemProvider('nginx', {
provideCompletionItems: (model: any, position: any) => {
const word = model.getWordUntilPosition(position)
const range = {
startLineNumber: position.lineNumber,
endLineNumber: position.lineNumber,
startColumn: word.startColumn,
endColumn: word.endColumn
}
return { suggestions: suggestions(range) }
}
})
monaco.languages.registerHoverProvider('nginx', {
provideHover: (model: any, position: any) => {
const word = model.getWordAtPosition(position)
if (!word) return
const data = directives.find((item) => item.n === word.word || item.n === `$${word.word}`)
if (!data) return
const range = {
startLineNumber: position.lineNumber,
endLineNumber: position.lineNumber,
startColumn: word.startColumn,
endColumn: word.endColumn
}
const contents = [{ value: `**\`${data.n}\`** | ${data.m} | ${data.c || ''}` }]
if (data.s) {
contents.push({ value: `**syntax:** ${data.s || ''}` })
}
if (data.v) {
contents.push({ value: `**default:** ${data.v || ''}` })
}
if (data.d) {
contents.push({ value: `${data.d}` })
}
return {
contents: [...contents],
range: range
}
}
})
}
onMounted(() => {
getInfo()
getConfig().then((res) => {
@@ -139,11 +84,10 @@ onMounted(() => {
</n-alert>
<Editor
v-model:value="config"
language="nginx"
theme="nginx-theme-dark"
language="ini"
theme="vs-dark"
height="60vh"
mt-8
@before-mount="editorOnBeforeMount"
:options="{
automaticLayout: true,
formatOnType: true,

View File

@@ -84,11 +84,7 @@ onMounted(async () => {
<template>
<AppPage :show-footer="true" :style="{ backgroundImage: `url(${bgImg})` }" bg-cover>
<div m-auto min-w-345 f-c-c rounded-10 bg-white bg-opacity-60 p-15 card-shadow dark:bg-dark>
<div hidden w-380 px-20 py-35 md:block>
<img alt="login_banner" src="@/assets/images/login_banner.png" w-full />
</div>
<div w-320 flex-col px-20 py-35>
<div w-480 flex-col px-20 py-35>
<h5 color="#6a6a6a" f-c-c text-24 font-normal>
<img class="mr-10" height="50" src="@/assets/images/logo.png" />{{ title }}
</h5>

View File

@@ -4,9 +4,6 @@ import website from '@/api/panel/website'
import { NButton } from 'naive-ui'
import info from '@/api/panel/info'
import Editor from '@guolao/vue-monaco-editor'
import { themeConfig, themeDarkConfig, tokenConf } from 'monaco-editor-nginx/cjs/conf'
import suggestions from 'monaco-editor-nginx/cjs/suggestions'
import { directives } from 'monaco-editor-nginx/cjs/directives'
const route = useRoute()
const { id } = route.params
@@ -105,58 +102,6 @@ const title = computed(() => {
return '编辑网站 - 加载中...'
})
const editorOnBeforeMount = (monaco: any) => {
monaco.languages.register({
id: 'nginx'
})
monaco.languages.setMonarchTokensProvider('nginx', tokenConf)
monaco.editor.defineTheme('nginx-theme', themeConfig)
monaco.editor.defineTheme('nginx-theme-dark', themeDarkConfig)
monaco.languages.registerCompletionItemProvider('nginx', {
provideCompletionItems: (model: any, position: any) => {
const word = model.getWordUntilPosition(position)
const range = {
startLineNumber: position.lineNumber,
endLineNumber: position.lineNumber,
startColumn: word.startColumn,
endColumn: word.endColumn
}
return { suggestions: suggestions(range) }
}
})
monaco.languages.registerHoverProvider('nginx', {
provideHover: (model: any, position: any) => {
const word = model.getWordAtPosition(position)
if (!word) return
const data = directives.find((item) => item.n === word.word || item.n === `$${word.word}`)
if (!data) return
const range = {
startLineNumber: position.lineNumber,
endLineNumber: position.lineNumber,
startColumn: word.startColumn,
endColumn: word.endColumn
}
const contents = [{ value: `**\`${data.n}\`** | ${data.m} | ${data.c || ''}` }]
if (data.s) {
contents.push({ value: `**syntax:** ${data.s || ''}` })
}
if (data.v) {
contents.push({ value: `**default:** ${data.v || ''}` })
}
if (data.d) {
contents.push({ value: `${data.d}` })
}
return {
contents: [...contents],
range: range
}
}
})
}
onMounted(() => {
getWebsiteSetting()
getPhpAndDb()
@@ -354,10 +299,9 @@ onMounted(() => {
<Editor
v-if="setting"
v-model:value="setting.rewrite"
language="nginx"
theme="nginx-theme-dark"
language="ini"
theme="vs-dark"
height="60vh"
@before-mount="editorOnBeforeMount"
:options="{
automaticLayout: true,
formatOnType: true,
@@ -385,10 +329,9 @@ onMounted(() => {
<Editor
v-if="setting"
v-model:value="setting.raw"
language="nginx"
theme="nginx-theme-dark"
language="ini"
theme="vs-dark"
height="60vh"
@before-mount="editorOnBeforeMount"
:options="{
automaticLayout: true,
formatOnType: true,