This commit is contained in:
zhbaor 2021-04-24 14:05:23 +08:00
parent 6f3b109c90
commit bf22cb6ae3
2 changed files with 17 additions and 24 deletions

View file

@ -77,8 +77,8 @@ interface Message {
@Component
export default class App extends Vue {
private nickname = "Zhao Zuohong";
private loggedIn = true;
private nickname = "";
private loggedIn = false;
private error = false;
private loginInfo = "";
private message = "";
@ -107,23 +107,12 @@ export default class App extends Vue {
ipcRenderer.send("message", this.message);
}
mounted(): void {
this.messages.push({
avatar: "EE",
nickname: "EE0000",
message:
"The Old Spanish Trail half dollar was a commemorative coin struck by the United States Bureau of the Mint in 1935.",
});
this.messages.push({
avatar: "66",
nickname: "66CCFF",
message:
"It was designed by L. W. Hoffecker, a coin dealer who had been the moving force behind the effort for a Gadsden Purchase half dollar, vetoed by President Herbert Hoover in 1930, and he sought another commemorative coin that he could control if authorizing legislation was passed.",
});
this.messages.push({
avatar: "ZH",
nickname: "Zhao Zuohong",
message:
"He chose the travels of Spanish officer Álvar Núñez Cabeza de Vaca in the early 16th century.",
ipcRenderer.on("message", (_, nickname, message) => {
this.messages.push({
avatar: this.avatarAbbr(nickname),
nickname: nickname,
message: message,
});
});
}
}

View file

@ -89,13 +89,17 @@ ipcMain.on("login", (event, nickname) => {
event.reply("loginStatus", false, "Nickname too short!");
} else {
event.reply("loginStatus", true, "");
client = net.createConnection({ port: 8000 }, () => {
console.log("connected to server.");
client.write(`login: ${nickname}\n`);
});
client = net.createConnection(
{ host: "cn-zz-bgp-7.sakurafrp.com", port: 8000 },
() => {
client.write(`login: ${nickname}\n`);
}
);
client.on("data", (data) => {
console.log(data.toString());
const msg = data.toString();
const sep = msg.indexOf("\n");
event.reply("message", msg.substring(6, sep), msg.substring(sep + 1));
});
}
});