Skip to content

Commit

Permalink
feat: Add workplace api
Browse files Browse the repository at this point in the history
  • Loading branch information
kailong502431556 committed Jan 24, 2022
1 parent 83327ea commit cb558f8
Show file tree
Hide file tree
Showing 7 changed files with 344 additions and 123 deletions.
172 changes: 172 additions & 0 deletions mock/workplace/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
import { config } from '@/config/axios/config'
import { MockMethod } from 'vite-plugin-mock'

const { result_code } = config

const timeout = 1000

export default [
// 获取统计
{
url: '/workplace/total',
method: 'get',
timeout,
response: () => {
return {
code: result_code,
data: {
project: 40,
access: 2340,
todo: 10
}
}
}
},
// 获取项目
{
url: '/workplace/project',
method: 'get',
timeout,
response: () => {
return {
code: result_code,
data: [
{
name: 'Github',
icon: 'akar-icons:github-fill',
message: 'workplace.introduction',
personal: 'Archer',
time: new Date()
},
{
name: 'Vue',
icon: 'logos:vue',
message: 'workplace.introduction',
personal: 'Archer',
time: new Date()
},
{
name: 'Angular',
icon: 'logos:angular-icon',
message: 'workplace.introduction',
personal: 'Archer',
time: new Date()
},
{
name: 'React',
icon: 'logos:react',
message: 'workplace.introduction',
personal: 'Archer',
time: new Date()
},
{
name: 'Webpack',
icon: 'logos:webpack',
message: 'workplace.introduction',
personal: 'Archer',
time: new Date()
},
{
name: 'Vite',
icon: 'vscode-icons:file-type-vite',
message: 'workplace.introduction',
personal: 'Archer',
time: new Date()
}
]
}
}
},
// 获取动态
{
url: '/workplace/dynamic',
method: 'get',
timeout,
response: () => {
return {
code: result_code,
data: [
{
keys: ['workplace.push', 'Github'],
time: new Date()
},
{
keys: ['workplace.push', 'Github'],
time: new Date()
},
{
keys: ['workplace.push', 'Github'],
time: new Date()
},
{
keys: ['workplace.push', 'Github'],
time: new Date()
},
{
keys: ['workplace.push', 'Github'],
time: new Date()
},
{
keys: ['workplace.push', 'Github'],
time: new Date()
}
]
}
}
},
// 获取团队信息
{
url: '/workplace/team',
method: 'get',
timeout,
response: () => {
return {
code: result_code,
data: [
{
name: 'Github',
icon: 'akar-icons:github-fill'
},
{
name: 'Vue',
icon: 'logos:vue'
},
{
name: 'Angular',
icon: 'logos:angular-icon'
},
{
name: 'React',
icon: 'logos:react'
},
{
name: 'Webpack',
icon: 'logos:webpack'
},
{
name: 'Vite',
icon: 'vscode-icons:file-type-vite'
}
]
}
}
},
// 获取指数
{
url: '/workplace/radar',
method: 'get',
timeout,
response: () => {
return {
code: result_code,
data: [
{ name: 'workplace.quote', max: 65, personal: 42, team: 50 },
{ name: 'workplace.contribution', max: 160, personal: 30, team: 140 },
{ name: 'workplace.hot', max: 300, personal: 20, team: 28 },
{ name: 'workplace.yield', max: 130, personal: 35, team: 35 },
{ name: 'workplace.follow', max: 100, personal: 80, team: 90 }
]
}
}
}
] as MockMethod[]
24 changes: 24 additions & 0 deletions src/api/dashboard/workplace/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { useAxios } from '@/hooks/web/useAxios'
import type { WorkplaceTotal, Project, Dynamic, Team, RadarData } from './types'

const { request } = useAxios()

export const getCountApi = () => {
return request<WorkplaceTotal>({ url: '/workplace/total', method: 'get' })
}

export const getProjectApi = () => {
return request<Project[]>({ url: '/workplace/project', method: 'get' })
}

export const getDynamicApi = () => {
return request<Dynamic[]>({ url: '/workplace/dynamic', method: 'get' })
}

export const getTeamApi = () => {
return request<Team[]>({ url: '/workplace/team', method: 'get' })
}

export const getRadarApi = () => {
return request<RadarData[]>({ url: '/workplace/radar', method: 'get' })
}
30 changes: 30 additions & 0 deletions src/api/dashboard/workplace/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export type WorkplaceTotal = {
project: number
access: number
todo: number
}

export type Project = {
name: string
icon: string
message: string
personal: string
time: Date | number | string
}

export type Dynamic = {
keys: string[]
time: Date | number | string
}

export type Team = {
name: string
icon: string
}

export type RadarData = {
personal: number
team: number
max: number
name: string
}
3 changes: 2 additions & 1 deletion src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ export default {
yield: 'Yield',
dynamic: 'Dynamic',
push: 'push',
pushCode: 'Archer push code to Github'
pushCode: 'Archer push code to Github',
follow: 'Follow'
},
formDemo: {
input: 'Input',
Expand Down
3 changes: 2 additions & 1 deletion src/locales/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ export default {
yield: '产量',
dynamic: '动态',
push: '推送',
pushCode: 'Archer 推送 代码到 Github'
pushCode: 'Archer 推送 代码到 Github',
follow: '关注'
},
formDemo: {
input: '输入框',
Expand Down
Loading

0 comments on commit cb558f8

Please sign in to comment.