diff --git a/examples/app/index-vite.html b/examples/app/index-vite.html new file mode 100644 index 000000000..194fdfa81 --- /dev/null +++ b/examples/app/index-vite.html @@ -0,0 +1,68 @@ + + + + + amis app 模式 + + + + + + + + + + + + + +
+ + + diff --git a/scripts/mockApiPlugin.ts b/scripts/mockApiPlugin.ts index c7a0aabce..6f4b764e7 100644 --- a/scripts/mockApiPlugin.ts +++ b/scripts/mockApiPlugin.ts @@ -33,6 +33,25 @@ export default function mockApiPlugin(options: {} = {}): Plugin { }); }); + // 处理 app 模式 + server.middlewares.use('/examples/app/', async (req, res, next) => { + if (req.originalUrl !== '/examples/app/') { + next(); + return; + } + + let template = fs.readFileSync( + path.resolve(__dirname, '../examples/app/index-vite.html'), + 'utf-8' + ); + template = await server.transformIndexHtml( + '/examples/app/index-vite.html', + template + ); + res.statusCode = 200; + res.end(template); + }); + server.middlewares.use('/schema.json', (req, res, next) => { initExpress(req, res, next, () => { const filepath = path.resolve(