mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-12-22 09:00:10 +00:00
fix navigation with URL base set
This commit is contained in:
parent
23fecb16b2
commit
6691ae27f4
@ -292,6 +292,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="js/admin.js" type="module"></script>
|
||||
<script src="{{ .urlBase }}/js/admin.js" type="module"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
15
ts/admin.ts
15
ts/admin.ts
@ -84,23 +84,24 @@ window.tabs.addTab("accounts", null, accounts.reload);
|
||||
window.tabs.addTab("settings", null, settings.reload);
|
||||
|
||||
for (let tab of ["invites", "accounts", "settings"]) {
|
||||
if (window.location.pathname == "/" + tab) {
|
||||
if (window.location.pathname == window.URLBase + "/" + tab) {
|
||||
window.tabs.switch(tab, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (window.location.pathname == "/") {
|
||||
if (window.location.pathname == window.URLBase + "/") {
|
||||
window.tabs.switch("invites", true);
|
||||
}
|
||||
|
||||
document.addEventListener("tab-change", (event: CustomEvent) => {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const lang = urlParams.get('lang');
|
||||
let tab = "/" + event.detail;
|
||||
if (tab == "/invites") {
|
||||
if (window.location.pathname == "/") {
|
||||
tab = "/";
|
||||
} else { tab = "../"; }
|
||||
let tab = window.URLBase + "/" + event.detail;
|
||||
if (tab == window.URLBase + "/invites") {
|
||||
if (window.location.pathname == window.URLBase + "/") {
|
||||
tab = window.URLBase + "/";
|
||||
} else if (window.URLBase) { tab = window.URLBase; }
|
||||
else { tab = "../"; }
|
||||
}
|
||||
if (lang) {
|
||||
tab += "?lang=" + lang
|
||||
|
@ -45,7 +45,7 @@ export class DOMInvite implements Invite {
|
||||
for (let split of ["#", "?"]) {
|
||||
codeLink = codeLink.split(split)[0];
|
||||
}
|
||||
this._codeLink = codeLink + "invite/" + code;
|
||||
this._codeLink = codeLink + window.URLBase + "invite/" + code;
|
||||
const linkEl = this._codeArea.querySelector("a") as HTMLAnchorElement;
|
||||
if (this.label == "") {
|
||||
linkEl.textContent = code.replace(/-/g, '-');
|
||||
|
2
views.go
2
views.go
@ -36,7 +36,7 @@ func (app *appContext) pushResources(gc *gin.Context, admin bool) {
|
||||
if admin {
|
||||
toPush := []string{"/js/admin.js", "/js/theme.js", "/js/lang.js", "/js/modal.js", "/js/tabs.js", "/js/invites.js", "/js/accounts.js", "/js/settings.js", "/js/profiles.js", "/js/common.js"}
|
||||
for _, f := range toPush {
|
||||
if err := pusher.Push(f, nil); err != nil {
|
||||
if err := pusher.Push(app.URLBase+f, nil); err != nil {
|
||||
app.debug.Printf("Failed HTTP2 ServerPush of \"%s\": %+v", f, err)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user