Nattiden 1 gadu atpakaļ
vecāks
revīzija
166bcccd29

+ 44 - 0
Project/libraries/Homepage/debug.xaml

@@ -0,0 +1,44 @@
+<local:MyCard Margin="0,10">
+    <local:MyCard.Inlines>
+        <InlineUIContainer>
+            <Border Background="{DynamicResource ColorBrush3}" CornerRadius="5" Margin="0,0,2,-7">
+                <TextBlock FontSize="12" Margin="4" Foreground="White">
+                    🔩
+                </TextBlock>
+            </Border>
+        </InlineUIContainer>
+        <Run>调试工具</Run>
+    </local:MyCard.Inlines>
+    <Border Margin="-0.5" CornerRadius="5" BorderThickness="2.5" BorderBrush="{DynamicResource ColorBrush3}">
+        <DockPanel Margin="20">
+            <Grid Margin="0,20">
+                <Grid.ColumnDefinitions>
+                    <ColumnDefinition Width="100"/>
+                    <ColumnDefinition/> 
+                </Grid.ColumnDefinitions>
+                <Grid.RowDefinitions>
+                    <RowDefinition/>
+                    <RowDefinition/> 
+                </Grid.RowDefinitions>
+                <TextBlock Grid.Column="0" Grid.Row="0" Text="Commit 版本" VerticalAlignment="Center"/>
+                <TextBlock Grid.Column="1" Grid.Row="0" Text="${@Global|git.commit.id}" VerticalAlignment="Center"/>
+            </Grid>
+            <StackPanel DockPanel.Dock="Right">
+                <local:MyIconTextButton HorizontalAlignment="Right" Text="刷新主页" ToolTip="刷新新闻主页" EventType="刷新主页"
+                        LogoScale="0.9" Logo="M960 416V192l-73.056 73.056a447.712 447.712 0 0 0-373.6-201.088C265.92 63.968 65.312 264.544 65.312 512S265.92 960.032 513.344 960.032a448.064 448.064 0 0 0 415.232-279.488 38.368 38.368 0 1 0-71.136-28.896 371.36 371.36 0 0 1-344.096 231.584C308.32 883.232 142.112 717.024 142.112 512S308.32 140.768 513.344 140.768c132.448 0 251.936 70.08 318.016 179.84L736 416h224z"/>
+                <local:MyIconTextButton HorizontalAlignment="Right" Text="刷新后端" ToolTip="刷新本地后端" EventType="打开文件"
+                        EventData="cmd.exe|/C curl http://localhost:6608/reload"
+                        LogoScale="0.9" Logo="M960 416V192l-73.056 73.056a447.712 447.712 0 0 0-373.6-201.088C265.92 63.968 65.312 264.544 65.312 512S265.92 960.032 513.344 960.032a448.064 448.064 0 0 0 415.232-279.488 38.368 38.368 0 1 0-71.136-28.896 371.36 371.36 0 0 1-344.096 231.584C308.32 883.232 142.112 717.024 142.112 512S308.32 140.768 513.344 140.768c132.448 0 251.936 70.08 318.016 179.84L736 416h224z"/>
+                <local:MyIconTextButton HorizontalAlignment="Right" Text="切换为本地源" ToolTip="切换为本地" EventType="修改设置"
+                        EventData="UiCustomNet|${@XamlLink||http://localhost:6608/?debug}"
+                        LogoScale="0.9" Logo="M900.4 424.87c19.47 0 37.03-11.73 44.49-29.73 7.46-17.98 3.33-38.7-10.43-52.48L713.97 122.19c-7.3-7.3-19.12-7.3-26.42 0l-41.69 41.69c-7.3 7.3-7.3 19.13 0 26.42l138.28 138.27H86.32c-10.19 0-18.46 8.26-18.46 18.46v59.39c0 10.19 8.26 18.46 18.46 18.46H900.4zM937.65 598.72H123.8c-19.47 0-37.03 11.73-44.49 29.73-7.46 17.98-3.33 38.7 10.43 52.48l220.49 220.48c7.3 7.3 19.12 7.3 26.42 0l41.69-41.69c7.3-7.3 7.3-19.13 0-26.42L240.06 695.02h697.59c10.32 0 18.68-8.37 18.68-18.68v-58.93c0-10.32-8.36-18.69-18.68-18.69z"/>
+                 <local:MyIconTextButton HorizontalAlignment="Right" 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"/>
+                <local:MyIconTextButton HorizontalAlignment="Right" Text="GitHub 仓库" ToolTip="前往新闻主页 GitHub 页面" EventType="打开网页"
+                        EventData="https://github.com/Light-Beacon/PCL2-NewsHomepage"
+                        LogoScale="1" Logo="M512 42.666667A464.64 464.64 0 0 0 42.666667 502.186667 460.373333 460.373333 0 0 0 363.52 938.666667c23.466667 4.266667 32-9.813333 32-22.186667v-78.08c-130.56 27.733333-158.293333-61.44-158.293333-61.44a122.026667 122.026667 0 0 0-52.053334-67.413333c-42.666667-28.16 3.413333-27.733333 3.413334-27.733334a98.56 98.56 0 0 1 71.68 47.36 101.12 101.12 0 0 0 136.533333 37.973334 99.413333 99.413333 0 0 1 29.866667-61.44c-104.106667-11.52-213.333333-50.773333-213.333334-226.986667a177.066667 177.066667 0 0 1 47.36-124.16 161.28 161.28 0 0 1 4.693334-121.173333s39.68-12.373333 128 46.933333a455.68 455.68 0 0 1 234.666666 0c89.6-59.306667 128-46.933333 128-46.933333a161.28 161.28 0 0 1 4.693334 121.173333A177.066667 177.066667 0 0 1 810.666667 477.866667c0 176.64-110.08 215.466667-213.333334 226.986666a106.666667 106.666667 0 0 1 32 85.333334v125.866666c0 14.933333 8.533333 26.88 32 22.186667A460.8 460.8 0 0 0 981.333333 502.186667 464.64 464.64 0 0 0 512 42.666667"/>
+            </StackPanel>            
+        </DockPanel>
+    </Border>
+</local:MyCard>

+ 1 - 0
Project/modules/homepage_preference.py

@@ -180,6 +180,7 @@ class PreferenceManager:
         return self.__entries.values()
     
 PreferenceManager.add_entries([
+    PrefenrenceHiddenEntry('debug', bool, False, True),
     PrefenrenceChoiceEntry('Skin', str, 'basic',
                         ['basic', 'newra', 'classic',]),
     PrefenrenceChoiceEntry('Edition', str, 'standard',

+ 22 - 7
Project/modules/homepage_url.py

@@ -6,14 +6,17 @@ is_true = pref_module.is_true
 PREFERENCE_LIST_LENGTH = PREFERENCE_MANAGER.pref_length()
 GET_DOMAIN_URL = require('domain').get_doamin_url
 
-@script('Link')
-def link_script(page_name, context, *_args, **kwargs):
+def get_url(context, location, domain = None):
+    if domain:
+        return domain + location
+    else:
+        return GET_DOMAIN_URL(context) + location
+
+def get_page_link(page_name, context, domain = None, *_args, **kwargs):
     settings:dict = context.setter.toProperties().get('args',{})
     settings_length = len(settings)
-    if '.json' not in page_name:
-        page_name += '.json'
     if settings_length == 0:
-        return GET_DOMAIN_URL(context) + page_name
+        return get_url(context, page_name, domain)
     new_args = []
     # 判断优化: 取长度小的遍历
     if PREFERENCE_LIST_LENGTH > len(settings):
@@ -31,9 +34,21 @@ def link_script(page_name, context, *_args, **kwargs):
                 else:
                     new_args.append(entry.name + '=' + value)
     if len(new_args) == 0:
-        return GET_DOMAIN_URL(context) + page_name
+        return get_url(context, page_name, domain)
     if '?' not in page_name:
         page_name += '?'
     else:
         page_name += '&amp;'
-    return GET_DOMAIN_URL(context) + page_name + '&amp;'.join(new_args)
+    return get_url(context,  page_name + '&amp;'.join(new_args) , domain)
+
+@script('XamlLink')
+def link_script(page_name, domain=None, *_args, **kwargs):
+    context = kwargs['context']
+    return get_page_link(page_name, context, domain)
+
+@script('Link')
+def link_script(page_name, domain=None, *_args, **kwargs):
+    context = kwargs['context']
+    if '.json' not in page_name:
+        page_name += '.json'
+    return get_page_link(page_name, context, domain)

+ 1 - 0
Project/pages/News.yml

@@ -5,6 +5,7 @@ alias:
  - 主界面
 cards:
  - animated_noticebar | s = false
+ - ${@IF|${args.debug}|debug}
  - ${@NewsList}
  - ${@MainPageVersions|new}
 # - VersionLatestListCard | title=更新日志 | enable-card-style=True