fix: issues
This commit is contained in:
BIN
backend/__debug_bin457628671
Executable file
BIN
backend/__debug_bin457628671
Executable file
Binary file not shown.
@@ -27,7 +27,7 @@ DevMode = true
|
|||||||
|
|
||||||
[JWT]
|
[JWT]
|
||||||
ExpiresTime = "168h"
|
ExpiresTime = "168h"
|
||||||
SignKey = "LiXi.Y@140202"
|
SigningKey = "LiXi.Y@140202"
|
||||||
|
|
||||||
[HashIDs]
|
[HashIDs]
|
||||||
Salt = "LiXi.Y@140202"
|
Salt = "LiXi.Y@140202"
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ type ListFilter struct {
|
|||||||
|
|
||||||
type ListItem struct {
|
type ListItem struct {
|
||||||
ID int64 `json:"-"`
|
ID int64 `json:"-"`
|
||||||
|
Poster string `json:"poster"`
|
||||||
Hash string `json:"hash"`
|
Hash string `json:"hash"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ func (svc *Service) GetMediaByID(ctx context.Context, tenantId, userId, id int64
|
|||||||
func (svc *Service) ModelToListItem(ctx context.Context, m *model.Medias) *ListItem {
|
func (svc *Service) ModelToListItem(ctx context.Context, m *model.Medias) *ListItem {
|
||||||
return &ListItem{
|
return &ListItem{
|
||||||
ID: m.ID,
|
ID: m.ID,
|
||||||
|
Poster: fmt.Sprintf("/static/%s/poster.jpg", m.Hash),
|
||||||
Hash: m.Hash,
|
Hash: m.Hash,
|
||||||
Title: m.Title,
|
Title: m.Title,
|
||||||
Description: m.Description,
|
Description: m.Description,
|
||||||
@@ -96,7 +97,7 @@ func (svc *Service) ModelToListItem(ctx context.Context, m *model.Medias) *ListI
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List
|
// List
|
||||||
func (svc *Service) List(ctx context.Context, tenantId, userId int64, filter *ListFilter) ([]ListItem, error) {
|
func (svc *Service) List(ctx context.Context, tenantId, userId int64, filter *ListFilter) ([]*ListItem, error) {
|
||||||
log := svc.log.WithField("method", "List")
|
log := svc.log.WithField("method", "List")
|
||||||
|
|
||||||
boughtIDs, err := svc.GetUserBoughtMedias(ctx, tenantId, userId)
|
boughtIDs, err := svc.GetUserBoughtMedias(ctx, tenantId, userId)
|
||||||
@@ -144,21 +145,8 @@ func (svc *Service) List(ctx context.Context, tenantId, userId int64, filter *Li
|
|||||||
return nil, errors.Wrap(err, "query medias")
|
return nil, errors.Wrap(err, "query medias")
|
||||||
}
|
}
|
||||||
|
|
||||||
items := lo.Map(dest, func(m model.Medias, _ int) ListItem {
|
items := lo.Map(dest, func(m model.Medias, _ int) *ListItem {
|
||||||
item := ListItem{
|
return svc.ModelToListItem(ctx, &m)
|
||||||
ID: m.ID,
|
|
||||||
Hash: m.Hash,
|
|
||||||
Title: m.Title,
|
|
||||||
Description: m.Description,
|
|
||||||
Duration: m.Duration,
|
|
||||||
Price: m.Price,
|
|
||||||
Discount: m.Discount,
|
|
||||||
Resources: m.Resources,
|
|
||||||
CreatedAt: m.CreatedAt,
|
|
||||||
UpdatedAt: m.UpdatedAt,
|
|
||||||
Bought: lo.Contains(boughtIDs, m.ID),
|
|
||||||
}
|
|
||||||
return item
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return items, nil
|
return items, nil
|
||||||
|
|||||||
@@ -14,12 +14,15 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (f *Middlewares) WeChatAuthUserInfo(c fiber.Ctx) error {
|
func (f *Middlewares) WeChatAuthUserInfo(c fiber.Ctx) error {
|
||||||
|
log.WithField("module", "middleware.WeChatAuthUserInfo").Debug("Begin")
|
||||||
|
defer log.WithField("module", "middleware.WeChatAuthUserInfo").Debug("END")
|
||||||
|
|
||||||
// 如果请求存在 Authorization 头,则跳过
|
// 如果请求存在 Authorization 头,则跳过
|
||||||
if len(c.GetReqHeaders()["Authorization"]) != 0 {
|
if len(c.GetReqHeaders()["Authorization"]) != 0 {
|
||||||
return c.Next()
|
return c.Next()
|
||||||
}
|
}
|
||||||
|
|
||||||
log.WithField("module", "middleware.AuthUserInfo").Debugf("query: %v", c.Queries())
|
log.WithField("module", "middleware.AuthUserInfo").Debugf("%s, query: %v", c.OriginalURL(), c.Queries())
|
||||||
state := c.Query("state")
|
state := c.Query("state")
|
||||||
code := c.Query("code")
|
code := c.Query("code")
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (f *Middlewares) WeChatSilentAuth(c fiber.Ctx) error {
|
func (f *Middlewares) WeChatSilentAuth(c fiber.Ctx) error {
|
||||||
|
log.WithField("module", "middleware.WeChatSilentAuth").Debug("Begin")
|
||||||
|
defer log.WithField("module", "middleware.WeChatSilentAuth").Debug("END")
|
||||||
|
|
||||||
// if cookie not exists key "openid", then redirect to the wechat auth page
|
// if cookie not exists key "openid", then redirect to the wechat auth page
|
||||||
token := c.GetReqHeaders()["Authorization"]
|
token := c.GetReqHeaders()["Authorization"]
|
||||||
if len(token) != 0 {
|
if len(token) != 0 {
|
||||||
@@ -24,7 +27,7 @@ func (f *Middlewares) WeChatSilentAuth(c fiber.Ctx) error {
|
|||||||
url = strings.ReplaceAll(url, c.BaseURL(), *f.app.BaseURI)
|
url = strings.ReplaceAll(url, c.BaseURL(), *f.app.BaseURI)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.WithField("module", "middleware.SilentAuth").Debug("url:", url)
|
log.WithField("module", "middleware.SilentAuth").Debug("redirect_uri: ", url)
|
||||||
|
|
||||||
to, err := f.client.ScopeAuthorizeURL(
|
to, err := f.client.ScopeAuthorizeURL(
|
||||||
wechat.ScopeAuthorizeURLWithRedirectURI(url),
|
wechat.ScopeAuthorizeURLWithRedirectURI(url),
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import (
|
|||||||
|
|
||||||
// 此方法用于微信首次接入时的数据验证
|
// 此方法用于微信首次接入时的数据验证
|
||||||
func (f *Middlewares) WeChatVerify(c fiber.Ctx) error {
|
func (f *Middlewares) WeChatVerify(c fiber.Ctx) error {
|
||||||
|
log.WithField("module", "middleware.WeChatVerify").Debug("Begin")
|
||||||
|
defer log.WithField("module", "middleware.WeChatVerify").Debug("END")
|
||||||
|
|
||||||
// get the query parameters
|
// get the query parameters
|
||||||
signature := c.Query("signature")
|
signature := c.Query("signature")
|
||||||
timestamp := c.Query("timestamp")
|
timestamp := c.Query("timestamp")
|
||||||
|
|||||||
@@ -2,9 +2,12 @@ package middlewares
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gofiber/fiber/v3"
|
"github.com/gofiber/fiber/v3"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (f *Middlewares) DebugMode(c fiber.Ctx) error {
|
func (f *Middlewares) DebugMode(c fiber.Ctx) error {
|
||||||
|
log.WithField("module", "middleware.DebugMode").Debug("Begin")
|
||||||
|
defer log.WithField("module", "middleware.DebugMode").Debug("END")
|
||||||
// fullURI := c.Request().URI().FullURI()
|
// fullURI := c.Request().URI().FullURI()
|
||||||
// host := c.BaseURL()
|
// host := c.BaseURL()
|
||||||
// fmt.Println(strings.Split(c.Path(), "/"))
|
// fmt.Println(strings.Split(c.Path(), "/"))
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (f *Middlewares) ProcessResponse(c fiber.Ctx) error {
|
func (f *Middlewares) ProcessResponse(c fiber.Ctx) error {
|
||||||
|
log.WithField("module", "middleware.ProcessResponse").Debug("Begin")
|
||||||
|
defer log.WithField("module", "middleware.ProcessResponse").Debug("END")
|
||||||
|
|
||||||
if err := c.Next(); err != nil {
|
if err := c.Next(); err != nil {
|
||||||
log.WithError(err).Error("process response error")
|
log.WithError(err).Error("process response error")
|
||||||
|
|
||||||
@@ -26,5 +29,5 @@ func (f *Middlewares) ProcessResponse(c fiber.Ctx) error {
|
|||||||
return errorx.Wrap(err).Response(c)
|
return errorx.Wrap(err).Response(c)
|
||||||
|
|
||||||
}
|
}
|
||||||
return c.Next()
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ import (
|
|||||||
"git.ipao.vip/rogeecn/atom"
|
"git.ipao.vip/rogeecn/atom"
|
||||||
"git.ipao.vip/rogeecn/atom/container"
|
"git.ipao.vip/rogeecn/atom/container"
|
||||||
"git.ipao.vip/rogeecn/atom/contracts"
|
"git.ipao.vip/rogeecn/atom/contracts"
|
||||||
|
"github.com/gofiber/fiber/v3"
|
||||||
|
"github.com/gofiber/fiber/v3/middleware/favicon"
|
||||||
|
"github.com/gofiber/fiber/v3/middleware/static"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"go.uber.org/dig"
|
"go.uber.org/dig"
|
||||||
@@ -50,6 +53,7 @@ type Http struct {
|
|||||||
dig.In
|
dig.In
|
||||||
|
|
||||||
App *app.Config
|
App *app.Config
|
||||||
|
Storage *storage.Config
|
||||||
Service *http.Service
|
Service *http.Service
|
||||||
Initials []contracts.Initial `group:"initials"`
|
Initials []contracts.Initial `group:"initials"`
|
||||||
Routes []contracts.HttpRoute `group:"routes"`
|
Routes []contracts.HttpRoute `group:"routes"`
|
||||||
@@ -61,16 +65,31 @@ func Serve(cmd *cobra.Command, args []string) error {
|
|||||||
if http.App.Mode == app.AppModeDevelopment {
|
if http.App.Mode == app.AppModeDevelopment {
|
||||||
log.SetLevel(log.DebugLevel)
|
log.SetLevel(log.DebugLevel)
|
||||||
}
|
}
|
||||||
|
engine := http.Service.Engine
|
||||||
mid := http.Middlewares
|
mid := http.Middlewares
|
||||||
http.Service.Engine.Use(mid.DebugMode)
|
|
||||||
http.Service.Engine.Use(mid.ProcessResponse)
|
engine.Use(mid.DebugMode)
|
||||||
http.Service.Engine.Use(mid.WeChatVerify)
|
engine.Use(mid.ProcessResponse)
|
||||||
http.Service.Engine.Use(mid.WeChatAuthUserInfo)
|
|
||||||
http.Service.Engine.Use(mid.WeChatSilentAuth)
|
wechatGroup := engine.Group("/t")
|
||||||
http.Service.Engine.Use(mid.ParseJWT)
|
wechatGroup.Use(mid.WeChatVerify)
|
||||||
|
wechatGroup.Use(mid.WeChatAuthUserInfo)
|
||||||
|
wechatGroup.Use(mid.WeChatSilentAuth)
|
||||||
|
wechatGroup.Get("*", func(c fiber.Ctx) error {
|
||||||
|
return c.SendString("ok")
|
||||||
|
})
|
||||||
|
|
||||||
|
http.Service.Engine.Use(favicon.New(favicon.Config{
|
||||||
|
Data: []byte{},
|
||||||
|
}))
|
||||||
|
|
||||||
|
http.Service.Engine.Use("/static", static.New(http.Storage.Path, static.Config{
|
||||||
|
Browse: true,
|
||||||
|
}))
|
||||||
|
|
||||||
group := http.Service.Engine.Group("/v1")
|
group := http.Service.Engine.Group("/v1")
|
||||||
|
group.Use(mid.ParseJWT)
|
||||||
|
|
||||||
for _, route := range http.Routes {
|
for _, route := range http.Routes {
|
||||||
route.Register(group)
|
route.Register(group)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"backend/modules/medias"
|
"backend/modules/medias"
|
||||||
"backend/modules/users"
|
"backend/modules/users"
|
||||||
"backend/providers/app"
|
"backend/providers/app"
|
||||||
|
"backend/providers/hashids"
|
||||||
"backend/providers/postgres"
|
"backend/providers/postgres"
|
||||||
"backend/providers/storage"
|
"backend/providers/storage"
|
||||||
|
|
||||||
@@ -21,6 +22,7 @@ func defaultProviders(providers ...container.ProviderContainer) container.Provid
|
|||||||
app.DefaultProvider(),
|
app.DefaultProvider(),
|
||||||
storage.DefaultProvider(),
|
storage.DefaultProvider(),
|
||||||
postgres.DefaultProvider(),
|
postgres.DefaultProvider(),
|
||||||
|
hashids.DefaultProvider(),
|
||||||
}, providers...)
|
}, providers...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
@Token=Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvcGVuX2lkIjoib01MYTV0eUoydlJIYS1ISTRDTUVrSHp0cTNlVSIsInRlbmFudCI6InlwbCIsInVzZXJfaWQiOjEsInRlbmFudF9pZCI6MSwiZXhwIjoxNzM0MzQ5NDA3LCJuYmYiOjE3MzM3NDQ1OTd9.iQtyxfFDXht4mpCYSllv7opFjYuUHO22WwBl7hAzQYw
|
@Token=Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvcGVuX2lkIjoib01MYTV0eUoydlJIYS1ISTRDTUVrSHp0cTNlVSIsInRlbmFudCI6InlwbCIsInVzZXJfaWQiOjEsInRlbmFudF9pZCI6MiwiZXhwIjoxNzM0NDkxNzkwLCJuYmYiOjE3MzM4ODY5ODB9.qwG-Z3bkh1RD7wYVH7DTLRTdjHYrCW0aSnghhNlmOzo
|
||||||
@host=http://localhost:9600
|
@host=http://localhost:9600
|
||||||
|
|
||||||
### Get Medias
|
### Get Medias
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<link rel="icon" href="/favicon.ico">
|
<link rel="icon" href="/favicon.ico">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>动态曲谱</title>
|
<title>加载中...</title>
|
||||||
<script>
|
<script>
|
||||||
|
var __GA = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvcGVuX2lkIjoib01MYTV0eUoydlJIYS1ISTRDTUVrSHp0cTNlVSIsInRlbmFudCI6InlwbCIsInVzZXJfaWQiOjEsInRlbmFudF9pZCI6MiwiZXhwIjoxNzM0NTAzMDQzLCJuYmYiOjE3MzM4OTgyMzN9.wl4c-4DdZ-qC7MJHMD8rP2zPiTwBK7J_YKw2im3ve9U"
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|||||||
2719
frontend/package-lock.json
generated
Normal file
2719
frontend/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -9,18 +9,19 @@
|
|||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"axios": "^1.7.9",
|
||||||
"pinia": "^2.2.6",
|
"pinia": "^2.2.6",
|
||||||
"vant": "^4.9.9",
|
"vant": "^4.9.9",
|
||||||
"vue": "^3.5.12",
|
"vue": "^3.5.12",
|
||||||
"vue-router": "^4.4.5"
|
"vue-router": "^4.4.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vitejs/plugin-vue": "^5.1.4",
|
|
||||||
"vite": "^5.4.10",
|
|
||||||
"vite-plugin-vue-devtools": "^7.5.4",
|
|
||||||
"@vant/auto-import-resolver": "^1.1.0",
|
"@vant/auto-import-resolver": "^1.1.0",
|
||||||
|
"@vitejs/plugin-vue": "^5.1.4",
|
||||||
"less": "^4.1.3",
|
"less": "^4.1.3",
|
||||||
"unplugin-auto-import": "^0.17.5",
|
"unplugin-auto-import": "^0.17.8",
|
||||||
"unplugin-vue-components": "^0.26.0"
|
"unplugin-vue-components": "^0.26.0",
|
||||||
|
"vite": "^5.4.10",
|
||||||
|
"vite-plugin-vue-devtools": "^7.5.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
30
frontend/src/components/ListItemCard.vue
Normal file
30
frontend/src/components/ListItemCard.vue
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<template>
|
||||||
|
<van-card
|
||||||
|
v-for="item in list"
|
||||||
|
:key="item.Hash"
|
||||||
|
price="2.00"
|
||||||
|
desc="描述信息"
|
||||||
|
title="商品标题"
|
||||||
|
thumb="https://fastly.jsdelivr.net/van-listt/assets/ipad.jpeg"
|
||||||
|
lazy-load="true"
|
||||||
|
@click="play(item)"
|
||||||
|
>
|
||||||
|
<template #tags>
|
||||||
|
<van-space>
|
||||||
|
<van-tag plain type="primary">视频</van-tag>
|
||||||
|
<van-tag plain type="primary">音频</van-tag>
|
||||||
|
<van-tag plain type="primary">PDF</van-tag>
|
||||||
|
</van-space>
|
||||||
|
</template>
|
||||||
|
</van-card>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { defineProps } from "vue";
|
||||||
|
const props = defineProps({
|
||||||
|
list: {
|
||||||
|
type: Array,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
30
frontend/src/utils/request.js
Normal file
30
frontend/src/utils/request.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import axios from 'axios'; // 引入axios
|
||||||
|
|
||||||
|
console.log("__GA: ", __GA)
|
||||||
|
const service = axios.create({
|
||||||
|
baseURL: "/v1",
|
||||||
|
timeout: 30,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Authorization': 'Bearer ' + __GA,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
// http request 拦截器
|
||||||
|
service.interceptors.request.use(
|
||||||
|
(config) => {
|
||||||
|
return config
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// http response 拦截器
|
||||||
|
service.interceptors.response.use(
|
||||||
|
(response) => {
|
||||||
|
return response
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
}
|
||||||
|
)
|
||||||
|
export default service
|
||||||
@@ -3,27 +3,26 @@
|
|||||||
|
|
||||||
<van-back-top bottom="80" />
|
<van-back-top bottom="80" />
|
||||||
|
|
||||||
<van-list
|
<van-list v-model:loading="loading" :finished="finished" finished-text="没有更多了" offset="100" @load="loadData">
|
||||||
v-model:loading="loading"
|
<van-card v-for="item in items" :key="item" :desc="item.title" :thumb="item.poster" @click="play(item)">
|
||||||
:finished="finished"
|
<template #title>
|
||||||
finished-text="没有更多了"
|
<span>{{ item.title }}</span>
|
||||||
@load="onLoad"
|
</template>
|
||||||
>
|
<template #price>
|
||||||
<van-card
|
<template v-if="item.discount == 100"> 价格:{{ item.price }} 点 </template>
|
||||||
v-for="item in list"
|
|
||||||
:key="item"
|
<template v-else>
|
||||||
price="2.00"
|
<del>{{ item.price }}</del>
|
||||||
desc="描述信息"
|
<span>{{ (item.price * item.discount) / 100 }}</span>
|
||||||
title="商品标题"
|
</template>
|
||||||
thumb="https://fastly.jsdelivr.net/van-listt/assets/ipad.jpeg"
|
</template>
|
||||||
lazy-load="true"
|
|
||||||
@click="play(item)"
|
|
||||||
>
|
|
||||||
<template #tags>
|
<template #tags>
|
||||||
<van-space>
|
<van-space>
|
||||||
<van-tag plain type="primary">视频</van-tag>
|
<van-tag v-for="resource in item.resources" plain type="primary">
|
||||||
<van-tag plain type="primary">音频</van-tag>
|
<template v-if="resource == 'video'">视频</template>
|
||||||
<van-tag plain type="primary">PDF</van-tag>
|
<template v-if="resource == 'audio'">音频</template>
|
||||||
|
</van-tag>
|
||||||
</van-space>
|
</van-space>
|
||||||
</template>
|
</template>
|
||||||
</van-card>
|
</van-card>
|
||||||
@@ -33,35 +32,58 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
|
import request from "@/utils/request";
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const search = ref("");
|
const search = ref("");
|
||||||
const list = ref([]);
|
const items = ref([]);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const finished = ref(false);
|
const finished = ref(false);
|
||||||
|
|
||||||
const onLoad = () => {
|
const offset = ref("");
|
||||||
// 异步更新数据
|
|
||||||
// setTimeout 仅做示例,真实场景中一般为 ajax 请求
|
|
||||||
setTimeout(() => {
|
|
||||||
for (let i = 0; i < 10; i++) {
|
|
||||||
list.value.push(list.value.length + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 加载状态结束
|
const onLoad = () => { };
|
||||||
loading.value = false;
|
|
||||||
|
|
||||||
// 数据全部加载完成
|
|
||||||
if (list.value.length >= 40) {
|
|
||||||
finished.value = true;
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
};
|
|
||||||
|
|
||||||
const play = (item) => {
|
const play = (item) => {
|
||||||
// vue router goto play view
|
// vue router goto play view
|
||||||
console.log("play", item);
|
console.log("play -", item);
|
||||||
router.push({ name: "play", params: { id: item } });
|
router.push({ name: "play", params: { id: item } });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const loadData = () => {
|
||||||
|
loading.value = true;
|
||||||
|
console.log("loadData");
|
||||||
|
// request /v1/medias
|
||||||
|
const data = {
|
||||||
|
offset: offset.value,
|
||||||
|
action: 0,
|
||||||
|
};
|
||||||
|
request
|
||||||
|
.post("/medias", data)
|
||||||
|
.then((res) => {
|
||||||
|
console.log(res);
|
||||||
|
if (offset.value == "") {
|
||||||
|
items.value = res.data;
|
||||||
|
} else {
|
||||||
|
items.value = items.value.concat(res.data);
|
||||||
|
if (res.data.length == 0) {
|
||||||
|
finished.value = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
offset.value = res.data[res.data.length - 1].hash;
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error(err);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
loading.value = true;
|
||||||
|
// finished.value = true;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
// loadData();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -5,18 +5,39 @@ import AutoImport from "unplugin-auto-import/vite";
|
|||||||
import Components from "unplugin-vue-components/vite";
|
import Components from "unplugin-vue-components/vite";
|
||||||
import { defineConfig } from "vite";
|
import { defineConfig } from "vite";
|
||||||
|
|
||||||
import vueDevTools from 'vite-plugin-vue-devtools';
|
// import vueDevTools from 'vite-plugin-vue-devtools';
|
||||||
|
|
||||||
// https://vite.dev/config/
|
// https://vite.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
|
server: {
|
||||||
|
proxy: {
|
||||||
|
'^/static': {
|
||||||
|
target: 'http://localhost:9600',
|
||||||
|
changeOrigin: true,
|
||||||
|
// rewrite: (path) => path.replace(/^\/api/, '')
|
||||||
|
},
|
||||||
|
'^/v1': {
|
||||||
|
target: 'http://localhost:9600',
|
||||||
|
changeOrigin: true,
|
||||||
|
// rewrite: (path) => path.replace(/^\/api/, '')
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
vue(),
|
vue(),
|
||||||
vueDevTools(),
|
// vueDevTools(),
|
||||||
AutoImport({
|
AutoImport({
|
||||||
|
imports: [
|
||||||
|
'vue',
|
||||||
|
'vue-router',
|
||||||
|
'pinia',
|
||||||
|
],
|
||||||
resolvers: [VantResolver()],
|
resolvers: [VantResolver()],
|
||||||
}),
|
}),
|
||||||
Components({
|
Components({
|
||||||
resolvers: [VantResolver()],
|
resolvers: [
|
||||||
|
VantResolver(),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
resolve: {
|
resolve: {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"settings": {
|
"settings": {
|
||||||
"vue3snippets.enable-compile-vue-file-on-did-save-code": true,
|
"vue3snippets.enable-compile-vue-file-on-did-save-code": false,
|
||||||
"cSpell.words": [
|
"cSpell.words": [
|
||||||
"qvyun"
|
"qvyun"
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user