Skip to content

Commit

Permalink
feat: rename API path from expansion to extension
Browse files Browse the repository at this point in the history
  • Loading branch information
surmon-china committed Aug 6, 2024
1 parent c529a14 commit 4355546
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 16 deletions.
11 changes: 4 additions & 7 deletions public/__demo__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,11 @@ window.__axiosAdapter = (config) => {
'/auth/admin': {
get: () => ensureJSON('auth/admin')
},
'/expansion/statistic': {
get: () => ensureJSON('expansion/statistic')
'/extension/statistic': {
get: () => ensureJSON('extension/statistic')
},
'/expansion/google-token': {
get: () => ensureJSON('expansion/google-token')
},
'/expansion/uptoken': {
get: () => ensureJSON('expansion/uptoken')
'/extension/uptoken': {
get: () => ensureJSON('extension/uptoken')
},
'/vote': {
get: () => ensureJSON('vote')
Expand Down
18 changes: 9 additions & 9 deletions src/apis/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import { Option } from '@/constants/option'

export const OPTION_API_PATH = '/option'
export const ARCHIVE_API_PATH = '/archive'
export const EXPANSION_API_PATHS = {
UPLOAD: '/expansion/upload',
STATISTIC: '/expansion/statistic',
GOOGLE_TOKEN: '/expansion/google-token',
DATA_BASE_BACKUP: '/expansion/database-backup'
export const EXTENSION_API_PATHS = {
UPLOAD: '/extension/upload',
STATISTIC: '/extension/statistic',
GOOGLE_TOKEN: '/extension/google-token',
DATA_BASE_BACKUP: '/extension/database-backup'
}

export interface Statistics {
Expand All @@ -23,7 +23,7 @@ export interface Statistics {
/** 获取全站统计信息 */
export function getStatistics() {
return nodepress
.get<Statistics>(EXPANSION_API_PATHS.STATISTIC)
.get<Statistics>(EXTENSION_API_PATHS.STATISTIC)
.then((response) => response.result)
}

Expand Down Expand Up @@ -51,7 +51,7 @@ export function getCommentCalendar() {
/** 获取 GA Token(仅适用于 V3) */
export function getGAToken(): Promise<string> {
return nodepress
.get<any>(EXPANSION_API_PATHS.GOOGLE_TOKEN)
.get<any>(EXTENSION_API_PATHS.GOOGLE_TOKEN)
.then(({ result: credentials }) => credentials.access_token as string)
}

Expand All @@ -62,7 +62,7 @@ export function updateArchiveCache() {

/** 更新数据库备份 */
export function updateDatabaseBackup() {
return nodepress.patch(EXPANSION_API_PATHS.DATA_BASE_BACKUP).then((response) => response.result)
return nodepress.patch(EXTENSION_API_PATHS.DATA_BASE_BACKUP).then((response) => response.result)
}

/** 获取系统配置 */
Expand All @@ -89,7 +89,7 @@ export async function uploadStaticToNodePress(options: {
url: string
key: string
size: number
}>(EXPANSION_API_PATHS.UPLOAD, param, {
}>(EXTENSION_API_PATHS.UPLOAD, param, {
onUploadProgress: ({ loaded, total }) => {
if (lodash.isNumber(total)) {
const progress = (loaded / total) * 100
Expand Down
40 changes: 40 additions & 0 deletions src/pages/Dashboard/GaTodo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// import React from 'react'
// import { Link } from 'react-router-dom'

// interface StatisticCardProps extends React.PropsWithChildren {
// loading: boolean
// title: string
// suffix?: string
// value: string | number
// icon: React.ReactNode
// extra?: React.ReactNode
// }

// export const StatisticCard: React.FC<StatisticCardProps> = (props) => {
// getGA({
// dateRanges: [
// {
// startDate: '2020-03-31',
// endDate: 'today'
// }
// ],
// dimensions: [
// {
// name: 'city'
// }
// ],
// metrics: [
// {
// name: 'activeUsers'
// }
// ]
// })
// .then((res) => {
// console.log('---------------ga', res)
// })
// .catch((error) => {
// console.warn('---------------error', error)
// })

// return <div>GA 测试</div>
// }

0 comments on commit 4355546

Please sign in to comment.