windi.config.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { defineConfig } from 'vite-plugin-windicss'
  2. import plugin from 'windicss/plugin'
  3. function range(size, startAt = 1) {
  4. return Array.from(Array(size).keys()).map((i) => i + startAt)
  5. }
  6. export default defineConfig({
  7. extract: {
  8. include: ['src/**/*.{vue,html,jsx,tsx}'],
  9. exclude: ['node_modules', '.git']
  10. },
  11. darkMode: 'class',
  12. attributify: false,
  13. theme: {
  14. extend: {
  15. backgroundColor: {
  16. // 暗黑背景色
  17. 'v-dark': 'var(--dark-bg-color)'
  18. }
  19. }
  20. },
  21. plugins: [
  22. plugin(({ addComponents }) => {
  23. const obj = {}
  24. range(50).map((i) => {
  25. obj[`.border-top-${i}`] = {
  26. borderTopWidth: `${i}px`
  27. }
  28. obj[`.border-left-${i}`] = {
  29. borderLeftWidth: `${i}px`
  30. }
  31. obj[`.border-right-${i}`] = {
  32. borderRightWidth: `${i}px`
  33. }
  34. obj[`.border-bottom-${i}`] = {
  35. borderBottomWidth: `${i}px`
  36. }
  37. })
  38. addComponents({
  39. '.hover-tigger': {
  40. display: 'flex',
  41. height: '100%',
  42. padding: '1px 10px 0',
  43. cursor: 'pointer',
  44. alignItems: 'center',
  45. transition: 'background var(--transition-time-02)',
  46. '&:hover': {
  47. backgroundColor: 'var(--top-header-hover-color)'
  48. }
  49. },
  50. '.dark .hover-tigger': {
  51. '&:hover': {
  52. backgroundColor: 'var(--el-bg-color-overlay)'
  53. }
  54. },
  55. ...obj
  56. })
  57. })
  58. ]
  59. })