| 1234567891011121314151617181920212223242526272829303132333435363738 |
- const routes = {
- page1: "pages/page1.html",
- page2: "pages/page2.html",
- page3: "pages/page3.html",
- page4: "pages/page4.html",
- page5: "pages/page5.html",
- page6: "pages/page6.html",
- page7: "pages/page7.html",
- page8: "pages/page8.html",
- };
- async function loadPage(name){
- const view = document.getElementById("view");
- const url = routes[name];
- if(!url){
- view.innerHTML = "<div class='card'>无法找到页面</div>";
- return;
- }
- try{
- const res = await fetch(url, {
- credentials: "include"
- });
- const html = await res.text();
- if (html.includes("login.html") || html.includes("登录")) {
- window.location.href = "/";
- return;
- }
- view.innerHTML = html;
- }catch(e){
- view.innerHTML = "<div class='card'>页面加载失败</div>";
- }
- }
|