main.ts 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. import { translateRouteTitle } from './utils/i18n';
  2. import { createApp } from 'vue';
  3. // global css
  4. import 'virtual:uno.css';
  5. import '@/assets/styles/index.scss';
  6. import 'element-plus/theme-chalk/dark/css-vars.css';
  7. // App、router、store
  8. import App from './App.vue';
  9. import store from './store';
  10. import router from './router';
  11. // 自定义指令
  12. import directive from './directive';
  13. // 注册插件
  14. import plugins from './plugins/index'; // plugins
  15. // 高亮组件
  16. // import 'highlight.js/styles/a11y-light.css';
  17. import 'highlight.js/styles/atom-one-dark.css';
  18. import 'highlight.js/lib/common';
  19. import HighLight from '@highlightjs/vue-plugin';
  20. // svg图标
  21. import 'virtual:svg-icons-register';
  22. import ElementIcons from '@/plugins/svgicon';
  23. // permission control
  24. import './permission';
  25. // 国际化
  26. import i18n from '@/lang/index';
  27. // vxeTable
  28. import VXETable from 'vxe-table';
  29. import 'vxe-table/lib/style.css';
  30. VXETable.setConfig({
  31. zIndex: 999999
  32. });
  33. // 修改 el-dialog 默认点击遮照为不关闭
  34. import { ElDialog } from 'element-plus';
  35. ElDialog.props.closeOnClickModal.default = false;
  36. // 全局配置Element Plus图标
  37. import { ElConfigProvider } from 'element-plus';
  38. import * as ElementPlusIconsVue from '@element-plus/icons-vue';
  39. const app = createApp(App);
  40. app.use(HighLight);
  41. app.use(ElementIcons);
  42. app.use(router);
  43. app.use(store);
  44. app.use(i18n);
  45. app.use(VXETable);
  46. app.use(plugins);
  47. // 自定义指令
  48. directive(app);
  49. // 修复Element Plus Dialog关闭按钮图标显示问题
  50. const style = document.createElement('style');
  51. style.textContent = `
  52. /* Element Plus Dialog 关闭按钮图标修复 */
  53. .el-dialog__headerbtn {
  54. position: absolute !important;
  55. top: 6px !important;
  56. right: 0 !important;
  57. padding: 0 !important;
  58. background: transparent !important;
  59. border: none !important;
  60. outline: none !important;
  61. cursor: pointer !important;
  62. font-size: 16px !important;
  63. color: #909399 !important;
  64. width: 54px !important;
  65. height: 54px !important;
  66. display: flex !important;
  67. align-items: center !important;
  68. justify-content: center !important;
  69. }
  70. .el-dialog__headerbtn:hover {
  71. color: #409eff !important;
  72. background: transparent !important;
  73. }
  74. /* 彻底去除所有状态下的背景色 */
  75. .el-dialog__headerbtn:active,
  76. .el-dialog__headerbtn:focus,
  77. .el-dialog__headerbtn:focus-visible {
  78. background: transparent !important;
  79. outline: none !important;
  80. box-shadow: none !important;
  81. }
  82. /* 去除所有子元素的背景 */
  83. .el-dialog__headerbtn *,
  84. .el-dialog__headerbtn:before,
  85. .el-dialog__headerbtn:after,
  86. .el-dialog__headerbtn .el-icon:before,
  87. .el-dialog__headerbtn .el-icon:after {
  88. background: transparent !important;
  89. background-color: transparent !important;
  90. }
  91. /* 去除hover状态下所有子元素的背景 */
  92. .el-dialog__headerbtn:hover *,
  93. .el-dialog__headerbtn:hover:before,
  94. .el-dialog__headerbtn:hover:after,
  95. .el-dialog__headerbtn:hover .el-icon:before,
  96. .el-dialog__headerbtn:hover .el-icon:after {
  97. background: transparent !important;
  98. background-color: transparent !important;
  99. }
  100. /* 隐藏Element Plus弹窗和消息框关闭按钮的颜色 */
  101. .el-message-box__headerbtn .el-message-box__close,
  102. .el-dialog__headerbtn .el-dialog__close {
  103. /* color: transparent !important; */
  104. }
  105. .el-message-box__headerbtn .el-message-box__close:hover,
  106. .el-dialog__headerbtn .el-dialog__close:hover {
  107. background-color: transparent !important;
  108. }
  109. /* 优先显示Element Plus原生图标 */
  110. .el-dialog__headerbtn .el-icon {
  111. width: 16px !important;
  112. height: 16px !important;
  113. font-size: 16px !important;
  114. position: relative !important;
  115. z-index: 2 !important;
  116. }
  117. .el-dialog__headerbtn .el-icon svg {
  118. display: block !important;
  119. width: 16px !important;
  120. height: 16px !important;
  121. }
  122. /* Element Plus 菜单图标修复 */
  123. .el-menu .el-icon {
  124. font-family: "element-plus-icons" !important;
  125. width: 16px !important;
  126. height: 16px !important;
  127. font-size: 16px !important;
  128. display: inline-block !important;
  129. vertical-align: middle !important;
  130. -webkit-font-smoothing: antialiased !important;
  131. -moz-osx-font-smoothing: grayscale !important;
  132. }
  133. /* 侧边栏菜单图标修复 */
  134. .el-menu--vertical .el-icon,
  135. .el-sub-menu .el-icon,
  136. .el-menu-item .el-icon {
  137. width: 16px !important;
  138. height: 16px !important;
  139. font-size: 16px !important;
  140. margin-right: 8px !important;
  141. display: inline-block !important;
  142. vertical-align: middle !important;
  143. }
  144. /* 如果图标仍然不显示,为场地管理菜单提供特定的备选图标 */
  145. .el-menu-item[data-menu-id="2210"]:before,
  146. .el-menu-item:has(.menu-text:contains("场地管理")):before {
  147. content: "🏢" !important;
  148. margin-right: 8px !important;
  149. font-size: 14px !important;
  150. display: inline-block !important;
  151. }
  152. /* 通用图标备选方案 */
  153. .el-icon:empty:before {
  154. content: "📋" !important;
  155. display: inline-block !important;
  156. font-size: 14px !important;
  157. }
  158. /* 强制图标显示 */
  159. .el-icon {
  160. speak: none !important;
  161. font-style: normal !important;
  162. font-weight: normal !important;
  163. font-variant: normal !important;
  164. text-transform: none !important;
  165. line-height: 1 !important;
  166. vertical-align: baseline !important;
  167. display: inline-block !important;
  168. }
  169. `;
  170. document.head.appendChild(style);
  171. app.mount('#app');
  172. // 确保图标样式在最后加载
  173. const iconStyle = document.createElement('style');
  174. iconStyle.textContent = `
  175. /* 全局图标样式修复 */
  176. .el-icon {
  177. display: inline-flex !important;
  178. justify-content: center !important;
  179. align-items: center !important;
  180. height: 1em !important;
  181. width: 1em !important;
  182. vertical-align: middle !important;
  183. line-height: 1 !important;
  184. }
  185. .el-icon svg {
  186. height: 1em !important;
  187. width: 1em !important;
  188. fill: currentColor !important;
  189. }
  190. /* 按钮中的图标 */
  191. .el-button .el-icon {
  192. margin-right: 4px !important;
  193. vertical-align: middle !important;
  194. }
  195. .el-button.is-circle .el-icon {
  196. margin-right: 0 !important;
  197. }
  198. /* 菜单中的图标 */
  199. .el-menu .el-icon,
  200. .el-sub-menu .el-icon,
  201. .el-menu-item .el-icon {
  202. margin-right: 8px !important;
  203. }
  204. `;
  205. document.head.appendChild(iconStyle);