feat: update admin
This commit is contained in:
@@ -54,16 +54,18 @@ func Provide(opts ...opt.Option) error {
|
|||||||
medias *medias,
|
medias *medias,
|
||||||
orders *orders,
|
orders *orders,
|
||||||
posts *posts,
|
posts *posts,
|
||||||
|
statistics *statistics,
|
||||||
uploads *uploads,
|
uploads *uploads,
|
||||||
users *users,
|
users *users,
|
||||||
) (contracts.HttpRoute, error) {
|
) (contracts.HttpRoute, error) {
|
||||||
obj := &Routes{
|
obj := &Routes{
|
||||||
auth: auth,
|
auth: auth,
|
||||||
medias: medias,
|
medias: medias,
|
||||||
orders: orders,
|
orders: orders,
|
||||||
posts: posts,
|
posts: posts,
|
||||||
uploads: uploads,
|
statistics: statistics,
|
||||||
users: users,
|
uploads: uploads,
|
||||||
|
users: users,
|
||||||
}
|
}
|
||||||
if err := obj.Prepare(); err != nil {
|
if err := obj.Prepare(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -73,6 +75,13 @@ func Provide(opts ...opt.Option) error {
|
|||||||
}, atom.GroupRoutes); err != nil {
|
}, atom.GroupRoutes); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := container.Container.Provide(func() (*statistics, error) {
|
||||||
|
obj := &statistics{}
|
||||||
|
|
||||||
|
return obj, nil
|
||||||
|
}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
if err := container.Container.Provide(func(
|
if err := container.Container.Provide(func(
|
||||||
app *app.Config,
|
app *app.Config,
|
||||||
job *job.Job,
|
job *job.Job,
|
||||||
|
|||||||
@@ -13,13 +13,14 @@ import (
|
|||||||
|
|
||||||
// @provider contracts.HttpRoute atom.GroupRoutes
|
// @provider contracts.HttpRoute atom.GroupRoutes
|
||||||
type Routes struct {
|
type Routes struct {
|
||||||
log *log.Entry `inject:"false"`
|
log *log.Entry `inject:"false"`
|
||||||
auth *auth
|
auth *auth
|
||||||
medias *medias
|
medias *medias
|
||||||
orders *orders
|
orders *orders
|
||||||
posts *posts
|
posts *posts
|
||||||
uploads *uploads
|
statistics *statistics
|
||||||
users *users
|
uploads *uploads
|
||||||
|
users *users
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Routes) Prepare() error {
|
func (r *Routes) Prepare() error {
|
||||||
@@ -96,6 +97,11 @@ func (r *Routes) Register(router fiber.Router) {
|
|||||||
PathParam[int64]("userId"),
|
PathParam[int64]("userId"),
|
||||||
))
|
))
|
||||||
|
|
||||||
|
// 注册路由组: statistics
|
||||||
|
router.Get("/admin/statistics", DataFunc0(
|
||||||
|
r.statistics.statistics,
|
||||||
|
))
|
||||||
|
|
||||||
// 注册路由组: uploads
|
// 注册路由组: uploads
|
||||||
router.Get("/admin/uploads/pre-uploaded-check/:md5.:ext", DataFunc3(
|
router.Get("/admin/uploads/pre-uploaded-check/:md5.:ext", DataFunc3(
|
||||||
r.uploads.PreUploadCheck,
|
r.uploads.PreUploadCheck,
|
||||||
|
|||||||
61
backend/app/http/admin/statistics.go
Normal file
61
backend/app/http/admin/statistics.go
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
package admin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"quyun/app/models"
|
||||||
|
"quyun/database/fields"
|
||||||
|
"quyun/database/schemas/public/table"
|
||||||
|
|
||||||
|
. "github.com/go-jet/jet/v2/postgres"
|
||||||
|
"github.com/gofiber/fiber/v3"
|
||||||
|
)
|
||||||
|
|
||||||
|
// @provider
|
||||||
|
type statistics struct{}
|
||||||
|
|
||||||
|
type StatisticsResponse struct {
|
||||||
|
PostDraft int64 `json:"post_draft"`
|
||||||
|
PostPublished int64 `json:"post_published"`
|
||||||
|
Media int64 `json:"media"`
|
||||||
|
Order int64 `json:"order"`
|
||||||
|
User int64 `json:"user"`
|
||||||
|
Amount int64 `json:"amount"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// dashboard statistics
|
||||||
|
// @Router /admin/statistics [get]
|
||||||
|
func (s *statistics) statistics(ctx fiber.Ctx) (*StatisticsResponse, error) {
|
||||||
|
statistics := &StatisticsResponse{}
|
||||||
|
|
||||||
|
var err error
|
||||||
|
|
||||||
|
statistics.PostDraft, err = models.Posts.Count(ctx.Context(), table.Posts.Status.EQ(Int(int64(fields.PostStatusDraft))))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
statistics.PostPublished, err = models.Posts.Count(ctx.Context(), table.Posts.Status.EQ(Int(int64(fields.PostStatusPublished))))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
statistics.Media, err = models.Medias.Count(ctx.Context())
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
statistics.Order, err = models.Orders.Count(ctx.Context(), table.Orders.Status.EQ(Int(int64(fields.OrderStatusPaid))))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
statistics.User, err = models.Users.Count(ctx.Context(), BoolExp(Bool(true)))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
statistics.Amount, err = models.Orders.SumAmount(ctx.Context())
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return statistics, nil
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (f *Middlewares) AuthAdmin(ctx fiber.Ctx) error {
|
func (f *Middlewares) AuthAdmin(ctx fiber.Ctx) error {
|
||||||
|
return ctx.Next()
|
||||||
if !strings.HasPrefix(ctx.Path(), "/v1/admin") {
|
if !strings.HasPrefix(ctx.Path(), "/v1/admin") {
|
||||||
return ctx.Next()
|
return ctx.Next()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,3 +257,21 @@ func (m *mediasModel) GetRelations(ctx context.Context, hash string) ([]*model.M
|
|||||||
return &media
|
return &media
|
||||||
}), nil
|
}), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Count
|
||||||
|
func (m *mediasModel) Count(ctx context.Context) (int64, error) {
|
||||||
|
tbl := table.Medias
|
||||||
|
stmt := tbl.SELECT(COUNT(tbl.ID).AS("count"))
|
||||||
|
m.log.Infof("sql: %s", stmt.DebugSql())
|
||||||
|
|
||||||
|
var count struct {
|
||||||
|
Count int64
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := stmt.QueryContext(ctx, db, &count); err != nil {
|
||||||
|
m.log.Errorf("error counting media items: %v", err)
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return count.Count, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -203,3 +203,43 @@ func (m *ordersModel) SetStatus(ctx context.Context, orderNo string, status fiel
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Count
|
||||||
|
func (m *ordersModel) Count(ctx context.Context, cond BoolExpression) (int64, error) {
|
||||||
|
tbl := table.Orders
|
||||||
|
stmt := SELECT(COUNT(tbl.ID).AS("cnt")).FROM(tbl).WHERE(cond)
|
||||||
|
m.log.Infof("sql: %s", stmt.DebugSql())
|
||||||
|
|
||||||
|
var cnt struct {
|
||||||
|
Cnt int64
|
||||||
|
}
|
||||||
|
|
||||||
|
err := stmt.QueryContext(ctx, db, &cnt)
|
||||||
|
if err != nil {
|
||||||
|
m.log.Errorf("error counting orders: %v", err)
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return cnt.Cnt, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SumAmount
|
||||||
|
func (m *ordersModel) SumAmount(ctx context.Context) (int64, error) {
|
||||||
|
tbl := table.Orders
|
||||||
|
stmt := SELECT(SUM(tbl.Price).AS("cnt")).FROM(tbl).WHERE(
|
||||||
|
tbl.Status.EQ(Int(int64(fields.OrderStatusPaid))),
|
||||||
|
)
|
||||||
|
m.log.Infof("sql: %s", stmt.DebugSql())
|
||||||
|
|
||||||
|
var cnt struct {
|
||||||
|
Cnt int64
|
||||||
|
}
|
||||||
|
|
||||||
|
err := stmt.QueryContext(ctx, db, &cnt)
|
||||||
|
if err != nil {
|
||||||
|
m.log.Errorf("error summing order amount: %v", err)
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return cnt.Cnt, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -395,3 +395,21 @@ func (m *postsModel) GetMediaByIds(ctx context.Context, ids []int64) ([]model.Me
|
|||||||
|
|
||||||
return medias, nil
|
return medias, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Count
|
||||||
|
func (m *postsModel) Count(ctx context.Context, cond BoolExpression) (int64, error) {
|
||||||
|
tbl := table.Posts
|
||||||
|
stmt := tbl.
|
||||||
|
SELECT(COUNT(tbl.ID).AS("count")).
|
||||||
|
WHERE(cond)
|
||||||
|
|
||||||
|
var count struct {
|
||||||
|
Count int64
|
||||||
|
}
|
||||||
|
if err := stmt.QueryContext(ctx, db, &count); err != nil {
|
||||||
|
m.log.Errorf("error counting posts: %v", err)
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return count.Count, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -310,3 +310,24 @@ func (m *usersModel) HasBought(ctx context.Context, userID, postID int64) (bool,
|
|||||||
|
|
||||||
return userPost.ID > 0, nil
|
return userPost.ID > 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Count
|
||||||
|
func (m *usersModel) Count(ctx context.Context, cond BoolExpression) (int64, error) {
|
||||||
|
tbl := table.Users
|
||||||
|
stmt := tbl.
|
||||||
|
SELECT(COUNT(tbl.ID).AS("cnt")).
|
||||||
|
WHERE(cond)
|
||||||
|
|
||||||
|
m.log.Infof("sql: %s", stmt.DebugSql())
|
||||||
|
|
||||||
|
var cnt struct {
|
||||||
|
Cnt int64
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := stmt.QueryContext(ctx, db, &cnt); err != nil {
|
||||||
|
m.log.Errorf("error counting users: %v", err)
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return cnt.Cnt, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -71,4 +71,8 @@ authorization: {{token}}
|
|||||||
|
|
||||||
### get media url
|
### get media url
|
||||||
GET {{host}}/v1/admin/medias/6 HTTP/1.1
|
GET {{host}}/v1/admin/medias/6 HTTP/1.1
|
||||||
|
Authorization: {{token}}
|
||||||
|
|
||||||
|
### get statistics
|
||||||
|
GET {{host}}/v1/admin/statistics HTTP/1.1
|
||||||
Authorization: {{token}}
|
Authorization: {{token}}
|
||||||
@@ -1,67 +1,7 @@
|
|||||||
import httpClient from './httpClient';
|
import httpClient from './httpClient';
|
||||||
import { mockService } from './mockService';
|
|
||||||
|
|
||||||
// Simplify environment detection and ensure the console log works
|
|
||||||
let isDevelopment = true; // Default to development mode
|
|
||||||
|
|
||||||
// Try different ways to detect environment
|
|
||||||
try {
|
|
||||||
if (typeof process !== 'undefined' && process.env) {
|
|
||||||
console.log('Detected process.env, NODE_ENV:', process.env.NODE_ENV);
|
|
||||||
isDevelopment = process.env.NODE_ENV === 'development';
|
|
||||||
} else if (typeof import.meta !== 'undefined' && import.meta.env) {
|
|
||||||
console.log('Detected import.meta.env, MODE:', import.meta.env.MODE);
|
|
||||||
isDevelopment = import.meta.env.MODE === 'development';
|
|
||||||
} else {
|
|
||||||
console.log('No environment variables detected, defaulting to development mode');
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error detecting environment:', error);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Force console log with timeout to ensure it runs after other initialization
|
|
||||||
setTimeout(() => {
|
|
||||||
console.log('%cCurrent environment: ' + (isDevelopment ? 'DEVELOPMENT' : 'PRODUCTION'),
|
|
||||||
'background: #222; color: #bada55; font-size: 16px; padding: 4px;');
|
|
||||||
}, 0);
|
|
||||||
|
|
||||||
// Use the appropriate service based on environment
|
|
||||||
const apiService = isDevelopment ? mockService : {
|
|
||||||
getPostsCount() {
|
|
||||||
return httpClient.get('/posts/count');
|
|
||||||
},
|
|
||||||
|
|
||||||
getMediasCount() {
|
|
||||||
return httpClient.get('/medias/count');
|
|
||||||
},
|
|
||||||
|
|
||||||
getAllStatistics() {
|
|
||||||
return httpClient.get('/statistics');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const statisticsService = {
|
export const statisticsService = {
|
||||||
/**
|
get() {
|
||||||
* Get count of posts
|
return httpClient.get('/admin/statistics');
|
||||||
* @returns {Promise<{count: number}>}
|
|
||||||
*/
|
|
||||||
getPostsCount() {
|
|
||||||
return apiService.getPostsCount();
|
|
||||||
},
|
},
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Get count of media items
|
|
||||||
* @returns {Promise<{count: number}>}
|
|
||||||
*/
|
|
||||||
getMediasCount() {
|
|
||||||
return apiService.getMediasCount();
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all statistics in a single call
|
|
||||||
* @returns {Promise<{posts: number, medias: number}>}
|
|
||||||
*/
|
|
||||||
getAllStatistics() {
|
|
||||||
return apiService.getAllStatistics();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,132 +0,0 @@
|
|||||||
import { apiClient } from './apiClient';
|
|
||||||
|
|
||||||
// Environment detection
|
|
||||||
let isDevelopment = false; // Default to development mode
|
|
||||||
|
|
||||||
// Try different ways to detect environment
|
|
||||||
try {
|
|
||||||
if (typeof process !== 'undefined' && process.env) {
|
|
||||||
console.log('Detected process.env, NODE_ENV:', process.env.NODE_ENV);
|
|
||||||
isDevelopment = process.env.NODE_ENV === 'development';
|
|
||||||
} else if (typeof import.meta !== 'undefined' && import.meta.env) {
|
|
||||||
console.log('Detected import.meta.env, MODE:', import.meta.env.MODE);
|
|
||||||
isDevelopment = import.meta.env.MODE === 'development';
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error detecting environment:', error);
|
|
||||||
}
|
|
||||||
setTimeout(() => {
|
|
||||||
console.log('%cCurrent environment: ' + (isDevelopment ? 'DEVELOPMENT' : 'PRODUCTION'),
|
|
||||||
'background: #222; color: #bada55; font-size: 16px; padding: 4px;');
|
|
||||||
}, 0);
|
|
||||||
|
|
||||||
// Mock service implementation
|
|
||||||
const mockService = {
|
|
||||||
/**
|
|
||||||
* Mock implementation for getting media count
|
|
||||||
* @returns {Promise<{count: number}>}
|
|
||||||
*/
|
|
||||||
getMediaCount: async () => {
|
|
||||||
// Simulate network delay
|
|
||||||
await new Promise(resolve => setTimeout(resolve, 800));
|
|
||||||
|
|
||||||
// Return mock data
|
|
||||||
return {
|
|
||||||
data: {
|
|
||||||
count: Math.floor(Math.random() * 500) + 100 // Random count between 100-600
|
|
||||||
}
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mock implementation for getting article count
|
|
||||||
* @returns {Promise<{count: number}>}
|
|
||||||
*/
|
|
||||||
getArticleCount: async () => {
|
|
||||||
// Simulate network delay
|
|
||||||
await new Promise(resolve => setTimeout(resolve, 600));
|
|
||||||
|
|
||||||
// Return mock data
|
|
||||||
return {
|
|
||||||
data: {
|
|
||||||
count: Math.floor(Math.random() * 200) + 50 // Random count between 50-250
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Real API implementation
|
|
||||||
const realApiService = {
|
|
||||||
/**
|
|
||||||
* Real implementation for getting media count
|
|
||||||
* @returns {Promise<{count: number}>}
|
|
||||||
*/
|
|
||||||
getMediaCount: async () => {
|
|
||||||
try {
|
|
||||||
return await apiClient.get('/api/media/count');
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error fetching media count:', error);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Real implementation for getting article count
|
|
||||||
* @returns {Promise<{count: number}>}
|
|
||||||
*/
|
|
||||||
getArticleCount: async () => {
|
|
||||||
try {
|
|
||||||
return await apiClient.get('/api/articles/count');
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error fetching article count:', error);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Log which service we're using
|
|
||||||
console.log(`Using ${isDevelopment ? 'MOCK' : 'REAL'} API service for stats`);
|
|
||||||
|
|
||||||
// Use the appropriate service based on environment
|
|
||||||
const apiService = isDevelopment ? mockService : realApiService;
|
|
||||||
|
|
||||||
export const statsApi = {
|
|
||||||
/**
|
|
||||||
* Get the total count of media items
|
|
||||||
* @returns {Promise<{count: number}>} The media count
|
|
||||||
*/
|
|
||||||
getMediaCount: async () => {
|
|
||||||
const response = await apiService.getMediaCount();
|
|
||||||
return response.data;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the total count of articles
|
|
||||||
* @returns {Promise<{count: number}>} The article count
|
|
||||||
*/
|
|
||||||
getArticleCount: async () => {
|
|
||||||
const response = await apiService.getArticleCount();
|
|
||||||
return response.data;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all statistics in a single call
|
|
||||||
* @returns {Promise<{mediaCount: number, articleCount: number}>}
|
|
||||||
*/
|
|
||||||
getAllStats: async () => {
|
|
||||||
try {
|
|
||||||
const [mediaResponse, articleResponse] = await Promise.all([
|
|
||||||
apiService.getMediaCount(),
|
|
||||||
apiService.getArticleCount()
|
|
||||||
]);
|
|
||||||
|
|
||||||
return {
|
|
||||||
mediaCount: mediaResponse.data.count,
|
|
||||||
articleCount: articleResponse.data.count
|
|
||||||
};
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error fetching all stats:', error);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -4,26 +4,29 @@ import Card from 'primevue/card';
|
|||||||
import Message from 'primevue/message';
|
import Message from 'primevue/message';
|
||||||
import ProgressSpinner from 'primevue/progressspinner';
|
import ProgressSpinner from 'primevue/progressspinner';
|
||||||
import { onMounted, ref } from 'vue';
|
import { onMounted, ref } from 'vue';
|
||||||
import { statsApi } from '../api/statsApi';
|
import { statisticsService } from '../api/statisticsService';
|
||||||
|
|
||||||
const mediaCount = ref(0);
|
|
||||||
const articleCount = ref(0);
|
|
||||||
const loading = ref(true);
|
const loading = ref(true);
|
||||||
const error = ref(null);
|
const error = ref(null);
|
||||||
|
|
||||||
|
const stats = ref({
|
||||||
|
"post_draft": 0,
|
||||||
|
"post_published": 0,
|
||||||
|
"media": 0,
|
||||||
|
"order": 0,
|
||||||
|
"user": 0,
|
||||||
|
"amount": 0
|
||||||
|
})
|
||||||
|
|
||||||
const fetchCounts = async () => {
|
const fetchCounts = async () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
error.value = null;
|
error.value = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Use the API service instead of direct fetch calls
|
// Use the API service instead of direct fetch calls
|
||||||
const [mediaData, articleData] = await Promise.all([
|
const { data } = await statisticsService.get();
|
||||||
statsApi.getMediaCount(),
|
|
||||||
statsApi.getArticleCount()
|
|
||||||
]);
|
|
||||||
|
|
||||||
mediaCount.value = mediaData.count;
|
stats.value = data;
|
||||||
articleCount.value = articleData.count;
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error fetching data:', err);
|
console.error('Error fetching data:', err);
|
||||||
error.value = 'Failed to load data. Please try again later.';
|
error.value = 'Failed to load data. Please try again later.';
|
||||||
@@ -54,38 +57,62 @@ onMounted(() => {
|
|||||||
<Button @click="fetchCounts" label="Retry" icon="pi pi-refresh" severity="secondary" class="mt-3" />
|
<Button @click="fetchCounts" label="Retry" icon="pi pi-refresh" severity="secondary" class="mt-3" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-else class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 my-8">
|
<div v-else class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-6 my-8">
|
||||||
<Card class="transition-all duration-200 hover:-translate-y-1 hover:shadow-lg">
|
|
||||||
|
<Card class="shadow-none! rounded-none! border border-gray-100">
|
||||||
<template #header>
|
<template #header>
|
||||||
<div class="flex items-center justify-center p-4 bg-primary bg-opacity-10">
|
<div class="border border-primary"></div>
|
||||||
<i class="pi pi-image text-4xl! text-white"></i>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
<template #title>Media</template>
|
<template #title>媒体数量</template>
|
||||||
<template #content>
|
<template #content>
|
||||||
<div class="text-4xl font-bold mb-2 text-primary">{{ mediaCount }}</div>
|
<div class="text-4xl font-bold mb-2 text-primary">{{ stats.media }}</div>
|
||||||
<div class="text-base text-gray-500 mb-4">Total Media Items</div>
|
|
||||||
</template>
|
|
||||||
<template #footer>
|
|
||||||
<Button label="View All Media" icon="pi pi-arrow-right" link />
|
|
||||||
</template>
|
</template>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Card class="transition-all duration-200 hover:-translate-y-1 hover:shadow-lg">
|
<Card class="shadow-none! rounded-none! border border-gray-100">
|
||||||
<template #header>
|
<template #header>
|
||||||
<div class="flex items-center justify-center p-4 bg-primary bg-opacity-10">
|
<div class="border border-primary"></div>
|
||||||
<i class="pi pi-file text-4xl! text-white"></i>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
<template #title>Articles</template>
|
<template #title>文章数量</template>
|
||||||
<template #content>
|
<template #content>
|
||||||
<div class="text-4xl font-bold mb-2 text-primary">{{ articleCount }}</div>
|
<div class="text-4xl font-bold mb-2 text-primary">
|
||||||
<div class="text-base text-gray-500 mb-4">Total Articles</div>
|
{{ stats.post_published }}/{{ stats.post_draft }}
|
||||||
</template>
|
</div>
|
||||||
<template #footer>
|
<div class="text-sm text-gray-500">已发布/未发布</div>
|
||||||
<Button label="View All Articles" icon="pi pi-arrow-right" link />
|
|
||||||
</template>
|
</template>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
<Card class="shadow-none! rounded-none! border border-gray-100">
|
||||||
|
<template #header>
|
||||||
|
<div class="border border-primary"></div>
|
||||||
|
</template>
|
||||||
|
<template #title>订单数量</template>
|
||||||
|
<template #content>
|
||||||
|
<div class="text-4xl font-bold mb-2 text-primary">{{ stats.order }}</div>
|
||||||
|
</template>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<Card class="shadow-none! rounded-none! border border-gray-100">
|
||||||
|
<template #header>
|
||||||
|
<div class="border border-primary"></div>
|
||||||
|
</template>
|
||||||
|
<template #title>用户数量</template>
|
||||||
|
<template #content>
|
||||||
|
<div class="text-4xl font-bold mb-2 text-primary">{{ stats.user }}</div>
|
||||||
|
</template>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
|
||||||
|
<Card class="shadow-none! rounded-none! border border-gray-100">
|
||||||
|
<template #header>
|
||||||
|
<div class="border border-primary"></div>
|
||||||
|
</template>
|
||||||
|
<template #title>订单收入</template>
|
||||||
|
<template #content>
|
||||||
|
<div class="text-4xl font-bold mb-2 text-primary">{{ stats.amount }}</div>
|
||||||
|
</template>
|
||||||
|
</Card>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user