Skip to content

Commit

Permalink
feat: pyl7vp 支持暗色模式
Browse files Browse the repository at this point in the history
  • Loading branch information
lvisei committed Jan 23, 2024
1 parent 980a3f3 commit ed46563
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 30 deletions.
1 change: 1 addition & 0 deletions bindings/pyl7vp/pyl7vp/l7vp.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ def _get_html_str(
}

self.read_only = read_only
self.theme = "dark"

# get html string
return Engine(env=env).render(
Expand Down
49 changes: 19 additions & 30 deletions bindings/pyl7vp/pyl7vp/templates/l7vp.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,23 @@
if (MAP_TOKEN) LI_Config.spec.map.config.token = MAP_TOKEN
</script>

<!-- LI Theme -->
<script>
const LI_Theme = "{{ l7vp.theme }}"
const _theme = window.antd.theme;
const _darkTheme = {
algorithm: _theme.darkAlgorithm,
token: {
colorPrimary: "#8274FF",
colorTextBase: "rgba(255,255,255,0.85)",
colorBgBase: "#0f0f13",
colorInfo: "#8274FF",
borderRadius: 6,
},
}
const Antd_Theme = LI_Theme === "light" ? {} : _darkTheme
</script>

{% if l7vp.app_mode %}
<!-- Render LI App -->
<script>
Expand All @@ -84,21 +101,7 @@
});
};

const appTheme = {
algorithm: theme.darkAlgorithm,
token: {
colorPrimary: "#8274FF",
colorBgLayout: "#0F0F13",
colorBgContainer: "#282932",
colorBgElevated: "#3D3E4A",
colorText: "rgba(255,255,255,0.85)",
colorTextSecondary: "rgba(255,255,255,0.45)",
colorBorder: "#434343",
colorSplit: "#303030",
borderRadius: 4,
},
}
const App = React.createElement(ConfigProvider, { theme: {} }, React.createElement(LIAppElement, null));
const App = React.createElement(ConfigProvider, { theme: Antd_Theme }, React.createElement(LIAppElement, null));

ReactDOM.render(App, document.getElementById("{{ l7vp.instance_id }}"));
</script>
Expand All @@ -119,21 +122,7 @@
});
};

const appTheme = {
algorithm: theme.darkAlgorithm,
token: {
colorPrimary: "#8274FF",
colorBgLayout: "#0F0F13",
colorBgContainer: "#282932",
colorBgElevated: "#3D3E4A",
colorText: "rgba(255,255,255,0.85)",
colorTextSecondary: "rgba(255,255,255,0.45)",
colorBorder: "#434343",
colorSplit: "#303030",
borderRadius: 4,
},
}
const App = React.createElement(ConfigProvider, { theme: {} }, React.createElement(LIEditorElement, null));
const App = React.createElement(ConfigProvider, { theme: Antd_Theme }, React.createElement(LIEditorElement, null));

ReactDOM.render(App, document.getElementById("{{ l7vp.instance_id }}"));
</script>
Expand Down

0 comments on commit ed46563

Please sign in to comment.