-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
866fdec
commit 1b6b903
Showing
5 changed files
with
65 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,7 @@ pnpm run dev | |
- npm 发布 ✅ | ||
- 文章摘要标题 ✅ | ||
- 图片懒加载 ✅ | ||
- 文章懒加载 (working) | ||
- 文章懒加载 ✅ | ||
- 站内搜索 | ||
- 文章评论 ✅ | ||
- 不同颜色主题 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "vitepress-theme-sakurairo", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "a sakurairo blog theme base on vitepress", | ||
"author": "wuyifan <[email protected]>", | ||
"license": "MIT", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,12 @@ | |
* @Author: wuyifan0203 [email protected] | ||
* @Date: 2024-03-14 15:59:38 | ||
* @LastEditors: wuyifan0203 [email protected] | ||
* @LastEditTime: 2024-03-15 13:39:48 | ||
* @LastEditTime: 2024-03-21 17:51:53 | ||
* @FilePath: /vitepress-theme-sakurairo/src/utils/lazyLoad.ts | ||
* Copyright (c) 2024 by wuyifan0203 email: [email protected], All Rights Reserved. | ||
*/ | ||
|
||
import type { App, Ref } from "vue" | ||
import type { App, DirectiveBinding } from "vue" | ||
import { ImageLoader, State } from "./ImageLoader"; | ||
|
||
function lazy(options: { loading: string, error?: string }) { | ||
|
@@ -21,7 +21,6 @@ function lazy(options: { loading: string, error?: string }) { | |
const manager = managerQueue.find((manager) => { | ||
return manager.el === entry.target | ||
}) | ||
// console.log(manager, 'manager'); | ||
|
||
if (manager) { | ||
if (manager.state === State.LOADED) { | ||
|
@@ -49,8 +48,7 @@ function lazy(options: { loading: string, error?: string }) { | |
} | ||
} | ||
|
||
function add(el: HTMLImageElement, binding: Ref<string>) { | ||
// console.log(el, binding, 'add'); | ||
function add(el: HTMLImageElement, binding: DirectiveBinding) { | ||
|
||
const src = binding.value; | ||
const manager = new ImageLoader({ | ||
|
@@ -73,7 +71,7 @@ function lazy(options: { loading: string, error?: string }) { | |
manager && removeManager(manager) | ||
} | ||
|
||
function update(el: HTMLImageElement, binding: Ref<string>) { | ||
function update(el: HTMLImageElement, binding: DirectiveBinding) { | ||
// console.log(el, binding, 'update'); | ||
const src = binding.value; | ||
const manager = managerQueue.find((manager) => { | ||
|
@@ -82,11 +80,12 @@ function lazy(options: { loading: string, error?: string }) { | |
manager && manager.update(src) | ||
} | ||
|
||
// window.cache = cache; | ||
return { | ||
managerQueue, | ||
remove, | ||
add, | ||
update | ||
update, | ||
} | ||
|
||
|
||
|