Commit f1f0eda4 authored by 王曜嵚 Wang Yaoqin's avatar 王曜嵚 Wang Yaoqin

dev: 更换文件地址

parent 8a7ef11e
// 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'],
......
{
"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
......@@ -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 () => {
......
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
......@@ -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 })
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment