From 835bccf28881e1f9e0eae11aeebbe77e602c9289 Mon Sep 17 00:00:00 2001 From: Azalea <22280294+hykilpikonna@users.noreply.github.com> Date: Fri, 24 Oct 2025 15:23:20 +0800 Subject: [PATCH] [+] Sass migrate https://github.com/sass/migrator/issues/211 --- src/App.vue | 4 +- src/components/BlogIndex.vue | 4 +- src/components/BlogPost.vue | 8 ++-- src/components/MetaTable.vue | 4 +- src/components/Tag.vue | 6 +-- src/css/responsive.sass | 2 +- src/sass-migrate.py | 78 ++++++++++++++++++++++++++++++++++++ src/views/About.vue | 2 +- src/views/Blog.vue | 6 +-- src/views/Life.vue | 4 +- src/views/Others.vue | 8 ++-- src/views/others/Friends.vue | 6 +-- src/views/others/Menu.vue | 8 ++-- 13 files changed, 109 insertions(+), 31 deletions(-) create mode 100644 src/sass-migrate.py diff --git a/src/App.vue b/src/App.vue index 7193516..77bf12b 100644 --- a/src/App.vue +++ b/src/App.vue @@ -114,8 +114,8 @@ export default class App extends Vue + style_pattern = re.compile(r'(.*?)', re.DOTALL) + + # Extract all matching style blocks + matches = list(style_pattern.finditer(content)) + + if not matches: + print(f"No block + scoped = match.group(1) # The scoped attribute if present + sass_content = match.group(2) # The content inside the ' + + # Replace the original style block with the new one + updated_content = updated_content.replace(original_style_block, new_style_block) + + # Remove the temporary file + temp_file_path.unlink() + + # Write the updated content back to the original file + with open(file_path, 'w', encoding='utf-8') as file: + file.write(updated_content) + + print(f"Updated {file_path}") + +def process_svelte_files(directory): + """Recursively processes all .svelte files in the given directory.""" + svelte_files = Path(directory).rglob("*.vue") + + for svelte_file in svelte_files: + extract_and_migrate_sass(svelte_file) + +def main(): + """Main function to process all .svelte files in the current directory.""" + current_directory = Path(__file__).parent + process_svelte_files(current_directory) + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/src/views/About.vue b/src/views/About.vue index ce86183..23c2ed4 100644 --- a/src/views/About.vue +++ b/src/views/About.vue @@ -51,7 +51,7 @@ export default class About extends Vue diff --git a/src/views/others/Friends.vue b/src/views/others/Friends.vue index ecbda59..7aac589 100644 --- a/src/views/others/Friends.vue +++ b/src/views/others/Friends.vue @@ -76,8 +76,8 @@ export default class Friends extends Vue