-
Notifications
You must be signed in to change notification settings - Fork 19
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
Showing
24 changed files
with
1,205 additions
and
152 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
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** @type {import('eslint').Linter.Config} */ | ||
module.exports = { | ||
root: true, | ||
extends: ['gbeata-eslint'], | ||
parserOptions: { | ||
tsconfigRootDir: __dirname, | ||
project: ['./tsconfig.json'], | ||
}, | ||
rules: { | ||
'@typescript-eslint/no-unused-expressions': 'off', | ||
}, | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
declare type Recordable<T = any> = Record<string, T>; | ||
|
||
interface ViteEnv { | ||
VITE_PORT: number; | ||
VITE_PROXY: [string, string][]; | ||
VITE_DROP_CONSOLE: boolean; | ||
} | ||
|
||
// read all environment variable configuration files to process.env | ||
export function wrapperEnv(envConf: Recordable): ViteEnv { | ||
const result: any = {}; | ||
|
||
for (const envName of Object.keys(envConf)) { | ||
let realName = envConf[envName].replace(/\\n/g, '\n'); | ||
realName = realName === 'true' ? true : realName === 'false' ? false : realName; | ||
|
||
if (envName === 'VITE_PORT') { | ||
realName = Number(realName); | ||
} | ||
|
||
if (envName === 'VITE_PROXY' && realName) { | ||
try { | ||
realName = JSON.parse(realName.replace(/'/g, '"')); | ||
} catch (error) { | ||
realName = ''; | ||
} | ||
} | ||
|
||
result[envName] = realName; | ||
|
||
if (typeof realName === 'string') { | ||
process.env[envName] = realName; | ||
} else if (typeof realName === 'object') { | ||
process.env[envName] = JSON.stringify(realName); | ||
} | ||
} | ||
|
||
return result; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// 配置文档: https://prettier.nodejs.cn/ | ||
|
||
/** @type {import('prettier').Config} */ | ||
export default { | ||
// 每行最大宽度,超过换行 | ||
printWidth: 120, | ||
// 缩进级别的空格数 | ||
tabWidth: 2, | ||
// 用制表符而不是空格缩进行 | ||
useTabs: false, | ||
// 使用单引号而不是双引号 | ||
singleQuote: true, | ||
// 在 JSX 中使用单引号而不是双引号 | ||
jsxSingleQuote: true, | ||
// 对象字面量中括号之间有空格 { foo: bar } | ||
bracketSpacing: true, | ||
// 将多行 HTML(HTML、JSX)元素的 > 放在最后一行的末尾,而不是单独放在下一行 | ||
bracketSameLine: false, | ||
// 在唯一的箭头函数参数周围包含括号(avoid:省略括号, always:不省略括号) | ||
arrowParens: 'always', | ||
// 换行符使用 lf 结尾 可选值 auto|lf|crlf|cr | ||
endOfLine: 'lf', | ||
objectCurlyNewline: { | ||
// 对象大括号换行 | ||
multiline: true, | ||
}, | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import { createProdMockServer } from 'vite-plugin-mock/es/createProdMockServer'; | ||
|
||
// 获取mock目录data的数据 | ||
|
||
const modules = import.meta.glob('../mock/data/*.ts', { eager: true }) as Recordable; | ||
|
||
const mockModules: any[] = []; | ||
Object.keys(modules).forEach((key) => { | ||
if (key.includes('/_')) return; | ||
|
||
const module = modules[key].default || {}; | ||
const moduleList = Array.isArray(module) ? [...module] : [module]; | ||
mockModules.push(...moduleList); | ||
}); | ||
|
||
/** | ||
* Used in a production environment, need to manually import all modules. | ||
*/ | ||
export function setupProdMockServer() { | ||
console.log(mockModules); | ||
createProdMockServer(mockModules); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import LazyLoad from './src/LazyLoad'; | ||
|
||
export default LazyLoad; |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { type ReactNode, Suspense } from 'react'; | ||
|
||
import Loading from './Loading'; | ||
|
||
import type { LoadableComponent } from '@loadable/component'; | ||
|
||
/** | ||
* @description 路由懒加载 | ||
* @param {Element} Component 需要访问的组件 | ||
* @returns element | ||
*/ | ||
const LazyLoad = (Component: LoadableComponent<{}>): ReactNode => ( | ||
<> | ||
<Suspense fallback={<Loading />}> | ||
<Component /> | ||
</Suspense> | ||
</> | ||
); | ||
|
||
export default LazyLoad; |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* HTML: <div class="loader"></div> */ | ||
import { createStyles } from 'antd-style'; | ||
|
||
const useStyles = createStyles(({ css, token }) => ({ | ||
loadingContainer: css` | ||
width: 100%; | ||
height: 100%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
background: rgba(255, 255, 255, 0.2); | ||
backdrop-filter: blur(10px); | ||
`, | ||
loading: css` | ||
width: 50px; | ||
aspect-ratio: 1; | ||
display: grid; | ||
border: 4px solid #0000; | ||
border-radius: 50%; | ||
border-right-color: ${token.colorPrimary}; | ||
animation: l15 1s infinite linear; | ||
&:before, | ||
&:after { | ||
content: ''; | ||
grid-area: 1/1; | ||
margin: 2px; | ||
border: inherit; | ||
border-radius: 50%; | ||
animation: l15 2s infinite; | ||
} | ||
&:after { | ||
margin: 8px; | ||
animation-duration: 3s; | ||
} | ||
@keyframes l15 { | ||
100% { | ||
transform: rotate(1turn); | ||
} | ||
} | ||
`, | ||
})); | ||
|
||
const Loading = () => { | ||
const { styles } = useStyles(); | ||
return ( | ||
<div className={styles.loadingContainer}> | ||
<div className={styles.loading} /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Loading; |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import SvgIcon from '../SvgIcon'; | ||
import useStyles from './style'; | ||
|
||
const LoadingPage = () => { | ||
const { styles } = useStyles(); | ||
return ( | ||
<div className={styles['loading-page']}> | ||
<div className='loading-side'></div> | ||
<SvgIcon | ||
className=' | ||
loading-logo' | ||
name='logo' | ||
size={32} | ||
/> | ||
<div className='loading-in'></div> | ||
</div> | ||
); | ||
}; | ||
export default LoadingPage; |
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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { createStyles } from 'antd-style'; | ||
|
||
const useStyles = createStyles(({ token }) => ({ | ||
'loading-page': { | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
width: '100%', | ||
height: '100vh', | ||
'.loading-logo': { | ||
position: 'absolute', | ||
color: token.colorPrimary, | ||
left: '50%', | ||
marginLeft: '-16px', | ||
animation: 'loading3 3s linear forwards', | ||
transformOrigin: 'center center', | ||
}, | ||
'@keyframes loading3': { | ||
'50%': { | ||
transform: 'perspective(100px) rotateY(360deg) scale(0.8)', | ||
opacity: 0.6, | ||
}, | ||
}, | ||
'.loading-side': { | ||
width: '80px', | ||
height: '80px', | ||
border: `2px solid ${token.colorPrimaryBorder}`, | ||
animation: 'loading 3s linear forwards', | ||
}, | ||
'@keyframes loading': { | ||
'25%': { | ||
transform: 'rotate(180deg)', | ||
}, | ||
'50%': { | ||
opacity: 0.5, | ||
borderRadius: '50%', | ||
transform: 'scale(0.85)', | ||
}, | ||
'100%': { | ||
transform: 'scale(1.15)', | ||
opacity: 1, | ||
borderRadius: '30%', | ||
borderColor: token.colorPrimaryBorderHover, | ||
}, | ||
}, | ||
'.loading-in': { | ||
width: '68px', | ||
height: '68px', | ||
position: 'absolute', | ||
left: '50%', | ||
marginLeft: '-38px', | ||
border: `4px solid ${token.colorPrimaryBorderHover}`, | ||
animation: 'loading1 3s linear forwards', | ||
}, | ||
'@keyframes loading1': { | ||
'0%': { | ||
transform: 'rotate(45deg)', | ||
}, | ||
'25%': { | ||
transform: 'rotate(270deg) ', | ||
}, | ||
'50%': { | ||
opacity: 0.5, | ||
borderRadius: '50%', | ||
transform: 'scale(1.4)', | ||
}, | ||
'100%': { | ||
transform: 'scale(0.98)', | ||
opacity: 1, | ||
borderRadius: '30%', | ||
borderColor: token.colorPrimaryBorder, | ||
}, | ||
}, | ||
}, | ||
})); | ||
|
||
export default useStyles; |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { createStyles } from 'antd-style'; | ||
|
||
const useStyles = createStyles(() => ({ | ||
'svg-icon': { | ||
display: 'inline-block', | ||
verticalAlign: '-0.15em', | ||
fill: 'currentColor', | ||
overflow: 'hidden', | ||
}, | ||
})); | ||
export default useStyles; |
Oops, something went wrong.