index.js 965 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import store from "@/store";
  2. import { iconfontUrl, app } from "@/config/env";
  3. import { createLink } from "../utils";
  4. import { colorPrimary } from "@/assets/css/common.scss";
  5. if (app.theme) {
  6. const { url, color } = app.theme;
  7. if (url) {
  8. createLink(url, "theme-style");
  9. }
  10. document
  11. .getElementsByTagName("body")[0]
  12. .style.setProperty("--color-primary", color || colorPrimary);
  13. }
  14. if (iconfontUrl) {
  15. createLink(iconfontUrl);
  16. }
  17. const req = require.context("@/icons/svg/", false, /\.svg$/);
  18. req.keys().map(req);
  19. export function iconList() {
  20. return req
  21. .keys()
  22. .map(req)
  23. .map(e => e.default.id)
  24. .filter(e => e.includes("icon"))
  25. .sort();
  26. }
  27. export const resize = () => {
  28. if (document.body.clientWidth < 1000) {
  29. store.commit("COLLAPSE_MENU", true);
  30. store.commit("UPDATE_APP", {
  31. conf: {
  32. showAMenu: false
  33. }
  34. });
  35. }
  36. store.commit("SET_BROWSER");
  37. };
  38. window.onload = () => {
  39. window.addEventListener("resize", resize);
  40. resize();
  41. };