Skip to content

Commit

Permalink
修复Http Mock 无法存储Bug
Browse files Browse the repository at this point in the history
  • Loading branch information
YangLang committed Oct 27, 2024
1 parent 57d032a commit 9481aa8
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [未完待续]

## 4.2.3 - 2024-10-27

- `Http Mock`: Bug修复

## 4.2.2 - 2024-10-14

- `Base`: 主题适配
Expand Down
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ repositories {

dependencies {
implementation("org.json:json:20240303")
implementation("com.google.code.gson:gson:2.11.0")
implementation("org.apache.xmlgraphics:batik-all:1.17") {
exclude("xml-apis", "xml-apis")
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pluginName=iFlutter
pluginVersion=4.2.2
pluginVersion=4.2.3
gradleVersion=17
pluginSinceBuild=223
platformType=IC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font style="1"/>
<font size="16" style="1"/>
<text value="Host:"/>
</properties>
</component>
Expand All @@ -34,6 +34,7 @@
<properties>
<editable value="false"/>
<enabled value="false"/>
<font size="13"/>
</properties>
</component>
</children>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.xtu.plugin.flutter.action.mock.ui.render;

import com.intellij.ui.JBColor;
import com.intellij.util.ui.JBUI;
import com.xtu.plugin.flutter.store.project.entity.HttpEntity;
import icons.PluginIcons;
Expand All @@ -14,25 +15,25 @@ public class HttpListRender extends JPanel implements ListCellRenderer<HttpEntit

public HttpListRender() {
setLayout(new BorderLayout());
setBorder(JBUI.Borders.empty(0, 5));
setBorder(JBUI.Borders.empty(0, 10));
add(new JLabel(PluginIcons.LINK), BorderLayout.WEST);

Box infoPanel = Box.createVerticalBox();
infoPanel.setBorder(JBUI.Borders.empty(5, 5));
infoPanel.add(this.pathLabel = createLabel(Font.BOLD, 13));
infoPanel.add(Box.createVerticalStrut(2));
infoPanel.add(this.descLabel = createLabel(Font.PLAIN, 12));
infoPanel.setBorder(JBUI.Borders.empty(5, 10, 5, 0));
this.pathLabel = new JLabel();
pathLabel.setForeground(JBColor.foreground());
pathLabel.setFont(new Font(null, Font.BOLD, 16));
infoPanel.add(pathLabel);
infoPanel.add(Box.createVerticalStrut(5));
this.descLabel = new JLabel();
descLabel.setForeground(JBColor.foreground().darker());
descLabel.setFont(new Font(null, Font.BOLD, 13));
infoPanel.add(descLabel);
add(infoPanel, BorderLayout.CENTER);

add(new JSeparator(), BorderLayout.SOUTH);
}

private JLabel createLabel(int style, int size) {
JLabel label = new JLabel();
label.setFont(new Font(null, style, JBUI.scaleFontSize(size)));
return label;
}

@Override
public Component getListCellRendererComponent(JList<? extends HttpEntity> list,
HttpEntity entity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.xtu.plugin.flutter.store.ide.entity.IdeStorageEntity;
import org.jetbrains.annotations.NotNull;

@State(name = "iFlutter", storages = {@Storage("idea.iFlutter.xml")})
@State(name = "iFlutter", storages = {@Storage("ide.iFlutter.xml")})
public class IdeStorageService implements PersistentStateComponent<IdeStorageEntity> {

private IdeStorageEntity storageEntity = new IdeStorageEntity();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.xtu.plugin.flutter.store.project.converter;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.intellij.util.xmlb.Converter;
import com.xtu.plugin.flutter.store.project.entity.HttpEntity;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class HttpEntityConverter extends Converter<List<HttpEntity>> {

private final Gson gson = new Gson();

@Nullable
@Override
public List<HttpEntity> fromString(@NotNull String s) {
return gson.fromJson(s, new TypeToken<>() {
});
}

@Nullable
@Override
public String toString(List<HttpEntity> list) {
return gson.toJson(list);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.xtu.plugin.flutter.store.project.entity;

import com.intellij.util.xmlb.annotations.OptionTag;
import com.intellij.util.xmlb.annotations.Transient;
import com.xtu.plugin.flutter.component.packages.update.PackageInfo;
import com.xtu.plugin.flutter.store.project.converter.HttpEntityConverter;

import java.util.*;

Expand All @@ -16,6 +18,7 @@ public class ProjectStorageEntity {
//是否打开资源变更检查
public boolean resCheckEnable = true;
//HTTP Mock 配置
@OptionTag(converter = HttpEntityConverter.class)
public List<HttpEntity> httpEntityList = new ArrayList<>();
//资源是否以目录形式注册
public boolean foldRegisterEnable = false;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/icons/link.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/main/resources/icons/link_dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9481aa8

Please sign in to comment.