most-box 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +156 -73
- package/cli.js +2 -2
- package/package.json +9 -5
- package/public/app.css +1519 -0
- package/public/app.jsx +607 -399
- package/public/bundle.css +1 -0
- package/public/bundle.js +10 -14
- package/public/error-boundary.jsx +50 -0
- package/public/index.html +2 -1
- package/public/index.jsx +16 -1
- package/server.js +280 -197
- package/src/config.js +24 -7
- package/src/core/cid.js +23 -18
- package/src/index.js +400 -272
- package/src/utils/security.js +27 -24
- package/public/bundle.js.map +0 -7
- package/public/icons/apple-touch-icon.png +0 -0
- package/public/icons/mask-icon.svg +0 -3
- package/public/icons/most.png +0 -0
- package/public/icons/pwa-192x192.png +0 -0
- package/public/icons/pwa-512x512.png +0 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
export class ErrorBoundary extends React.Component {
|
|
4
|
+
constructor(props) {
|
|
5
|
+
super(props)
|
|
6
|
+
this.state = { hasError: false, error: null }
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
static getDerivedStateFromError(error) {
|
|
10
|
+
return { hasError: true, error }
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
componentDidCatch(error, info) {
|
|
14
|
+
console.error('[ErrorBoundary]', error, info)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
handleReload = () => {
|
|
18
|
+
window.location.reload()
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
render() {
|
|
22
|
+
if (this.state.hasError) {
|
|
23
|
+
return (
|
|
24
|
+
<div style={{
|
|
25
|
+
display: 'flex', flexDirection: 'column', alignItems: 'center',
|
|
26
|
+
justifyContent: 'center', minHeight: '100vh', padding: 32,
|
|
27
|
+
background: '#f8fafc', fontFamily: 'system-ui'
|
|
28
|
+
}}>
|
|
29
|
+
<h1 style={{ fontSize: 20, fontWeight: 600, marginBottom: 8, color: '#1e293b' }}>
|
|
30
|
+
出错了
|
|
31
|
+
</h1>
|
|
32
|
+
<p style={{ color: '#64748b', marginBottom: 24, textAlign: 'center', maxWidth: 400 }}>
|
|
33
|
+
发生了意外错误,请尝试重新加载页面
|
|
34
|
+
</p>
|
|
35
|
+
<button
|
|
36
|
+
onClick={this.handleReload}
|
|
37
|
+
style={{
|
|
38
|
+
padding: '10px 24px', borderRadius: 8, border: 'none',
|
|
39
|
+
background: '#3b82f6', color: '#fff', fontSize: 14,
|
|
40
|
+
cursor: 'pointer'
|
|
41
|
+
}}
|
|
42
|
+
>
|
|
43
|
+
重新加载
|
|
44
|
+
</button>
|
|
45
|
+
</div>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
return this.props.children
|
|
49
|
+
}
|
|
50
|
+
}
|
package/public/index.html
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
<head>
|
|
5
5
|
<meta charset="UTF-8" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
|
7
7
|
<title>MostBox 文件管理</title>
|
|
8
|
+
<link rel="stylesheet" href="./bundle.css" />
|
|
8
9
|
</head>
|
|
9
10
|
|
|
10
11
|
<body>
|
package/public/index.jsx
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import { createRoot } from 'react-dom/client'
|
|
2
|
+
import React from 'react'
|
|
2
3
|
import App from './app.jsx'
|
|
4
|
+
import { ErrorBoundary } from './error-boundary.jsx'
|
|
5
|
+
import './app.css'
|
|
6
|
+
|
|
7
|
+
window.onerror = (message, source, lineno, colno, error) => {
|
|
8
|
+
console.error('[Global Error]', { message, source, lineno, colno, error })
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
window.onunhandledrejection = (event) => {
|
|
12
|
+
console.error('[Unhandled Promise Rejection]', event.reason)
|
|
13
|
+
}
|
|
3
14
|
|
|
4
15
|
const root = createRoot(document.getElementById('root'))
|
|
5
|
-
root.render(
|
|
16
|
+
root.render(
|
|
17
|
+
<ErrorBoundary>
|
|
18
|
+
<App />
|
|
19
|
+
</ErrorBoundary>
|
|
20
|
+
)
|