|
1 | 1 | import { make_friends_list } from '@/utils/main';
|
2 | 2 | import { AnatoloManager } from './anatolo';
|
3 | 3 | import { AnatoloRef } from './ref';
|
4 |
| -import $ from 'jquery'; |
5 | 4 | import { SiteStatic } from './site-static';
|
6 | 5 |
|
7 | 6 | type RouterState = { url: string; body: string; title: string; scrollY?: number };
|
@@ -47,11 +46,14 @@ export class AnatoloRouter {
|
47 | 46 | set loading(status: boolean) {
|
48 | 47 | this.__loading.value = status;
|
49 | 48 | this.__animating.value = true;
|
| 49 | + const mainEl = document.querySelector('.main.animated'); |
50 | 50 | if (status === true) {
|
51 |
| - $('.main.animated').removeClass('fadeInDown').addClass('fadeOutDown'); |
| 51 | + mainEl?.classList.add('fadeOutDown'); |
| 52 | + mainEl?.classList.remove('fadeInDown'); |
52 | 53 | }
|
53 | 54 | if (status === false) {
|
54 |
| - $('.main.animated').addClass('fadeInDown').removeClass('fadeOutDown'); |
| 55 | + mainEl?.classList.remove('fadeOutDown'); |
| 56 | + mainEl?.classList.add('fadeInDown'); |
55 | 57 | }
|
56 | 58 | setTimeout(() => {
|
57 | 59 | this.__animating.value = false;
|
@@ -87,7 +89,7 @@ export class AnatoloRouter {
|
87 | 89 | async queryPageData(link: string) {
|
88 | 90 | const cached = this.routerStates.get(link);
|
89 | 91 | if (cached) return cached;
|
90 |
| - const res = await $.ajax(link); |
| 92 | + const res = await fetch(link).then((res) => res.text()); |
91 | 93 | if (typeof res !== 'string') {
|
92 | 94 | throw {
|
93 | 95 | reason: 'NOT HTML',
|
@@ -119,7 +121,7 @@ export class AnatoloRouter {
|
119 | 121 | history.pushState({ time: new Date(), url: url }, '', url);
|
120 | 122 | }
|
121 | 123 |
|
122 |
| - $('main-outlet').html(body); |
| 124 | + document.querySelector('main-outlet')!.innerHTML = body; |
123 | 125 | document.title = title;
|
124 | 126 |
|
125 | 127 | this.updateRouterState({
|
@@ -162,6 +164,7 @@ export class AnatoloRouter {
|
162 | 164 |
|
163 | 165 | async routeTo(link: string, pushState = true) {
|
164 | 166 | console.log(`Route to: ${link}`);
|
| 167 | + |
165 | 168 | if (!link) return;
|
166 | 169 | if (this.isThisSite(link)) {
|
167 | 170 | const url = new URL(link, window.location.origin);
|
|
0 commit comments