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