diff --git a/package.json b/package.json index b42a631..9fda164 100644 --- a/package.json +++ b/package.json @@ -650,10 +650,13 @@ "name": "插件自动升级", "description": "定时检测、升级插件。", "labels": "自动更新", - "version": "1.4", + "version": "1.5", "icon": "PluginAutoUpgrade.png", "author": "hotlcc", - "level": 1 + "level": 1, + "history": { + "v1.5": "支持配置升级记录最大保存数量和最大展示数量。" + } }, "MergeSiteSwitch": { "name": "聚合站点开关", diff --git a/plugins/pluginautoupgrade/__init__.py b/plugins/pluginautoupgrade/__init__.py index af63364..f80cc9e 100644 --- a/plugins/pluginautoupgrade/__init__.py +++ b/plugins/pluginautoupgrade/__init__.py @@ -23,7 +23,7 @@ class PluginAutoUpgrade(_PluginBase): # 插件图标 plugin_icon = "PluginAutoUpgrade.png" # 插件版本 - plugin_version = "1.4" + plugin_version = "1.5" # 插件作者 plugin_author = "hotlcc" # 作者主页 @@ -52,7 +52,9 @@ class PluginAutoUpgrade(_PluginBase): # 配置相关 # 插件缺省配置 __config_default: Dict[str, Any] = { - 'cron': '* 0/4 * * *' + 'cron': '* 0/4 * * *', + 'save_record_quantity': 100, + 'display_record_quantity': 10, } # 插件用户配置 __config: Dict[str, Any] = {} @@ -128,6 +130,10 @@ class PluginAutoUpgrade(_PluginBase): config_suggest.update(self.__config_default) # 定时周期 cron = self.__config_default.get('cron') + # 保存记录数量 + save_record_quantity = self.__config_default.get('save_record_quantity') + # 展示记录数量 + display_record_quantity = self.__config_default.get('display_record_quantity') # 已安装的在线插件下拉框数据 installed_online_plugin_options = self.__get_installed_online_plugin_options() form = [{ @@ -200,6 +206,41 @@ class PluginAutoUpgrade(_PluginBase): 'cols': 12, 'xxl': 4, 'xl': 4, 'lg': 4, 'md': 4, 'sm': 6, 'xs': 12 }, + 'content': [{ + 'component': 'VTextField', + 'props': { + 'model': 'save_record_quantity', + 'label': '保存记录数量', + 'type': 'number', + 'placeholder': save_record_quantity, + 'hint': f'设置插件最多保存多少条插件升级记录。缺省时为{save_record_quantity}。' + } + }] + }, { + 'component': 'VCol', + 'props': { + 'cols': 12, + 'xxl': 4, 'xl': 4, 'lg': 4, 'md': 4, 'sm': 6, 'xs': 12 + }, + 'content': [{ + 'component': 'VTextField', + 'props': { + 'model': 'display_record_quantity', + 'label': '展示记录数量', + 'type': 'number', + 'placeholder': display_record_quantity, + 'hint': f'设置插件数据页最多展示多少条插件升级记录。缺省时为{display_record_quantity}。' + } + }] + }] + }, { + 'component': 'VRow', + 'content': [{ + 'component': 'VCol', + 'props': { + 'cols': 12, + 'xxl': 6, 'xl': 6, 'lg': 6, 'md': 6, 'sm': 6, 'xs': 12 + }, 'content': [{ 'component': 'VSelect', 'props': { @@ -215,7 +256,7 @@ class PluginAutoUpgrade(_PluginBase): 'component': 'VCol', 'props': { 'cols': 12, - 'xxl': 4, 'xl': 4, 'lg': 4, 'md': 4, 'sm': 6, 'xs': 12 + 'xxl': 6, 'xl': 6, 'lg': 6, 'md': 6, 'sm': 6, 'xs': 12 }, 'content': [{ 'component': 'VSelect', @@ -627,8 +668,9 @@ class PluginAutoUpgrade(_PluginBase): if not upgrade_records: upgrade_records = [] upgrade_records.extend(records) - # 最多保存100条 - upgrade_records = upgrade_records[-100:] + # 最多保存多少条 + save_record_quantity = self.__get_config_item('save_record_quantity') + upgrade_records = upgrade_records[-save_record_quantity:] self.save_data(self.__data_key_upgrade_records, upgrade_records) @staticmethod @@ -646,8 +688,9 @@ class PluginAutoUpgrade(_PluginBase): upgrade_records = self.get_data(self.__data_key_upgrade_records) if not upgrade_records: return [] - # 只展示最近10条 - upgrade_records = upgrade_records[-10:] + # 只展示最近多少条 + display_record_quantity = self.__get_config_item('display_record_quantity') + upgrade_records = upgrade_records[-display_record_quantity:] page_data = [self.__convert_upgrade_record_to_page_data(upgrade_record) for upgrade_record in upgrade_records if upgrade_record] # 按时间倒序