Skip to content

Commit

Permalink
修改为非编译环境下启动与切换模板
Browse files Browse the repository at this point in the history
  • Loading branch information
rwx committed Feb 28, 2024
1 parent 7f004cb commit 12fb31b
Show file tree
Hide file tree
Showing 47 changed files with 20,767 additions and 119 deletions.
2 changes: 1 addition & 1 deletion web-project/.env.local
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ENV = 'local'

# base api
# 本地 反向代理 服务路径(非特殊情况,不用修改)
VUE_APP_BASE = '/localpath'
VUE_APP_BASE = '/mockapi'

# 本地 mock 服务路径
VUE_APP_MOCK_SERVER = '/mockapi'
10 changes: 10 additions & 0 deletions web-project/.env.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
NODE_ENV = production

# just a flag
ENV = 'production'
# base api
# 本地 反向代理 服务路径(非特殊情况,不用修改)
VUE_APP_BASE = '/mockapi'

# 本地 mock 服务路径
VUE_APP_MOCK_SERVER = '/mockapi'
1 change: 1 addition & 0 deletions web-project/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = {
arguments: true,
$: true,
_$cusComponents$_: true,
_$configFormValidMsg$_: true,
_$cusConfig$_: true,
process: true,
__dirname: true
Expand Down
1 change: 0 additions & 1 deletion web-project/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ yarn-error.log*
*.sln
*.sw?

package-lock.json
yarn.lock
/tests/coverage/

Expand Down
2 changes: 1 addition & 1 deletion web-project/.npmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
registry=https://registry.npm.taobao.org
registry=https://registry.npmmirror.com
28 changes: 16 additions & 12 deletions web-project/mock/json/createPage.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
const fs = require('fs')
const path = require('path')
const comConfig_ = require('../../src/config.js')

const template_ = require('art-template')
const axios = require('axios')

const nodeFileApi = require('create-vue-page-npm').nodeFileApi
const fsExtra = require('fs-extra')

const target_ = process.env.npm_config_target || 'vue2'
const targetFromPath_ = path.join(__dirname, '../../../server/create_cfg_tmpl', target_)
console.log('导入模板:', target_)
if (fsExtra.existsSync(targetFromPath_)) {
const targetToPath_ = path.join(__dirname, '../../public/tmpl_cfg')
fsExtra.emptyDirSync(targetToPath_)
fsExtra.copySync(targetFromPath_, targetToPath_)
} else {
console.log('未找到模板目录:', targetFromPath_)
}
// 注意:必须先拷贝模板文件,再导入配置文件
const comConfig_ = require('../../public/tmpl_cfg/config/config.js')
const templateCfg = { ...comConfig_, _templateRoot_: path.join(__dirname, '../../public/tmpl_cfg/template') }
// 初始化模板解析器
nodeFileApi.initTemplate(template_, comConfig_)
nodeFileApi.initTemplate(template_, templateCfg)

module.exports = [
{
Expand Down Expand Up @@ -52,15 +65,6 @@ module.exports = [
}
}
},
{
url: '/getComConfig',
type: 'get',
response: (req, res) => {
var data = fs.readFileSync(path.resolve('src/config.js'))
const str = data.toString()
res.send(str.replace(/module.exports\s*?=\s*?/, ''))
}
},
{
url: '/getCatalog',
type: 'get',
Expand Down
Loading

0 comments on commit 12fb31b

Please sign in to comment.