refactor: 整理资源文件,添加legacy路由
- 将原版文件移到frontend/legacy/3dearthmult/ - 纹理文件移到frontend/public/earth/assets/ - vite.config添加/legacy/earth路由支持 - earth.js纹理路径改为assets/
|
Before Width: | Height: | Size: 4.4 MiB After Width: | Height: | Size: 4.4 MiB |
|
Before Width: | Height: | Size: 18 MiB After Width: | Height: | Size: 18 MiB |
|
Before Width: | Height: | Size: 4.4 MiB After Width: | Height: | Size: 4.4 MiB |
|
Before Width: | Height: | Size: 18 MiB After Width: | Height: | Size: 18 MiB |
@@ -28,7 +28,7 @@ export function createEarth(scene) {
|
|||||||
scene.add(earth);
|
scene.add(earth);
|
||||||
|
|
||||||
const textureUrls = [
|
const textureUrls = [
|
||||||
'./8k_earth_daymap.jpg',
|
'./assets/8k_earth_daymap.jpg',
|
||||||
'https://raw.githubusercontent.com/mrdoob/three.js/dev/examples/textures/planets/earth_atmos_2048.jpg',
|
'https://raw.githubusercontent.com/mrdoob/three.js/dev/examples/textures/planets/earth_atmos_2048.jpg',
|
||||||
'https://threejs.org/examples/textures/planets/earth_atmos_2048.jpg',
|
'https://threejs.org/examples/textures/planets/earth_atmos_2048.jpg',
|
||||||
'https://assets.codepen.io/982762/earth_texture_2048.jpg'
|
'https://assets.codepen.io/982762/earth_texture_2048.jpg'
|
||||||
|
|||||||
@@ -1,9 +1,43 @@
|
|||||||
import { defineConfig } from 'vite'
|
import { defineConfig } from 'vite'
|
||||||
import react from '@vitejs/plugin-react'
|
import react from '@vitejs/plugin-react'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
import fs from 'fs'
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [react()],
|
plugins: [
|
||||||
|
react(),
|
||||||
|
{
|
||||||
|
name: 'legacy-earth',
|
||||||
|
configureServer(server) {
|
||||||
|
server.middlewares.use('/legacy/earth', (req, res, next) => {
|
||||||
|
let url = req.url || '/'
|
||||||
|
|
||||||
|
if (url === '' || url === '/') {
|
||||||
|
url = '/3dearthmult.html'
|
||||||
|
}
|
||||||
|
|
||||||
|
const filePath = path.resolve(__dirname, 'legacy/3dearthmult' + url)
|
||||||
|
|
||||||
|
if (fs.existsSync(filePath) && fs.statSync(filePath).isFile()) {
|
||||||
|
const ext = path.extname(filePath).toLowerCase()
|
||||||
|
const contentTypes = {
|
||||||
|
'.html': 'text/html',
|
||||||
|
'.json': 'application/json',
|
||||||
|
'.jpg': 'image/jpeg',
|
||||||
|
'.jpeg': 'image/jpeg',
|
||||||
|
'.png': 'image/png',
|
||||||
|
'.js': 'application/javascript',
|
||||||
|
'.css': 'text/css'
|
||||||
|
}
|
||||||
|
res.setHeader('Content-Type', contentTypes[ext] || 'text/plain')
|
||||||
|
fs.createReadStream(filePath).pipe(res)
|
||||||
|
} else {
|
||||||
|
next()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
server: {
|
server: {
|
||||||
port: 3000,
|
port: 3000,
|
||||||
proxy: {
|
proxy: {
|
||||||
|
|||||||