# PowerShell script to add onResize functionality to all student pages $studentPages = @( "favorite-exercises.uvue", "goal-settings.uvue", "preferences-analytics.uvue", "profile.uvue", "progress.uvue", "record-detail.uvue", "records.uvue", "reminder-settings.uvue", "simple-records.uvue" ) $basePath = "h:\blews\akmon\pages\sport\student" foreach ($page in $studentPages) { $filePath = Join-Path $basePath $page if (Test-Path $filePath) { Write-Host "Processing $page..." # Read the file content $content = Get-Content $filePath -Raw # Add imports if not present if ($content -notmatch "onResize") { $content = $content -replace "import \{ ref,([^}]+)\} from 'vue'", "import { ref,$1, onUnmounted } from 'vue'" $content = $content -replace "import \{ onLoad, OnLoadOptions \} from '@dcloudio/uni-app'", "import { onLoad, OnLoadOptions, onResize } from '@dcloudio/uni-app'" } # Add responsive state after userId declaration if ($content -notmatch "screenWidth") { $content = $content -replace "(const userId = ref\(''\))", "`$1`r`n`r`n`t// Responsive state - using onResize for dynamic updates`r`n`tconst screenWidth = ref(uni.getSystemInfoSync().windowWidth)`r`n`r`n`t// Computed properties for responsive design`r`n`tconst isLargeScreen = computed(() : boolean => {`r`n`t`treturn screenWidth.value >= 768`r`n`t})" } # Add onResize lifecycle if ($content -notmatch "onResize\(") { $content = $content -replace "(onMounted\(\(\) => \{[^}]+\}\))", "`$1`r`n`r`n`t// Handle resize events for responsive design`r`n`tonResize((size: any) => {`r`n`t`tscreenWidth.value = size.size.windowWidth`r`n`t})" } # Update onMounted to include screen width initialization if ($content -notmatch "screenWidth.value = uni.getSystemInfoSync") { $content = $content -replace "(onMounted\(\(\) => \{)", "`$1`r`n`t`t// Initialize screen width`r`n`t`tscreenWidth.value = uni.getSystemInfoSync().windowWidth" } # Write back to file Set-Content $filePath $content Write-Host "Updated $page" } } Write-Host "Batch update complete!"