Skip to content

Commit 141cf66

Browse files
committed
docs: ✏️ Upgrade Website Demo
1 parent 8f9fe1c commit 141cf66

21 files changed

Lines changed: 2071 additions & 212 deletions

.github/workflows/deploy.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,11 @@ jobs:
136136
- name: Deploy to GitHub Pages
137137
run: |
138138
git reset --hard HEAD
139-
git clean -xdf
140-
pnpm install gh-pages idmp @types/serialize-javascript -Dw
139+
git clean -ffdx
140+
pnpm install gh-pages idmp @types/serialize-javascript lucide-react react-icons -Dw
141141
pnpm run www
142142
echo "idmp.js.org" > dist/CNAME
143+
mv dist/index.html dist/404.html
143144
pnpm gh-pages -d dist -b gh-pages -m "Deploy version ${{ env.VERSION }}" -r "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git"
144145
env:
145146
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.prettierrc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@
33
"semi": false,
44
"tabWidth": 2,
55
"singleQuote": true,
6-
"plugins": ["prettier-plugin-organize-imports"]
6+
"plugins": [
7+
"prettier-plugin-organize-imports",
8+
"prettier-plugin-tailwindcss",
9+
"prettier-plugin-lint-md"
10+
]
711
}

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ An elegant, lightweight (~1KB gzipped) utility to deduplicate concurrent calls t
1111

1212
English | [简体中文](README.zh-CN.md)
1313

14-
- Demo <https://idmp.haozi.me>
14+
- Demo <https://idmp.js.org/>
1515

1616
## Breaking Changes
1717

@@ -28,7 +28,7 @@ English | [简体中文](README.zh-CN.md)
2828
import idmp from 'idmp'
2929

3030
const getInfo = async () => {
31-
const API = `https://idmp.haozi.me/api?/your-info`
31+
const API = `https://idmp.js.org/api?/your-info`
3232
return await fetch(API).then((d) => d.text())
3333
}
3434

@@ -48,7 +48,7 @@ Check the network console, there will be only 1 network request, but 10 callback
4848

4949
```typescript
5050
const getInfoById = async (id: string) => {
51-
const API = `https://idmp.haozi.me/api?/your-info&id=${id}`
51+
const API = `https://idmp.js.org/api?/your-info&id=${id}`
5252
return await fetch(API).then((d) => d.json())
5353
}
5454

@@ -160,7 +160,7 @@ In React, you can share requests using SWR, Provider and more complex state mana
160160
2. **Provider**: Needs centralized data management. The data center can't perceive which modules will consume the data, need to maintain the data for a long time, and dare not delete it in time
161161
3. **Redux**: Should focus on state changes and sequences, not data sharing. `idmp` lets you focus more on local state
162162

163-
See [demo](https://idmp.haozi.me) and [source code](https://github.com/ha0z1/idmp/tree/main/demo)
163+
See [demo](https://idmp.js.org/) and [source code](https://github.com/ha0z1/idmp/tree/main/demo)
164164

165165
So when module A or module B's code is deleted, there is no need to maintain their cache.
166166

README.zh-CN.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
[English](README.md) | 简体中文
1313

14-
- Demo <https://idmp.haozi.me>
14+
- Demo <https://idmp.js.org/>
1515

1616
## Breaking Changes
1717

@@ -28,7 +28,7 @@
2828
import idmp from 'idmp'
2929

3030
const getInfo = async () => {
31-
const API = `https://idmp.haozi.me/api?/your-info`
31+
const API = `https://idmp.js.org/api?/your-info`
3232
return await fetch(API).then((d) => d.text())
3333
}
3434

@@ -48,7 +48,7 @@ for (let i = 0; i < 10; ++i) {
4848

4949
```typescript
5050
const getInfoById = async (id: string) => {
51-
const API = `https://idmp.haozi.me/api?/your-info&id=${id}`
51+
const API = `https://idmp.js.org/api?/your-info&id=${id}`
5252
return await fetch(API).then((d) => d.json())
5353
}
5454

@@ -159,7 +159,7 @@ localStorage.idmp_debug = false,以禁用调试信息显示。
159159
2. Provider 数据共享: 需要一个中心化的数据管理。数据中心无法感知哪些模块会消费哪些数据,需要长期维护这些数据,而不敢及时删除
160160
3. Redux 等状态管理库:应该专注的是状态的变化和时序,而非共享数据。`idmp` 让你更关注于局部状态
161161

162-
查看 [demo](https://idmp.haozi.me)[源码](https://github.com/ha0z1/idmp/tree/main/demo)
162+
查看 [demo](https://idmp.js.org/)[源码](https://github.com/ha0z1/idmp/tree/main/demo)
163163

164164
这样当模块 A 或者模块 B 的代码删除后,是不需要维护他们的缓存的。
165165

demo/App.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@import 'tailwindcss';

demo/App.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react'
2-
import { createBrowserRouter, RouterProvider } from 'react-router-dom'
3-
2+
import { createBrowserRouter, Navigate, RouterProvider } from 'react-router-dom'
3+
import './App.css'
44
import Home from './pages/Home'
55
import Storage from './pages/Storage'
66

@@ -13,6 +13,10 @@ const router = createBrowserRouter([
1313
path: 'storage',
1414
element: <Storage />,
1515
},
16+
{
17+
path: '*',
18+
element: <Navigate to="/" replace />,
19+
},
1620
])
1721

1822
const App = () => <RouterProvider router={router} />

demo/api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import idmp from '../src'
1+
import idmp from 'idmp'
22
// ;(window as any).idmp = idmp
33
// ;(window as any).g = g
44
// export const getUserData = async (userId: string) => {
@@ -11,7 +11,7 @@ const sleep = (delay: number) =>
1111
new Promise((resolve) => setTimeout(resolve, delay))
1212

1313
export const getUserData = async (userId: string) => {
14-
const API = `https://idmp.haozi.me/api?id=${userId}&t=${Math.random()}`
14+
const API = `https://idmp.js.org/api?id=${userId}&t=${Math.random()}`
1515
await fetch(API).then((d) => d.text())
1616

1717
await sleep(2000)

demo/components/Ribbon.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export default function Ribbon() {
2+
return (
3+
<div className="fixed top-10 right-[-42px] z-50 w-[200px] rotate-45 shadow-lg">
4+
<a
5+
href="https://github.com/ha0z1/idmp"
6+
target="_blank"
7+
className="block h-6 border border-white/30 bg-black text-center leading-6 font-medium text-slate-200 no-underline shadow-[0_0_10px_rgba(0,0,0,0.31)] transition hover:bg-slate-900"
8+
>
9+
Fork me on GitHub
10+
</a>
11+
</div>
12+
)
13+
}

demo/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"private": true,
33
"dependencies": {
4-
"idmp": "3.6.6"
4+
"@tailwindcss/vite": "^4.1.12",
5+
"idmp": "*",
6+
"lucide-react": "^0.541.0",
7+
"react-icons": "^5.5.0"
58
}
69
}

0 commit comments

Comments
 (0)