mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-10 09:55:48 +02:00
enhance: db init
This commit is contained in:
parent
1a21c8406a
commit
40e8d6c40a
7 changed files with 15 additions and 41 deletions
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
|
@ -10,7 +10,7 @@
|
|||
"i18n-gettext.translatorConfig": {
|
||||
"onlyTranslateUntranslatedAndFuzzy": true,
|
||||
"batch": {
|
||||
"pageSize": 1000
|
||||
"pageSize": 20
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,8 +4,6 @@ import (
|
|||
"net/http"
|
||||
"time"
|
||||
|
||||
"code.pfad.fr/risefront"
|
||||
"github.com/0xJacky/Nginx-UI/internal/kernel"
|
||||
"github.com/0xJacky/Nginx-UI/internal/system"
|
||||
"github.com/0xJacky/Nginx-UI/model"
|
||||
"github.com/0xJacky/Nginx-UI/query"
|
||||
|
@ -51,8 +49,7 @@ func InstallLockCheck(c *gin.Context) {
|
|||
type InstallJson struct {
|
||||
Email string `json:"email" binding:"required,email"`
|
||||
Username string `json:"username" binding:"required,max=255"`
|
||||
Password string `json:"password" binding:"required,max=255"`
|
||||
Database string `json:"database"`
|
||||
Password string `json:"password" binding:"required,max=20"`
|
||||
}
|
||||
|
||||
func InstallNginxUI(c *gin.Context) {
|
||||
|
@ -79,9 +76,6 @@ func InstallNginxUI(c *gin.Context) {
|
|||
cSettings.AppSettings.JwtSecret = uuid.New().String()
|
||||
settings.NodeSettings.Secret = uuid.New().String()
|
||||
settings.CertSettings.Email = json.Email
|
||||
if json.Database != "" {
|
||||
settings.DatabaseSettings.Name = json.Database
|
||||
}
|
||||
|
||||
err := settings.Save()
|
||||
if err != nil {
|
||||
|
@ -89,9 +83,6 @@ func InstallNginxUI(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
// Init model
|
||||
kernel.InitDatabase(kernel.Context)
|
||||
|
||||
pwd, err := bcrypt.GenerateFromPassword([]byte(json.Password), bcrypt.DefaultCost)
|
||||
if err != nil {
|
||||
cosy.ErrHandler(c, err)
|
||||
|
@ -112,6 +103,4 @@ func InstallNginxUI(c *gin.Context) {
|
|||
c.JSON(http.StatusOK, gin.H{
|
||||
"message": "ok",
|
||||
})
|
||||
|
||||
risefront.Restart()
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ export interface InstallRequest {
|
|||
email: string
|
||||
username: string
|
||||
password: string
|
||||
database: string
|
||||
}
|
||||
|
||||
export interface InstallLockResponse {
|
||||
|
|
|
@ -231,9 +231,8 @@ msgid "API Base Url"
|
|||
msgstr "URL de base de l'API"
|
||||
|
||||
#: src/views/certificate/components/DNSChallenge.vue:83
|
||||
#, fuzzy
|
||||
msgid "API Document"
|
||||
msgstr "Documentation API"
|
||||
msgstr "Document API"
|
||||
|
||||
#: src/views/preference/tabs/OpenAISettings.vue:46
|
||||
msgid "API Proxy"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script setup lang="ts">
|
||||
import install from '@/api/install'
|
||||
import { DatabaseOutlined, LockOutlined, MailOutlined, UserOutlined } from '@ant-design/icons-vue'
|
||||
import { LockOutlined, MailOutlined, UserOutlined } from '@ant-design/icons-vue'
|
||||
import { Form, message } from 'ant-design-vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
|
@ -15,7 +15,6 @@ const modelRef = reactive({
|
|||
email: '',
|
||||
username: '',
|
||||
password: '',
|
||||
database: '',
|
||||
})
|
||||
|
||||
const rulesRef = reactive({
|
||||
|
@ -31,6 +30,10 @@ const rulesRef = reactive({
|
|||
required: true,
|
||||
message: () => $gettext('Please input your username!'),
|
||||
},
|
||||
{
|
||||
max: 255,
|
||||
message: () => $gettext('Username length cannot exceed 255 characters'),
|
||||
},
|
||||
],
|
||||
password: [
|
||||
{
|
||||
|
@ -42,12 +45,6 @@ const rulesRef = reactive({
|
|||
message: () => $gettext('Password length cannot exceed 20 characters'),
|
||||
},
|
||||
],
|
||||
database: [
|
||||
{
|
||||
message: () =>
|
||||
$gettext('The filename cannot contain the following characters: %{c}', { c: '& " ? < > # {} % ~ / \\' }),
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
const { validate, validateInfos } = Form.useForm(modelRef, rulesRef)
|
||||
|
@ -102,17 +99,6 @@ function onSubmit() {
|
|||
</template>
|
||||
</AInputPassword>
|
||||
</AFormItem>
|
||||
<AFormItem>
|
||||
<AInput
|
||||
v-bind="validateInfos.database"
|
||||
v-model:value="modelRef.database"
|
||||
:placeholder="$gettext('Database (Optional, default: database)')"
|
||||
>
|
||||
<template #prefix>
|
||||
<DatabaseOutlined />
|
||||
</template>
|
||||
</AInput>
|
||||
</AFormItem>
|
||||
<AFormItem>
|
||||
<AButton
|
||||
type="primary"
|
||||
|
|
|
@ -95,13 +95,11 @@ func InitDatabase(ctx context.Context) {
|
|||
skipInstall()
|
||||
}
|
||||
|
||||
if cSettings.AppSettings.JwtSecret != "" {
|
||||
db := cosy.InitDB(sqlite.Open(path.Dir(cSettings.ConfPath), settings.DatabaseSettings))
|
||||
model.Use(db)
|
||||
query.Init(db)
|
||||
db := cosy.InitDB(sqlite.Open(path.Dir(cSettings.ConfPath), settings.DatabaseSettings))
|
||||
model.Use(db)
|
||||
query.Init(db)
|
||||
|
||||
InitAfterDatabase(ctx)
|
||||
}
|
||||
InitAfterDatabase(ctx)
|
||||
}
|
||||
|
||||
func InitNodeSecret() {
|
||||
|
|
|
@ -9,5 +9,8 @@ var DatabaseSettings = &Database{
|
|||
}
|
||||
|
||||
func (d *Database) GetName() string {
|
||||
if d.Name == "" {
|
||||
d.Name = "database"
|
||||
}
|
||||
return d.Name
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue