mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 07:16:01 +00:00
promo widget colors
This commit is contained in:
@@ -286,7 +286,7 @@ module.exports = {
|
||||
|
||||
premiumPromoWidget_meta: true,
|
||||
async premiumPromoWidget() {
|
||||
const data = getPromoWidgetData();
|
||||
const data = await getPromoWidgetData();
|
||||
if (data?.state != 'data') {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ const logger = getLogger('cloudIntf');
|
||||
|
||||
let cloudFiles = null;
|
||||
let promoWidgetData = null;
|
||||
let promoWidgetDataLoaded = false;
|
||||
|
||||
const DBGATE_IDENTITY_URL = process.env.LOCAL_DBGATE_IDENTITY
|
||||
? 'http://localhost:3103'
|
||||
@@ -260,13 +261,21 @@ async function getPublicFileData(path) {
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
async function updatePremiumPromoWidget() {
|
||||
async function ensurePromoWidgetDataLoaded() {
|
||||
if (promoWidgetDataLoaded) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const fileContent = await fs.readFile(path.join(datadir(), 'promo-widget.json'), 'utf-8');
|
||||
promoWidgetData = JSON.parse(fileContent);
|
||||
} catch (err) {
|
||||
promoWidgetData = null;
|
||||
}
|
||||
promoWidgetDataLoaded = true;
|
||||
}
|
||||
|
||||
async function updatePremiumPromoWidget() {
|
||||
await ensurePromoWidgetDataLoaded();
|
||||
|
||||
const tags = (await collectCloudFilesSearchTags()).join(',');
|
||||
|
||||
@@ -466,7 +475,8 @@ async function getPublicIpInfo() {
|
||||
}
|
||||
}
|
||||
|
||||
function getPromoWidgetData() {
|
||||
async function getPromoWidgetData() {
|
||||
await ensurePromoWidgetDataLoaded();
|
||||
return promoWidgetData;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user