Show push example under the detail page (#3739)

This commit is contained in:
Louis Lam 2023-09-25 17:49:00 +08:00 committed by GitHub
parent bef6a7911f
commit 98b93c887a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 249 additions and 23 deletions

View file

@ -4,6 +4,8 @@ const { sendInfo } = require("../client");
const { checkLogin } = require("../util-server");
const GameResolver = require("gamedig/lib/GameResolver");
const { testChrome } = require("../monitor-types/real-browser-monitor-type");
const fs = require("fs");
const path = require("path");
let gameResolver = new GameResolver();
let gameList = null;
@ -62,4 +64,29 @@ module.exports.generalSocketHandler = (socket, server) => {
});
});
});
socket.on("getPushExample", (language, callback) => {
try {
let dir = path.join("./extra/push-examples", language);
let files = fs.readdirSync(dir);
for (let file of files) {
if (file.startsWith("index.")) {
callback({
ok: true,
code: fs.readFileSync(path.join(dir, file), "utf8"),
});
return;
}
}
} catch (e) {
}
callback({
ok: false,
msg: "Not found",
});
});
};