我在干什么(
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import io from '../lib/io.js';
|
||||
import { sha256 } from '../lib/crypto.js'
|
||||
|
||||
const baseDir = 'whiteslik_data/chat'
|
||||
const baseDir = 'whitesilk_data/chat'
|
||||
io.mkdirs(baseDir)
|
||||
|
||||
export class ChatManager {
|
||||
|
||||
@@ -2,7 +2,7 @@ import io from '../lib/io.js';
|
||||
import { sha256 } from '../lib/crypto.js'
|
||||
import { CallbackMessage } from '../Types.js';
|
||||
|
||||
const baseDir = 'whiteslik_data/user'
|
||||
const baseDir = 'whitesilk_data/user'
|
||||
io.mkdirs(baseDir)
|
||||
|
||||
export class UserManager {
|
||||
|
||||
44
server/build.js
Normal file
44
server/build.js
Normal file
@@ -0,0 +1,44 @@
|
||||
import babel from '@babel/core'
|
||||
import io from './lib/io.js'
|
||||
|
||||
function compileJs(path) {
|
||||
babel.transformFileAsync(path, {
|
||||
presets: [
|
||||
[
|
||||
"@babel/preset-env", {
|
||||
modules: false,
|
||||
},
|
||||
],
|
||||
"@babel/preset-react",
|
||||
[
|
||||
"minify", {
|
||||
|
||||
}
|
||||
],
|
||||
],
|
||||
targets: {
|
||||
chrome: "53",
|
||||
android: "40",
|
||||
},
|
||||
sourceMaps: true,
|
||||
}).then(function (result) {
|
||||
io.open(path, 'w').writeAll(result.code + '\n' + `//@ sourceMappingURL=${io.getName(path)}.map`).close()
|
||||
io.open(path + '.map', 'w').writeAll(JSON.stringify(result.map)).close()
|
||||
console.log(`Compile js: ${path}`)
|
||||
})
|
||||
}
|
||||
|
||||
export default function (path) {
|
||||
io.listFiles(path, {
|
||||
recursive: true,
|
||||
fullPath: true,
|
||||
}).forEach(function (v) {
|
||||
if (v.endsWith('.js'))
|
||||
compileJs(v)
|
||||
else if (v.endsWith('.jsx')) {
|
||||
let v2 = `${io.getParent(v)}//${io.getName(v).replace(/\.jsx/, '.js')}`
|
||||
io.move(v, v2)
|
||||
compileJs(v2)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -8,9 +8,13 @@ import { TheWhiteSilkParams, CallbackMessage } from './Types.js'
|
||||
|
||||
const app = express()
|
||||
const httpApp = http.createServer(app)
|
||||
const io = new SocketIoServer(httpApp, {})
|
||||
const sio = new SocketIoServer(httpApp, {})
|
||||
|
||||
app.use('/', express.static('client/'))
|
||||
// 编译前端代码
|
||||
import io from './lib/io.js'
|
||||
io.copyDir('./client/', './whitesilk_data/page_builded/')
|
||||
await import('./build.js').then(a => a.default('whitesilk_data/page_builded/'))
|
||||
app.use('/', express.static('whitesilk_data/page_builded/'))
|
||||
|
||||
const events = {}
|
||||
import { UserApi } from './api/User.js'
|
||||
@@ -24,7 +28,7 @@ for (let i of [
|
||||
}
|
||||
}
|
||||
|
||||
io.on("connection", (socket) => {
|
||||
sio.on("connection", (socket) => {
|
||||
socket.on('the_white_silk',
|
||||
/**
|
||||
* @param { TheWhiteSilkParams } params
|
||||
|
||||
Reference in New Issue
Block a user