|
|
@@ -24,7 +24,7 @@ app.use('*', cors(
|
|
|
|
|
|
app.route('/', createApi)
|
|
|
|
|
|
-if(!import.meta.env.PROD){
|
|
|
+if (!import.meta.env.PROD) {
|
|
|
app.get('/ui', swaggerUI({
|
|
|
url: '/doc',
|
|
|
persistAuthorization: true,
|
|
|
@@ -47,12 +47,12 @@ if(!import.meta.env.PROD){
|
|
|
}))
|
|
|
}
|
|
|
|
|
|
-if(import.meta.env.PROD){
|
|
|
+if (import.meta.env.PROD) {
|
|
|
app.get('/assets/:filename', async (c) => {
|
|
|
const filename = c.req.param('filename')
|
|
|
- const filePath = import.meta.env.PROD? `./dist/assets/${filename}` : `./public/assets/${filename}`
|
|
|
+ const filePath = import.meta.env.PROD ? `./dist/assets/${filename}` : `./public/assets/${filename}`
|
|
|
const content = await fs.readFile(filePath);
|
|
|
- const modifyDate = (await fs.stat(filePath))?.mtime?.toUTCString()?? new Date().toUTCString();
|
|
|
+ const modifyDate = (await fs.stat(filePath))?.mtime?.toUTCString() ?? new Date().toUTCString();
|
|
|
|
|
|
|
|
|
const fileExt = filePath.split('.').pop()?.toLowerCase()
|
|
|
@@ -82,28 +82,28 @@ if(import.meta.env.PROD){
|
|
|
|
|
|
app.use(renderer)
|
|
|
app.get('/*', (c) => {
|
|
|
-
|
|
|
+
|
|
|
return c.render(
|
|
|
<>
|
|
|
{!c.req.path.startsWith('/admin') && <script src="https://g.alicdn.com/apsara-media-box/imp-interaction/1.6.1/alivc-im.iife.js"></script>}
|
|
|
<div id="root"></div>
|
|
|
</>
|
|
|
)
|
|
|
-})
|
|
|
+})
|
|
|
|
|
|
-let exportDefault:any
|
|
|
-if(import.meta.env.PROD){
|
|
|
+let exportDefault: any
|
|
|
+if (import.meta.env.PROD) {
|
|
|
exportDefault = {
|
|
|
websocket: (httpServer: ServerType) => {
|
|
|
// 创建 Socket.IO 服务器并集成到主服务
|
|
|
new SocketIOServer({
|
|
|
- server: httpServer
|
|
|
+ server: httpServer
|
|
|
});
|
|
|
},
|
|
|
fetch: app.fetch
|
|
|
}
|
|
|
}else if(!import.meta.hot){
|
|
|
new SocketIOServer({});
|
|
|
- exportDefault = app;
|
|
|
+ exportDefault = app;
|
|
|
}
|
|
|
export default exportDefault
|