Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
appbase-edge-function
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanjinfei
appbase-edge-function
Commits
5d13859d
Commit
5d13859d
authored
Feb 07, 2025
by
duanjinfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:修复缓存Category报错问题
parent
0511b03a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
19 deletions
+53
-19
cli-latest
supabase/.temp/cli-latest
+1
-1
index.ts
supabase/functions/crawl-data/index.ts
+27
-1
index.ts
supabase/functions/update-app/index.ts
+25
-17
No files found.
supabase/.temp/cli-latest
View file @
5d13859d
v2.6.8
v2.9.6
\ No newline at end of file
\ No newline at end of file
supabase/functions/crawl-data/index.ts
View file @
5d13859d
...
@@ -282,6 +282,32 @@ async function getTonAppInfo(supabase) {
...
@@ -282,6 +282,32 @@ async function getTonAppInfo(supabase) {
languagesCodes
,
languagesCodes
,
caption
caption
}
=
appDetailData
.
pageProps
.
app
;
}
=
appDetailData
.
pageProps
.
app
;
let
modifiedLinks
=
[];
if
(
links
.
length
>
0
)
{
for
(
let
i
=
0
;
i
<
links
.
length
;
i
++
)
{
let
newLink
=
{};
for
(
let
key
in
links
[
i
])
{
if
(
links
[
i
][
key
])
{
let
modifiedKey
=
key
;
if
(
key
==
"
webSite
"
)
{
modifiedKey
=
"
web
"
;
}
if
(
key
==
"
instagram
"
)
{
modifiedKey
=
"
inst
"
;
}
if
(
!
links
[
i
][
key
].
startsWith
(
"
http://
"
)
&&
!
links
[
i
][
key
].
startsWith
(
"
https://
"
)
)
{
links
[
i
][
key
]
=
"
https://
"
+
links
[
i
][
key
];
}
newLink
[
modifiedKey
.
replace
(
/
([
a-z
])([
A-Z
])
/g
,
"
$1_$2
"
).
toLowerCase
()]
=
links
[
i
][
key
];
}
}
modifiedLinks
.
push
(
newLink
);
}
}
const
cleanedAppDetail
=
databaseCache
.
cleanAppData
(
app
);
const
cleanedAppDetail
=
databaseCache
.
cleanAppData
(
app
);
// 准备插入的应用数据
// 准备插入的应用数据
const
insertApp
=
{
const
insertApp
=
{
...
@@ -298,7 +324,7 @@ async function getTonAppInfo(supabase) {
...
@@ -298,7 +324,7 @@ async function getTonAppInfo(supabase) {
});
});
insertApp
.
languages
=
(
languagesCodes
||
[]).
join
(
"
"
);
insertApp
.
languages
=
(
languagesCodes
||
[]).
join
(
"
"
);
insertApp
.
link
=
app
.
externalLink
insertApp
.
link
=
app
.
externalLink
insertApp
.
appPlatforms
=
l
inks
insertApp
.
appPlatforms
=
modifiedL
inks
if
(
!
insertApp
.
appPlatforms
&&
!
insertApp
.
description
&&
!
insertApp
.
images
&&
insertApp
.
images
==
[]
&&
(
!
insertApp
.
link
||
insertApp
.
link
==
"
https://
"
))
{
if
(
!
insertApp
.
appPlatforms
&&
!
insertApp
.
description
&&
!
insertApp
.
images
&&
insertApp
.
images
==
[]
&&
(
!
insertApp
.
link
||
insertApp
.
link
==
"
https://
"
))
{
continue
continue
}
else
if
(
!
insertApp
.
appPlatforms
&&
!
insertApp
.
description
&&
(
!
insertApp
.
images
||
insertApp
.
images
==
[]))
{
}
else
if
(
!
insertApp
.
appPlatforms
&&
!
insertApp
.
description
&&
(
!
insertApp
.
images
||
insertApp
.
images
==
[]))
{
...
...
supabase/functions/update-app/index.ts
View file @
5d13859d
...
@@ -164,24 +164,12 @@ async function cacheCategoryApp(supabase, allApps, directory, bucketName) {
...
@@ -164,24 +164,12 @@ async function cacheCategoryApp(supabase, allApps, directory, bucketName) {
}
}
}
}
// 缓存分类信息的数据
EdgeRuntime
.
waitUntil
(
cacheCategoryInfo
(
supabase
,
categoryInfo
,
directory
,
bucketName
));
const
categoryInfoFileName
=
`
${
directory
}
/category_Info.json`
;
const
categoryInfoJson
=
JSON
.
stringify
(
categoryInfo
);
EdgeRuntime
.
waitUntil
(
cacheCategoryCount
(
supabase
,
categoryCount
,
directory
,
bucketName
));
const
{
error
:
categoryInfoUploadError
}
=
await
supabase
.
storage
}
.
from
(
bucketName
)
.
upload
(
categoryInfoFileName
,
new
Blob
([
categoryInfoJson
]),
{
contentType
:
'
application/json
'
,
upsert
:
true
,
});
if
(
categoryInfoUploadError
)
{
console
.
error
(
`Error uploading category_info JSON:`
,
categoryInfoUploadError
);
}
else
{
console
.
log
(
`Uploading page category_info JSON successful`
);
}
async
function
cacheCategoryCount
(
supabase
,
categoryCount
,
directory
,
bucketName
)
{
// 缓存分类数量的数据
// 缓存分类数量的数据
const
categoryCountFileName
=
`
${
directory
}
/category_count.json`
;
const
categoryCountFileName
=
`
${
directory
}
/category_count.json`
;
const
categoryCountJson
=
JSON
.
stringify
(
categoryCount
);
const
categoryCountJson
=
JSON
.
stringify
(
categoryCount
);
...
@@ -201,6 +189,26 @@ async function cacheCategoryApp(supabase, allApps, directory, bucketName) {
...
@@ -201,6 +189,26 @@ async function cacheCategoryApp(supabase, allApps, directory, bucketName) {
}
}
}
}
async
function
cacheCategoryInfo
(
supabase
,
categoryInfo
,
directory
,
bucketName
)
{
// 缓存分类信息的数据
const
categoryInfoFileName
=
`
${
directory
}
/category_Info.json`
;
const
categoryInfoJson
=
JSON
.
stringify
(
categoryInfo
);
const
{
error
:
categoryInfoUploadError
}
=
await
supabase
.
storage
.
from
(
bucketName
)
.
upload
(
categoryInfoFileName
,
new
Blob
([
categoryInfoJson
]),
{
contentType
:
'
application/json
'
,
upsert
:
true
,
});
if
(
categoryInfoUploadError
)
{
console
.
error
(
`Error uploading category_info JSON:`
,
categoryInfoUploadError
);
}
else
{
console
.
log
(
`Uploading page category_info JSON successful`
);
}
}
async
function
cacheRentUpdateApp
(
supabase
,
allApps
,
directory
,
bucketName
)
{
async
function
cacheRentUpdateApp
(
supabase
,
allApps
,
directory
,
bucketName
)
{
const
recentUpdateAppFileName
=
`
${
directory
}
/resent_update_app.json`
;
const
recentUpdateAppFileName
=
`
${
directory
}
/resent_update_app.json`
;
const
pageJson
=
JSON
.
stringify
(
allApps
.
slice
(
0
,
6
))
const
pageJson
=
JSON
.
stringify
(
allApps
.
slice
(
0
,
6
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment