You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
2.3 KiB

  1. # -*- coding: utf-8 -*-
  2. import os
  3. import re
  4. import io
  5. directory = r'd:\WorkSpace\boying\boying-pda\src\views\modules'
  6. css_to_add = u'''
  7. /* */
  8. .label-list .list-body::-webkit-scrollbar {
  9. width: 4px;
  10. }
  11. .label-list .list-body::-webkit-scrollbar-track {
  12. background: #f1f1f1;
  13. border-radius: 2px;
  14. }
  15. .label-list .list-body::-webkit-scrollbar-thumb {
  16. background: #17B3A3;
  17. border-radius: 2px;
  18. }
  19. .label-list .list-body::-webkit-scrollbar-thumb:hover {
  20. background: #0d8f7f;
  21. }
  22. '''
  23. for root, _, files in os.walk(directory):
  24. for file in files:
  25. if file.endswith('.vue'):
  26. path = os.path.join(root, file)
  27. with io.open(path, 'r', encoding='utf-8') as f:
  28. content = f.read()
  29. changed = False
  30. # 1. Update text-align for numeric columns
  31. num_cols = ['col-qty', 'col-required-qty', 'col-picked-qty', 'col-available-qty', 'col-inbound-qty', 'col-scans-qty', 'col-roll-qty']
  32. for col in num_cols:
  33. # Find .col-xyz { ... text-align: center; ... }
  34. # The pattern matches \.col-xyz \s* \{ [^}]*? text-align:\s*center;
  35. pattern_center = r'(\.' + col + r'\s*\{[^}]*?)text-align:\s*center;'
  36. if re.search(pattern_center, content):
  37. content = re.sub(pattern_center, r'\1text-align: right;\n padding-right: 12px;', content)
  38. changed = True
  39. # The pattern matches \.col-xyz \s* \{ [^}]*? text-align:\s*left;
  40. pattern_left = r'(\.' + col + r'\s*\{[^}]*?)text-align:\s*left;'
  41. if re.search(pattern_left, content):
  42. content = re.sub(pattern_left, r'\1text-align: right;\n padding-right: 12px;', content)
  43. changed = True
  44. # Also check .material-table inside material dialog
  45. # 2. Add scrollbar CSS if list-body is present and scrollbar is missing
  46. if 'class="list-body"' in content and '::-webkit-scrollbar' not in content:
  47. content = content.replace('</style>', css_to_add + '\n</style>')
  48. changed = True
  49. if changed:
  50. with io.open(path, 'w', encoding='utf-8') as f:
  51. f.write(content)
  52. print('Updated ' + file)