Nattiden 1 rok temu
rodzic
commit
59eb874531

+ 8 - 3
Project/libraries/Homepage/Light/LightFooter.xaml

@@ -6,9 +6,14 @@
     LogoScale="1.1" Logo="M11.93 8.5a4.002 4.002 0 0 1-7.86 0H.75a.75.75 0 0 1 0-1.5h3.32a4.002 4.002 0 0 1 7.86 0h3.32a.75.75 0 0 1 0 1.5Zm-1.43-.75a2.5 2.5 0 1 0-5 0 2.5 2.5 0 0 0 5 0Z" />
     </StackPanel>
     <StackPanel VerticalAlignment="Center" Orientation="Horizontal" HorizontalAlignment="Right" Margin="-4,0,0,0">
-    <local:MyIconTextButton HorizontalAlignment="Left" Text="设置" ToolTip="新闻主页设置" EventType="打开帮助"
-    EventData="https://pcl.mcnews.thestack.top/BetaNotice.json"
-    LogoScale="1.1" Logo="M959 493.08L750.69 133.218c-7.559-11.362-18.92-18.92-32.183-18.92h-414.77a36.669 36.669 0 0 0-32.182 18.92L63.195 493.08a34.426 34.426 0 0 0 0 37.84l208.36 359.862c7.558 11.362 18.92 18.92 32.183 18.92h414.769a36.669 36.669 0 0 0 32.183-18.92L959 530.92a34.426 34.426 0 0 0 0-37.84z m-66.316 37.84L718.507 833.975c-7.607 11.361-18.969 18.92-32.183 18.92H335.872a36.669 36.669 0 0 1-32.183-18.92L127.561 530.92a34.426 34.426 0 0 1 0-37.84L303.69 190.025c7.558-11.361 18.92-18.92 32.183-18.92h350.354c13.264 0 26.527 7.559 32.183 18.92L892.684 493.08a34.377 34.377 0 0 1 0 37.84z M510.245 341.528a169.74 169.74 0 0 0-170.423 170.423 169.74 169.74 0 0 0 170.423 170.472A169.74 169.74 0 0 0 680.716 511.95a169.74 169.74 0 0 0-170.471-170.423z m0 284.087A113.957 113.957 0 0 1 396.629 512a113.957 113.957 0 0 1 113.616-113.615A113.957 113.957 0 0 1 623.86 512a113.957 113.957 0 0 1-113.615 113.615z"/>
+    ${@IF|${beta}|
+   <local:MyIconTextButton HorizontalAlignment="Left" Text="设置" ToolTip="新闻主页设置" EventType="打开帮助"
+    EventData="${@Link|Preference}"
+    LogoScale="1.1" Logo="M959 493.08L750.69 133.218c-7.559-11.362-18.92-18.92-32.183-18.92h-414.77a36.669 36.669 0 0 0-32.182 18.92L63.195 493.08a34.426 34.426 0 0 0 0 37.84l208.36 359.862c7.558 11.362 18.92 18.92 32.183 18.92h414.769a36.669 36.669 0 0 0 32.183-18.92L959 530.92a34.426 34.426 0 0 0 0-37.84z m-66.316 37.84L718.507 833.975c-7.607 11.361-18.969 18.92-32.183 18.92H335.872a36.669 36.669 0 0 1-32.183-18.92L127.561 530.92a34.426 34.426 0 0 1 0-37.84L303.69 190.025c7.558-11.361 18.92-18.92 32.183-18.92h350.354c13.264 0 26.527 7.559 32.183 18.92L892.684 493.08a34.377 34.377 0 0 1 0 37.84z M510.245 341.528a169.74 169.74 0 0 0-170.423 170.423 169.74 169.74 0 0 0 170.423 170.472A169.74 169.74 0 0 0 680.716 511.95a169.74 169.74 0 0 0-170.471-170.423z m0 284.087A113.957 113.957 0 0 1 396.629 512a113.957 113.957 0 0 1 113.616-113.615A113.957 113.957 0 0 1 623.86 512a113.957 113.957 0 0 1-113.615 113.615z"/>}
+    ${@IF|${beta-test}|
+   <local:MyIconTextButton HorizontalAlignment="Left" Text="设置" ToolTip="新闻主页设置" EventType="打开帮助"
+    EventData="${@Link|BetaNotice}"
+    LogoScale="1.1" Logo="M959 493.08L750.69 133.218c-7.559-11.362-18.92-18.92-32.183-18.92h-414.77a36.669 36.669 0 0 0-32.182 18.92L63.195 493.08a34.426 34.426 0 0 0 0 37.84l208.36 359.862c7.558 11.362 18.92 18.92 32.183 18.92h414.769a36.669 36.669 0 0 0 32.183-18.92L959 530.92a34.426 34.426 0 0 0 0-37.84z m-66.316 37.84L718.507 833.975c-7.607 11.361-18.969 18.92-32.183 18.92H335.872a36.669 36.669 0 0 1-32.183-18.92L127.561 530.92a34.426 34.426 0 0 1 0-37.84L303.69 190.025c7.558-11.361 18.92-18.92 32.183-18.92h350.354c13.264 0 26.527 7.559 32.183 18.92L892.684 493.08a34.377 34.377 0 0 1 0 37.84z M510.245 341.528a169.74 169.74 0 0 0-170.423 170.423 169.74 169.74 0 0 0 170.423 170.472A169.74 169.74 0 0 0 680.716 511.95a169.74 169.74 0 0 0-170.471-170.423z m0 284.087A113.957 113.957 0 0 1 396.629 512a113.957 113.957 0 0 1 113.616-113.615A113.957 113.957 0 0 1 623.86 512a113.957 113.957 0 0 1-113.615 113.615z"/>}
     <local:MyIconTextButton HorizontalAlignment="Left" Text="反馈" ToolTip="反馈新闻主页问题" EventType="打开网页"
     EventData="https://github.com/Light-Beacon/PCL2-NewsHomepage/issues/new/choose"
     LogoScale="1" Logo="M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3z M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0z M1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0z"/>

+ 6 - 1
Project/libraries/Homepage/NewFooter.xaml

@@ -26,9 +26,14 @@
     </StackPanel>
     </StackPanel>
     <StackPanel HorizontalAlignment="Right" >
+    ${@IF|${beta}|
+   <local:MyIconTextButton HorizontalAlignment="Left" Text="设置" ToolTip="新闻主页设置" EventType="打开帮助"
+    EventData="${@Link|Preference}"
+    LogoScale="1.1" Logo="M959 493.08L750.69 133.218c-7.559-11.362-18.92-18.92-32.183-18.92h-414.77a36.669 36.669 0 0 0-32.182 18.92L63.195 493.08a34.426 34.426 0 0 0 0 37.84l208.36 359.862c7.558 11.362 18.92 18.92 32.183 18.92h414.769a36.669 36.669 0 0 0 32.183-18.92L959 530.92a34.426 34.426 0 0 0 0-37.84z m-66.316 37.84L718.507 833.975c-7.607 11.361-18.969 18.92-32.183 18.92H335.872a36.669 36.669 0 0 1-32.183-18.92L127.561 530.92a34.426 34.426 0 0 1 0-37.84L303.69 190.025c7.558-11.361 18.92-18.92 32.183-18.92h350.354c13.264 0 26.527 7.559 32.183 18.92L892.684 493.08a34.377 34.377 0 0 1 0 37.84z M510.245 341.528a169.74 169.74 0 0 0-170.423 170.423 169.74 169.74 0 0 0 170.423 170.472A169.74 169.74 0 0 0 680.716 511.95a169.74 169.74 0 0 0-170.471-170.423z m0 284.087A113.957 113.957 0 0 1 396.629 512a113.957 113.957 0 0 1 113.616-113.615A113.957 113.957 0 0 1 623.86 512a113.957 113.957 0 0 1-113.615 113.615z"/>
+    }
     ${@IF|${beta-test}|
    <local:MyIconTextButton HorizontalAlignment="Left" Text="设置" ToolTip="新闻主页设置" EventType="打开帮助"
-    EventData="https://pcl.mcnews.thestack.top/BetaNotice.json"
+    EventData="${@Link|BetaNotice}"
     LogoScale="1.1" Logo="M959 493.08L750.69 133.218c-7.559-11.362-18.92-18.92-32.183-18.92h-414.77a36.669 36.669 0 0 0-32.182 18.92L63.195 493.08a34.426 34.426 0 0 0 0 37.84l208.36 359.862c7.558 11.362 18.92 18.92 32.183 18.92h414.769a36.669 36.669 0 0 0 32.183-18.92L959 530.92a34.426 34.426 0 0 0 0-37.84z m-66.316 37.84L718.507 833.975c-7.607 11.361-18.969 18.92-32.183 18.92H335.872a36.669 36.669 0 0 1-32.183-18.92L127.561 530.92a34.426 34.426 0 0 1 0-37.84L303.69 190.025c7.558-11.361 18.92-18.92 32.183-18.92h350.354c13.264 0 26.527 7.559 32.183 18.92L892.684 493.08a34.377 34.377 0 0 1 0 37.84z M510.245 341.528a169.74 169.74 0 0 0-170.423 170.423 169.74 169.74 0 0 0 170.423 170.472A169.74 169.74 0 0 0 680.716 511.95a169.74 169.74 0 0 0-170.471-170.423z m0 284.087A113.957 113.957 0 0 1 396.629 512a113.957 113.957 0 0 1 113.616-113.615A113.957 113.957 0 0 1 623.86 512a113.957 113.957 0 0 1-113.615 113.615z"/>
     }<local:MyIconTextButton HorizontalAlignment="Left" Text="反馈" ToolTip="反馈新闻主页问题" EventType="打开网页"
     EventData="https://github.com/Light-Beacon/PCL2-NewsHomepage/issues/new/choose"

+ 1 - 1
Project/libraries/Homepage/VersionArchiveList/ConfirmButtonCard.xaml

@@ -2,6 +2,6 @@
     <StackPanel Margin="15,10">
     <local:MyListItem Margin="0,1,0,1" ToolTip="继续浏览"
 	Logo="pack://application:,,,/images/Blocks/GoldBlock.png" Title="确认" Info="继续浏览"
-	EventType="打开帮助" EventData="https://${domain}/${version}_archive.json" Type="Clickable" />
+	EventType="打开帮助" EventData="${@Link|${version}_archive}" Type="Clickable" />
     </StackPanel>
 </local:MyCard>

+ 6 - 6
Project/libraries/Homepage/VersionArchiveList/VersionArchiveList.xaml

@@ -2,23 +2,23 @@
     <StackPanel Margin="20,40,20,15">
     <local:MyListItem Margin="0,2" ToolTip="点击查看该版本更新日志列表" LogoScale="1.04"
 	Logo="https://img.picgo.net/2025/02/15/Active_Trial_Spawner_JE4_BE3813f27e2213dec08.png" Title="棘巧试炼 | 1.21" Info="加入了试炼密室"
-	EventType="打开帮助" EventData="https://${domain}/1.21_archive.json" Type="Clickable" />
+	EventType="打开帮助" EventData="${@Link|1.21_archive}" Type="Clickable" />
     <local:MyListItem Margin="0,2" ToolTip="点击查看该版本更新日志列表" LogoScale="1.04"
 	Logo="https://img.picgo.net/2025/02/15/Cherry_Leaves_JE29cc390fd9b51333d.png" Title="足迹与故事 | 1.20 " Info="加入了考古学与樱花树"
-	EventType="打开帮助" EventData="https://${domain}/1.20_archive.json" Type="Clickable" />
+	EventType="打开帮助" EventData="${@Link|1.20_archive}" Type="Clickable" />
     <local:MyListItem Margin="0,2" ToolTip="点击查看该版本更新日志列表" LogoScale="1.04"
 	Logo="https://img.picgo.net/2025/02/15/Sculk_JE1_BE141e57ad22b2b968e.png" Title="荒野更新 | 1.19" Info="加入了深暗之域与远古城市,以及红树林沼泽"
-	EventType="打开帮助" EventData="https://${domain}/1.19_archive.json" Type="Clickable" />
+	EventType="打开帮助" EventData="${@Link|1.19_archive}" Type="Clickable" />
     <local:MyListItem Margin="0,2" ToolTip="点击查看该版本更新日志列表" LogoScale="1.04"
 	Logo="https://img.picgo.net/2025/02/15/Deepslate_JE3_BE227b47de799b509d8.png" Title="洞穴与山崖(第二部分) | 1.18" Info="扩展地下,大幅更改洞穴生成,加入新的山地生物群系"
-	EventType="打开帮助" EventData="https://${domain}/1.18_archive_confirm.json" Type="Clickable" />
+	EventType="打开帮助" EventData="${@Link|1.18_archive_confirm}" Type="Clickable" />
     <local:MyListItem Margin="0,2" ToolTip="点击查看该版本更新日志列表" LogoScale="1.04"
 	Logo="https://img.picgo.net/2025/02/15/Block_of_Amethyst_JE3_BE14f18267120f7bf34.png" Title="洞穴与山崖(第一部分) | 1.17" Info="加入了繁茂洞穴、紫晶洞"
-	EventType="打开帮助" EventData="https://${domain}/1.17_archive_confirm.json" Type="Clickable" />
+	EventType="打开帮助" EventData="${@Link|1.17_archive_confirm}" Type="Clickable" />
 	<Line X1="0" X2="100" Stroke="{DynamicResource ColorBrush5}"  Opacity="0.7" StrokeThickness="1.2"
      HorizontalAlignment="Center" Stretch="Fill" Margin="2"/>
 	<local:MyListItem Margin="0,2" ToolTip="点击查看该版本更新日志列表" LogoScale="1.04"
 	Logo="https://img.picgo.net/2025/02/15/Locked_Chest_JE108f3a29ad950e185.png" Title="愚人节快照" Info="23w13a_or_b、24w14potato"
-	EventType="打开帮助" EventData="https://${domain}/april_fools_archive.json" Type="Clickable" />
+	EventType="打开帮助" EventData="${@Link|april_fools_archive}" Type="Clickable" />
     </StackPanel>
 </local:MyCard>

+ 1 - 1
Project/libraries/Homepage/VersionArchiveList/ViewMoreLogs.xaml

@@ -2,6 +2,6 @@
     <StackPanel Margin="15,10">
     <local:MyListItem Margin="0,1" ToolTip="点击跳转到列表界面" LogoScale="1.04"
     Logo="https://s21.ax1x.com/2025/07/11/pVQXQTx.png" Title="历史版本更新日志" Info="点击查看更多更新日志"
-    EventType="打开帮助" EventData="https://${domain}/VersionArchiveList.json" Type="Clickable" />
+    EventType="打开帮助" EventData="${@Link|VersionArchiveList}" Type="Clickable" />
     </StackPanel>
 </local:MyCard>

+ 1 - 1
Project/libraries/Homepage/VersionLatestListCard.xaml

@@ -5,6 +5,6 @@ ${@VersionLatestList}
      HorizontalAlignment="Center" Stretch="Fill" Margin="4,4"/>
 <local:MyListItem Margin="10,1" ToolTip="点击跳转到列表界面" LogoScale="1.04"
 Logo="https://img.picgo.net/2025/02/15/Bookshelf_JE4_BE2de3fa45de5d6d91f.png" Title="历史版本更新日志" Info="点击查看更多更新日志"
-EventType="打开帮助" EventData="https://${domain}/VersionArchiveList.json" Type="Clickable" />
+EventType="打开帮助" EventData="${@Link|VersionArchiveList}" Type="Clickable" />
 </StackPanel>
 </local:MyCard>

+ 1 - 1
Project/libraries/Homepage/addressCard.xaml

@@ -8,7 +8,7 @@
       <local:MyTextBox x:Name="jumpbox" Height="30" />
         <local:MyButton HorizontalAlignment="Center" Width="80"
             Grid.Column="1" Text="打开→" EventType="打开帮助" 
-            EventData="{Binding Path=Text,ElementName=jumpbox,StringFormat=https://${domain}/{0}.json}"/>
+            EventData="{Binding Path=Text,ElementName=jumpbox,StringFormat=${@Link|{0}}"/>
     </Grid>
     </StackPanel>
 </local:MyCard>

+ 1 - 1
Project/libraries/Homepage/goToVer.xaml

@@ -8,7 +8,7 @@
       <local:MyTextBox x:Name="toverbox" Height="30" />
         <local:MyButton HorizontalAlignment="Center" Width="80"
             Grid.Column="1" Text="打开→" EventType="打开帮助" 
-            EventData="{Binding Path=Text,ElementName=toverbox,StringFormat=https://${domain}/VersionDetail.json?ver={0}}"/>
+            EventData="{Binding Path=Text,ElementName=toverbox,StringFormat=${@Link|VersionDetail.json?ver={0}}"/>
     </Grid>
     </StackPanel>
 </local:MyCard>

+ 1 - 1
Project/libraries/Homepage/jumpCard.xaml

@@ -16,7 +16,7 @@
       </local:MyComboBox>
         <local:MyButton HorizontalAlignment="Center" Width="80"
             Grid.Column="1" Text="打开→" EventType="打开帮助" 
-            EventData="{Binding Path=Text,ElementName=jumpbox,StringFormat=https://${domain}/{0}.json}"/>
+            EventData="{Binding Path=Text,ElementName=jumpbox,StringFormat=${@Link|{0}}"/>
     </Grid>
     </StackPanel>
 </local:MyCard>

+ 0 - 0
Project/modules/domain_limit.py → Project/modules/domain_limit.py.disabled


+ 10 - 1
Project/modules/homepage_preference.py

@@ -7,13 +7,22 @@ def true_that(obj:str):
     if isinstance(obj, str):
         return obj.lower() == 'true'
 
+PREFERENCE_LIST=[
+    'skin',
+    'not_finished',
+    'beta',
+    'domain'
+]
+DOMAIN = 'https://pcl.mcnews.thestack.top/'
+
 @script('PreferenceUrl')
 def get_preferece_url(context:'Context', *_args, **_kwargs):
     settings = context.setter.toProperties()
-    url = 'https://pcl.mcnews.thestack.top/'
+    url = DOMAIN
     if true_that(settings.get('LightEdition', False)):
         url += 'Light'
     args = []
+    args.append('beta=true')
     if true_that(settings.get('SkinNewra', False)):
         args.append('skin=newra')
     if true_that(settings.get('HideTranslating', False)):

+ 32 - 0
Project/modules/homepage_url.py

@@ -0,0 +1,32 @@
+from homepagebuilder.interfaces import require, script
+
+pref_module = require('homepage_preference')
+PREFERENCE_LIST = pref_module.PREFERENCE_LIST
+PREFERENCE_LIST_LENGTH = len(PREFERENCE_LIST)
+DOMAIN = pref_module.DOMAIN
+
+@script('Link')
+def link_script(page_name, context, *_args, **kwargs):
+    settings:dict = context.setter.toProperties()
+    settings_length = len(settings)
+    if '.json' not in page_name:
+        page_name += '.json'
+    if settings_length == 0:
+        return DOMAIN + page_name
+    new_args = []
+    # 判断优化: 取长度小的遍历
+    if PREFERENCE_LIST_LENGTH > len(settings):
+        for name, value in settings.items():
+            if name in PREFERENCE_LIST:
+                new_args.append(name + '=' + value)
+    else:
+        for name in PREFERENCE_LIST:
+            if value := settings.get(name, None) is not None:
+                new_args.append(name + '=' + value)
+    if len(new_args) == 0:
+        return DOMAIN + page_name
+    if '?' not in page_name:
+        page_name += '?'
+    else:
+        page_name += '&amp;'
+    return DOMAIN + page_name + '&amp;'.join(new_args)

+ 1 - 1
Project/pages/Preference/BetaNotice.xaml

@@ -31,7 +31,7 @@
         </TextBlock>
         <local:MyCheckBox Text="我已阅读、了解并同意上述内容" x:Name="ConfirmCheckBox"/>
         <local:MyButton IsEnabled="{Binding Path=Checked, ElementName=ConfirmCheckBox}" Text="进入设置页面" 
-                        EventType="打开帮助" EventData="https://pcl.mcnews.thestack.top/Preference.json"
+                        EventType="打开帮助" EventData="${@Link|Preference}"
                         Height="40" Margin="20,10,20,10"/>
     </StackPanel>
 </local:MyCard>

+ 1 - 1
Project/pages/Preference/Preference.xaml

@@ -45,7 +45,7 @@
     <StackPanel Margin="15,5">
         <TextBlock x:Name="OutputTextBlock" Visibility="Collapsed">
             <TextBlock.Text>
-                <MultiBinding StringFormat="{}https://pcl.mcnews.thestack.top/SaveChanges.json?SkinBasic={0}&amp;SkinNewra={1}&amp;StandardEdition={2}&amp;LightEdition={3}&amp;HideTranslating={4}">
+                <MultiBinding StringFormat="{}${@Link|SaveChanges.json?SkinBasic={0}&amp;SkinNewra={1}&amp;StandardEdition={2}&amp;LightEdition={3}&amp;HideTranslating={4}}">
                     <Binding Path="Checked" ElementName="BasicSkinRadioBox"/>
                     <Binding Path="Checked" ElementName="NewraSkinRadioBox"/>
                     <Binding Path="Checked" ElementName="StandardEditionRadioBox"/>

+ 1 - 1
Project/structures/components/VersionLinks/Common.xaml

@@ -1,3 +1,3 @@
 <local:MyListItem Margin="${@IF|${important-version}|10,1,10,1|40,1,10,1}" ToolTip="${version-type} 点击查看该版本更新日志"
 	Logo="${list-icon}" Title="${version-id}" Info="${@IF|${intro}|${intro}|${version-type}}"
-	EventType="打开帮助" EventData="https://${domain}/VersionDetail.json?ver=${version-id}" Type="Clickable" />
+	EventType="打开帮助" EventData="${@Link|VersionDetail.json?ver=${version-id}}" Type="Clickable" />

+ 1 - 1
Project/structures/components/VersionLinks/Latest.xaml

@@ -1,3 +1,3 @@
 <local:MyListItem Margin="10,1,10,1" ToolTip="最新${version-type} 点击查看该版本更新日志"
 	Logo="${list-icon}" Title="最新${version-type} - ${version-id}" Info="${@IF|${intro}|${intro}|${version-type}}"
-	EventType="打开帮助" EventData="https://${domain}/VersionDetail.json?ver=${version-id}" Type="Clickable" />
+	EventType="打开帮助" EventData="${@Link|VersionDetail.json?ver=${version-id}}" Type="Clickable" />