tiddly-gittly / tw-echarts

An All-in-one Visualization Framework for TiddlyWiki5 based on ECharts
https://tiddly-gittly.github.io/tw-echarts/
MIT License
48 stars 8 forks source link

启动检测黑暗模式 #96

Open oeyoews opened 11 months ago

oeyoews commented 11 months ago

https://github.com/tiddly-gittly/tw-echarts/blob/d67ea4faa6d17b4e9d1a9ad0432a47cd1ed9d4be/src/echarts/widget/index.ts#L130

这里使用 $:/info/darkmode 判断是不是更合适

oeyoews commented 11 months ago

echarts 现在似乎不支持动态改变theme https://github.com/apache/echarts/issues/18198

下面是暂时借助tailwindcss实现的动态切换

<div class="dark:hidden">
<$echarts $tiddler="sevenday.js" $theme='light'/>
</div>

<div class="hidden dark:inline">
<$echarts $tiddler="sevenday.js" $theme='dark'/>
</div>
oeyoews commented 11 months ago

@Gk0Wk 可以直接在 onUpdate 函数里面像widget那样直接 重新刷新当前dom吗, 比如使用refreshSelf, 这样应该直接可以监听系统主题的变换,从而动态切换echart的主题了

ps: 感觉可以把监听事件直接写在echart的widget里面,这样每个addon就不用自己再判断一遍了