fix: all
This commit is contained in:
@@ -28,7 +28,7 @@ func (ctl *posts) List(ctx fiber.Ctx, pagination *requests.Pagination, query *Li
|
|||||||
|
|
||||||
type PostForm struct {
|
type PostForm struct {
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
HeadImageIds []int64 `json:"head_image_ids"`
|
HeadImages []int64 `json:"head_images"`
|
||||||
Price int64 `json:"price"`
|
Price int64 `json:"price"`
|
||||||
Discount int16 `json:"discount"`
|
Discount int16 `json:"discount"`
|
||||||
Introduction string `json:"introduction"`
|
Introduction string `json:"introduction"`
|
||||||
@@ -43,7 +43,7 @@ type PostForm struct {
|
|||||||
func (ctl *posts) Create(ctx fiber.Ctx, form *PostForm) error {
|
func (ctl *posts) Create(ctx fiber.Ctx, form *PostForm) error {
|
||||||
post := model.Posts{
|
post := model.Posts{
|
||||||
Title: form.Title,
|
Title: form.Title,
|
||||||
HeadImages: fields.ToJson(form.HeadImageIds),
|
HeadImages: fields.ToJson(form.HeadImages),
|
||||||
Price: form.Price,
|
Price: form.Price,
|
||||||
Discount: form.Discount,
|
Discount: form.Discount,
|
||||||
Description: form.Introduction,
|
Description: form.Introduction,
|
||||||
@@ -60,7 +60,7 @@ func (ctl *posts) Create(ctx fiber.Ctx, form *PostForm) error {
|
|||||||
}
|
}
|
||||||
assets := lo.Map(medias, func(media *model.Medias, _ int) fields.MediaAsset {
|
assets := lo.Map(medias, func(media *model.Medias, _ int) fields.MediaAsset {
|
||||||
return fields.MediaAsset{
|
return fields.MediaAsset{
|
||||||
Type: models.Medias.ConvertFileTypeByMimeType(media.MimeType),
|
Type: media.MimeType,
|
||||||
Media: media.ID,
|
Media: media.ID,
|
||||||
Mark: nil,
|
Mark: nil,
|
||||||
}
|
}
|
||||||
@@ -86,7 +86,7 @@ func (ctl *posts) Update(ctx fiber.Ctx, id int64, form *PostForm) error {
|
|||||||
|
|
||||||
post := &model.Posts{
|
post := &model.Posts{
|
||||||
Title: form.Title,
|
Title: form.Title,
|
||||||
HeadImages: fields.ToJson(form.HeadImageIds),
|
HeadImages: fields.ToJson(form.HeadImages),
|
||||||
Price: form.Price,
|
Price: form.Price,
|
||||||
Discount: form.Discount,
|
Discount: form.Discount,
|
||||||
Description: form.Introduction,
|
Description: form.Introduction,
|
||||||
@@ -108,7 +108,7 @@ func (ctl *posts) Update(ctx fiber.Ctx, id int64, form *PostForm) error {
|
|||||||
}
|
}
|
||||||
assets := lo.Map(medias, func(media *model.Medias, _ int) fields.MediaAsset {
|
assets := lo.Map(medias, func(media *model.Medias, _ int) fields.MediaAsset {
|
||||||
return fields.MediaAsset{
|
return fields.MediaAsset{
|
||||||
Type: models.Medias.ConvertFileTypeByMimeType(media.MimeType),
|
Type: media.MimeType,
|
||||||
Media: media.ID,
|
Media: media.ID,
|
||||||
Mark: nil,
|
Mark: nil,
|
||||||
}
|
}
|
||||||
@@ -164,13 +164,11 @@ func (ctl *posts) Show(ctx fiber.Ctx, id int64) (*PostItem, error) {
|
|||||||
Posts: post,
|
Posts: post,
|
||||||
Medias: lo.Map(medias, func(media *model.Medias, _ int) *models.MediaItem {
|
Medias: lo.Map(medias, func(media *model.Medias, _ int) *models.MediaItem {
|
||||||
return &models.MediaItem{
|
return &models.MediaItem{
|
||||||
ID: media.ID,
|
ID: media.ID,
|
||||||
Name: media.Name,
|
Name: media.Name,
|
||||||
UploadTime: media.CreatedAt.Format("2006-01-02 15:04:05"),
|
UploadTime: media.CreatedAt.Format("2006-01-02 15:04:05"),
|
||||||
FileSize: media.Size,
|
FileSize: media.Size,
|
||||||
MimeType: media.MimeType,
|
MimeType: media.MimeType,
|
||||||
FileType: models.Medias.ConvertFileTypeByMimeType(media.MimeType),
|
|
||||||
ThumbnailUrl: "",
|
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
}, nil
|
}, nil
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"quyun/app/requests"
|
"quyun/app/requests"
|
||||||
"quyun/database/fields"
|
|
||||||
"quyun/database/schemas/public/model"
|
"quyun/database/schemas/public/model"
|
||||||
"quyun/database/schemas/public/table"
|
"quyun/database/schemas/public/table"
|
||||||
|
|
||||||
@@ -15,13 +14,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type MediaItem struct {
|
type MediaItem struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
UploadTime string `json:"upload_time"`
|
UploadTime string `json:"upload_time"`
|
||||||
FileSize int64 `json:"file_size"`
|
FileSize int64 `json:"file_size"`
|
||||||
MimeType string `json:"media_type"`
|
MimeType string `json:"media_type"`
|
||||||
FileType fields.MediaAssetType `json:"file_type"`
|
|
||||||
ThumbnailUrl string `json:"thumbnail_url"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @provider
|
// @provider
|
||||||
@@ -97,13 +94,11 @@ func (m *mediasModel) List(ctx context.Context, pagination *requests.Pagination,
|
|||||||
// Convert model.Medias to MediaItem
|
// Convert model.Medias to MediaItem
|
||||||
mediaItems := lo.Map(medias, func(media model.Medias, _ int) *MediaItem {
|
mediaItems := lo.Map(medias, func(media model.Medias, _ int) *MediaItem {
|
||||||
return &MediaItem{
|
return &MediaItem{
|
||||||
ID: media.ID,
|
ID: media.ID,
|
||||||
Name: media.Name,
|
Name: media.Name,
|
||||||
UploadTime: media.CreatedAt.Format("2006-01-02 15:04:05"),
|
UploadTime: media.CreatedAt.Format("2006-01-02 15:04:05"),
|
||||||
FileSize: media.Size,
|
FileSize: media.Size,
|
||||||
MimeType: media.MimeType,
|
MimeType: media.MimeType,
|
||||||
FileType: m.ConvertFileTypeByMimeType(media.MimeType),
|
|
||||||
ThumbnailUrl: "",
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -141,33 +136,6 @@ func (m *mediasModel) Create(ctx context.Context, model *model.Medias) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mediasModel) ConvertFileTypeByMimeType(mimeType string) fields.MediaAssetType {
|
|
||||||
switch mimeType {
|
|
||||||
case "image/jpeg", "image/jpg", "image/png", "image/gif":
|
|
||||||
return fields.MediaAssetTypeImage
|
|
||||||
case "video/mp4", "video/x-m4v":
|
|
||||||
return fields.MediaAssetTypeVideo
|
|
||||||
case "audio/mpeg":
|
|
||||||
return fields.MediaAssetTypeAudio
|
|
||||||
case "application/pdf",
|
|
||||||
"application/msword",
|
|
||||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
||||||
"application/vnd.ms-excel",
|
|
||||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
||||||
"application/vnd.ms-powerpoint",
|
|
||||||
"application/vnd.openxmlformats-officedocument.presentationml.presentation":
|
|
||||||
return fields.MediaAssetTypeDocument
|
|
||||||
case "application/rar",
|
|
||||||
"application/x-rar-compressed",
|
|
||||||
"application/x-zip-compressed",
|
|
||||||
"application/x-zip",
|
|
||||||
"application/zip",
|
|
||||||
"application/x-7z-compressed":
|
|
||||||
return fields.MediaAssetTypeArchive
|
|
||||||
}
|
|
||||||
return fields.MediaAssetTypeUnknown
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetByIds
|
// GetByIds
|
||||||
func (m *mediasModel) GetByIds(ctx context.Context, ids []int64) ([]*model.Medias, error) {
|
func (m *mediasModel) GetByIds(ctx context.Context, ids []int64) ([]*model.Medias, error) {
|
||||||
if len(ids) == 0 {
|
if len(ids) == 0 {
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import (
|
|||||||
"quyun/app/requests"
|
"quyun/app/requests"
|
||||||
"quyun/app/service/testx"
|
"quyun/app/service/testx"
|
||||||
"quyun/database"
|
"quyun/database"
|
||||||
"quyun/database/fields"
|
|
||||||
"quyun/database/schemas/public/model"
|
"quyun/database/schemas/public/model"
|
||||||
"quyun/database/schemas/public/table"
|
"quyun/database/schemas/public/table"
|
||||||
|
|
||||||
@@ -189,26 +188,3 @@ func (s *MediasTestSuite) Test_Page() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test ConvertFileTypeByMimeType
|
|
||||||
func (s *MediasTestSuite) Test_ConvertFileTypeByMimeType() {
|
|
||||||
Convey("ConvertFileTypeByMimeType", s.T(), func() {
|
|
||||||
Convey("image", func() {
|
|
||||||
mimeType := "image/jpeg"
|
|
||||||
fileType := Medias.ConvertFileTypeByMimeType(mimeType)
|
|
||||||
So(fileType, ShouldEqual, fields.MediaAssetTypeImage)
|
|
||||||
})
|
|
||||||
|
|
||||||
Convey("video", func() {
|
|
||||||
mimeType := "video/mp4"
|
|
||||||
fileType := Medias.ConvertFileTypeByMimeType(mimeType)
|
|
||||||
So(fileType, ShouldEqual, fields.MediaAssetTypeVideo)
|
|
||||||
})
|
|
||||||
|
|
||||||
Convey("invalid mime type", func() {
|
|
||||||
mimeType := "invalid/type"
|
|
||||||
fileType := Medias.ConvertFileTypeByMimeType(mimeType)
|
|
||||||
So(fileType, ShouldEqual, fields.MediaAssetTypeUnknown)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -58,11 +58,11 @@ func (s *PostsTestSuite) Test_BatchInsert() {
|
|||||||
Tags: fields.ToJson([]string{"tag1", "tag2", "tag3"}),
|
Tags: fields.ToJson([]string{"tag1", "tag2", "tag3"}),
|
||||||
Assets: fields.ToJson([]fields.MediaAsset{
|
Assets: fields.ToJson([]fields.MediaAsset{
|
||||||
{
|
{
|
||||||
Type: fields.MediaAssetTypeAudio,
|
Type: "video/mp4",
|
||||||
Media: rand.Int63n(10000),
|
Media: rand.Int63n(10000),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Type: fields.MediaAssetTypeVideo,
|
Type: "video/mp4",
|
||||||
Media: rand.Int63n(10000),
|
Media: rand.Int63n(10000),
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -14,196 +14,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
// MediaAssetTypeUnknown is a MediaAssetType of type Unknown.
|
|
||||||
MediaAssetTypeUnknown MediaAssetType = "unknown"
|
|
||||||
// MediaAssetTypePoster is a MediaAssetType of type Poster.
|
|
||||||
MediaAssetTypePoster MediaAssetType = "poster"
|
|
||||||
// MediaAssetTypeImage is a MediaAssetType of type Image.
|
|
||||||
MediaAssetTypeImage MediaAssetType = "image"
|
|
||||||
// MediaAssetTypeVideo is a MediaAssetType of type Video.
|
|
||||||
MediaAssetTypeVideo MediaAssetType = "video"
|
|
||||||
// MediaAssetTypeAudio is a MediaAssetType of type Audio.
|
|
||||||
MediaAssetTypeAudio MediaAssetType = "audio"
|
|
||||||
// MediaAssetTypeDocument is a MediaAssetType of type Document.
|
|
||||||
MediaAssetTypeDocument MediaAssetType = "document"
|
|
||||||
// MediaAssetTypeArchive is a MediaAssetType of type Archive.
|
|
||||||
MediaAssetTypeArchive MediaAssetType = "archive"
|
|
||||||
// MediaAssetTypeOther is a MediaAssetType of type Other.
|
|
||||||
MediaAssetTypeOther MediaAssetType = "other"
|
|
||||||
)
|
|
||||||
|
|
||||||
var ErrInvalidMediaAssetType = fmt.Errorf("not a valid MediaAssetType, try [%s]", strings.Join(_MediaAssetTypeNames, ", "))
|
|
||||||
|
|
||||||
var _MediaAssetTypeNames = []string{
|
|
||||||
string(MediaAssetTypeUnknown),
|
|
||||||
string(MediaAssetTypePoster),
|
|
||||||
string(MediaAssetTypeImage),
|
|
||||||
string(MediaAssetTypeVideo),
|
|
||||||
string(MediaAssetTypeAudio),
|
|
||||||
string(MediaAssetTypeDocument),
|
|
||||||
string(MediaAssetTypeArchive),
|
|
||||||
string(MediaAssetTypeOther),
|
|
||||||
}
|
|
||||||
|
|
||||||
// MediaAssetTypeNames returns a list of possible string values of MediaAssetType.
|
|
||||||
func MediaAssetTypeNames() []string {
|
|
||||||
tmp := make([]string, len(_MediaAssetTypeNames))
|
|
||||||
copy(tmp, _MediaAssetTypeNames)
|
|
||||||
return tmp
|
|
||||||
}
|
|
||||||
|
|
||||||
// MediaAssetTypeValues returns a list of the values for MediaAssetType
|
|
||||||
func MediaAssetTypeValues() []MediaAssetType {
|
|
||||||
return []MediaAssetType{
|
|
||||||
MediaAssetTypeUnknown,
|
|
||||||
MediaAssetTypePoster,
|
|
||||||
MediaAssetTypeImage,
|
|
||||||
MediaAssetTypeVideo,
|
|
||||||
MediaAssetTypeAudio,
|
|
||||||
MediaAssetTypeDocument,
|
|
||||||
MediaAssetTypeArchive,
|
|
||||||
MediaAssetTypeOther,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// String implements the Stringer interface.
|
|
||||||
func (x MediaAssetType) String() string {
|
|
||||||
return string(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsValid provides a quick way to determine if the typed value is
|
|
||||||
// part of the allowed enumerated values
|
|
||||||
func (x MediaAssetType) IsValid() bool {
|
|
||||||
_, err := ParseMediaAssetType(string(x))
|
|
||||||
return err == nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var _MediaAssetTypeValue = map[string]MediaAssetType{
|
|
||||||
"unknown": MediaAssetTypeUnknown,
|
|
||||||
"poster": MediaAssetTypePoster,
|
|
||||||
"image": MediaAssetTypeImage,
|
|
||||||
"video": MediaAssetTypeVideo,
|
|
||||||
"audio": MediaAssetTypeAudio,
|
|
||||||
"document": MediaAssetTypeDocument,
|
|
||||||
"archive": MediaAssetTypeArchive,
|
|
||||||
"other": MediaAssetTypeOther,
|
|
||||||
}
|
|
||||||
|
|
||||||
// ParseMediaAssetType attempts to convert a string to a MediaAssetType.
|
|
||||||
func ParseMediaAssetType(name string) (MediaAssetType, error) {
|
|
||||||
if x, ok := _MediaAssetTypeValue[name]; ok {
|
|
||||||
return x, nil
|
|
||||||
}
|
|
||||||
return MediaAssetType(""), fmt.Errorf("%s is %w", name, ErrInvalidMediaAssetType)
|
|
||||||
}
|
|
||||||
|
|
||||||
var errMediaAssetTypeNilPtr = errors.New("value pointer is nil") // one per type for package clashes
|
|
||||||
|
|
||||||
// Scan implements the Scanner interface.
|
|
||||||
func (x *MediaAssetType) Scan(value interface{}) (err error) {
|
|
||||||
if value == nil {
|
|
||||||
*x = MediaAssetType("")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// A wider range of scannable types.
|
|
||||||
// driver.Value values at the top of the list for expediency
|
|
||||||
switch v := value.(type) {
|
|
||||||
case string:
|
|
||||||
*x, err = ParseMediaAssetType(v)
|
|
||||||
case []byte:
|
|
||||||
*x, err = ParseMediaAssetType(string(v))
|
|
||||||
case MediaAssetType:
|
|
||||||
*x = v
|
|
||||||
case *MediaAssetType:
|
|
||||||
if v == nil {
|
|
||||||
return errMediaAssetTypeNilPtr
|
|
||||||
}
|
|
||||||
*x = *v
|
|
||||||
case *string:
|
|
||||||
if v == nil {
|
|
||||||
return errMediaAssetTypeNilPtr
|
|
||||||
}
|
|
||||||
*x, err = ParseMediaAssetType(*v)
|
|
||||||
default:
|
|
||||||
return errors.New("invalid type for MediaAssetType")
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Value implements the driver Valuer interface.
|
|
||||||
func (x MediaAssetType) Value() (driver.Value, error) {
|
|
||||||
return x.String(), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set implements the Golang flag.Value interface func.
|
|
||||||
func (x *MediaAssetType) Set(val string) error {
|
|
||||||
v, err := ParseMediaAssetType(val)
|
|
||||||
*x = v
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get implements the Golang flag.Getter interface func.
|
|
||||||
func (x *MediaAssetType) Get() interface{} {
|
|
||||||
return *x
|
|
||||||
}
|
|
||||||
|
|
||||||
// Type implements the github.com/spf13/pFlag Value interface.
|
|
||||||
func (x *MediaAssetType) Type() string {
|
|
||||||
return "MediaAssetType"
|
|
||||||
}
|
|
||||||
|
|
||||||
type NullMediaAssetType struct {
|
|
||||||
MediaAssetType MediaAssetType
|
|
||||||
Valid bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewNullMediaAssetType(val interface{}) (x NullMediaAssetType) {
|
|
||||||
err := x.Scan(val) // yes, we ignore this error, it will just be an invalid value.
|
|
||||||
_ = err // make any errcheck linters happy
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Scan implements the Scanner interface.
|
|
||||||
func (x *NullMediaAssetType) Scan(value interface{}) (err error) {
|
|
||||||
if value == nil {
|
|
||||||
x.MediaAssetType, x.Valid = MediaAssetType(""), false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
err = x.MediaAssetType.Scan(value)
|
|
||||||
x.Valid = (err == nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Value implements the driver Valuer interface.
|
|
||||||
func (x NullMediaAssetType) Value() (driver.Value, error) {
|
|
||||||
if !x.Valid {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
// driver.Value accepts int64 for int values.
|
|
||||||
return string(x.MediaAssetType), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type NullMediaAssetTypeStr struct {
|
|
||||||
NullMediaAssetType
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewNullMediaAssetTypeStr(val interface{}) (x NullMediaAssetTypeStr) {
|
|
||||||
x.Scan(val) // yes, we ignore this error, it will just be an invalid value.
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Value implements the driver Valuer interface.
|
|
||||||
func (x NullMediaAssetTypeStr) Value() (driver.Value, error) {
|
|
||||||
if !x.Valid {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
return x.MediaAssetType.String(), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// PostStatusDraft is a PostStatus of type Draft.
|
// PostStatusDraft is a PostStatus of type Draft.
|
||||||
PostStatusDraft PostStatus = iota
|
PostStatusDraft PostStatus = iota
|
||||||
|
|||||||
@@ -1,24 +1,11 @@
|
|||||||
package fields
|
package fields
|
||||||
|
|
||||||
type MediaAsset struct {
|
type MediaAsset struct {
|
||||||
Type MediaAssetType `json:"type"`
|
Type string `json:"type"`
|
||||||
Media int64 `json:"media"`
|
Media int64 `json:"media"`
|
||||||
Mark *string `json:"mark,omitempty"`
|
Mark *string `json:"mark,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// swagger:enum MediaAssetType
|
|
||||||
// ENUM(
|
|
||||||
// Unknown = "unknown",
|
|
||||||
// Poster = "poster",
|
|
||||||
// Image = "image",
|
|
||||||
// Video = "video",
|
|
||||||
// Audio = "audio",
|
|
||||||
// Document = "document",
|
|
||||||
// Archive = "archive",
|
|
||||||
// Other = "other"
|
|
||||||
// )
|
|
||||||
type MediaAssetType string
|
|
||||||
|
|
||||||
// swagger:enum PostStatus
|
// swagger:enum PostStatus
|
||||||
// ENUM( draft, published )
|
// ENUM( draft, published )
|
||||||
type PostStatus int16
|
type PostStatus int16
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { postService } from '@/api/postService';
|
import { postService } from '@/api/postService';
|
||||||
import { formatDate } from '@/utils/date';
|
import { formatDate } from '@/utils/date';
|
||||||
|
import { getFileTypeByMimeCN } from "@/utils/filetype";
|
||||||
import { InputText } from 'primevue';
|
import { InputText } from 'primevue';
|
||||||
import Badge from 'primevue/badge';
|
import Badge from 'primevue/badge';
|
||||||
|
|
||||||
@@ -56,18 +57,14 @@ const total = ref(0); // 总记录数
|
|||||||
|
|
||||||
// Status mapping
|
// Status mapping
|
||||||
const statusMap = {
|
const statusMap = {
|
||||||
0: '发布',
|
0: '草稿',
|
||||||
1: '草稿',
|
1: '发布',
|
||||||
};
|
};
|
||||||
|
|
||||||
// Transform assets to media types
|
// Transform assets to media types
|
||||||
const getMediaTypes = (assets) => {
|
const getMediaTypes = (assets) => {
|
||||||
return [...new Set(assets.map(asset => {
|
return [...new Set(assets.map(asset => {
|
||||||
switch (asset.type) {
|
return getFileTypeByMimeCN(asset.Type)
|
||||||
case 'audio': return '音频';
|
|
||||||
case 'video': return '视频';
|
|
||||||
default: return '文章';
|
|
||||||
}
|
|
||||||
}))];
|
}))];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -193,8 +190,8 @@ const formatPrice = (price) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Format media types to display as comma-separated string
|
// Format media types to display as comma-separated string
|
||||||
const formatMediaTypes = (mediaTypes) => {
|
const formatMediaTypes = (assets) => {
|
||||||
return mediaTypes.join(', ');
|
return assets.map(asset => getFileTypeByMimeCN(asset.type)).join(', ');
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -250,7 +247,7 @@ const formatMediaTypes = (mediaTypes) => {
|
|||||||
<span class="text-orange-500">优惠: -{{ formatPrice(getDiscountAmount(data.price,
|
<span class="text-orange-500">优惠: -{{ formatPrice(getDiscountAmount(data.price,
|
||||||
data.discount)) }}</span>
|
data.discount)) }}</span>
|
||||||
<span class="font-bold">实付: {{ formatPrice(getFinalPrice(data.price, data.discount))
|
<span class="font-bold">实付: {{ formatPrice(getFinalPrice(data.price, data.discount))
|
||||||
}}</span>
|
}}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
@@ -275,9 +272,9 @@ const formatMediaTypes = (mediaTypes) => {
|
|||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
|
|
||||||
<Column field="mediaTypes" header="媒体类型" sortable>
|
<Column field="assets" header="媒体类型" sortable>
|
||||||
<template #body="{ data }">
|
<template #body="{ data }">
|
||||||
<div class="text-sm text-gray-900">{{ formatMediaTypes(data.mediaTypes) }}</div>
|
<div class="text-sm text-gray-900">{{ formatMediaTypes(data.assets) }}</div>
|
||||||
</template>
|
</template>
|
||||||
<template #filter="{ filterModel, filterCallback }">
|
<template #filter="{ filterModel, filterCallback }">
|
||||||
<Dropdown v-model="filterModel.value" @change="filterCallback()" :options="mediaTypeOptions"
|
<Dropdown v-model="filterModel.value" @change="filterCallback()" :options="mediaTypeOptions"
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ export function getFileTypeByMimeCN(mime) {
|
|||||||
'other': '其他',
|
'other': '其他',
|
||||||
'unknown': '未知'
|
'unknown': '未知'
|
||||||
};
|
};
|
||||||
|
console.log(mime)
|
||||||
|
|
||||||
return typeMap[getFileTypeByMime(mime)];
|
return typeMap[getFileTypeByMime(mime)];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user