theme.html 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <!-- 主题设置模板 -->
  2. <script type="text/html" template lay-done="layui.data.theme();">
  3. {{#
  4. var local = layui.data(layui.setter.tableName)
  5. ,theme = local.theme || {}
  6. ,themeColorIndex = parseInt((theme && theme.color) ? theme.color.index : 0) || 0;
  7. }}
  8. <div class="layui-card-header">
  9. 配色方案
  10. </div>
  11. <div class="layui-card-body layadmin-setTheme">
  12. <ul class="layadmin-setTheme-color">
  13. {{# layui.each(layui.setter.theme.color, function(index, item){ }}
  14. <li layadmin-event="setTheme" data-index="{{ index }}" data-alias="{{ item.alias }}"
  15. {{ index === themeColorIndex ? 'class="layui-this"' : '' }} title="{{ item.alias }}">
  16. <div class="layadmin-setTheme-header" style="background-color: {{ item.header }};"></div>
  17. <div class="layadmin-setTheme-side" style="background-color: {{ item.main }};">
  18. <div class="layadmin-setTheme-logo" style="background-color: {{ item.logo }};"></div>
  19. </div>
  20. </li>
  21. {{# }); }}
  22. </ul>
  23. </div>
  24. </script>
  25. <script>
  26. layui.data.theme = function(){
  27. layui.use('form', function(){
  28. var form = layui.form
  29. ,admin = layui.admin;
  30. //监听隐藏开关
  31. form.on('switch(system-theme-sideicon)', function(){
  32. admin.theme({
  33. hideSideIcon: this.checked
  34. })
  35. });
  36. });
  37. };
  38. </script>