Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nuxt-backend-helper
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王曜嵚 Wang Yaoqin
nuxt-backend-helper
Commits
f1f0eda4
Commit
f1f0eda4
authored
Apr 17, 2024
by
王曜嵚 Wang Yaoqin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dev: 更换文件地址
parent
8a7ef11e
Changes
21
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
129 additions
and
10 deletions
+129
-10
nuxt.config.ts
nuxt.config.ts
+1
-0
login.json
public/data/login.json
+57
-0
wyq.json
public/data/wyq.json
+0
-0
default-user-setting.json
public/files/default-user-setting.json
+0
-0
nginx.conf
public/files/nginx.conf
+0
-0
settings-security.xml
public/files/settings-security.xml
+0
-0
settings.xml
public/files/settings.xml
+0
-0
v1-application-server.properties
public/files/v1-application-server.properties
+0
-0
application.properties
public/files/v1/application.properties
+0
-0
application.tar
public/files/v1/application.tar
+0
-0
locale.gen
public/files/v1/locale.gen
+0
-0
locale.tar
public/files/v1/locale.tar
+0
-0
pomWithWeb.tar
public/files/v1/pomWithWeb.tar
+0
-0
pomWithoutWeb.tar
public/files/v1/pomWithoutWeb.tar
+0
-0
application-gateway.properties
public/files/v2/application-gateway.properties
+0
-0
application-server.properties
public/files/v2/application-server.properties
+0
-0
broker.conf
public/files/v2/broker.conf
+0
-0
install.post.ts
server/api/devops/v2/install.post.ts
+4
-4
getProjectInfo.get.ts
server/api/user/getProjectInfo.get.ts
+61
-1
login.post.ts
server/api/user/login.post.ts
+3
-2
server.ts
server/utils/server.ts
+3
-3
No files found.
nuxt.config.ts
View file @
f1f0eda4
// https://nuxt.com/docs/api/configuration/nuxt-config
export
default
defineNuxtConfig
({
ssr
:
false
,
devtools
:
{
enabled
:
true
},
modules
:
[
'@pinia/nuxt'
],
css
:
[
'~/assets/css/main.css'
,
'~/assets/css/color.css'
],
...
...
public/data/login.json
0 → 100644
View file @
f1f0eda4
{
"postgres"
:
{
"visible"
:
false
,
"username"
:
"postgres"
,
"password"
:
"postgres"
,
"ip"
:
"192.168.0.4"
,
"port"
:
"25556"
,
"database"
:
"login"
,
"schema"
:
"library"
},
"redis"
:
{
"visible"
:
false
,
"ip"
:
"192.168.0.4"
,
"port"
:
"25557"
},
"zookeeper"
:
{
"visible"
:
false
,
"ip"
:
"192.168.0.4"
,
"port"
:
"2182"
},
"rocketmq"
:
{
"visible"
:
false
,
"ip"
:
"192.168.0.4"
,
"port"
:
"9876"
},
"tenants"
:
{
"visible"
:
false
,
"id"
:
"login"
,
"host"
:
"a.test.com:23339,a.test.com:23340"
,
"database-schema"
:
"library"
,
"primary-namespace"
:
"library"
},
"postgresV1"
:
{
"visible"
:
false
,
"username"
:
"postgres"
,
"password"
:
"postgres"
,
"ip"
:
"192.168.0.4"
,
"port"
:
"25556"
,
"database"
:
"logwirev2"
,
"schema"
:
"library"
},
"redisV1"
:
{
"visible"
:
false
,
"ip"
:
"192.168.0.4"
,
"port"
:
"25557"
},
"tenantsV1"
:
{
"visible"
:
false
,
"id"
:
"wongyaqi"
,
"port"
:
8080
},
"debug"
:
{
"host"
:
"192.168.1.94"
},
"node-port"
:
30003
,
"username"
:
"login"
}
\ No newline at end of file
server
/data/wyq.json
→
public
/data/wyq.json
View file @
f1f0eda4
File moved
server
/files/default-user-setting.json
→
public
/files/default-user-setting.json
View file @
f1f0eda4
File moved
server
/files/nginx.conf
→
public
/files/nginx.conf
View file @
f1f0eda4
File moved
server
/files/settings-security.xml
→
public
/files/settings-security.xml
View file @
f1f0eda4
File moved
server
/files/settings.xml
→
public
/files/settings.xml
View file @
f1f0eda4
File moved
server
/files/v1-application-server.properties
→
public
/files/v1-application-server.properties
View file @
f1f0eda4
File moved
server
/files/v1/application.properties
→
public
/files/v1/application.properties
View file @
f1f0eda4
File moved
server
/files/v1/application.tar
→
public
/files/v1/application.tar
View file @
f1f0eda4
File moved
server
/files/v1/locale.gen
→
public
/files/v1/locale.gen
View file @
f1f0eda4
File moved
server
/files/v1/locale.tar
→
public
/files/v1/locale.tar
View file @
f1f0eda4
File moved
server
/files/v1/pomWithWeb.tar
→
public
/files/v1/pomWithWeb.tar
View file @
f1f0eda4
File moved
server
/files/v1/pomWithoutWeb.tar
→
public
/files/v1/pomWithoutWeb.tar
View file @
f1f0eda4
File moved
server
/files/v2/application-gateway.properties
→
public
/files/v2/application-gateway.properties
View file @
f1f0eda4
File moved
server
/files/v2/application-server.properties
→
public
/files/v2/application-server.properties
View file @
f1f0eda4
File moved
server
/files/v2/broker.conf
→
public
/files/v2/broker.conf
View file @
f1f0eda4
File moved
server/api/devops/v2/install.post.ts
View file @
f1f0eda4
...
...
@@ -93,7 +93,7 @@ export default defineEventHandler(async (event) => {
let
info
=
await
rocketmqbroker
.
inspect
()
if
(
info
?.
State
.
Status
===
'created'
)
{
let
brokerText
=
fs
.
readFileSync
(
path
.
resolve
(
'./
server
/files/v2/broker.conf'
),
{
encoding
:
'utf-8'
})
let
brokerText
=
fs
.
readFileSync
(
path
.
resolve
(
'./
public
/files/v2/broker.conf'
),
{
encoding
:
'utf-8'
})
await
docker
.
execContainerCommand
({
container
:
rocketmqbroker
,
cmd
:
'mkdir /home/rocketmq/conf -p'
})
await
docker
.
execContainerCommand
({
container
:
rocketmqbroker
,
cmd
:
'touch /home/rocketmq/conf/broker.conf'
})
await
docker
.
writeFile
({
container
:
rocketmqbroker
,
path
:
'/home/rocketmq/conf/broker.conf'
,
text
:
"'"
+
brokerText
+
"'"
})
...
...
@@ -128,10 +128,10 @@ export default defineEventHandler(async (event) => {
await
docker
.
execContainerCommand
({
container
,
cmd
:
'apt-get install -y maven'
})
})
await
LogUtil
.
run
(
username
,
'修改 maven 源'
,
async
()
=>
{
let
mavenSettingXml
=
fs
.
readFileSync
(
path
.
resolve
(
'./
server
/files/settings.xml'
),
{
encoding
:
'utf-8'
})
let
mavenSettingXml
=
fs
.
readFileSync
(
path
.
resolve
(
'./
public
/files/settings.xml'
),
{
encoding
:
'utf-8'
})
await
docker
.
writeFile
({
container
,
path
:
'/etc/maven/settings.xml'
,
text
:
'
\'
'
+
mavenSettingXml
+
'
\'
'
})
let
mavenSecurityXml
=
fs
.
readFileSync
(
path
.
resolve
(
'./
server
/files/settings-security.xml'
),
{
encoding
:
'utf-8'
})
let
mavenSecurityXml
=
fs
.
readFileSync
(
path
.
resolve
(
'./
public
/files/settings-security.xml'
),
{
encoding
:
'utf-8'
})
try
{
let
xml
=
await
docker
.
getFile
({
container
,
path
:
'/root/.m2/settings-security.xml'
})
}
catch
(
err
)
{
...
...
@@ -159,7 +159,7 @@ export default defineEventHandler(async (event) => {
await
docker
.
execContainerCommand
({
container
,
cmd
:
'apt-get install -y zip'
})
})
await
LogUtil
.
run
(
username
,
'配置 nginx '
,
async
()
=>
{
let
nginxConfigText
=
fs
.
readFileSync
(
path
.
resolve
(
'./
server
/files/nginx.conf'
),
{
encoding
:
'utf-8'
})
let
nginxConfigText
=
fs
.
readFileSync
(
path
.
resolve
(
'./
public
/files/nginx.conf'
),
{
encoding
:
'utf-8'
})
await
docker
.
writeFile
({
container
,
path
:
'/etc/nginx/nginx.conf'
,
text
:
'
\'
'
+
nginxConfigText
+
'
\'
'
})
})
await
LogUtil
.
run
(
username
,
'启动 code-server '
,
async
()
=>
{
...
...
server/api/user/getProjectInfo.get.ts
View file @
f1f0eda4
type
UserConfig
=
{
"postgres"
:
{
"visible"
:
boolean
,
"username"
:
string
,
"password"
:
string
,
"ip"
:
string
,
"port"
:
string
,
"database"
:
string
,
"schema"
:
string
},
"redis"
:
{
"visible"
:
boolean
,
"ip"
:
string
,
"port"
:
string
},
"zookeeper"
:
{
"visible"
:
boolean
,
"ip"
:
string
,
"port"
:
string
},
"rocketmq"
:
{
"visible"
:
boolean
,
"ip"
:
string
,
"port"
:
string
},
"tenants"
:
{
"visible"
:
boolean
,
"id"
:
string
,
"host"
:
string
,
"database-schema"
:
string
,
"primary-namespace"
:
string
},
"postgresV1"
:
{
"visible"
:
boolean
,
"username"
:
string
,
"password"
:
string
,
"ip"
:
string
,
"port"
:
string
,
"database"
:
string
,
"schema"
:
string
},
"redisV1"
:
{
"visible"
:
boolean
,
"ip"
:
string
,
"port"
:
string
},
"tenantsV1"
:
{
"visible"
:
boolean
,
"id"
:
string
,
"port"
:
number
},
"debug"
:
{
"host"
:
string
},
"node-port"
:
number
,
"username"
:
string
,
"status"
:
string
,
"InstallSteps"
:
string
[]
}
export
default
defineEventHandler
(
async
(
event
)
=>
{
const
username
=
event
.
context
.
username
const
configs
=
getUserAllConfigs
(
username
)
return
configs
return
configs
as
unknown
as
UserConfig
})
\ No newline at end of file
server/api/user/login.post.ts
View file @
f1f0eda4
...
...
@@ -9,14 +9,15 @@ export default defineEventHandler(async (event) => {
if
(
getUserConfig
(
username
,
'node-port'
)
===
undefined
)
{
let
host
=
process
.
env
.
NODE_ENV
?.
trim
()
===
'production'
?
'192.168.0.4'
:
'localhost'
const
port
=
await
getAvailableNodePort
(
host
)
const
userDefaultSetting
=
readJson
(
'./
server
/files/default-user-setting.json'
)
const
userDefaultSetting
=
readJson
(
'./
public
/files/default-user-setting.json'
)
const
userSetting
=
Object
.
assign
({},
userDefaultSetting
,
{
"node-port"
:
port
})
userSetting
[
'postgres'
][
'database'
]
=
username
userSetting
[
'tenants'
][
'id'
]
=
username
userSetting
[
'tenants'
][
'host'
]
=
`a.test.com:
${
23333
+
(
port
-
30000
)
*
2
}
,a.test.com:
${
23334
+
(
port
-
30000
)
*
2
}
`
userSetting
.
username
=
username
const
userDataPath
=
`./
server
/data/
${
username
}
.json`
const
userDataPath
=
`./
public
/data/
${
username
}
.json`
writeJson
(
userDataPath
,
userSetting
)
console
.
log
(
'usetSetting'
,
userSetting
)
}
const
session
=
await
useSession
(
event
,
{
password
:
SESSION_PASSWORD
})
await
session
.
update
({
username
})
...
...
server/utils/server.ts
View file @
f1f0eda4
...
...
@@ -4,7 +4,7 @@ import lodash from 'lodash'
import
{
Telnet
}
from
'telnet-client'
export
function
getUserConfig
(
username
:
string
,
config
:
string
)
{
let
jsonPath
=
path
.
resolve
(
'./
server
/data/'
+
username
+
'.json'
)
let
jsonPath
=
path
.
resolve
(
'./
public
/data/'
+
username
+
'.json'
)
try
{
let
jsonStr
=
fs
.
readFileSync
(
jsonPath
,
{
encoding
:
'utf-8'
})
let
json
=
JSON
.
parse
(
jsonStr
)
||
{}
...
...
@@ -36,14 +36,14 @@ export async function getAvailableNodePort (ip: string, startPort = 30000) {
}
export
function
getUserAllConfigs
(
username
:
string
):
Record
<
string
,
string
>
{
let
jsonPath
=
path
.
resolve
(
'./
server
/data/'
+
username
+
'.json'
)
let
jsonPath
=
path
.
resolve
(
'./
public
/data/'
+
username
+
'.json'
)
let
jsonStr
=
fs
.
readFileSync
(
jsonPath
,
{
encoding
:
'utf-8'
})
let
json
=
JSON
.
parse
(
jsonStr
)
||
{}
return
json
}
export
function
setUserConfig
(
username
:
string
,
config
:
string
,
value
:
any
)
{
let
jsonPath
=
path
.
resolve
(
'./
server
/data/'
+
username
+
'.json'
)
let
jsonPath
=
path
.
resolve
(
'./
public
/data/'
+
username
+
'.json'
)
let
jsonStr
=
fs
.
readFileSync
(
jsonPath
,
{
encoding
:
'utf-8'
})
let
json
=
JSON
.
parse
(
jsonStr
)
||
{}
let
newJson
=
lodash
.
set
(
json
,
config
,
value
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment