- 将wwjcloud目录重命名为wwjcloud-nest-v1作为项目根目录 - 将原nestjs目录重命名为wwjcloud作为NestJS后端目录 - 实现真正的前后端分离架构 - 恢复工作区中丢失的目录结构 - 更新相关配置文件路径引用 - 清理重复和嵌套目录问题 目录结构: wwjcloud-nest-v1/ ├── wwjcloud/ # NestJS 后端 ├── admin/ # 管理端前端 ├── web/ # PC端前端 ├── uni-app-x/ # 移动端前端 ├── wwjcloud-web/ # 部署根目录 ├── docker/ # Docker 配置 ├── docs/ # 文档 └── tools/ # 工具集
41 lines
1017 B
JavaScript
41 lines
1017 B
JavaScript
const fs = require('fs')
|
|
|
|
const publish = () => {
|
|
const src = './.output/public'
|
|
const dest = '../wwjcloud-web/public/web'
|
|
|
|
solve()
|
|
|
|
// 目标目录不存在停止复制
|
|
try {
|
|
const dir = fs.readdirSync(dest)
|
|
} catch (e) {
|
|
return
|
|
}
|
|
|
|
// 删除目标目录下文件
|
|
fs.rm(dest, { recursive: true }, err => {
|
|
if(err) {
|
|
console.log(err)
|
|
return
|
|
}
|
|
|
|
fs.cp(src, dest, { recursive: true }, (err) => {
|
|
if (err) {
|
|
console.error(err)
|
|
}
|
|
})
|
|
})
|
|
}
|
|
|
|
const solve = () => {
|
|
const fn = './.output/public/index.html'
|
|
const fc = fs.readFileSync(fn, 'utf-8')
|
|
let text = new String(fc)
|
|
text = text.replace('<script>window.__NUXT__', '<script>const match = location.href.match(/\\/web\\/(\\d*)\\//);window.__NUXT__')
|
|
text = text.replace('baseURL:"\\u002Fweb\\u002F"', 'baseURL: match ? `/web/${match[1]}/` : `/web/`')
|
|
fs.writeFileSync(fn, text, 'utf8')
|
|
}
|
|
|
|
publish()
|