Skip to content

Commit 083de1f

Browse files
committed
Remove jQuery
1 parent 49417ae commit 083de1f

File tree

16 files changed

+258
-204
lines changed

16 files changed

+258
-204
lines changed

README.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ Anatolo设计极致简约,但麻雀虽小,五脏理应俱全。因此,我
2929

3030

3131
## 改进
32+
33+
- 20240904 [BREAKING] 引入了 Rollup.js
34+
3235
- 我在学世界语所以主题改名为Anatolo(
3336
- 暗黑模式支持
3437
- 增加了文章概要的选项
@@ -60,12 +63,15 @@ Anatolo设计极致简约,但麻雀虽小,五脏理应俱全。因此,我
6063

6164
Clone:
6265

63-
```
66+
```bash
6467
git clone https://gitee.com/Lhcfl/hexo-theme-anatolo.git themes/Anatolo
65-
或者直接下载主题zip包解压至主题目录下,重命名为Anatolo
68+
cd themes/Anatolo
69+
yarn # 必须安装依赖
6670
```
6771

68-
安装依赖
72+
安装依赖:
73+
74+
在hexo博客根目录:
6975

7076
```
7177
npm install hexo-renderer-pug --save

includes/tasks/rollup.js

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ const cp = require('child_process');
22

33
module.exports = function (hexo) {
44
hexo.log.info('building js');
5-
console.log(cp);
65
cp.execSync('yarn build', { cwd: './themes/Anatolo', stdio: 'inherit' });
76
hexo.log.info('build successful!');
87
};

layout/mixins.pug

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ mixin make_post(item, is_detail)
4848
i.fa.fa-tag
4949
a.tag(href=config.root + tag.path, title=tag.name)= tag.name + " "
5050

51-
span.leancloud_visitors
5251
span
5352
- var words = word_count(item.content);
5453
- var needtime = duration((words / 300.0) * 60, "seconds");

layout/partial/comments.pug

-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ mixin require_comment_scripts
1919

2020
mixin make_comments
2121
if theme.always_enable_comments || page.comments
22-
script(src=url_for("js/visitors.js"))
23-
2422
if theme.duoshuo
2523
a#comments
2624
.ds-thread(data-thread-key=page.path, data-title=page.title, data-url=page.permalink, data-author-key="1")

layout/partial/components/float-btn.pug

-6
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,3 @@ button#scroll-to-top.float-button.hide(
44
title=__("scroll_to_top")
55
)
66
i.fa.fa-angle-up
7-
8-
script.
9-
$(document).on("scroll", () => {
10-
if (window.scrollY < 200) $("#scroll-to-top.float-button").addClass("hide");
11-
else $("#scroll-to-top.float-button").removeClass("hide");
12-
});

source/css/blog_basic.styl

-3
Original file line numberDiff line numberDiff line change
@@ -1185,8 +1185,5 @@ table tbody>tr:nth-child(odd)>td, table tbody>tr:nth-child(odd)>th
11851185
margin-top: 1%
11861186
margin-left: 7.2%
11871187

1188-
.leancloud-visitors-count
1189-
margin-left: 5px
1190-
11911188
.katex .katex-html
11921189
display: none

source/js/visitors.js

-8
This file was deleted.

src/anatolo/anatolo.ts

+3-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import { Site, WebPage } from '../types/site';
21
import EventEmitter3 from 'eventemitter3';
32
import { AnatoloRef } from './ref';
43
import { AnatoloSite } from './site';
54
import { AnatoloSearch } from './search';
65
import { AnatoloRouter } from './router';
7-
import $ from 'jquery';
86
import { loadComment } from './load-comment';
97
import { darkLightToggle } from './dark-light-toggle';
8+
import { success } from '@/components/success';
109

1110
export class AnatoloManager extends EventEmitter3 {
1211
commentConfig = new AnatoloRef<any>(null);
@@ -50,17 +49,9 @@ export class AnatoloManager extends EventEmitter3 {
5049
}
5150
return this.root + url;
5251
}
52+
5353
success() {
54-
return new Promise<void>((res) => {
55-
$('#success-indicator').addClass('show');
56-
setTimeout(() => {
57-
$('#success-indicator').addClass('animated fadeOut');
58-
}, 500);
59-
setTimeout(() => {
60-
$('#success-indicator').removeClass('show animated fadeOut');
61-
res();
62-
}, 1000);
63-
});
54+
return success();
6455
}
6556

6657
share = {

src/anatolo/router.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { make_friends_list } from '@/utils/main';
22
import { AnatoloManager } from './anatolo';
33
import { AnatoloRef } from './ref';
4-
import $ from 'jquery';
54
import { SiteStatic } from './site-static';
65

76
type RouterState = { url: string; body: string; title: string; scrollY?: number };
@@ -47,11 +46,14 @@ export class AnatoloRouter {
4746
set loading(status: boolean) {
4847
this.__loading.value = status;
4948
this.__animating.value = true;
49+
const mainEl = document.querySelector('.main.animated');
5050
if (status === true) {
51-
$('.main.animated').removeClass('fadeInDown').addClass('fadeOutDown');
51+
mainEl?.classList.add('fadeOutDown');
52+
mainEl?.classList.remove('fadeInDown');
5253
}
5354
if (status === false) {
54-
$('.main.animated').addClass('fadeInDown').removeClass('fadeOutDown');
55+
mainEl?.classList.remove('fadeOutDown');
56+
mainEl?.classList.add('fadeInDown');
5557
}
5658
setTimeout(() => {
5759
this.__animating.value = false;
@@ -87,7 +89,7 @@ export class AnatoloRouter {
8789
async queryPageData(link: string) {
8890
const cached = this.routerStates.get(link);
8991
if (cached) return cached;
90-
const res = await $.ajax(link);
92+
const res = await fetch(link).then((res) => res.text());
9193
if (typeof res !== 'string') {
9294
throw {
9395
reason: 'NOT HTML',
@@ -119,7 +121,7 @@ export class AnatoloRouter {
119121
history.pushState({ time: new Date(), url: url }, '', url);
120122
}
121123

122-
$('main-outlet').html(body);
124+
document.querySelector('main-outlet')!.innerHTML = body;
123125
document.title = title;
124126

125127
this.updateRouterState({
@@ -162,6 +164,7 @@ export class AnatoloRouter {
162164

163165
async routeTo(link: string, pushState = true) {
164166
console.log(`Route to: ${link}`);
167+
165168
if (!link) return;
166169
if (this.isThisSite(link)) {
167170
const url = new URL(link, window.location.origin);

0 commit comments

Comments
 (0)