The project advance

This commit is contained in:
Xamora 2023-11-27 21:59:41 +01:00
parent ffbfe2ddd0
commit 8bce7d33ca
5 changed files with 14 additions and 3 deletions

View File

@ -31,7 +31,6 @@ class ChatConsumer(WebsocketConsumer):
self.send(text_data=json.dumps({
'type':'chat',
'username':self.scope["user"].pk,
'username':self.scope["user"].username,
'message':message
}))

View File

@ -10,6 +10,8 @@ import RegisterView from "./views/accounts/RegisterView.js";
let client = new Client(location.protocol + "//" + location.host)
let lastView = undefined
const pathToRegex = path => new RegExp("^" + path.replace(/\//g, "\\/").replace(/:\w+/g, "(.+)") + "$");
const getParams = match => {
@ -54,7 +56,10 @@ const router = async () => {
};
}
if (lastView !== undefined)
await lastView.leavePage();
const view = new match.route.view(getParams(match));
lastView = view;
document.querySelector("#app").innerHTML = await view.getHtml();

View File

@ -6,6 +6,9 @@ export default class {
async postInit() {
}
async leavePage() {
}
setTitle(title) {
document.title = title;
}

View File

@ -36,6 +36,10 @@ export default class extends AbstractView {
}
async leavePage() {
this.chatSocket.close();
}
async getHtml() {
return `
<h1>Chat</h1>

View File

@ -6,5 +6,5 @@ djangorestframework==3.14.0
install==1.3.5
pytz==2023.3.post1
sqlparse==0.4.4
channels==3.0.5
channels==4.0.0
daphne