Improve theme preview

This commit is contained in:
qianlifeng 2024-10-16 16:24:43 +08:00
parent a8bc507ce6
commit 06127d0639
No known key found for this signature in database
19 changed files with 385 additions and 226 deletions

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"dart.lineLength": 200
}

View File

@ -57,11 +57,11 @@ class WoxApi {
await WoxHttpUtil.instance.postData("/plugin/enable", {"id": id});
}
Future<List<WoxSettingTheme>> findStoreThemes() async {
Future<List<WoxTheme>> findStoreThemes() async {
return await WoxHttpUtil.instance.postData("/theme/store", null);
}
Future<List<WoxSettingTheme>> findInstalledThemes() async {
Future<List<WoxTheme>> findInstalledThemes() async {
return await WoxHttpUtil.instance.postData("/theme/installed", null);
}

View File

@ -0,0 +1,58 @@
import 'package:flutter/material.dart';
import 'package:from_css_color/from_css_color.dart';
import 'package:wox/entity/wox_theme.dart';
class WoxThemeIconView extends StatelessWidget {
final WoxTheme theme;
final double? width;
final double? height;
const WoxThemeIconView({super.key, required this.theme, this.width, this.height});
@override
Widget build(BuildContext context) {
Color backgroundColor = fromCssColor(theme.appBackgroundColor);
Color queryBoxColor = fromCssColor(theme.queryBoxBackgroundColor);
Color resultItemActiveColor = fromCssColor(theme.resultItemActiveBackgroundColor);
return Container(
width: width,
height: height,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: backgroundColor,
),
child: Padding(
padding: const EdgeInsets.only(left: 4, right: 4, top: 4),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Query box
Container(
width: width,
height: 10,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4),
color: queryBoxColor,
),
),
const SizedBox(height: 4),
// Result items
Column(
children: [
Container(
height: 5,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(2),
color: resultItemActiveColor,
),
),
const SizedBox(height: 6),
],
),
],
),
),
);
}
}

View File

@ -0,0 +1,140 @@
import 'package:flutter/material.dart';
import 'package:from_css_color/from_css_color.dart';
import 'package:wox/components/wox_image_view.dart';
import 'package:wox/components/wox_hotkey_view.dart';
import 'package:wox/entity/wox_image.dart';
import 'package:wox/entity/wox_theme.dart';
import 'package:wox/entity/wox_hotkey.dart';
import 'package:wox/enums/wox_image_type_enum.dart';
import 'package:wox/utils/consts.dart';
import 'package:wox/utils/wox_theme_util.dart';
class WoxThemePreview extends StatelessWidget {
final WoxTheme theme;
const WoxThemePreview({super.key, required this.theme});
@override
Widget build(BuildContext context) {
Color backgroundColor = fromCssColor(theme.appBackgroundColor);
Color queryBoxColor = fromCssColor(theme.queryBoxBackgroundColor);
Color resultItemActiveColor = fromCssColor(theme.resultItemActiveBackgroundColor);
Color resultItemColor = fromCssColor(theme.appBackgroundColor);
final List<String> previewTexts = [
"Search for applications, folders, files and more",
"Plenty of Plugins and AI Themes",
"Single executable file, no installation required",
"Develop plugins with Javascript, Python, C#",
"Customizable and extensible launcher",
];
return Padding(
padding: const EdgeInsets.fromLTRB(20, 20, 20, 200),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: backgroundColor,
),
child: Column(
children: [
Padding(
padding: const EdgeInsets.fromLTRB(10, 10, 10, 10),
child: Container(
height: 40,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(theme.queryBoxBorderRadius.toDouble()),
color: queryBoxColor,
),
child: Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: const EdgeInsets.only(left: 10),
child: Text(
"Wox Theme Preview",
style: TextStyle(color: fromCssColor(theme.queryBoxFontColor)),
),
),
),
),
),
Expanded(
child: ListView(
children: List.generate(5, (index) {
bool isActive = index == 1;
return Container(
height: 60,
margin: const EdgeInsets.symmetric(vertical: 0, horizontal: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(theme.resultItemBorderRadius.toDouble()),
color: isActive ? resultItemActiveColor : resultItemColor,
),
child: ListTile(
leading: WoxImageView(
woxImage: WoxImage(imageType: WoxImageTypeEnum.WOX_IMAGE_TYPE_SVG.code, imageData: QUERY_ICON_SELECTION_FILE),
width: 30,
),
title: Text(
previewTexts[index],
style: TextStyle(
color: fromCssColor(isActive ? theme.resultItemActiveTitleColor : theme.resultItemTitleColor),
),
),
subtitle: Text(
"Wox Feature ${index + 1}",
style: TextStyle(
color: fromCssColor(isActive ? theme.resultItemActiveSubTitleColor : theme.resultItemSubTitleColor),
),
),
),
);
}),
),
),
Container(
height: WoxThemeUtil.instance.getToolbarHeight(),
decoration: BoxDecoration(
color: fromCssColor(theme.toolbarBackgroundColor),
border: Border(
top: BorderSide(
color: fromCssColor(theme.toolbarFontColor).withOpacity(0.1),
width: 1,
),
),
),
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: theme.toolbarPaddingLeft.toDouble(),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Row(
children: [],
),
Row(
children: [
Text(
"Open",
style: TextStyle(color: fromCssColor(theme.toolbarFontColor)),
),
const SizedBox(width: 8),
WoxHotkeyView(
hotkey: WoxHotkey.parseHotkeyFromString("Enter")!,
backgroundColor: fromCssColor(theme.toolbarBackgroundColor),
borderColor: fromCssColor(theme.toolbarFontColor),
textColor: fromCssColor(theme.toolbarFontColor),
),
],
),
],
),
),
),
],
),
),
);
}
}

View File

@ -5,6 +5,9 @@ class WoxTheme {
late String themeUrl;
late String version;
late String description;
late bool isSystem;
late bool isInstalled;
late bool isUpgradable;
late String appBackgroundColor;
late int appPaddingLeft;
@ -56,59 +59,64 @@ class WoxTheme {
late int toolbarPaddingLeft;
late int toolbarPaddingRight;
WoxTheme(
{themeId,
themeName,
themeAuthor,
themeUrl,
version,
appBackgroundColor,
appPaddingLeft,
appPaddingTop,
appPaddingRight,
appPaddingBottom,
resultContainerPaddingLeft,
resultContainerPaddingTop,
resultContainerPaddingRight,
resultContainerPaddingBottom,
resultItemBorderRadius,
resultItemPaddingLeft,
resultItemPaddingTop,
resultItemPaddingRight,
resultItemPaddingBottom,
resultItemTitleColor,
resultItemSubTitleColor,
resultItemBorderLeft,
resultItemActiveBackgroundColor,
resultItemActiveTitleColor,
resultItemActiveSubTitleColor,
resultItemActiveBorderLeft,
queryBoxFontColor,
queryBoxBackgroundColor,
queryBoxBorderRadius,
queryBoxCursorColor,
queryBoxTextSelectionColor,
actionContainerBackgroundColor,
actionContainerHeaderFontColor,
actionContainerPaddingLeft,
actionContainerPaddingTop,
actionContainerPaddingRight,
actionContainerPaddingBottom,
actionItemActiveBackgroundColor,
actionItemActiveFontColor,
actionItemFontColor,
actionQueryBoxFontColor,
actionQueryBoxBackgroundColor,
actionQueryBoxBorderRadius,
previewFontColor,
previewSplitLineColor,
previewPropertyTitleColor,
previewPropertyContentColor,
previewTextSelectionColor,
toolbarFontColor,
toolbarBackgroundColor,
toolbarPaddingLeft,
toolbarPaddingRight});
WoxTheme({
themeId,
themeName,
themeAuthor,
themeUrl,
version,
description,
isSystem,
isInstalled,
isUpgradable,
appBackgroundColor,
appPaddingLeft,
appPaddingTop,
appPaddingRight,
appPaddingBottom,
resultContainerPaddingLeft,
resultContainerPaddingTop,
resultContainerPaddingRight,
resultContainerPaddingBottom,
resultItemBorderRadius,
resultItemPaddingLeft,
resultItemPaddingTop,
resultItemPaddingRight,
resultItemPaddingBottom,
resultItemTitleColor,
resultItemSubTitleColor,
resultItemBorderLeft,
resultItemActiveBackgroundColor,
resultItemActiveTitleColor,
resultItemActiveSubTitleColor,
resultItemActiveBorderLeft,
queryBoxFontColor,
queryBoxBackgroundColor,
queryBoxBorderRadius,
queryBoxCursorColor,
queryBoxTextSelectionColor,
actionContainerBackgroundColor,
actionContainerHeaderFontColor,
actionContainerPaddingLeft,
actionContainerPaddingTop,
actionContainerPaddingRight,
actionContainerPaddingBottom,
actionItemActiveBackgroundColor,
actionItemActiveFontColor,
actionItemFontColor,
actionQueryBoxFontColor,
actionQueryBoxBackgroundColor,
actionQueryBoxBorderRadius,
previewFontColor,
previewSplitLineColor,
previewPropertyTitleColor,
previewPropertyContentColor,
previewTextSelectionColor,
toolbarFontColor,
toolbarBackgroundColor,
toolbarPaddingLeft,
toolbarPaddingRight,
});
WoxTheme.fromJson(Map<String, dynamic> json) {
themeId = json['ThemeId'];
@ -116,6 +124,10 @@ class WoxTheme {
themeAuthor = json['ThemeAuthor'];
themeUrl = json['ThemeUrl'];
version = json['Version'];
description = json['Description'];
isSystem = json['IsSystem'] ?? false;
isInstalled = json['IsInstalled'] ?? false;
isUpgradable = json['IsUpgradable'] ?? false;
appBackgroundColor = json['AppBackgroundColor'];
appPaddingLeft = json['AppPaddingLeft'];
appPaddingTop = json['AppPaddingTop'];
@ -174,6 +186,10 @@ class WoxTheme {
data['ThemeAuthor'] = themeAuthor;
data['ThemeUrl'] = themeUrl;
data['Version'] = version;
data['Description'] = description;
data['IsSystem'] = isSystem;
data['IsInstalled'] = isInstalled;
data['IsUpgradable'] = isUpgradable;
data['AppBackgroundColor'] = appBackgroundColor;
data['AppPaddingLeft'] = appPaddingLeft;
data['AppPaddingTop'] = appPaddingTop;
@ -225,38 +241,8 @@ class WoxTheme {
data['ToolbarPaddingRight'] = toolbarPaddingRight;
return data;
}
}
class WoxSettingTheme {
late String themeId;
late String themeName;
late String themeAuthor;
late String themeUrl;
late String version;
late String description;
late List<String> screenshotUrls;
late bool isSystem;
late bool isInstalled;
late bool isUpgradable;
WoxSettingTheme.fromJson(Map<String, dynamic> json) {
themeId = json['ThemeId'];
themeName = json['ThemeName'];
themeAuthor = json['ThemeAuthor'];
themeUrl = json['ThemeUrl'];
version = json['Version'];
description = json['Description'];
isSystem = json['IsSystem'];
isInstalled = json['IsInstalled'];
isUpgradable = json['IsUpgradable'];
if (json['ScreenshotUrls'] != null) {
screenshotUrls = List<String>.from(json['ScreenshotUrls']);
} else {
screenshotUrls = <String>[];
}
}
WoxSettingTheme.empty() {
WoxTheme.empty() {
themeId = '';
themeName = '';
themeAuthor = '';
@ -266,19 +252,5 @@ class WoxSettingTheme {
isSystem = false;
isInstalled = false;
isUpgradable = false;
screenshotUrls = <String>[];
}
WoxSettingTheme.fromWoxSettingTheme(WoxSettingTheme woxSettingTheme) {
themeId = woxSettingTheme.themeId;
themeName = woxSettingTheme.themeName;
themeAuthor = woxSettingTheme.themeAuthor;
themeUrl = woxSettingTheme.themeUrl;
version = woxSettingTheme.version;
description = woxSettingTheme.description;
isSystem = woxSettingTheme.isSystem;
isInstalled = woxSettingTheme.isInstalled;
isUpgradable = woxSettingTheme.isUpgradable;
screenshotUrls = woxSettingTheme.screenshotUrls;
}
}

View File

@ -456,7 +456,7 @@ class WoxLauncherController extends GetxController {
}
void changeActionScrollPosition(String traceId, WoxEventDeviceType deviceType, WoxDirection direction) {
updateActiveAction(traceId,direction);
updateActiveAction(traceId, direction);
actions.refresh();
}
@ -943,9 +943,9 @@ class WoxLauncherController extends GetxController {
void updateToolbarOnQueryChanged(String traceId, PlainQuery query) {
//if doctor check is not passed and query is empty, show doctor tip
if (query.isEmpty && !doctorCheckPassed) {
Logger.instance.debug(traceId, "update toolbar to doctor warning, query is empty and doctor check not passed");
toolbar.value = ToolbarInfo(
text: "Doctor check not passed",
Logger.instance.debug(traceId, "update toolbar to doctor warning, query is empty and doctor check not passed");
toolbar.value = ToolbarInfo(
text: "Doctor check not passed",
icon: WoxImage(imageType: WoxImageTypeEnum.WOX_IMAGE_TYPE_BASE64.code, imageData: QUERY_ICON_DOCTOR_WARNING),
hotkey: "enter",
actionName: "Check",
@ -969,7 +969,7 @@ class WoxLauncherController extends GetxController {
hotkey: "enter",
actionName: activeAction.name.value,
action: () {
executeAction(traceId, getActiveResult(), activeAction);
executeAction(traceId, getActiveResult(), activeAction);
},
);
} else {
@ -977,4 +977,4 @@ class WoxLauncherController extends GetxController {
toolbar.value = ToolbarInfo.empty();
}
}
}
}

View File

@ -1,8 +1,11 @@
import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter/material.dart' as base;
import 'package:flutter/services.dart';
import 'package:flutter_image_slideshow/flutter_image_slideshow.dart';
import 'package:from_css_color/from_css_color.dart';
import 'package:get/get.dart';
import 'package:wox/components/wox_theme_icon_view.dart';
import 'package:wox/components/wox_theme_preview.dart';
import 'package:wox/entity/wox_theme.dart';
import 'package:wox/modules/setting/wox_setting_controller.dart';
import 'package:wox/utils/colors.dart';
@ -63,7 +66,7 @@ class WoxSettingThemeView extends GetView<WoxSettingController> {
controller.activeTheme.value = theme;
},
child: base.ListTile(
//ellipsis: true,
leading: WoxThemeIconView(theme: theme, width: 32, height: 32),
title: Text(theme.themeName,
maxLines: 1,
overflow: TextOverflow.ellipsis,
@ -208,7 +211,7 @@ class WoxSettingThemeView extends GetView<WoxSettingController> {
),
Expanded(
child: base.DefaultTabController(
length: theme.isInstalled ? 2 : 1,
length: 2,
child: Column(
children: [
const base.TabBar(
@ -217,6 +220,9 @@ class WoxSettingThemeView extends GetView<WoxSettingController> {
labelColor: SettingPrimaryColor,
indicatorColor: SettingPrimaryColor,
tabs: [
base.Tab(
child: Text('Preview'),
),
base.Tab(
child: Text('Description'),
),
@ -225,6 +231,7 @@ class WoxSettingThemeView extends GetView<WoxSettingController> {
Expanded(
child: base.TabBarView(
children: [
themeTabPreview(theme),
themeTabDescription(),
],
),
@ -238,6 +245,14 @@ class WoxSettingThemeView extends GetView<WoxSettingController> {
);
}
Widget themeTabPreview(WoxTheme theme) {
if (theme.themeId.isEmpty) {
return const Text('Theme data is empty');
}
return WoxThemePreview(theme: theme);
}
Widget themeTabDescription() {
return base.Padding(
padding: const EdgeInsets.all(16),
@ -247,17 +262,6 @@ class WoxSettingThemeView extends GetView<WoxSettingController> {
Text(
controller.activeTheme.value.description,
),
const SizedBox(height: 20),
controller.activeTheme.value.screenshotUrls.isNotEmpty
? ImageSlideshow(
width: double.infinity,
height: 400,
indicatorColor: SettingPrimaryColor,
children: [
...controller.activeTheme.value.screenshotUrls.map((e) => base.Image.network(e)),
],
)
: const SizedBox(),
],
),
);

View File

@ -22,9 +22,9 @@ class WoxSettingController extends GetxController {
late TabController activePluginTabController;
//themes
final themeList = <WoxSettingTheme>[];
final filteredThemeList = <WoxSettingTheme>[].obs;
final activeTheme = WoxSettingTheme.empty().obs;
final themeList = <WoxTheme>[];
final filteredThemeList = <WoxTheme>[].obs;
final activeTheme = WoxTheme.empty().obs;
final isStoreThemeList = true.obs;
//lang
@ -165,7 +165,7 @@ class WoxSettingController extends GetxController {
storeThemes.sort((a, b) => a.themeName.compareTo(b.themeName));
themeList.clear();
for (var theme in storeThemes) {
themeList.add(WoxSettingTheme.fromWoxSettingTheme(theme));
themeList.add(theme);
}
filteredThemeList.clear();
filteredThemeList.addAll(themeList);
@ -176,19 +176,19 @@ class WoxSettingController extends GetxController {
installThemes.sort((a, b) => a.themeName.compareTo(b.themeName));
themeList.clear();
for (var theme in installThemes) {
themeList.add(WoxSettingTheme.fromWoxSettingTheme(theme));
themeList.add(theme);
}
filteredThemeList.clear();
filteredThemeList.addAll(themeList);
}
Future<void> installTheme(WoxSettingTheme theme) async {
Future<void> installTheme(WoxTheme theme) async {
Logger.instance.info(const UuidV4().generate(), 'Installing theme: ${theme.themeId}');
await WoxApi.instance.installTheme(theme.themeId);
await refreshThemeList();
}
Future<void> uninstallTheme(WoxSettingTheme theme) async {
Future<void> uninstallTheme(WoxTheme theme) async {
Logger.instance.info(const UuidV4().generate(), 'Uninstalling theme: ${theme.themeId}');
await WoxApi.instance.uninstallTheme(theme.themeId);
await refreshThemeList();
@ -223,7 +223,7 @@ class WoxSettingController extends GetxController {
Future<void> switchToThemeList(bool isStoreTheme) async {
activePaneIndex.value = isStoreTheme ? 6 : 7;
isStoreThemeList.value = isStoreTheme;
activeTheme.value = WoxSettingTheme.empty();
activeTheme.value = WoxTheme.empty();
await refreshThemeList();
setFirstFilteredThemeActive();
}

View File

@ -21,8 +21,8 @@ class EntityFactory {
return WoxLang.fromJson(json) as T;
} else if (T.toString() == "List<PluginDetail>") {
return (json as List).map((e) => PluginDetail.fromJson(e)).toList() as T;
} else if (T.toString() == "List<WoxSettingTheme>") {
return (json as List).map((e) => WoxSettingTheme.fromJson(e)).toList() as T;
} else if (T.toString() == "List<WoxTheme>") {
return (json as List).map((e) => WoxTheme.fromJson(e)).toList() as T;
} else if (T.toString() == "List<AIModel>") {
return (json as List).map((e) => AIModel.fromJson(e)).toList() as T;
} else if (T.toString() == "List<WoxLang>") {

View File

@ -4,8 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/google/uuid"
"github.com/samber/lo"
"wox/ai"
"wox/plugin"
"wox/resource"
@ -13,6 +11,9 @@ import (
"wox/setting/definition"
"wox/share"
"wox/util"
"github.com/google/uuid"
"github.com/samber/lo"
)
var themeIcon = plugin.NewWoxImageBase64(`data:image/png;base64,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`)
@ -184,14 +185,14 @@ func (c *ThemePlugin) queryAI(ctx context.Context, query plugin.Query) []plugin.
conversations = append(conversations, ai.Conversation{
Role: ai.ConversationRoleUser,
Text: `
我正在编写Wox的主题该主题是由一段json组成例如` + exampleThemeJson + `
我正在编写Wox的主题, 该主题是由一段json组成, 例如` + exampleThemeJson + `
现在我想让你根据上面的格式生成一个新的主题主题的要求是` + query.Search + `
有一些注意点需要你遵守
1. 你的回答结果必须是JSON格式, {开头, }结尾.忽略解释注释等信息
1. 你的回答结果必须是JSON格式, {开头, }结尾. 忽略解释注释等信息
2. 主题名称你自己决定, 但是必须有意义
3. 背景跟字体需要有区分度不要让背景跟字体颜色太接近(这里包括正常未选中的结果与被高亮选中的结果)
3. 背景颜色跟字体颜色需要有区分度不要让这两者的颜色太接近(这里包括正常未选中的结果与被高亮选中的结果)
`,
})
@ -226,7 +227,6 @@ func (c *ThemePlugin) queryAI(ctx context.Context, query plugin.Query) []plugin.
theme.ThemeUrl = "https://www.github.com/wox-launcher/wox"
theme.Version = "1.0.0"
theme.IsSystem = false
theme.ScreenshotUrls = []string{}
plugin.GetPluginManager().GetUI().InstallTheme(ctx, theme)
})
}

View File

@ -6,7 +6,6 @@
"Version": "1.0.0",
"ThemeUrl": "https://www.github.com/wox-launcher/wox",
"IsSystemTheme": true,
"ScreenshotUrls": [],
"AppBackgroundColor": "rgba(0,0,0, 0.65)",
"AppPaddingLeft": 10,
"AppPaddingTop": 10,

View File

@ -6,7 +6,6 @@
"Version": "1.0.0",
"ThemeUrl": "https://www.github.com/wox-launcher/wox",
"IsSystemTheme": true,
"ScreenshotUrls": [],
"AppBackgroundColor": "rgba(236, 240, 240, 0.65)",
"AppPaddingLeft": 10,
"AppPaddingTop": 10,

View File

@ -6,7 +6,6 @@
"Version": "1.0.0",
"IsSystem": true,
"Description": "A sweet and colorful theme inspired by macaroons",
"ScreenshotUrls": [],
"AppBackgroundColor": "rgba(255, 235, 205, 0.8)",
"AppPaddingLeft": 10,
"AppPaddingTop": 10,

View File

@ -6,7 +6,6 @@
"Version": "1.0.0",
"IsSystem": true,
"Description": "A soothing theme inspired by Giorgio Morandi's still life paintings",
"ScreenshotUrls": [],
"AppBackgroundColor": "rgba(240, 235, 225, 0.95)",
"AppPaddingLeft": 10,
"AppPaddingTop": 10,

View File

@ -6,7 +6,6 @@
"Version": "1.0.0",
"IsSystem": true,
"Description": "A luxurious and elegant theme inspired by the Rococo era",
"ScreenshotUrls": [],
"AppBackgroundColor": "rgba(245, 245, 220, 0.8)",
"AppPaddingLeft": 10,
"AppPaddingTop": 10,

View File

@ -1,15 +1,14 @@
package share
type Theme struct {
ThemeId string
ThemeName string
ThemeAuthor string
ThemeUrl string
Version string
Description string
ScreenshotUrls []string
IsSystem bool
IsInstalled bool
ThemeId string
ThemeName string
ThemeAuthor string
ThemeUrl string
Version string
Description string
IsSystem bool
IsInstalled bool
AppBackgroundColor string
AppPaddingLeft int

View File

@ -1,14 +1,63 @@
package dto
type SettingTheme struct {
ThemeId string
ThemeName string
ThemeAuthor string
ThemeUrl string
Version string
Description string
IsInstalled bool
IsSystem bool
IsUpgradable bool
ScreenshotUrls []string
type ThemeDto struct {
ThemeId string
ThemeName string
ThemeAuthor string
ThemeUrl string
Version string
Description string
IsSystem bool
IsInstalled bool
IsUpgradable bool
AppBackgroundColor string
AppPaddingLeft int
AppPaddingTop int
AppPaddingRight int
AppPaddingBottom int
ResultContainerPaddingLeft int
ResultContainerPaddingTop int
ResultContainerPaddingRight int
ResultContainerPaddingBottom int
ResultItemBorderRadius int
ResultItemPaddingLeft int
ResultItemPaddingTop int
ResultItemPaddingRight int
ResultItemPaddingBottom int
ResultItemTitleColor string
ResultItemSubTitleColor string
ResultItemTailTextColor string
ResultItemBorderLeft string
ResultItemActiveBackgroundColor string
ResultItemActiveTitleColor string
ResultItemActiveSubTitleColor string
ResultItemActiveBorderLeft string
ResultItemActiveTailTextColor string
QueryBoxFontColor string
QueryBoxBackgroundColor string
QueryBoxBorderRadius int
QueryBoxCursorColor string
QueryBoxTextSelectionColor string
ActionContainerBackgroundColor string
ActionContainerHeaderFontColor string
ActionContainerPaddingLeft int
ActionContainerPaddingTop int
ActionContainerPaddingRight int
ActionContainerPaddingBottom int
ActionItemActiveBackgroundColor string
ActionItemActiveFontColor string
ActionItemFontColor string
ActionQueryBoxFontColor string
ActionQueryBoxBackgroundColor string
ActionQueryBoxBorderRadius int
PreviewFontColor string
PreviewSplitLineColor string
PreviewPropertyTitleColor string
PreviewPropertyContentColor string
PreviewTextSelectionColor string
ToolbarFontColor string
ToolbarBackgroundColor string
ToolbarPaddingLeft int
ToolbarPaddingRight int
}

View File

@ -303,10 +303,7 @@ func handlePluginEnable(w http.ResponseWriter, r *http.Request) {
plugins := plugin.GetPluginManager().GetPluginInstances()
findPlugin, exist := lo.Find(plugins, func(item *plugin.Instance) bool {
if item.Metadata.Id == pluginId {
return true
}
return false
return item.Metadata.Id == pluginId
})
if !exist {
writeErrorResponse(w, "can't find plugin")
@ -327,7 +324,7 @@ func handleThemeStore(w http.ResponseWriter, r *http.Request) {
ctx := util.NewTraceContext()
storeThemes := GetStoreManager().GetThemes()
var themes = make([]dto.SettingTheme, len(storeThemes))
var themes = make([]dto.ThemeDto, len(storeThemes))
copyErr := copier.Copy(&themes, &storeThemes)
if copyErr != nil {
writeErrorResponse(w, copyErr.Error())
@ -350,7 +347,7 @@ func handleThemeInstalled(w http.ResponseWriter, r *http.Request) {
ctx := util.NewTraceContext()
installedThemes := GetUIManager().GetAllThemes(ctx)
var themes = make([]dto.SettingTheme, len(installedThemes))
var themes = make([]dto.ThemeDto, len(installedThemes))
copyErr := copier.Copy(&themes, &installedThemes)
if copyErr != nil {
writeErrorResponse(w, copyErr.Error())

View File

@ -1,59 +1 @@
[
{
"ThemeId": "53c1d0a4-ffc8-4d90-91dc-b408fb0b9a05",
"ThemeName": "Dark Theme QLF",
"ThemeAuthor": "Wox launcher",
"ThemeUrl": "http://www.github.com/wox-launcher/wox",
"Version": "1.0.0",
"IsSystemTheme": true,
"AppBackgroundColor": "rgba(0,0,0, 0.65)",
"AppPaddingLeft": 10,
"AppPaddingTop": 10,
"AppPaddingRight": 10,
"AppPaddingBottom": 10,
"ResultContainerPaddingLeft": 0,
"ResultContainerPaddingTop": 10,
"ResultContainerPaddingRight": 0,
"ResultContainerPaddingBottom": 0,
"ResultItemBorderRadius": 0,
"ResultItemPaddingLeft": 0,
"ResultItemPaddingTop": 0,
"ResultItemPaddingRight": 0,
"ResultItemPaddingBottom": 0,
"ResultItemTitleColor": "#f0f0f0",
"ResultItemSubTitleColor": "#dbd9d9",
"ResultItemTailTextColor": "#dbd9d9",
"ResultItemBorderLeft": "0",
"ResultItemActiveBackgroundColor": "rgba(31, 118, 124, 0.8)",
"ResultItemActiveTitleColor": "#f0f0f0",
"ResultItemActiveSubTitleColor": "#dbd9d9",
"ResultItemActiveTailTextColor": "#dbd9d9",
"ResultItemActiveBorderLeft": "0",
"QueryBoxFontColor": "#e4e7e7",
"QueryBoxBackgroundColor": "rgba(24, 25, 26, 0.4)",
"QueryBoxBorderRadius": 8,
"QueryBoxCursorColor": "#e4e7e7",
"QueryBoxTextSelectionColor": "rgba(31, 118, 124, 0.8)",
"ActionContainerBackgroundColor": "#373839",
"ActionContainerHeaderFontColor": "#e4e7e7",
"ActionContainerPaddingLeft": 14,
"ActionContainerPaddingTop": 10,
"ActionContainerPaddingRight": 14,
"ActionContainerPaddingBottom": 10,
"ActionItemActiveBackgroundColor": "rgba(31, 118, 124, 0.8)",
"ActionItemActiveFontColor": "#f0f0f0",
"ActionItemFontColor": "#f0f0f0",
"ActionQueryBoxFontColor": "#e4e7e7",
"ActionQueryBoxBackgroundColor": "rgba(44, 48, 50, 0.98)",
"ActionQueryBoxBorderRadius": 8,
"PreviewFontColor": "#f0f0f0",
"PreviewSplitLineColor": "#3a474e",
"PreviewPropertyTitleColor": "#b0b3b5",
"PreviewPropertyContentColor": "#f0f0f0",
"PreviewTextSelectionColor": "rgba(31, 118, 124, 0.8)",
"Description": "Dark theme for QLF",
"ScreenshotUrls": [
"https://raw.githubusercontent.com/Wox-launcher/Wox/v2/store-theme-screenshot.png"
]
}
]
[]