feat: init project

This commit is contained in:
aibayanyu20 2025-02-19 20:55:04 +08:00
commit 24a6c59d73
30 changed files with 6578 additions and 0 deletions

7
.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
node_modules
dist
.data
.nitro
.cache
.output
.env

8
.idea/.gitignore generated vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

10
.idea/UniappTool.xml generated Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="cn.fjdmy.uniapp.UniappProjectDataService">
<option name="generalBasePath" value="$PROJECT_DIR$" />
<option name="manifestPath" value="$PROJECT_DIR$/manifest.json" />
<option name="pagesPath" value="$PROJECT_DIR$/pages.json" />
<option name="scanNum" value="1" />
<option name="type" value="store" />
</component>
</project>

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
</profile>
</component>

6
.idea/jsLinters/eslint.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EslintConfiguration">
<option name="fix-on-save" value="true" />
</component>
</project>

12
.idea/mock-nitro.iml generated Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

8
.idea/modules.xml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/mock-nitro.iml" filepath="$PROJECT_DIR$/.idea/mock-nitro.iml" />
</modules>
</component>
</project>

2
.npmrc Normal file
View File

@ -0,0 +1,2 @@
shamefully-hoist=true
strict-peer-dependencies=false

21
README.md Normal file
View File

@ -0,0 +1,21 @@
# Naviui Admin Mock Server
这是navieui 组件库的mock server用于模拟后端接口方便前端开发调试。
## 安装
```bash
npm install
# pnpm安装的方式
pnpm install
```
### 启动
```bash
npm run dev
```

7
eslint.config.js Normal file
View File

@ -0,0 +1,7 @@
import antfu from '@antfu/eslint-config'
export default antfu({
rules: {
'unused-imports/no-unused-vars': 0,
},
})

5
nitro.config.ts Normal file
View File

@ -0,0 +1,5 @@
// https://nitro.unjs.io/config
export default defineNitroConfig({
srcDir: 'server',
compatibilityDate: '2025-02-18',
})

15
package.json Normal file
View File

@ -0,0 +1,15 @@
{
"type": "module",
"private": true,
"scripts": {
"build": "nitro build",
"dev": "nitro dev",
"prepare": "nitro prepare",
"preview": "node .output/server/index.mjs",
"lint": "eslint . --fix"
},
"devDependencies": {
"@antfu/eslint-config": "^4.2.1",
"nitropack": "latest"
}
}

6140
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

3
server/routes/index.ts Normal file
View File

@ -0,0 +1,3 @@
export default defineEventHandler((event) => {
return 'Start by editing <code>server/routes/index.ts</code>.'
})

View File

@ -0,0 +1,26 @@
export default defineEventHandler((event) => {
const page = 1
const pageSize = 10
const dataList: Record<string, any>[] = []
// 根据分页计算数据
for (let i = 0; i < pageSize; i++) {
dataList.push({
id: i + (page - 1) * pageSize,
pid: null,
path: '/dashboard',
redirect: '/dashboard/analysis',
name: `Dashboard` + `_${i + 1}`,
icon: 'AppstoreOutlined',
title: 'pages.dashboard.title',
component: 'RouteView',
})
}
return {
code: 200,
data: {
data: dataList,
total: 200,
},
}
})

View File

@ -0,0 +1,7 @@
export default defineEventHandler((event) => {
return {
code: 200,
msg: '请求成功',
data: {},
}
})

View File

@ -0,0 +1,6 @@
export default defineEventHandler((event) => {
return {
code: 401,
msg: '暂无权限',
}
})

View File

@ -0,0 +1,6 @@
export default defineEventHandler((event) => {
return {
code: 403,
msg: '暂无权限',
}
})

View File

@ -0,0 +1,6 @@
export default defineEventHandler((event) => {
return {
code: 404,
msg: '页面不存在',
}
})

View File

@ -0,0 +1,6 @@
export default defineEventHandler((event) => {
return {
code: 500,
msg: '服务器错误',
}
})

View File

@ -0,0 +1,6 @@
export default defineEventHandler((event) => {
return {
code: 200,
msg: 'delete success',
}
})

View File

@ -0,0 +1,6 @@
export default defineEventHandler((event) => {
return {
code: 200,
msg: 'post request success',
}
})

View File

@ -0,0 +1,6 @@
export default defineEventHandler((event) => {
return {
code: 200,
msg: 'put request success',
}
})

View File

@ -0,0 +1,32 @@
export interface UserInfo {
id: number
username: string
nickname?: string
email?: string
mobile?: string
avatar?: string
signature?: string
realName?: string
money?: number
birth?: string
}
export default defineEventHandler((event) => {
const userInfo: UserInfo = {
id: 1,
username: 'admin',
nickname: 'admin',
email: 'test@qq.com',
mobile: '13000000000',
avatar: 'https://avatars.githubusercontent.com/u/21073088',
signature: '海纳百川,有容乃大',
realName: '张三',
money: 10000,
birth: '1990-01-01',
}
return {
code: 200,
data: userInfo,
msg: '获取成功',
}
})

View File

@ -0,0 +1,9 @@
export default defineEventHandler((event) => {
return {
code: 200,
data: {
token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.UQmqAUhUrpDVV2ST7mZKyLTomVfg7sYkEjmdDI5XF8Q',
},
msg: '登录成功',
}
})

View File

@ -0,0 +1,45 @@
export default defineEventHandler((event) => {
return {
code: 200,
data: [
{
id: 1,
pid: null,
path: '/dashboard',
redirect: '/dashboard/analysis',
name: 'Dashboard',
icon: 'AppstoreOutlined',
title: 'pages.dashboard.title',
component: 'RouteView',
},
{
id: 2,
pid: 1,
path: '/dashboard/analysis',
name: 'DashboardAnalysis',
component: 'DashboardAnalysis',
title: 'pages.dashboard.analysis.title',
icon: null,
},
{
id: 3,
pid: 1,
name: 'DashboardWorkspace',
component: 'DashboardWorkspace',
path: '/dashboard/workspace',
title: 'pages.dashboard.workspace.title',
icon: null,
},
{
id: 4,
pid: null,
name: 'FullPath',
path: 'https://www.baidu.com',
component: 'BlankRoute',
title: 'pages.jump.baidu',
icon: 'LinkOutlined',
},
],
msg: '获取成功',
}
})

View File

@ -0,0 +1,45 @@
export default defineEventHandler((event) => {
return {
code: 200,
data: [
{
id: 1,
pid: null,
path: '/',
redirect: '/home',
name: 'Home',
icon: 'AppstoreOutlined',
title: '工作区',
component: 'RouteView',
},
{
id: 2,
pid: 1,
path: '/home',
name: 'Home',
component: 'Home',
title: 'Home',
icon: null,
},
{
id: 3,
pid: 1,
name: 'workspace',
component: 'Workspace',
path: '/workspace',
title: '工作台',
icon: null,
},
{
id: 4,
pid: null,
name: 'FullPath',
path: 'https://www.baidu.com',
component: 'BlankRoute',
title: '跳转百度',
icon: 'LinkOutlined',
},
],
msg: '获取成功',
}
})

View File

@ -0,0 +1,109 @@
export default defineEventHandler((event) => {
return {
code: 200,
data: [
{
id: 1,
pid: null,
path: '/dashboard',
redirect: '/dashboard/analysis',
name: 'Dashboard',
icon: 'AppstoreOutlined',
title: 'pages.dashboard.title',
component: 'RouteView',
},
{
id: 2,
pid: 1,
path: '/dashboard/analysis',
name: 'DashboardAnalysis',
component: 'DashboardAnalysis',
title: 'pages.dashboard.analysis.title',
icon: null,
},
{
id: 3,
pid: 1,
name: 'DashboardWorkspace',
component: 'DashboardWorkspace',
path: '/dashboard/workspace',
title: 'pages.dashboard.workspace.title',
icon: null,
},
{
id: 5,
pid: null,
component: 'RouteView',
name: 'Menu1',
path: '/menu1',
redirect: '/menu1/1-1',
title: 'pages.menu.title',
icon: 'MenuOutlined',
},
{
id: 6,
pid: 5,
name: 'Menu1-1',
component: 'RouteView',
redirect: '/menu1/1-1/1-1-1',
title: 'pages.menu.menu1.title',
path: '/menu1/1-1',
},
{
id: 7,
pid: 6,
name: 'Menu1-1-1',
component: 'Menu11',
title: 'pages.menu.menu11.title',
path: '/menu1/1-1/1-1-1',
keepAlive: false,
},
{
id: 11,
pid: 6,
name: 'Menu1-1-2',
component: 'Menu12',
title: 'pages.menu.menu12.title',
path: '/menu1/1-1/1-1-2',
keepAlive: false,
},
{
id: 8,
pid: null,
name: 'Menu1-2',
path: '/menu1/1-2',
component: 'RouteView',
redirect: '/menu1/1-2/1-2-1',
title: 'pages.menu.menu2.title',
},
{
id: 9,
pid: 8,
name: 'Menu1-2-1',
path: '/menu1/1-2/1-2-1',
component: 'Menu21',
redirect: null,
title: 'pages.menu.menu2.title',
},
{
id: 10,
pid: 8,
name: 'Menu1-2-2',
path: '/menu1/1-2/1-2-2',
component: 'Menu22',
redirect: null,
title: 'pages.menu.menu2.title',
},
{
id: 4,
pid: null,
name: 'FullPath',
path: 'https://www.baidu.com',
component: 'BlankRoute',
title: 'pages.jump.baidu',
icon: 'LinkOutlined',
},
],
msg: '获取成功',
}
})

View File

@ -0,0 +1,9 @@
export default defineEventHandler((event) => {
return {
code: 200,
data: {
code: '123456',
},
msg: '发送成功',
}
})

4
tsconfig.json Normal file
View File

@ -0,0 +1,4 @@
// https://nitro.unjs.io/guide/typescript
{
"extends": "./.nitro/types/tsconfig.json"
}