@@ -15,6 +15,15 @@ const onOpenSponsor = (link) => {
1515 BrowserOpenURL (link)
1616}
1717
18+ const openBanner = (link ) => {
19+ BrowserOpenURL (link)
20+ }
21+
22+ const skipBanner = () => {
23+ // Show again after 30 days
24+ localStorage .setItem (' banner_next_time' , Date .now () + 30 * 24 * 60 * 60 * 1000 )
25+ }
26+
1827const sponsorAd = computed (() => {
1928 try {
2029 const content = localStorage .getItem (' sponsor_ad' )
@@ -27,10 +36,54 @@ const sponsorAd = computed(() => {
2736 return null
2837 }
2938})
39+
40+ const banner = computed (() => {
41+ try {
42+ const nextTime = localStorage .getItem (' banner_next_time' ) || 0
43+ if (nextTime > 0 && nextTime > Date .now ()) {
44+ return null
45+ }
46+
47+ const content = localStorage .getItem (' banner' )
48+ const banners = JSON .parse (content)
49+ let banner = find (banners, ({ lang }) => {
50+ return lang === prefStore .currentLanguage
51+ })
52+ if (banner == null ) {
53+ banner = find (banners, ({ lang }) => {
54+ return lang === ' en'
55+ })
56+ }
57+ return banner || null
58+ // return {
59+ // lang: 'zh',
60+ // title: 'title',
61+ // content: 'content',
62+ // button: 'button',
63+ // link: 'https://redis.tinycraft.cc',
64+ // }
65+ } catch {
66+ return null
67+ }
68+ })
3069 </script >
3170
3271<template >
3372 <div class =" content-container flex-box-v" >
73+ <n-alert
74+ v-if =" banner != null"
75+ :bordered =" false"
76+ :on-close =" skipBanner"
77+ :title =" banner.title"
78+ class =" banner"
79+ closable
80+ type =" warning" >
81+ <span style =" margin : 0 10px 0 0 " >{{ banner.content }}</span >
82+ <n-button size =" small" tertiary type =" warning" @click =" openBanner(banner.link)" >
83+ {{ banner.button }}
84+ </n-button >
85+ </n-alert >
86+
3487 <!-- TODO: replace icon to app icon -->
3588 <n-empty :description =" $t('interface.empty_server_content')" >
3689 <template #extra >
@@ -56,6 +109,14 @@ const sponsorAd = computed(() => {
56109 justify-content : center ;
57110 padding : 5px ;
58111 box-sizing : border-box ;
112+ position : relative ;
113+
114+ & > .banner {
115+ position : absolute ;
116+ top : 0 ;
117+ left : 0 ;
118+ width : 100% ;
119+ }
59120
60121 & > .sponsor-ad {
61122 text-align : center ;
0 commit comments