<# .SYNOPSIS A toolkit script that provides a menu for various operations. .DESCRIPTION This script displays a menu to the user with multiple options. 1. Run a specific command-line tool. 2. Display configuration information for a local service. 3. Exit the script. It's designed to be hosted on a server and executed remotely. .AUTHOR Gemini .DATE 2024-06-25 #> # ============================================================================== # 重要提示:文件编码 (IMPORTANT: FILE ENCODING) # # 此脚本包含中文字符。为了防止出现解析错误 (ParserError), # 请确保将此文件另存为 "UTF-8 with BOM" 编码格式。 # # This script contains Chinese characters. To prevent parsing errors, # please ensure you save this file with "UTF-8 with BOM" encoding. # # 在 VS Code 中:点击右下角的编码(例如 UTF-8),选择“通过编码保存”, # 然后选择“UTF-8 with BOM”。 # In VS Code: Click the encoding in the bottom-right (e.g., UTF-8), # select "Save with Encoding", and choose "UTF-8 with BOM". # ============================================================================== # Clear the host for a clean user interface Clear-Host # Start an infinite loop to display the menu until the user chooses to exit. while ($true) { # --- Display Menu --- # Set title color and display the main title Write-Host "=============================================" -ForegroundColor Cyan Write-Host " 欢迎使用,请使用WindowsPowerShell执行" -ForegroundColor White Write-Host "=============================================" -ForegroundColor Cyan Write-Host "" # Add a blank line for spacing # Display the menu options Write-Host " 1. 破解idea " -ForegroundColor Yellow Write-Host " 2. 本地使用Gemini " -ForegroundColor Yellow Write-Host " 3. 退出 " -ForegroundColor Yellow Write-Host "" # --- User Input --- # Prompt the user to enter their choice. $choice = Read-Host "请输入选项 (Enter your choice) [1, 2, or 3]" # --- Process Choice --- # Use a switch statement to handle the user's input. switch ($choice) { '1' { # If user selects '1', execute the crack command. Write-Host "[INFO] 正在执行破解命令 (Executing crack command)..." -ForegroundColor Green try { # The command `irm ckey.run | iex` is executed here. # irm is an alias for Invoke-RestMethod. # iex is an alias for Invoke-Expression. Invoke-Expression "irm ckey.run | iex" } catch { # Catch and display any errors that occur during execution. Write-Host "[ERROR] 执行命令时出错 (Error executing command): $($_.Exception.Message)" -ForegroundColor Red } Write-Host "[SUCCESS] 操作完成 (Operation complete)." -ForegroundColor Green # Pause and wait for user to press Enter to continue. Read-Host "按 Enter 键返回主菜单 (Press Enter to return to main menu)..." Clear-Host } '2' { # If user selects '2', display the Gemini configuration info. Clear-Host Write-Host "=============================================" -ForegroundColor Cyan Write-Host " Gemini 本地配置说明 (Gemini Local Configuration)" -ForegroundColor White Write-Host "=============================================" -ForegroundColor Cyan Write-Host "" Write-Host "请在cherrystudio中配置:" -ForegroundColor Green Write-Host "在模型服务中添加" -ForegroundColor White Write-Host "---------------------------------------------" -ForegroundColor Gray Write-Host "供应商名:aistudi-build" -ForegroundColor White Write-Host "提供商类型:gemini" -ForegroundColor White Write-Host "添加模型并复制:gemini-2.5-flash-lite-preview-06-17" -ForegroundColor White Write-Host "API地址:http://192.168.10.21:5345" -ForegroundColor White Write-Host "---------------------------------------------" -ForegroundColor Gray Write-Host "" # Pause and wait for user to press Enter to continue. Read-Host "按 Enter 键返回主菜单 (Press Enter to return to main menu)..." Clear-Host } '3' { # If user selects '3', exit the script. Write-Host "[INFO] 正在退出 (Exiting)..." -ForegroundColor Green # The 'return' command exits the script. return } default { # If the user enters an invalid option. Write-Host "[WARNING] 无效的选项,请重新输入 (Invalid option, please try again)." -ForegroundColor Red # Pause for 2 seconds before clearing the screen and re-displaying the menu. Start-Sleep -Seconds 2 Clear-Host } } }