Compare commits

...

3 Commits

Author SHA1 Message Date
CrescentLeaf
930a9c6c07 Merge branch 'main' of codeberg.org:CrescentLeaf/TheWhiteSilk 2025-07-14 22:26:48 +08:00
CrescentLeaf
89e730496f 好亂( 2025-07-14 22:26:13 +08:00
CrescentLeaf
c8c80685ec buzhidao 2025-07-14 21:51:36 +08:00
9 changed files with 1916 additions and 76 deletions

View File

@@ -1,3 +1,7 @@
import config from './server/config.ts'
import io from './server/lib/io.js'
config.ensureAllDirsAreCreated()
io.copyDir('./client', config.dirs.WEB_PAGE_DIR)
await import('./server/build.ts').then(a => a.default(config.dirs.WEB_PAGE_DIR))

View File

@@ -5,16 +5,16 @@
"express": "npm:express@^4.21.2",
"socket.io": "npm:socket.io@^4.8.1",
// Database
"sequelize": "npm:sequelize@^6.37.7",
"sqlite3": "npm:sqlite3@^5.1.7",
// Front-end Compiling
"@babel/core": "npm:@babel/core@^7.26.10",
"@babel/preset-env": "npm:@babel/preset-env@^7.26.9",
"@babel/preset-react": "npm:@babel/preset-react@^7.26.3",
"babel-minify": "npm:babel-minify@^0.5.2"
"@babel/preset-react": "npm:@babel/preset-react@^7.26.3"
},
"tasks": {
// 編譯並運行
"run": "deno run --allow-read --allow-write --allow-import --allow-env --allow-net --allow-sys ./start-server.ts",
// 編譯前端頁面
"compile-webpage": "deno run --allow-read --allow-write --allow-import --allow-env ./compile-webpage.ts"
"compile-webpage": "deno run --allow-read --allow-write --allow-import --allow-env --allow-sys ./compile-webpage.ts"
}
}

1907
deno.lock generated

File diff suppressed because it is too large Load Diff

4
run.sh Normal file
View File

@@ -0,0 +1,4 @@
echo "主文件夾 = $HOME"
# mkdir usr_home || true
# HOME=./usr_home
deno task run

View File

@@ -11,11 +11,7 @@ function compileJs(path: string) {
},
],
"@babel/preset-react",
[
"minify", {
}
],
// "minify",
],
targets: {
chrome: "53",

View File

@@ -1,10 +1,7 @@
// @ts-types="npm:sequelize"
import { Sequelize } from 'sequelize'
import Config from "../config.ts"
import User from "./User.ts";
abstract class BaseDataManager {
declare sequelize: Sequelize
declare name: string
constructor(name: string) {
this.init(name)
@@ -12,10 +9,7 @@ abstract class BaseDataManager {
}
private init(name: string) {
this.name = name
this.sequelize = new Sequelize({
dialect: 'sqlite',
storage: Config.dirs.DATABASES_DIR + '/' + name + '.db'
})
}
abstract onInit(): void
}
@@ -23,7 +17,7 @@ abstract class BaseDataManager {
class UserDataManager extends BaseDataManager {
static SINGLE_INSTANCE = new UserDataManager('users')
override onInit(): void {
User.initTable(this.sequelize, this.name)
}
}

View File

@@ -1,35 +1,3 @@
// @ts-types="npm:sequelize"
import { Sequelize, Model, DataTypes, CreationOptional } from 'sequelize'
export default class User extends Model {
declare created_id: CreationOptional<number>
declare user_name: string | null
declare nick_name: string | null
declare avatar: Blob
static async initTable(sequelize: Sequelize, name: string) {
this.init({
created_id: {
type: DataTypes.INTEGER.UNSIGNED,
autoIncrement: true,
primaryKey: true,
},
user_name: {
type: DataTypes.STRING,
allowNull: true,
},
nick_name: {
type: DataTypes.STRING,
allowNull: true,
},
avatar: {
type: DataTypes.BLOB,
allowNull: true,
},
}, {
sequelize: sequelize,
tableName: name,
})
await this.sync({ alter: true })
}
export default class User {
}

View File

@@ -41,4 +41,8 @@ sio.on("connection", (socket) => {
})
})
httpApp.listen(80)
export {
app as expressApp,
httpApp as httpServer,
sio as SocketIoServer,
}

View File

@@ -0,0 +1,11 @@
import './compile-webpage.ts'
import {
expressApp,
httpServer,
SocketIoServer,
} from './server/http.ts'
httpServer.listen(8080)
console.log("TheWhiteSilk server started successfully")