├── .gitignore ├── Directory.Build.props ├── Gotrays.sln ├── LICENSE ├── README.md ├── builder.iss ├── favicon.ico └── src ├── Gotrays.Application ├── Gotrays.Application.csproj ├── GotraysApplicationModule.cs ├── Services │ ├── AppService.cs │ ├── ChannelService.cs │ ├── ChatMessageService.cs │ ├── ChatProductService.cs │ ├── ChatService.cs │ ├── PayService.cs │ ├── ServiceBase.cs │ ├── StorageService.cs │ └── UserService.cs └── _Imports.cs ├── Gotrays.Contract ├── Dtos │ ├── Activitys │ │ └── InvitationItem.cs │ ├── Admin │ │ ├── ChatRecordItem.cs │ │ ├── ChatRecordTop10Summary.cs │ │ ├── EditUserDto.cs │ │ ├── GlobalSummary.cs │ │ ├── PayRecordItem.cs │ │ ├── PayRecordPaginatedListPayload.cs │ │ ├── TrendChart.cs │ │ ├── UserItem.cs │ │ └── UserPaginatedListPayload.cs │ ├── Apps │ │ └── AppInfoDto.cs │ ├── Auth │ │ ├── CurrentUser.cs │ │ ├── JwtOptions.cs │ │ ├── LoginPayload.cs │ │ └── RegistryPayload.cs │ ├── Chats │ │ ├── AIRoleSettingDto.cs │ │ ├── ChannelDto.cs │ │ ├── ChatCompletionDto.cs │ │ ├── ChatItem.cs │ │ ├── ChatMessageDto.cs │ │ ├── CreateAIRoleSettingPayload.cs │ │ └── GetChatHistoryInput.cs │ ├── ErrorDto.cs │ ├── PaginatedListPayloadBase.cs │ ├── Pays │ │ ├── ProductListDto.cs │ │ └── StartPayPayloadDto.cs │ ├── Products │ │ ├── GetProductListDto.cs │ │ └── StartPayPayload.cs │ ├── Systems │ │ ├── AnnouncementDto.cs │ │ └── GiteeReleaseDto.cs │ └── Users │ │ ├── EditPayload.cs │ │ ├── GetDayDosageDto.cs │ │ ├── GetUserDto.cs │ │ └── RetrievePasswordload.cs ├── ErrorException.cs ├── Gotrays.Contract.csproj ├── GotraysContractModule.cs ├── Services │ ├── IAppService.cs │ ├── IChannelService.cs │ ├── IChatMessageService.cs │ ├── IChatProductService.cs │ ├── IChatRecordService.cs │ ├── IChatService.cs │ ├── IPayService.cs │ ├── IStorageService.cs │ ├── IUserService.cs │ └── IWindowService.cs └── Shared │ ├── ChatModel.cs │ ├── Constant.cs │ ├── PayState.cs │ ├── PayType.cs │ ├── ProductType.cs │ └── VerificationType.cs ├── Gotrays.Desktop ├── App.xaml ├── App.xaml.cs ├── AssemblyInfo.cs ├── Gotrays.Desktop.csproj ├── GotraysDesktopModule.cs ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── Services │ └── WindowService.cs ├── _Imports.razor ├── favicon.ico └── wwwroot │ ├── css │ └── app.css │ ├── favicon.ico │ └── index.html ├── Gotrays.Rcl ├── Components │ ├── About.razor │ ├── About.razor.cs │ ├── About.razor.css │ ├── AddChannel.razor │ ├── BuyAProduct.razor │ ├── BuyAProduct.razor.cs │ ├── ChatMessage.razor │ ├── ChatMessage.razor.cs │ ├── PurchaseHistory.razor │ ├── PurchaseHistory.razor.cs │ ├── UpdateChannel.razor │ ├── UpdateVersion.razor │ └── UpdateVersion.razor.cs ├── GlobalUsing.cs ├── Gotrays.Rcl.csproj ├── GotraysAuthenticationStateProvider.cs ├── GotraysRclModule.cs ├── Interops │ ├── GotraysInterop.cs │ └── JsEventBusInterop.cs ├── Main.razor ├── Pages │ ├── Authentication │ │ ├── Login.razor │ │ └── Login.razor.cs │ ├── Index.razor │ ├── Index.razor.cs │ ├── Shopping.razor │ ├── Shopping.razor.css │ └── System │ │ ├── Setting.razor │ │ ├── Setting.razor.cs │ │ └── Setting.razor.css ├── RclContext.cs ├── Shared │ ├── EmptyLayout.razor │ ├── MainLayout.razor │ └── MainLayout.razor.cs ├── _Imports.razor └── wwwroot │ ├── css │ └── gotrays.rcl.css │ ├── img │ └── chatgpt.png │ └── js │ ├── gotrays.js │ ├── markdow.js │ └── qrcode.js └── Gotrays.Shared ├── ChatMessageType.cs ├── Constant.cs └── Gotrays.Shared.csproj /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from `dotnet new gitignore` 5 | 6 | # dotenv files 7 | .env 8 | 9 | # User-specific files 10 | *.rsuser 11 | *.suo 12 | *.user 13 | *.userosscache 14 | *.sln.docstates 15 | 16 | # User-specific files (MonoDevelop/Xamarin Studio) 17 | *.userprefs 18 | 19 | # Mono auto generated files 20 | mono_crash.* 21 | 22 | # Build results 23 | [Dd]ebug/ 24 | [Dd]ebugPublic/ 25 | [Rr]elease/ 26 | [Rr]eleases/ 27 | x64/ 28 | x86/ 29 | [Ww][Ii][Nn]32/ 30 | [Aa][Rr][Mm]/ 31 | [Aa][Rr][Mm]64/ 32 | bld/ 33 | [Bb]in/ 34 | [Oo]bj/ 35 | [Ll]og/ 36 | [Ll]ogs/ 37 | 38 | # Visual Studio 2015/2017 cache/options directory 39 | .vs/ 40 | # Uncomment if you have tasks that create the project's static files in wwwroot 41 | #wwwroot/ 42 | 43 | # Visual Studio 2017 auto generated files 44 | Generated\ Files/ 45 | 46 | # MSTest test Results 47 | [Tt]est[Rr]esult*/ 48 | [Bb]uild[Ll]og.* 49 | 50 | # NUnit 51 | *.VisualState.xml 52 | TestResult.xml 53 | nunit-*.xml 54 | 55 | # Build Results of an ATL Project 56 | [Dd]ebugPS/ 57 | [Rr]eleasePS/ 58 | dlldata.c 59 | 60 | # Benchmark Results 61 | BenchmarkDotNet.Artifacts/ 62 | 63 | # .NET 64 | project.lock.json 65 | project.fragment.lock.json 66 | artifacts/ 67 | 68 | # Tye 69 | .tye/ 70 | 71 | # ASP.NET Scaffolding 72 | ScaffoldingReadMe.txt 73 | 74 | # StyleCop 75 | StyleCopReport.xml 76 | 77 | # Files built by Visual Studio 78 | *_i.c 79 | *_p.c 80 | *_h.h 81 | *.ilk 82 | *.meta 83 | *.obj 84 | *.iobj 85 | *.pch 86 | *.pdb 87 | *.ipdb 88 | *.pgc 89 | *.pgd 90 | *.rsp 91 | *.sbr 92 | *.tlb 93 | *.tli 94 | *.tlh 95 | *.tmp 96 | *.tmp_proj 97 | *_wpftmp.csproj 98 | *.log 99 | *.tlog 100 | *.vspscc 101 | *.vssscc 102 | .builds 103 | *.pidb 104 | *.svclog 105 | *.scc 106 | 107 | # Chutzpah Test files 108 | _Chutzpah* 109 | 110 | # Visual C++ cache files 111 | ipch/ 112 | *.aps 113 | *.ncb 114 | *.opendb 115 | *.opensdf 116 | *.sdf 117 | *.cachefile 118 | *.VC.db 119 | *.VC.VC.opendb 120 | 121 | # Visual Studio profiler 122 | *.psess 123 | *.vsp 124 | *.vspx 125 | *.sap 126 | 127 | # Visual Studio Trace Files 128 | *.e2e 129 | 130 | # TFS 2012 Local Workspace 131 | $tf/ 132 | 133 | # Guidance Automation Toolkit 134 | *.gpState 135 | 136 | # ReSharper is a .NET coding add-in 137 | _ReSharper*/ 138 | *.[Rr]e[Ss]harper 139 | *.DotSettings.user 140 | 141 | # TeamCity is a build add-in 142 | _TeamCity* 143 | 144 | # DotCover is a Code Coverage Tool 145 | *.dotCover 146 | 147 | # AxoCover is a Code Coverage Tool 148 | .axoCover/* 149 | !.axoCover/settings.json 150 | 151 | # Coverlet is a free, cross platform Code Coverage Tool 152 | coverage*.json 153 | coverage*.xml 154 | coverage*.info 155 | 156 | # Visual Studio code coverage results 157 | *.coverage 158 | *.coveragexml 159 | 160 | # NCrunch 161 | _NCrunch_* 162 | .*crunch*.local.xml 163 | nCrunchTemp_* 164 | 165 | # MightyMoose 166 | *.mm.* 167 | AutoTest.Net/ 168 | 169 | # Web workbench (sass) 170 | .sass-cache/ 171 | 172 | # Installshield output folder 173 | [Ee]xpress/ 174 | 175 | # DocProject is a documentation generator add-in 176 | DocProject/buildhelp/ 177 | DocProject/Help/*.HxT 178 | DocProject/Help/*.HxC 179 | DocProject/Help/*.hhc 180 | DocProject/Help/*.hhk 181 | DocProject/Help/*.hhp 182 | DocProject/Help/Html2 183 | DocProject/Help/html 184 | 185 | # Click-Once directory 186 | publish/ 187 | 188 | # Publish Web Output 189 | *.[Pp]ublish.xml 190 | *.azurePubxml 191 | # Note: Comment the next line if you want to checkin your web deploy settings, 192 | # but database connection strings (with potential passwords) will be unencrypted 193 | *.pubxml 194 | *.publishproj 195 | 196 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 197 | # checkin your Azure Web App publish settings, but sensitive information contained 198 | # in these scripts will be unencrypted 199 | PublishScripts/ 200 | 201 | # NuGet Packages 202 | *.nupkg 203 | # NuGet Symbol Packages 204 | *.snupkg 205 | # The packages folder can be ignored because of Package Restore 206 | **/[Pp]ackages/* 207 | # except build/, which is used as an MSBuild target. 208 | !**/[Pp]ackages/build/ 209 | # Uncomment if necessary however generally it will be regenerated when needed 210 | #!**/[Pp]ackages/repositories.config 211 | # NuGet v3's project.json files produces more ignorable files 212 | *.nuget.props 213 | *.nuget.targets 214 | 215 | # Microsoft Azure Build Output 216 | csx/ 217 | *.build.csdef 218 | 219 | # Microsoft Azure Emulator 220 | ecf/ 221 | rcf/ 222 | 223 | # Windows Store app package directories and files 224 | AppPackages/ 225 | BundleArtifacts/ 226 | Package.StoreAssociation.xml 227 | _pkginfo.txt 228 | *.appx 229 | *.appxbundle 230 | *.appxupload 231 | 232 | # Visual Studio cache files 233 | # files ending in .cache can be ignored 234 | *.[Cc]ache 235 | # but keep track of directories ending in .cache 236 | !?*.[Cc]ache/ 237 | 238 | # Others 239 | ClientBin/ 240 | ~$* 241 | *~ 242 | *.dbmdl 243 | *.dbproj.schemaview 244 | *.jfm 245 | *.pfx 246 | *.publishsettings 247 | orleans.codegen.cs 248 | 249 | # Including strong name files can present a security risk 250 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 251 | #*.snk 252 | 253 | # Since there are multiple workflows, uncomment next line to ignore bower_components 254 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 255 | #bower_components/ 256 | 257 | # RIA/Silverlight projects 258 | Generated_Code/ 259 | 260 | # Backup & report files from converting an old project file 261 | # to a newer Visual Studio version. Backup files are not needed, 262 | # because we have git ;-) 263 | _UpgradeReport_Files/ 264 | Backup*/ 265 | UpgradeLog*.XML 266 | UpgradeLog*.htm 267 | ServiceFabricBackup/ 268 | *.rptproj.bak 269 | 270 | # SQL Server files 271 | *.mdf 272 | *.ldf 273 | *.ndf 274 | 275 | # Business Intelligence projects 276 | *.rdl.data 277 | *.bim.layout 278 | *.bim_*.settings 279 | *.rptproj.rsuser 280 | *- [Bb]ackup.rdl 281 | *- [Bb]ackup ([0-9]).rdl 282 | *- [Bb]ackup ([0-9][0-9]).rdl 283 | 284 | # Microsoft Fakes 285 | FakesAssemblies/ 286 | 287 | # GhostDoc plugin setting file 288 | *.GhostDoc.xml 289 | 290 | # Node.js Tools for Visual Studio 291 | .ntvs_analysis.dat 292 | node_modules/ 293 | 294 | # Visual Studio 6 build log 295 | *.plg 296 | 297 | # Visual Studio 6 workspace options file 298 | *.opt 299 | 300 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 301 | *.vbw 302 | 303 | # Visual Studio 6 auto-generated project file (contains which files were open etc.) 304 | *.vbp 305 | 306 | # Visual Studio 6 workspace and project file (working project files containing files to include in project) 307 | *.dsw 308 | *.dsp 309 | 310 | # Visual Studio 6 technical files 311 | *.ncb 312 | *.aps 313 | 314 | # Visual Studio LightSwitch build output 315 | **/*.HTMLClient/GeneratedArtifacts 316 | **/*.DesktopClient/GeneratedArtifacts 317 | **/*.DesktopClient/ModelManifest.xml 318 | **/*.Server/GeneratedArtifacts 319 | **/*.Server/ModelManifest.xml 320 | _Pvt_Extensions 321 | 322 | # Paket dependency manager 323 | .paket/paket.exe 324 | paket-files/ 325 | 326 | # FAKE - F# Make 327 | .fake/ 328 | 329 | # CodeRush personal settings 330 | .cr/personal 331 | 332 | # Python Tools for Visual Studio (PTVS) 333 | __pycache__/ 334 | *.pyc 335 | 336 | # Cake - Uncomment if you are using it 337 | # tools/** 338 | # !tools/packages.config 339 | 340 | # Tabs Studio 341 | *.tss 342 | 343 | # Telerik's JustMock configuration file 344 | *.jmconfig 345 | 346 | # BizTalk build output 347 | *.btp.cs 348 | *.btm.cs 349 | *.odx.cs 350 | *.xsd.cs 351 | 352 | # OpenCover UI analysis results 353 | OpenCover/ 354 | 355 | # Azure Stream Analytics local run output 356 | ASALocalRun/ 357 | 358 | # MSBuild Binary and Structured Log 359 | *.binlog 360 | 361 | # NVidia Nsight GPU debugger configuration file 362 | *.nvuser 363 | 364 | # MFractors (Xamarin productivity tool) working folder 365 | .mfractor/ 366 | 367 | # Local History for Visual Studio 368 | .localhistory/ 369 | 370 | # Visual Studio History (VSHistory) files 371 | .vshistory/ 372 | 373 | # BeatPulse healthcheck temp database 374 | healthchecksdb 375 | 376 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 377 | MigrationBackup/ 378 | 379 | # Ionide (cross platform F# VS Code tools) working folder 380 | .ionide/ 381 | 382 | # Fody - auto-generated XML schema 383 | FodyWeavers.xsd 384 | 385 | # VS Code files for those working on multiple tools 386 | .vscode/* 387 | !.vscode/settings.json 388 | !.vscode/tasks.json 389 | !.vscode/launch.json 390 | !.vscode/extensions.json 391 | *.code-workspace 392 | 393 | # Local History for Visual Studio Code 394 | .history/ 395 | 396 | # Windows Installer files from build outputs 397 | *.cab 398 | *.msi 399 | *.msix 400 | *.msm 401 | *.msp 402 | 403 | # JetBrains Rider 404 | *.sln.iml 405 | .idea 406 | 407 | ## 408 | ## Visual studio for Mac 409 | ## 410 | 411 | 412 | # globs 413 | Makefile.in 414 | *.userprefs 415 | *.usertasks 416 | config.make 417 | config.status 418 | aclocal.m4 419 | install-sh 420 | autom4te.cache/ 421 | *.tar.gz 422 | tarballs/ 423 | test-results/ 424 | 425 | # Mac bundle stuff 426 | *.dmg 427 | *.app 428 | 429 | # content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore 430 | # General 431 | .DS_Store 432 | .AppleDouble 433 | .LSOverride 434 | 435 | # Icon must end with two \r 436 | Icon 437 | 438 | 439 | # Thumbnails 440 | ._* 441 | 442 | # Files that might appear in the root of a volume 443 | .DocumentRevisions-V100 444 | .fseventsd 445 | .Spotlight-V100 446 | .TemporaryItems 447 | .Trashes 448 | .VolumeIcon.icns 449 | .com.apple.timemachine.donotpresent 450 | 451 | # Directories potentially created on remote AFP share 452 | .AppleDB 453 | .AppleDesktop 454 | Network Trash Folder 455 | Temporary Items 456 | .apdisk 457 | 458 | # content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore 459 | # Windows thumbnail cache files 460 | Thumbs.db 461 | ehthumbs.db 462 | ehthumbs_vista.db 463 | 464 | # Dump file 465 | *.stackdump 466 | 467 | # Folder config file 468 | [Dd]esktop.ini 469 | 470 | # Recycle Bin used on file shares 471 | $RECYCLE.BIN/ 472 | 473 | # Windows Installer files 474 | *.cab 475 | *.msi 476 | *.msix 477 | *.msm 478 | *.msp 479 | 480 | # Windows shortcuts 481 | *.lnk 482 | 483 | # Vim temporary swap files 484 | *.swp 485 | -------------------------------------------------------------------------------- /Directory.Build.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 1.0.0.4 5 | Gotrays 6 | Gotrays 7 | Gotrays 8 | All rights reserved by Gotrays 9 | 10 | 11 | 12 | 1.1.1 13 | 14 | -------------------------------------------------------------------------------- /Gotrays.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.8.34004.107 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{18B95ED8-4FC9-4AF8-95E1-BA61E513442F}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gotrays.Rcl", "src\Gotrays.Rcl\Gotrays.Rcl.csproj", "{25B9E9C8-E844-4883-8E0F-D5E96C7F1756}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gotrays.Desktop", "src\Gotrays.Desktop\Gotrays.Desktop.csproj", "{0911A72B-01FD-41A6-85AA-763CEA8729C2}" 11 | EndProject 12 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "solution items", "solution items", "{F92D9977-7925-47B6-A1CF-A05F7D10DC94}" 13 | ProjectSection(SolutionItems) = preProject 14 | .gitignore = .gitignore 15 | Directory.Build.props = Directory.Build.props 16 | README.md = README.md 17 | EndProjectSection 18 | EndProject 19 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gotrays.Contract", "src\Gotrays.Contract\Gotrays.Contract.csproj", "{C324DD4A-6D76-47CD-AC19-521D8B035D61}" 20 | EndProject 21 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gotrays.Application", "src\Gotrays.Application\Gotrays.Application.csproj", "{5615B99C-936E-460B-A41D-AE86ADDB7B68}" 22 | EndProject 23 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gotrays.Shared", "src\Gotrays.Shared\Gotrays.Shared.csproj", "{A22BB595-D38E-461E-83A2-5FA619EDEB3D}" 24 | EndProject 25 | Global 26 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 27 | Debug|Any CPU = Debug|Any CPU 28 | Release|Any CPU = Release|Any CPU 29 | EndGlobalSection 30 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 31 | {25B9E9C8-E844-4883-8E0F-D5E96C7F1756}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 32 | {25B9E9C8-E844-4883-8E0F-D5E96C7F1756}.Debug|Any CPU.Build.0 = Debug|Any CPU 33 | {25B9E9C8-E844-4883-8E0F-D5E96C7F1756}.Release|Any CPU.ActiveCfg = Release|Any CPU 34 | {25B9E9C8-E844-4883-8E0F-D5E96C7F1756}.Release|Any CPU.Build.0 = Release|Any CPU 35 | {0911A72B-01FD-41A6-85AA-763CEA8729C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 36 | {0911A72B-01FD-41A6-85AA-763CEA8729C2}.Debug|Any CPU.Build.0 = Debug|Any CPU 37 | {0911A72B-01FD-41A6-85AA-763CEA8729C2}.Release|Any CPU.ActiveCfg = Release|Any CPU 38 | {0911A72B-01FD-41A6-85AA-763CEA8729C2}.Release|Any CPU.Build.0 = Release|Any CPU 39 | {C324DD4A-6D76-47CD-AC19-521D8B035D61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 40 | {C324DD4A-6D76-47CD-AC19-521D8B035D61}.Debug|Any CPU.Build.0 = Debug|Any CPU 41 | {C324DD4A-6D76-47CD-AC19-521D8B035D61}.Release|Any CPU.ActiveCfg = Release|Any CPU 42 | {C324DD4A-6D76-47CD-AC19-521D8B035D61}.Release|Any CPU.Build.0 = Release|Any CPU 43 | {5615B99C-936E-460B-A41D-AE86ADDB7B68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 44 | {5615B99C-936E-460B-A41D-AE86ADDB7B68}.Debug|Any CPU.Build.0 = Debug|Any CPU 45 | {5615B99C-936E-460B-A41D-AE86ADDB7B68}.Release|Any CPU.ActiveCfg = Release|Any CPU 46 | {5615B99C-936E-460B-A41D-AE86ADDB7B68}.Release|Any CPU.Build.0 = Release|Any CPU 47 | {A22BB595-D38E-461E-83A2-5FA619EDEB3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 48 | {A22BB595-D38E-461E-83A2-5FA619EDEB3D}.Debug|Any CPU.Build.0 = Debug|Any CPU 49 | {A22BB595-D38E-461E-83A2-5FA619EDEB3D}.Release|Any CPU.ActiveCfg = Release|Any CPU 50 | {A22BB595-D38E-461E-83A2-5FA619EDEB3D}.Release|Any CPU.Build.0 = Release|Any CPU 51 | EndGlobalSection 52 | GlobalSection(SolutionProperties) = preSolution 53 | HideSolutionNode = FALSE 54 | EndGlobalSection 55 | GlobalSection(NestedProjects) = preSolution 56 | {25B9E9C8-E844-4883-8E0F-D5E96C7F1756} = {18B95ED8-4FC9-4AF8-95E1-BA61E513442F} 57 | {0911A72B-01FD-41A6-85AA-763CEA8729C2} = {18B95ED8-4FC9-4AF8-95E1-BA61E513442F} 58 | {C324DD4A-6D76-47CD-AC19-521D8B035D61} = {18B95ED8-4FC9-4AF8-95E1-BA61E513442F} 59 | {5615B99C-936E-460B-A41D-AE86ADDB7B68} = {18B95ED8-4FC9-4AF8-95E1-BA61E513442F} 60 | {A22BB595-D38E-461E-83A2-5FA619EDEB3D} = {18B95ED8-4FC9-4AF8-95E1-BA61E513442F} 61 | EndGlobalSection 62 | GlobalSection(ExtensibilityGlobals) = postSolution 63 | SolutionGuid = {4BDF19AE-B795-4A19-AD74-C7DA592BA6AF} 64 | EndGlobalSection 65 | EndGlobal 66 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Gotrays 客户端 2 | 3 | ## 介绍 4 | Gotrays Suspension, open666的客户端智能助手 5 | 基于Blazor实现基本UI功能,使用Masa Blazor作为UI组件库,并且使用WPF做为Window执行平台 6 | 7 | 8 | -------------------------------------------------------------------------------- /builder.iss: -------------------------------------------------------------------------------- 1 | ; Script generated by the Inno Setup Script Wizard. 2 | ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! 3 | 4 | #define MyAppName "Gotrays.Desktop" 5 | #define MyAppVersion "1.0.0.0" 6 | #define MyAppPublisher "Gotrays" 7 | #define MyAppURL "https://open666.cn/" 8 | #define MyAppExeName "Gotrays.Desktop.exe" 9 | #define MyAppAssocName MyAppName + " File" 10 | #define MyAppAssocExt ".exe" 11 | #define MyAppAssocKey StringChange(MyAppAssocName, " ", "") + MyAppAssocExt 12 | 13 | [Setup] 14 | ; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications. 15 | ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) 16 | AppId={{4D6B439C-3230-4CDA-9043-2FEB6991FD11} 17 | AppName={#MyAppName} 18 | AppVersion={#MyAppVersion} 19 | ;AppVerName={#MyAppName} {#MyAppVersion} 20 | AppPublisher={#MyAppPublisher} 21 | AppPublisherURL={#MyAppURL} 22 | AppSupportURL={#MyAppURL} 23 | AppUpdatesURL={#MyAppURL} 24 | DefaultDirName={autopf}\{#MyAppName} 25 | ChangesAssociations=yes 26 | DisableProgramGroupPage=yes 27 | ; Remove the following line to run in administrative install mode (install for all users.) 28 | PrivilegesRequired=lowest 29 | PrivilegesRequiredOverridesAllowed=commandline 30 | OutputDir=C:\Users\23957\Desktop\Gotrays.Desktop 31 | OutputBaseFilename=Gotrays.Desktop 32 | SetupIconFile=D:\token\gotrays-suspension\favicon.ico 33 | Compression=lzma 34 | SolidCompression=yes 35 | WizardStyle=modern 36 | 37 | [Languages] 38 | Name: "chinesesimplified"; MessagesFile: "compiler:Languages\ChineseSimplified.isl" 39 | 40 | [Tasks] 41 | Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked 42 | 43 | [Files] 44 | Source: "D:\token\gotrays-suspension\src\Gotrays.Desktop\bin\Release\net7.0-windows\publish\win-x64\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion 45 | Source: "D:\token\gotrays-suspension\src\Gotrays.Desktop\bin\Release\net7.0-windows\publish\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs 46 | ; NOTE: Don't use "Flags: ignoreversion" on any shared system files 47 | 48 | [Registry] 49 | Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue 50 | Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}"; ValueType: string; ValueName: ""; ValueData: "{#MyAppAssocName}"; Flags: uninsdeletekey 51 | Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName},0" 52 | Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1""" 53 | Root: HKA; Subkey: "Software\Classes\Applications\{#MyAppExeName}\SupportedTypes"; ValueType: string; ValueName: ".myp"; ValueData: "" 54 | 55 | [Icons] 56 | Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" 57 | Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon 58 | 59 | [Run] 60 | Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent 61 | 62 | -------------------------------------------------------------------------------- /favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/239573049/Suspension/28d830e96ffe519d77da7762c93aed11ab55d91c/favicon.ico -------------------------------------------------------------------------------- /src/Gotrays.Application/Gotrays.Application.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/Gotrays.Application/GotraysApplicationModule.cs: -------------------------------------------------------------------------------- 1 | using CoreFlex.Module; 2 | using Gotrays.Application.Services; 3 | using Microsoft.Extensions.DependencyInjection; 4 | 5 | namespace Gotrays.Application; 6 | 7 | public class GotraysApplicationModule : CoreFlexModule 8 | { 9 | public override void ConfigureServices(CoreFlexServiceContext context) 10 | { 11 | 12 | context.Services.AddSingleton(_ => new FreeSql.FreeSqlBuilder() 13 | .UseConnectionString(FreeSql.DataType.Sqlite, "Data Source=Gotrays.db;") 14 | .UseAutoSyncStructure(true) //自动同步实体结构到数据库 15 | .Build()); 16 | 17 | context.Services.AddHttpClient(Constant.HttpClientOptions.OpenService, (services, options) => 18 | { 19 | options.BaseAddress = new Uri("https://open666.cn/api/v1/"); 20 | var storage = services.GetService(); 21 | var token = storage.Get(Constant.HttpClientOptions.Token); 22 | 23 | if (!token.IsNullOrWhiteSpace()) 24 | { 25 | options.DefaultRequestHeaders.Remove("Authorization"); 26 | options.DefaultRequestHeaders.Add("Authorization", "Bearer " + token); 27 | } 28 | }); 29 | 30 | context.Services.AddScoped(); 31 | context.Services.AddScoped(); 32 | context.Services.AddScoped(); 33 | context.Services.AddScoped(); 34 | context.Services.AddScoped(); 35 | context.Services.AddScoped(); 36 | context.Services.AddScoped(); 37 | context.Services.AddScoped(); 38 | } 39 | } -------------------------------------------------------------------------------- /src/Gotrays.Application/Services/AppService.cs: -------------------------------------------------------------------------------- 1 | using Gotrays.Contract.Dtos.Systems; 2 | 3 | namespace Gotrays.Application.Services; 4 | 5 | public class AppService : IAppService 6 | { 7 | private readonly IHttpClientFactory _httpClientFactory; 8 | 9 | public AppService(IHttpClientFactory httpClientFactory) 10 | { 11 | _httpClientFactory = httpClientFactory; 12 | } 13 | 14 | public async Task GetApp() 15 | { 16 | var client = _httpClientFactory.CreateClient(nameof(AppService)); 17 | 18 | var result = 19 | await client.GetFromJsonAsync( 20 | "https://gitee.com/api/v5/repos/gotrays/gotrays-suspension/releases/latest"); 21 | 22 | return result; 23 | } 24 | } -------------------------------------------------------------------------------- /src/Gotrays.Application/Services/ChannelService.cs: -------------------------------------------------------------------------------- 1 | namespace Gotrays.Application.Services; 2 | 3 | public class ChannelService : IChannelService 4 | { 5 | private readonly IFreeSql _freeSql; 6 | 7 | public ChannelService(IFreeSql freeSql) 8 | { 9 | _freeSql = freeSql; 10 | } 11 | 12 | public async Task> GetListAsync(string? search) 13 | { 14 | return await _freeSql.Select() 15 | .WhereIf(!search.IsNullOrWhiteSpace(), x => x.Description.Contains(search) || x.Title.Contains(search)) 16 | .OrderBy(x => x.Sort).ToListAsync(); 17 | } 18 | 19 | public async Task UpdateAsync(ChannelDto channel) 20 | { 21 | await _freeSql.Update() 22 | .Where(x => x.Id == channel.Id) 23 | .Set(x => x.Sort, channel.Sort) 24 | .Set(x => x.Description, channel.Description) 25 | .Set(x => x.Title, channel.Title) 26 | .Set(x => x.Icon, channel.Icon) 27 | .Set(x => x.Model, channel.Model) 28 | .Set(x => x.Role, channel.Role) 29 | .Set(x => x.MaxHistory, channel.MaxHistory) 30 | .ExecuteAffrowsAsync(); 31 | } 32 | 33 | public async Task DeleteAsync(Guid id) 34 | { 35 | await _freeSql.Delete() 36 | .Where(x => x.Id == id) 37 | .ExecuteAffrowsAsync(); 38 | } 39 | 40 | public async Task AddAsync(ChannelDto channel) 41 | { 42 | await _freeSql.Insert(channel) 43 | .ExecuteAffrowsAsync(); 44 | } 45 | } -------------------------------------------------------------------------------- /src/Gotrays.Application/Services/ChatMessageService.cs: -------------------------------------------------------------------------------- 1 | namespace Gotrays.Application.Services; 2 | 3 | public class ChatMessageService : IChatMessageService 4 | { 5 | private readonly IFreeSql _freeSql; 6 | 7 | public ChatMessageService(IFreeSql freeSql) 8 | { 9 | _freeSql = freeSql; 10 | } 11 | 12 | public async Task> GetListAsync(Guid channelId, int page = 1, int pageSize = 5) 13 | { 14 | var result = await _freeSql.Select() 15 | .Where(x => x.ChannelId == channelId) 16 | .OrderByDescending(x=>x.CreatedTime) 17 | .Page(page, pageSize) 18 | .ToListAsync(); 19 | 20 | return result.OrderBy(x=>x.CreatedTime).ToList(); 21 | } 22 | 23 | public async Task UpdateAsync(ChatMessageDto messageDto) 24 | { 25 | await _freeSql.Update() 26 | .Where(x => x.Id == messageDto.Id) 27 | .Set(x => x.Message, messageDto.Message) 28 | .Set(x => x.Type, messageDto.Type) 29 | .ExecuteAffrowsAsync(); 30 | } 31 | 32 | public async Task DeleteAsync(Guid id) 33 | { 34 | await _freeSql.Delete() 35 | .Where(x => x.Id == id) 36 | .ExecuteAffrowsAsync(); 37 | } 38 | 39 | public async Task CreateAsync(ChatMessageDto dto) 40 | { 41 | await _freeSql.Insert(dto) 42 | .ExecuteAffrowsAsync(); 43 | } 44 | 45 | public async Task DeleteChannelAsync(Guid channelId) 46 | { 47 | await _freeSql.Delete() 48 | .Where(x => x.ChannelId == channelId) 49 | .ExecuteAffrowsAsync(); 50 | } 51 | } -------------------------------------------------------------------------------- /src/Gotrays.Application/Services/ChatProductService.cs: -------------------------------------------------------------------------------- 1 | using GotraysService.Contracts.Dtos.Products; 2 | 3 | namespace Gotrays.Application.Services; 4 | 5 | public class ChatProductService : ServiceBase,IChatProductService 6 | { 7 | public ChatProductService(IHttpClientFactory httpClientFactory, IStorageService storageService) : base("ChatProducts", httpClientFactory, storageService) 8 | { 9 | } 10 | 11 | 12 | public async Task> GetListAsync() 13 | { 14 | var result = await Client.GetFromJsonAsync>(Prefix+"/List"); 15 | 16 | return result; 17 | } 18 | } -------------------------------------------------------------------------------- /src/Gotrays.Application/Services/ChatService.cs: -------------------------------------------------------------------------------- 1 | namespace Gotrays.Application.Services; 2 | 3 | public class ChatService : ServiceBase, IChatService 4 | { 5 | public ChatService(IHttpClientFactory httpClientFactory, IStorageService storageService) : base( 6 | "Chats", httpClientFactory, storageService) 7 | { 8 | } 9 | 10 | public async Task ChatAsync(ChatCompletionDto dto, Action onMessage) 11 | { 12 | using HttpRequestMessage req = new(HttpMethod.Post, Prefix); 13 | 14 | req.Content = new StringContent(JsonSerializer.Serialize(dto, new JsonSerializerOptions 15 | { 16 | IgnoreNullValues = true 17 | }), Encoding.UTF8, "application/json"); 18 | 19 | UpdateToken(_storageService.Get(Constant.HttpClientOptions.Token)); 20 | using var response = await Client.SendAsync(req, HttpCompletionOption.ResponseHeadersRead); 21 | 22 | if (response.IsSuccessStatusCode) 23 | { 24 | var json = await response.Content.ReadAsStreamAsync(); 25 | using var strings = new StreamReader(json); 26 | while (!strings.EndOfStream) 27 | { 28 | var str = await strings.ReadLineAsync(); 29 | onMessage.Invoke(str ?? string.Empty); 30 | } 31 | 32 | return; 33 | } 34 | 35 | var errorException = await response.Content.ReadFromJsonAsync(); 36 | 37 | throw new ErrorException(errorException.Message); 38 | } 39 | } -------------------------------------------------------------------------------- /src/Gotrays.Application/Services/PayService.cs: -------------------------------------------------------------------------------- 1 | using Gotrays.Contract.Dtos.Pays; 2 | using Gotrays.Contract.Dtos.Products; 3 | using Masa.Utils.Models; 4 | 5 | namespace Gotrays.Application.Services; 6 | 7 | public class PayService : ServiceBase, IPayService 8 | { 9 | public PayService(IHttpClientFactory httpClientFactory, IStorageService storageService) : base("Pays", httpClientFactory, storageService) 10 | { 11 | } 12 | 13 | public async Task StartPayAsync(StartPayPayload payload) 14 | { 15 | var response = await Client.PostAsJsonAsync(Prefix + "/StartPay", payload); 16 | 17 | return await response.Content.ReadFromJsonAsync(); 18 | } 19 | 20 | public async Task> PayHistoryAsync(int page, int pageSize) 21 | { 22 | return await Client.GetFromJsonAsync>(Prefix + "/PayHistory?page="+ page+"&pageSize="+pageSize); 23 | 24 | } 25 | } -------------------------------------------------------------------------------- /src/Gotrays.Application/Services/ServiceBase.cs: -------------------------------------------------------------------------------- 1 | namespace Gotrays.Application.Services; 2 | 3 | public abstract class ServiceBase 4 | { 5 | protected HttpClient Client; 6 | protected readonly IStorageService _storageService; 7 | protected readonly string Prefix; 8 | protected readonly IHttpClientFactory _httpClientFactory; 9 | protected ServiceBase(string prefix, IHttpClientFactory httpClientFactory, IStorageService storageService) 10 | { 11 | Prefix = prefix; 12 | _httpClientFactory = httpClientFactory; 13 | _storageService = storageService; 14 | Client = _httpClientFactory.CreateClient(Constant.HttpClientOptions.OpenService); 15 | } 16 | 17 | /// 18 | /// 更新HttpClient中的Token 19 | /// 20 | /// 21 | protected void UpdateToken(string token) 22 | { 23 | Client.DefaultRequestHeaders.Remove("Authorization"); 24 | Client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token); 25 | _storageService.Add(Constant.HttpClientOptions.Token, token); 26 | } 27 | } -------------------------------------------------------------------------------- /src/Gotrays.Application/Services/StorageService.cs: -------------------------------------------------------------------------------- 1 | namespace Gotrays.Application.Services; 2 | 3 | public class StorageService : IStorageService 4 | { 5 | private string filePath = "Gotrays.json"; 6 | private Dictionary cache = new Dictionary(); 7 | 8 | public void Add(string key, string value) 9 | { 10 | Dictionary data = LoadData(); 11 | data[key] = value; 12 | SaveData(data); 13 | UpdateCache(key, value); 14 | } 15 | 16 | public void Add(string key, T value) 17 | { 18 | Dictionary data = LoadData(); 19 | data[key] = value; 20 | SaveData(data); 21 | UpdateCache(key, value.ToString()); 22 | } 23 | 24 | public void Remove(string key) 25 | { 26 | Dictionary data = LoadData(); 27 | data.Remove(key); 28 | SaveData(data); 29 | RemoveFromCache(key); 30 | } 31 | 32 | public void Delete(string key) 33 | { 34 | Remove(key); 35 | } 36 | 37 | public void RemoveAll() 38 | { 39 | File.Delete(filePath); 40 | ClearCache(); 41 | } 42 | 43 | public string Get(string key) 44 | { 45 | if (cache.ContainsKey(key)) 46 | { 47 | return cache[key]; 48 | } 49 | else 50 | { 51 | Dictionary data = LoadData(); 52 | if (data.ContainsKey(key)) 53 | { 54 | string value = data[key]; 55 | UpdateCache(key, value); 56 | return value; 57 | } 58 | return null; 59 | } 60 | } 61 | 62 | public T Get(string key) 63 | { 64 | if (cache.ContainsKey(key)) 65 | { 66 | string value = cache[key]; 67 | return (T)Convert.ChangeType(value, typeof(T)); 68 | } 69 | else 70 | { 71 | Dictionary data = LoadData(); 72 | if (data.ContainsKey(key)) 73 | { 74 | T value = data[key]; 75 | UpdateCache(key, value.ToString()); 76 | return value; 77 | } 78 | return default(T); 79 | } 80 | } 81 | 82 | private Dictionary LoadData() 83 | { 84 | if (File.Exists(filePath)) 85 | { 86 | string json = File.ReadAllText(filePath); 87 | return JsonSerializer.Deserialize>(json); 88 | } 89 | return new Dictionary(); 90 | } 91 | 92 | private Dictionary LoadData() 93 | { 94 | if (File.Exists(filePath)) 95 | { 96 | string json = File.ReadAllText(filePath); 97 | return JsonSerializer.Deserialize>(json); 98 | } 99 | return new Dictionary(); 100 | } 101 | 102 | private void SaveData(Dictionary data) 103 | { 104 | string json = JsonSerializer.Serialize(data); 105 | File.WriteAllText(filePath, json); 106 | } 107 | 108 | private void SaveData(Dictionary data) 109 | { 110 | string json = JsonSerializer.Serialize(data); 111 | File.WriteAllText(filePath, json); 112 | } 113 | 114 | private void UpdateCache(string key, string value) 115 | { 116 | if (cache.ContainsKey(key)) 117 | { 118 | cache[key] = value; 119 | } 120 | else 121 | { 122 | cache.Add(key, value); 123 | } 124 | } 125 | 126 | private void RemoveFromCache(string key) 127 | { 128 | if (cache.ContainsKey(key)) 129 | { 130 | cache.Remove(key); 131 | } 132 | } 133 | 134 | private void ClearCache() 135 | { 136 | cache.Clear(); 137 | } 138 | } -------------------------------------------------------------------------------- /src/Gotrays.Application/Services/UserService.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace Gotrays.Application.Services; 3 | 4 | public class UserService : ServiceBase, IUserService 5 | { 6 | 7 | public UserService(IHttpClientFactory httpClientFactory, IStorageService storageService) : base("Users", httpClientFactory, storageService) 8 | { 9 | } 10 | 11 | public async Task Login(LoginPayload payload) 12 | { 13 | var response = await Client.PostAsJsonAsync(Prefix + "/Login", payload); 14 | 15 | if (response.IsSuccessStatusCode) 16 | { 17 | var result = await response.Content.ReadAsStringAsync(); 18 | 19 | UpdateToken(result); 20 | return result; 21 | } 22 | 23 | var errorException = await response.Content.ReadFromJsonAsync(); 24 | 25 | throw new ErrorException(errorException.Message); 26 | } 27 | 28 | public async Task Registry(RegistryPayload payload) 29 | { 30 | var response = await Client.PostAsJsonAsync(Prefix + "/", payload); 31 | 32 | } 33 | 34 | public async Task GetAsync() 35 | { 36 | var response = await Client.GetAsync(Prefix); 37 | 38 | if (response.IsSuccessStatusCode) 39 | { 40 | return await response.Content.ReadFromJsonAsync(); 41 | } 42 | else if (response.StatusCode == HttpStatusCode.Unauthorized) 43 | { 44 | throw new UnauthorizedAccessException(); 45 | } 46 | 47 | throw new UnauthorizedAccessException(); 48 | } 49 | 50 | public Task BindingPhone(string phone, string code) 51 | { 52 | throw new NotImplementedException(); 53 | } 54 | 55 | public async Task GetDayDosageAsync() 56 | { 57 | return await Client.GetFromJsonAsync(Prefix+"/DayDosage"); 58 | } 59 | 60 | public Task Edit(EditPayload payload) 61 | { 62 | throw new NotImplementedException(); 63 | } 64 | 65 | public Task RetrievePassword(RetrievePasswordload payload) 66 | { 67 | throw new NotImplementedException(); 68 | } 69 | 70 | } -------------------------------------------------------------------------------- /src/Gotrays.Application/_Imports.cs: -------------------------------------------------------------------------------- 1 | global using System.Net; 2 | global using System.Net.Http.Json; 3 | global using Gotrays.Contract; 4 | global using Gotrays.Contract.Dtos; 5 | global using Gotrays.Contract.Dtos.Auth; 6 | global using Gotrays.Contract.Dtos.Users; 7 | global using Gotrays.Contract.Services; 8 | global using GotraysService.Contracts.Dtos.Auth; 9 | global using System.Text.Json; 10 | global using Gotrays.Shared; 11 | global using System.Text; 12 | global using Gotrays.Contract.Dtos.Chats; -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Activitys/InvitationItem.cs: -------------------------------------------------------------------------------- 1 | namespace GotraysService.Contracts.Dtos.Activitys; 2 | 3 | public class InvitationItem 4 | { 5 | public Guid Id { get; set; } 6 | 7 | /// 8 | /// 被邀请人 9 | /// 10 | public string InviteTo { get; set; } 11 | 12 | /// 13 | /// 头像 14 | /// 15 | public string Avatar { get; set; } 16 | 17 | /// 18 | /// 邀请码 19 | /// 20 | public string InvitationCode { get; set; } 21 | 22 | /// 23 | /// 邀请时间 24 | /// 25 | public DateTime InvitationTime { get; set; } 26 | 27 | /// 28 | /// 可领取vip天数 29 | /// 30 | public int Days { get; set; } 31 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Admin/ChatRecordItem.cs: -------------------------------------------------------------------------------- 1 | namespace GotraysService.Contracts.Dtos.Admin; 2 | 3 | public class ChatRecordItem 4 | { 5 | public Guid Id { get; set; } 6 | 7 | /// 8 | /// 发起人 9 | /// 10 | public string UserName { get; set; } 11 | 12 | /// 13 | /// 提示 14 | /// 15 | public string Prompt { get; set; } 16 | 17 | /// 18 | /// 回应 19 | /// 20 | public string Replay { get; set; } 21 | 22 | /// 23 | /// 创建时间 24 | /// 25 | public DateTime CreateTime { get; set; } 26 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Admin/ChatRecordTop10Summary.cs: -------------------------------------------------------------------------------- 1 | namespace GotraysService.Contracts.Dtos.Admin; 2 | 3 | public class ChatRecordTop10Summary 4 | { 5 | public string UserName { get; set; } 6 | 7 | public string Account { get; set; } 8 | 9 | public string Avatar { get; set; } 10 | 11 | public DateTime VipExpires { get; set; } 12 | 13 | public int ChatRecordCount { get; set; } 14 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Admin/EditUserDto.cs: -------------------------------------------------------------------------------- 1 | namespace GotraysService.Contracts.Dtos.Admin; 2 | 3 | public class EditUserDto 4 | { 5 | public Guid UserId { get; set; } 6 | 7 | public string UserName { get; set; } 8 | 9 | public string Avatar { get; set; } 10 | 11 | public string Password { get; set; } 12 | 13 | public bool IsDisable { get; set; } 14 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Admin/GlobalSummary.cs: -------------------------------------------------------------------------------- 1 | namespace GotraysService.Contracts.Dtos.Admin; 2 | 3 | public class GlobalSummary 4 | { 5 | public int UserCount { get; set; } 6 | 7 | public int ChatRecordCount { get; set; } 8 | 9 | public int VipCount { get; set; } 10 | 11 | public int PaySuccessCount { get; set; } 12 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Admin/PayRecordItem.cs: -------------------------------------------------------------------------------- 1 | using GotraysService.Contracts.Shared; 2 | 3 | namespace GotraysService.Contracts.Dtos.Admin; 4 | 5 | public class PayRecordItem 6 | { 7 | public Guid Id { get; set; } 8 | 9 | /// 10 | /// 用户名称 11 | /// 12 | public string UserName { get; set; } 13 | 14 | /// 15 | /// 支付平台 16 | /// 17 | public PayType PayType { get; set; } 18 | 19 | /// 20 | /// 产品名称 21 | /// 22 | public string ProductName { get; set; } 23 | 24 | /// 25 | /// 原价 26 | /// 27 | public decimal OriginalPrice { get; set; } 28 | 29 | /// 30 | /// 实际支付金额 31 | /// 32 | public decimal ActualPayment { get; set; } 33 | 34 | /// 35 | /// 支付状态 36 | /// 37 | public PayState PayState { get; set; } 38 | 39 | /// 40 | /// 创建时间 41 | /// 42 | public DateTime CreationTime { get; set; } 43 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Admin/PayRecordPaginatedListPayload.cs: -------------------------------------------------------------------------------- 1 | using GotraysService.Contracts.Shared; 2 | using Masa.BuildingBlocks.Ddd.Domain.Repositories; 3 | 4 | namespace GotraysService.Contracts.Dtos.Admin; 5 | 6 | public class PayRecordPaginatedListPayload : PaginatedOptions 7 | { 8 | /// 9 | /// 用户名称 10 | /// 11 | public string? UserName { get; set; } 12 | 13 | /// 14 | /// 支付平台 15 | /// 16 | public PayType? PayType { get; set; } 17 | 18 | /// 19 | /// 产品名称 20 | /// 21 | public string? ProductName { get; set; } 22 | 23 | /// 24 | /// 支付状态 25 | /// 26 | public PayState? PayState { get; set; } 27 | 28 | /// 29 | /// 创建起始时间 30 | /// 31 | public DateTime? StartTime { get; set; } 32 | 33 | /// 34 | /// 创建截至时间 35 | /// 36 | public DateTime? EndTime { get; set; } 37 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Admin/TrendChart.cs: -------------------------------------------------------------------------------- 1 | namespace GotraysService.Contracts.Dtos.Admin; 2 | 3 | public class TrendChart 4 | { 5 | public IEnumerable> Items { get; set; } 6 | 7 | public T Sum { get; set; } 8 | } 9 | 10 | public class TrendChartItem 11 | { 12 | public string Date { get; set; } 13 | public T Value { get; set; } 14 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Admin/UserItem.cs: -------------------------------------------------------------------------------- 1 | namespace GotraysService.Contracts.Dtos.Admin; 2 | 3 | public class UserItem 4 | { 5 | public Guid Id { get; set; } 6 | 7 | /// 8 | /// 用户名称 9 | /// 10 | public string UserName { get; set; } 11 | 12 | /// 13 | /// 账户 14 | /// 15 | public string Account { get; set; } 16 | 17 | /// 18 | /// 是否vip 19 | /// 20 | public bool IsVip { get; set; } 21 | 22 | /// 23 | /// 是否禁用 24 | /// 25 | public bool IsDisable { get; set; } 26 | 27 | /// 28 | /// 手机号 29 | /// 30 | public string Phone { get; set; } 31 | 32 | /// 33 | /// 上一次登陆时间 34 | /// 35 | public DateTime LastLoginTime { get; set; } 36 | 37 | public DateTime CreationTime { get; set; } 38 | 39 | public DateTime ModificationTime { get; set; } 40 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Admin/UserPaginatedListPayload.cs: -------------------------------------------------------------------------------- 1 | using Masa.BuildingBlocks.Ddd.Domain.Repositories; 2 | 3 | namespace GotraysService.Contracts.Dtos.Admin; 4 | 5 | public class UserPaginatedListPayload : PaginatedOptions 6 | { 7 | /// 8 | /// 用户名 9 | /// 10 | public string Keyword { get; set; } 11 | 12 | /// 13 | /// 是否禁用 14 | /// 15 | public bool? IsDisable { get; set; } 16 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Apps/AppInfoDto.cs: -------------------------------------------------------------------------------- 1 | namespace GotraysService.Contracts.Dtos.Apps; 2 | 3 | public class AppInfoDto 4 | { 5 | public Guid Id { get; set; } 6 | 7 | /// 8 | /// 操作系统 9 | /// 10 | public string OS { get; set; } 11 | 12 | /// 13 | /// 备注 14 | /// 15 | public string Description { get; set; } 16 | 17 | /// 18 | /// 版本号 19 | /// 20 | public string Versions { get; set; } 21 | 22 | /// 23 | /// 下载地址 24 | /// 25 | public string Url { get; set; } 26 | 27 | /// 28 | /// 更新内容 29 | /// 30 | public string Message { get; set; } 31 | 32 | /// 33 | /// 上架日期 34 | /// 35 | public DateTime UploadDate { get; set; } 36 | } 37 | -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Auth/CurrentUser.cs: -------------------------------------------------------------------------------- 1 | namespace GotraysService.Contracts.Dtos.Auth; 2 | 3 | public class CurrentUser 4 | { 5 | /// 6 | /// 用户id 7 | /// 8 | public Guid UserId { get; set; } 9 | 10 | /// 11 | /// 用户名 12 | /// 13 | public string UserName { get; set; } 14 | 15 | /// 16 | /// 是否会员 17 | /// 18 | public bool IsVip { get; set; } 19 | 20 | /// 21 | /// 角色 22 | /// 23 | public string? Role { get; set; } 24 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Auth/JwtOptions.cs: -------------------------------------------------------------------------------- 1 | namespace GotraysService.Contracts.Dtos.Auth; 2 | 3 | public class JwtOptions 4 | { 5 | /// 6 | /// 秘钥 7 | /// 8 | public string Secret { get; set; } 9 | 10 | /// 11 | /// 有效时间(小时) 12 | /// 13 | public int EffectiveHours { get; set; } 14 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Auth/LoginPayload.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace Gotrays.Contract.Dtos.Auth; 4 | 5 | public class LoginPayload 6 | { 7 | /// 8 | /// 账户 9 | /// 10 | [Required(ErrorMessage = "账户不能为空")] 11 | [MinLength(6, ErrorMessage = "账号至少6位")] 12 | public string Account { get; set; } = string.Empty; 13 | 14 | /// 15 | /// 密码 16 | /// 17 | [Required(ErrorMessage = "密码不能为空")] 18 | [MinLength(6, ErrorMessage = "密码至少6位")] 19 | public string Password { get; set; } = string.Empty; 20 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Auth/RegistryPayload.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace GotraysService.Contracts.Dtos.Auth; 4 | 5 | public class RegistryPayload 6 | { 7 | /// 8 | /// 昵称 9 | /// 10 | [Required(ErrorMessage = "昵称不能为空")] 11 | public string UserName { get; set; } 12 | 13 | /// 14 | /// 账户 15 | /// 16 | [Required(ErrorMessage = "账号不能为空")] 17 | [MinLength(6)] 18 | public string Account { get; set; } 19 | 20 | /// 21 | /// 手机号 22 | /// 23 | [Required(ErrorMessage = "手机号不能为空")] 24 | [MinLength(6)] 25 | public string Phone { get; set; } 26 | 27 | /// 28 | /// 密码 29 | /// 30 | [Required(ErrorMessage = "密码不能为空")] 31 | [MinLength(6)] 32 | public string Password { get; set; } 33 | 34 | /// 35 | /// 邀请码 36 | /// 37 | public string? InvitationCode { get; set; } 38 | 39 | /// 40 | /// 验证码 41 | /// 42 | public string Verification { get; set; } 43 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Chats/AIRoleSettingDto.cs: -------------------------------------------------------------------------------- 1 | namespace GotraysService.Contracts.Dtos.Chats; 2 | 3 | public class AIRoleSettingDto 4 | { 5 | public Guid Id { get; set; } 6 | 7 | /// 8 | /// 标题 9 | /// 10 | public string Title { get; set; } 11 | 12 | /// 13 | /// 角色定义内容 14 | /// 15 | public string Content { get; set; } 16 | 17 | /// 18 | /// 描述 19 | /// 20 | public string Description { get; set; } 21 | 22 | /// 23 | /// 创建时间 24 | /// 25 | public DateTime CreationTime { get; set; } 26 | 27 | /// 28 | /// 是否用户自定义的 29 | /// 30 | public bool IsCustom { get; set; } 31 | } 32 | -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Chats/ChannelDto.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace Gotrays.Contract.Dtos.Chats; 4 | 5 | /// 6 | /// 频道 7 | /// 8 | public class ChannelDto :ICloneable 9 | { 10 | public Guid Id { get; set; } 11 | 12 | /// 13 | /// 标题 14 | /// 15 | [Required] 16 | public string Title { get; set; } 17 | 18 | /// 19 | /// 模型 20 | /// 21 | [Required] 22 | public string Model { get; set; } 23 | 24 | /// 25 | /// 角色定义 26 | /// 27 | public string Role { get; set; } 28 | 29 | /// 30 | /// 描述 31 | /// 32 | public string Description { get; set; } 33 | 34 | /// 35 | /// 图标 36 | /// 37 | public string Icon { get; set; } 38 | 39 | /// 40 | /// 最大关联历史数量 41 | /// 42 | public int MaxHistory { get; set; } 43 | 44 | /// 45 | /// 排序 46 | /// 47 | public int Sort { get; set; } 48 | 49 | /// 50 | /// 创建时间 51 | /// 52 | public DateTime CreatedTime { get; set; } 53 | 54 | public object Clone() 55 | { 56 | return new ChannelDto() 57 | { 58 | Title = this.Title, 59 | CreatedTime = this.CreatedTime, 60 | MaxHistory = this.MaxHistory, 61 | Description = Description, 62 | Icon = this.Icon, 63 | Sort = this.Sort, 64 | Model = this.Model, 65 | Role = this.Role, 66 | Id = this.Id, 67 | }; 68 | } 69 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Chats/ChatCompletionDto.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace Gotrays.Contract.Dtos.Chats; 4 | 5 | public class ChatCompletionDto 6 | { 7 | public string model { get; set; } 8 | 9 | public List messages { get; set; } = new(); 10 | 11 | public double? temperature { get; set; } 12 | 13 | /// 14 | /// 用温度采样的另一种方法称为核采样,其中模型考虑具有top_p概率质量的token的结果。因此0.1意味着只考虑包含前10%概率质量的标记。我们通常建议改变这个或“温度”,但不建议两者都改变。 15 | /// 16 | public double? top_p { get; set; } 17 | 18 | public int max_tokens { get; set; } = 500; 19 | 20 | /// 21 | /// 在-2.0到2.0之间的数字。正值会根据新标记在文本中存在的频率来惩罚它们,降低模型逐字重复同一行的可能性。[有关频率和存在惩罚的更多信息。](https://docs.api-reference/parameter -details) 22 | /// 23 | public double? frequency_penalty { get; set; } 24 | 25 | public Error error { get; set; } 26 | } 27 | 28 | public class ChatCompletionRequestMessage 29 | { 30 | public string role { get; set; } 31 | 32 | public string content { get; set; } 33 | 34 | public string? name { get; set; } 35 | 36 | [JsonIgnore] public int token { get; set; } 37 | 38 | [JsonIgnore] public int Sort { get; set; } 39 | } 40 | 41 | public class Error 42 | { 43 | public string message { get; set; } 44 | public string type { get; set; } 45 | public object param { get; set; } 46 | public string code { get; set; } 47 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Chats/ChatItem.cs: -------------------------------------------------------------------------------- 1 | using GotraysService.Contracts.Shared; 2 | 3 | namespace GotraysService.Contracts.Dtos.Chats; 4 | 5 | 6 | public class ChatItem 7 | { 8 | public Guid Id { get; set; } 9 | 10 | public ChatModel Model { get; set; } 11 | 12 | /// 13 | /// 对话id 14 | /// 15 | public Guid DialogId { get; set; } 16 | 17 | /// 18 | /// 提示 19 | /// 20 | public string Prompt { get; set; } 21 | 22 | /// 23 | /// 回应 24 | /// 25 | public string Replay { get; set; } 26 | 27 | /// 28 | /// 花费的tokens 29 | /// 30 | public double UsageTokens { get; set; } 31 | 32 | /// 33 | /// 创建时间 34 | /// 35 | public DateTime CreateTime { get; set; } 36 | 37 | public Guid UserId { get; set; } 38 | 39 | /// 40 | /// 访问IP 41 | /// 42 | public string? Ip { get; set; } 43 | 44 | /// 45 | /// 用户名 46 | /// 47 | public string UserName { get; set; } 48 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Chats/ChatMessageDto.cs: -------------------------------------------------------------------------------- 1 | using Gotrays.Shared; 2 | 3 | namespace Gotrays.Contract.Dtos.Chats; 4 | 5 | public class ChatMessageDto 6 | { 7 | public Guid Id { get; set; } 8 | 9 | /// 10 | /// 频道id 11 | /// 12 | public Guid ChannelId { get; set; } 13 | 14 | /// 15 | /// 内容 16 | /// 17 | public string Message { get; set; } 18 | 19 | /// 20 | /// 是否本人发送 21 | /// 22 | public bool Curren { get; set; } 23 | 24 | /// 25 | /// 创建时间 26 | /// 27 | public DateTime CreatedTime { get; set; } 28 | 29 | /// 30 | /// 消息内容 31 | /// 32 | public ChatMessageType Type { get; set; } 33 | 34 | public Func OnCopy { get; set; } 35 | 36 | public Func OnDelete { get; set; } 37 | 38 | public Func OnUpdate { get; set; } 39 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Chats/CreateAIRoleSettingPayload.cs: -------------------------------------------------------------------------------- 1 | namespace Gotrays.Contract.Dtos.Chats; 2 | 3 | public class CreateAIRoleSettingPayload 4 | { 5 | /// 6 | /// 标题 7 | /// 8 | public string Title { get; set; } 9 | 10 | /// 11 | /// 角色定义内容 12 | /// 13 | public string Content { get; set; } 14 | 15 | /// 16 | /// 描述 17 | /// 18 | public string Description { get; set; } 19 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Chats/GetChatHistoryInput.cs: -------------------------------------------------------------------------------- 1 | using GotraysService.Contracts.Shared; 2 | using Masa.BuildingBlocks.Ddd.Domain.Repositories; 3 | 4 | namespace GotraysService.Contracts.Dtos.Chats; 5 | 6 | public class GetChatHistoryInput : PaginatedOptions 7 | { 8 | public Guid? dialogId { get; set; } 9 | 10 | public string? keyword { get; set; } 11 | 12 | public ChatModel? model { get; set; } 13 | } 14 | -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/ErrorDto.cs: -------------------------------------------------------------------------------- 1 | namespace Gotrays.Contract.Dtos; 2 | 3 | public class ErrorDto 4 | { 5 | public string Message { get; set; } 6 | } 7 | 8 | -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/PaginatedListPayloadBase.cs: -------------------------------------------------------------------------------- 1 | namespace Gotrays.Contract.Dtos; 2 | 3 | public class PaginatedListPayloadBase 4 | { 5 | public int PageIndex { get; set; } 6 | 7 | public int PageSize { get; set; } 8 | 9 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Pays/ProductListDto.cs: -------------------------------------------------------------------------------- 1 | using GotraysService.Contracts.Shared; 2 | 3 | namespace Gotrays.Contract.Dtos.Pays; 4 | 5 | public class ProductListDto 6 | { 7 | public Guid Id { get; set; } 8 | 9 | /// 10 | /// 用户id 11 | /// 12 | public Guid UserId { get; set; } 13 | 14 | /// 15 | /// 用户名称 16 | /// 17 | public string UserName { get; set; } 18 | 19 | /// 20 | /// 支付平台 21 | /// 22 | public PayType PayType { get; set; } 23 | 24 | /// 25 | /// 产品Id 26 | /// 27 | public Guid ProductId { get; set; } 28 | 29 | /// 30 | /// 产品名称 31 | /// 32 | public string ProductName { get; set; } 33 | 34 | /// 35 | /// 原价 36 | /// 37 | public decimal OriginalPrice { get; set; } 38 | 39 | /// 40 | /// 实际支付金额 41 | /// 42 | public decimal ActualPayment { get; set; } 43 | 44 | /// 45 | /// 支付状态 46 | /// 47 | public PayState PayState { get; set; } 48 | 49 | public DateTime CreationTime { get; set; } 50 | } 51 | -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Pays/StartPayPayloadDto.cs: -------------------------------------------------------------------------------- 1 | namespace Gotrays.Contract.Dtos.Pays; 2 | 3 | public class StartPayPayloadDto 4 | { 5 | public string qr { get; set; } 6 | 7 | public string id { get; set; } 8 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Products/GetProductListDto.cs: -------------------------------------------------------------------------------- 1 | namespace GotraysService.Contracts.Dtos.Products; 2 | 3 | public class GetProductListDto 4 | { 5 | public Guid Id { get; set; } 6 | 7 | /// 8 | /// 产品名称 唯一 9 | /// 10 | public string Name { get; set; } 11 | 12 | /// 13 | /// 产品描述 14 | /// 15 | public string Description { get; set; } 16 | 17 | /// 18 | /// 实际需要支付金额 19 | /// 20 | public decimal ActualPrice { get; set; } 21 | 22 | /// 23 | /// 原价 24 | /// 25 | public decimal OriginalPrice { get; set; } 26 | 27 | /// 28 | /// 天 29 | /// 30 | public int Days { get; set; } 31 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Products/StartPayPayload.cs: -------------------------------------------------------------------------------- 1 | using GotraysService.Contracts.Shared; 2 | 3 | namespace Gotrays.Contract.Dtos.Products; 4 | 5 | public class StartPayPayload 6 | { 7 | /// 8 | /// 支付平台 9 | /// 10 | public PayType PayType { get; set; } = PayType.alipay; 11 | 12 | /// 13 | /// 产品Id 14 | /// 15 | public Guid ProductId { get; set; } 16 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Systems/AnnouncementDto.cs: -------------------------------------------------------------------------------- 1 | namespace Gotrays.Contract.Dtos.Systems; 2 | 3 | public class AnnouncementDto 4 | { 5 | /// 6 | /// 标题 7 | /// 8 | public string Title { get; set; } 9 | 10 | /// 11 | /// 内容 12 | /// 13 | public string Value { get; set; } 14 | 15 | /// 16 | /// 高亮内容 17 | /// 18 | public string Highlighting { get; set; } 19 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Systems/GiteeReleaseDto.cs: -------------------------------------------------------------------------------- 1 | namespace Gotrays.Contract.Dtos.Systems; 2 | 3 | public class GiteeReleaseDto 4 | { 5 | public int id { get; set; } 6 | public string tag_name { get; set; } 7 | public string target_commitish { get; set; } 8 | public bool prerelease { get; set; } 9 | public string name { get; set; } 10 | public string body { get; set; } 11 | public Author author { get; set; } 12 | public string created_at { get; set; } 13 | public Assets[] assets { get; set; } 14 | } 15 | 16 | public class Author 17 | { 18 | public int id { get; set; } 19 | public string login { get; set; } 20 | public string name { get; set; } 21 | public string avatar_url { get; set; } 22 | public string url { get; set; } 23 | public string html_url { get; set; } 24 | public string remark { get; set; } 25 | public string followers_url { get; set; } 26 | public string following_url { get; set; } 27 | public string gists_url { get; set; } 28 | public string starred_url { get; set; } 29 | public string subscriptions_url { get; set; } 30 | public string organizations_url { get; set; } 31 | public string repos_url { get; set; } 32 | public string events_url { get; set; } 33 | public string received_events_url { get; set; } 34 | public string type { get; set; } 35 | } 36 | 37 | public class Assets 38 | { 39 | public string browser_download_url { get; set; } 40 | public string name { get; set; } 41 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Users/EditPayload.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace Gotrays.Contract.Dtos.Users; 4 | 5 | public class EditPayload 6 | { 7 | public Guid UserId { get; set; } 8 | 9 | /// 10 | /// 昵称 11 | /// 12 | [Required(ErrorMessage = "昵称不能为空")] 13 | public string UserName { get; set; } 14 | 15 | /// 16 | /// 头像 17 | /// 18 | [Required(ErrorMessage = "头像不能为空")] 19 | public string Avatar { get; set; } 20 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Users/GetDayDosageDto.cs: -------------------------------------------------------------------------------- 1 | namespace Gotrays.Contract.Dtos.Users; 2 | 3 | public class GetDayDosageDto 4 | { 5 | public int money { get; set; } 6 | public int free { get; set; } 7 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Users/GetUserDto.cs: -------------------------------------------------------------------------------- 1 | namespace Gotrays.Contract.Dtos.Users; 2 | 3 | public class GetUserDto 4 | { 5 | public Guid Id { get; set; } 6 | 7 | /// 8 | /// 用户名称 9 | /// 10 | public string UserName { get; set; } 11 | 12 | /// 13 | /// 账户 14 | /// 15 | public string Account { get; set; } 16 | 17 | /// 18 | /// 头像 19 | /// 20 | public string Avatar { get; set; } 21 | 22 | /// 23 | /// 是否vip 24 | /// 25 | public bool IsVip { get; set; } 26 | 27 | /// 28 | /// 是否禁用 29 | /// 30 | public bool IsDisable { get; set; } 31 | 32 | /// 33 | /// 上一次登陆时间 34 | /// 35 | public DateTime LastLoginTime { get; set; } 36 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Dtos/Users/RetrievePasswordload.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace Gotrays.Contract.Dtos.Users; 4 | 5 | public class RetrievePasswordload 6 | { 7 | /// 8 | /// 手机号码 9 | /// 10 | [Required(ErrorMessage = "手机号码不能为空")] 11 | public string Phone { get; set; } 12 | 13 | /// 14 | /// 验证码 15 | /// 16 | [Required(ErrorMessage = "验证码不能为空")] 17 | public string Code { get; set; } 18 | 19 | /// 20 | /// 新的密码 21 | /// 22 | [Required(ErrorMessage = "新的密码不能为空")] 23 | public string NewPassword { get; set; } 24 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/ErrorException.cs: -------------------------------------------------------------------------------- 1 | namespace Gotrays.Contract; 2 | 3 | public class ErrorException : Exception 4 | { 5 | public ErrorException(string message):base(message) 6 | { 7 | } 8 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Gotrays.Contract.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/Gotrays.Contract/GotraysContractModule.cs: -------------------------------------------------------------------------------- 1 | using CoreFlex.Module; 2 | 3 | namespace Gotrays.Contract; 4 | 5 | public class GotraysContractModule : CoreFlexModule 6 | { 7 | 8 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Services/IAppService.cs: -------------------------------------------------------------------------------- 1 | using Gotrays.Contract.Dtos.Systems; 2 | 3 | namespace Gotrays.Contract.Services; 4 | 5 | public interface IAppService 6 | { 7 | Task GetApp(); 8 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Services/IChannelService.cs: -------------------------------------------------------------------------------- 1 | using Gotrays.Contract.Dtos.Chats; 2 | 3 | namespace Gotrays.Contract.Services; 4 | 5 | public interface IChannelService 6 | { 7 | /// 8 | /// 获取频道列表 9 | /// 10 | /// 11 | /// 12 | Task> GetListAsync(string? search); 13 | 14 | /// 15 | /// 修改频道 16 | /// 17 | /// 18 | /// 19 | Task UpdateAsync(ChannelDto channel); 20 | 21 | /// 22 | /// 删除指定频道 23 | /// 24 | /// 25 | /// 26 | Task DeleteAsync(Guid id); 27 | 28 | /// 29 | /// 增加频道 30 | /// 31 | /// 32 | /// 33 | Task AddAsync(ChannelDto channel); 34 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Services/IChatMessageService.cs: -------------------------------------------------------------------------------- 1 | using Gotrays.Contract.Dtos.Chats; 2 | 3 | namespace Gotrays.Contract.Services; 4 | 5 | public interface IChatMessageService 6 | { 7 | /// 8 | /// 9 | /// 10 | /// 频道id 11 | /// 默认1 最小1页 12 | /// 默认5 13 | /// 14 | Task> GetListAsync(Guid channelId, int page = 1, int pageSize = 5); 15 | 16 | /// 17 | /// 更新消息 18 | /// 19 | /// 20 | /// 21 | Task UpdateAsync(ChatMessageDto messageDto); 22 | 23 | /// 24 | /// 删除id 25 | /// 26 | /// 27 | /// 28 | Task DeleteAsync(Guid id); 29 | 30 | /// 31 | /// 创建消息 32 | /// 33 | /// 34 | /// 35 | Task CreateAsync(ChatMessageDto dto); 36 | 37 | /// 38 | /// 通过管道id删除 39 | /// 40 | /// 41 | /// 42 | Task DeleteChannelAsync(Guid channelId); 43 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Services/IChatProductService.cs: -------------------------------------------------------------------------------- 1 | using GotraysService.Contracts.Dtos.Products; 2 | 3 | namespace Gotrays.Contract.Services; 4 | 5 | public interface IChatProductService 6 | { 7 | /// 8 | /// 获取产品列表 9 | /// 10 | /// 11 | Task> GetListAsync(); 12 | 13 | 14 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Services/IChatRecordService.cs: -------------------------------------------------------------------------------- 1 | using GotraysService.Contracts.Dtos.Chats; 2 | using Masa.Utils.Models; 3 | 4 | namespace Gotrays.Contract.Services; 5 | 6 | public interface IChatRecordService 7 | { 8 | /// 9 | /// 获取聊天记录 10 | /// 11 | /// 12 | /// 13 | Task> ChatHistoryAsync(GetChatHistoryInput input); 14 | } 15 | -------------------------------------------------------------------------------- /src/Gotrays.Contract/Services/IChatService.cs: -------------------------------------------------------------------------------- 1 | using Gotrays.Contract.Dtos.Chats; 2 | 3 | namespace Gotrays.Contract.Services; 4 | 5 | public interface IChatService 6 | { 7 | /// 8 | /// Chat请求 9 | /// 10 | /// 11 | /// 12 | Task ChatAsync(ChatCompletionDto dto,Action onMessage); 13 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Services/IPayService.cs: -------------------------------------------------------------------------------- 1 | using Gotrays.Contract.Dtos.Pays; 2 | using Gotrays.Contract.Dtos.Products; 3 | using GotraysService.Contracts.Dtos.Products; 4 | using Masa.Utils.Models; 5 | 6 | namespace Gotrays.Contract.Services; 7 | 8 | public interface IPayService 9 | { 10 | Task StartPayAsync(StartPayPayload payload); 11 | 12 | Task> PayHistoryAsync(int page,int pageSize); 13 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Services/IStorageService.cs: -------------------------------------------------------------------------------- 1 | namespace Gotrays.Contract.Services; 2 | 3 | public interface IStorageService 4 | { 5 | void Add(string key, string value); 6 | 7 | void Add(string key, T value); 8 | 9 | void Remove(string key); 10 | 11 | void Delete(string key); 12 | 13 | void RemoveAll(); 14 | 15 | string Get(string key); 16 | 17 | T Get(string key); 18 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Services/IUserService.cs: -------------------------------------------------------------------------------- 1 | using Gotrays.Contract.Dtos.Auth; 2 | using Gotrays.Contract.Dtos.Users; 3 | using GotraysService.Contracts.Dtos.Auth; 4 | 5 | namespace Gotrays.Contract.Services; 6 | 7 | public interface IUserService 8 | { 9 | Task Login(LoginPayload payload); 10 | 11 | Task Registry(RegistryPayload payload); 12 | 13 | Task GetAsync(); 14 | 15 | Task BindingPhone(string phone, string code); 16 | 17 | Task GetDayDosageAsync(); 18 | 19 | Task Edit(EditPayload payload); 20 | 21 | Task RetrievePassword(RetrievePasswordload payload); 22 | } 23 | -------------------------------------------------------------------------------- /src/Gotrays.Contract/Services/IWindowService.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | 3 | namespace Gotrays.Contract.Services; 4 | 5 | public interface IWindowService 6 | { 7 | /// 8 | /// 更新窗口高宽 9 | /// 10 | /// 11 | void SetWindowSize(Size size); 12 | 13 | /// 14 | /// 更新窗口State 15 | /// 16 | /// 17 | void SetWindowState(int state); 18 | 19 | /// 20 | /// 修改窗口显示位置 21 | /// 22 | /// 23 | void SetWindowStartupLocation(int location); 24 | 25 | /// 26 | /// 修改窗口标题 27 | /// 28 | /// 29 | void UpdateTitle(string title); 30 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Shared/ChatModel.cs: -------------------------------------------------------------------------------- 1 | namespace GotraysService.Contracts.Shared; 2 | 3 | public enum ChatModel 4 | { 5 | ChatGpt35, 6 | 7 | DALLE, 8 | 9 | ChatGpt4, 10 | } 11 | -------------------------------------------------------------------------------- /src/Gotrays.Contract/Shared/Constant.cs: -------------------------------------------------------------------------------- 1 | namespace GotraysService.Contracts.Order.Shared; 2 | 3 | public class Constant 4 | { 5 | public const string AIRoleSettingCache = "Constant:AIRoleSettingCache"; 6 | 7 | public const string Announcement = "Gotrays:Announcement"; 8 | } 9 | -------------------------------------------------------------------------------- /src/Gotrays.Contract/Shared/PayState.cs: -------------------------------------------------------------------------------- 1 | namespace GotraysService.Contracts.Shared; 2 | 3 | public enum PayState 4 | { 5 | /// 6 | /// 未支付 7 | /// 8 | Unpaid, 9 | 10 | 11 | /// 12 | /// 已支付 13 | /// 14 | Succeed 15 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Shared/PayType.cs: -------------------------------------------------------------------------------- 1 | namespace GotraysService.Contracts.Shared; 2 | 3 | public enum PayType 4 | { 5 | /// 6 | /// 支付宝 7 | /// 8 | alipay, 9 | 10 | /// 11 | /// 微信 12 | /// 13 | wxpay, 14 | 15 | /// 16 | /// QQ钱包 17 | /// 18 | qqpay, 19 | 20 | /// 21 | /// 网银支付 22 | /// 23 | bank, 24 | 25 | /// 26 | /// 京东支付 27 | /// 28 | jdpay, 29 | 30 | /// 31 | /// PayPal 32 | /// 33 | paypal 34 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Shared/ProductType.cs: -------------------------------------------------------------------------------- 1 | namespace GotraysService.Contracts.Shared; 2 | 3 | public enum ProductType 4 | { 5 | /// 6 | /// 按天 7 | /// 8 | Day, 9 | 10 | /// 11 | /// 按量 12 | /// 13 | Dosage 14 | } -------------------------------------------------------------------------------- /src/Gotrays.Contract/Shared/VerificationType.cs: -------------------------------------------------------------------------------- 1 | namespace GotraysService.Contracts.Shared; 2 | 3 | public enum VerificationType 4 | { 5 | Login = 0, 6 | 7 | /// 8 | /// 注册 9 | /// 10 | Registry = 1, 11 | 12 | /// 13 | /// 绑定 14 | /// 15 | Binding = 2, 16 | 17 | /// 18 | /// 找回密码 19 | /// 20 | RetrievePassword = 3 21 | } -------------------------------------------------------------------------------- /src/Gotrays.Desktop/App.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/Gotrays.Desktop/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | using System.Reflection; 3 | using System.Windows; 4 | using System.Windows.Controls; 5 | using Hardcodet.Wpf.TaskbarNotification; 6 | 7 | namespace Gotrays.Desktop; 8 | /// 9 | /// Interaction logic for App.xaml 10 | /// 11 | public partial class App : System.Windows.Application 12 | { 13 | private TaskbarIcon notifyIcon; 14 | 15 | public App() 16 | { 17 | Assembly assembly = Assembly.GetExecutingAssembly(); 18 | 19 | // 获取资源文件的流 20 | using var stream = assembly.GetManifestResourceStream("Gotrays.Desktop.favicon.ico"); 21 | 22 | // 创建NotifyIcon实例 23 | notifyIcon = new TaskbarIcon(); 24 | notifyIcon.Icon = new Icon(stream); // 设置托盘图标 25 | notifyIcon.ContextMenu = new ContextMenu(); 26 | notifyIcon.TrayMouseDoubleClick += OnOpenWindow; 27 | 28 | // 添加托盘菜单项 29 | MenuItem openWindow = new MenuItem(); 30 | openWindow.Header = "打开首页"; 31 | openWindow.Click += OnOpenWindow; 32 | notifyIcon.ContextMenu.Items.Add(openWindow); 33 | 34 | // 添加托盘菜单项 35 | MenuItem exitItem = new MenuItem(); 36 | exitItem.Header = "退出"; 37 | exitItem.Click += OnExit; 38 | notifyIcon.ContextMenu.Items.Add(exitItem); 39 | 40 | } 41 | 42 | private void OnOpenWindow(object sender, RoutedEventArgs e) 43 | { 44 | this.MainWindow.Show(); 45 | } 46 | 47 | private void OnExit(object sender, RoutedEventArgs e) 48 | { 49 | Environment.Exit(0); 50 | } 51 | 52 | 53 | } 54 | 55 | -------------------------------------------------------------------------------- /src/Gotrays.Desktop/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | [assembly: ThemeInfo( 4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 5 | //(used if a resource is not found in the page, 6 | // or application resource dictionaries) 7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 8 | //(used if a resource is not found in the page, 9 | // app, or any theme specific resource dictionaries) 10 | )] 11 | -------------------------------------------------------------------------------- /src/Gotrays.Desktop/Gotrays.Desktop.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | WinExe 4 | net8.0-windows 5 | enable 6 | enable 7 | true 8 | Gotrays.Desktop 9 | favicon.ico 10 | 11 | 12 | 13 | Never 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | Always 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/Gotrays.Desktop/GotraysDesktopModule.cs: -------------------------------------------------------------------------------- 1 | using CoreFlex.Module; 2 | using Gotrays.Application; 3 | using Gotrays.Rcl; 4 | 5 | namespace Gotrays.Desktop; 6 | 7 | [DependOns(typeof(GotraysRclModule), typeof(GotraysApplicationModule))] 8 | public class GotraysDesktopModule : CoreFlexModule 9 | { 10 | } -------------------------------------------------------------------------------- /src/Gotrays.Desktop/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/Gotrays.Desktop/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Windows; 3 | using CoreFlex.Module.Extensions; 4 | using Gotrays.Contract.Services; 5 | using Gotrays.Desktop.Services; 6 | using Gotrays.Rcl; 7 | using Microsoft.AspNetCore.Components.WebView.Wpf; 8 | using Microsoft.Extensions.DependencyInjection; 9 | 10 | namespace Gotrays.Desktop; 11 | 12 | /// 13 | /// Interaction logic for MainWindow.xaml 14 | /// 15 | public partial class MainWindow : Window 16 | { 17 | public static MainWindow Windwo; 18 | 19 | private IServiceCollection _service; 20 | 21 | public MainWindow() 22 | { 23 | InitializeComponent(); 24 | 25 | Windwo = this; 26 | 27 | _service = new ServiceCollection(); 28 | 29 | _service.AddCoreFlexAutoInjectAsync().ConfigureAwait(false).GetAwaiter() 30 | .GetResult(); 31 | 32 | _service.AddWpfBlazorWebView(); 33 | 34 | #if DEBUG 35 | _service.AddBlazorWebViewDeveloperTools(); 36 | #endif 37 | 38 | _service.AddScoped(); 39 | 40 | var provider = _service.BuildServiceProvider(); 41 | 42 | provider.UseCoreFlexAsync().ConfigureAwait(false).GetAwaiter().GetResult(); 43 | Resources.Add("services", provider); 44 | 45 | GotraysWebView.RootComponents.Add(new RootComponent() 46 | { 47 | ComponentType = typeof(Main), 48 | Selector = "#app" 49 | }); 50 | 51 | Closing += MainWindow_Closing; 52 | 53 | } 54 | 55 | 56 | private void MainWindow_Closing(object sender, CancelEventArgs e) 57 | { 58 | e.Cancel = true; 59 | Hide(); 60 | } 61 | } -------------------------------------------------------------------------------- /src/Gotrays.Desktop/Services/WindowService.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using Gotrays.Contract.Services; 3 | using Size = System.Drawing.Size; 4 | 5 | namespace Gotrays.Desktop.Services; 6 | 7 | public class WindowService : IWindowService 8 | { 9 | public void SetWindowSize(Size size) 10 | { 11 | MainWindow.Windwo.Width = size.Width; 12 | MainWindow.Windwo.Height = size.Height; 13 | } 14 | 15 | public void SetWindowState(int state) 16 | { 17 | MainWindow.Windwo.WindowState = (WindowState)state; 18 | } 19 | 20 | public void SetWindowStartupLocation(int location) 21 | { 22 | MainWindow.Windwo.WindowStartupLocation = (WindowStartupLocation)location; 23 | } 24 | 25 | public void UpdateTitle(string title) 26 | { 27 | MainWindow.Windwo.Title = title; 28 | } 29 | } -------------------------------------------------------------------------------- /src/Gotrays.Desktop/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using Microsoft.AspNetCore.Components.Forms 3 | @using Microsoft.AspNetCore.Components.Routing 4 | @using Microsoft.AspNetCore.Components.Web 5 | @using Microsoft.AspNetCore.Components.Web.Virtualization 6 | @using Microsoft.JSInterop 7 | @using BlazorComponent 8 | @using Masa.Blazor 9 | @using Masa.Blazor.Presets 10 | @using System.Net.Http.Json 11 | @using System.IO; 12 | @using System.Text.Json; 13 | @using Gotrays.Rcl.Shared -------------------------------------------------------------------------------- /src/Gotrays.Desktop/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/239573049/Suspension/28d830e96ffe519d77da7762c93aed11ab55d91c/src/Gotrays.Desktop/favicon.ico -------------------------------------------------------------------------------- /src/Gotrays.Desktop/wwwroot/css/app.css: -------------------------------------------------------------------------------- 1 | #blazor-error-ui { 2 | background: lightyellow; 3 | bottom: 0; 4 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 5 | display: none; 6 | left: 0; 7 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 8 | position: fixed; 9 | width: 100%; 10 | z-index: 1000; 11 | } 12 | 13 | #blazor-error-ui .dismiss { 14 | cursor: pointer; 15 | position: absolute; 16 | right: 0.75rem; 17 | top: 0.5rem; 18 | } 19 | 20 | .blazor-error-boundary { 21 | background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121; 22 | padding: 1rem 1rem 1rem 3.7rem; 23 | color: white; 24 | } 25 | 26 | .blazor-error-boundary::after { 27 | content: "An error has occurred." 28 | } 29 | 30 | .status-bar-safe-area { 31 | display: none; 32 | } 33 | 34 | @supports (-webkit-touch-callout: none) { 35 | .status-bar-safe-area { 36 | display: flex; 37 | position: sticky; 38 | top: 0; 39 | height: env(safe-area-inset-top); 40 | background-color: #f7f7f7; 41 | width: 100%; 42 | z-index: 1; 43 | } 44 | 45 | .flex-column, .navbar-brand { 46 | padding-left: env(safe-area-inset-left); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Gotrays.Desktop/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/239573049/Suspension/28d830e96ffe519d77da7762c93aed11ab55d91c/src/Gotrays.Desktop/wwwroot/favicon.ico -------------------------------------------------------------------------------- /src/Gotrays.Desktop/wwwroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Gotrays.Desktop 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 |
Loading...
26 | 27 |
28 | An unhandled error has occurred. 29 | Reload 30 | 🗙 31 |
32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/Gotrays.Rcl/Components/About.razor: -------------------------------------------------------------------------------- 1 | 

Gotrays 客户端

2 |

Gotrays Suspension是open666的客户端智能助手,它基于Blazor实现基本UI功能,并使用Masa Blazor作为UI组件库。该客户端使用WPF作为Window执行平台。

3 |

当前版本: @Versions

4 |

开源地址:

5 |
    6 |
  • Gitee - Gotrays Suspension的开源地址,您可以在这里查看源代码、提交问题和贡献代码。
  • 7 |
  • GitHub - Gotrays Suspension的开源地址,您可以在这里查看源代码、提交问题和贡献代码。
  • 8 |
-------------------------------------------------------------------------------- /src/Gotrays.Rcl/Components/About.razor.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | namespace Gotrays.Rcl.Components; 4 | 5 | public partial class About 6 | { 7 | public string Versions { get; set; } 8 | 9 | protected override void OnInitialized() 10 | { 11 | Assembly assembly = typeof(About).Assembly; 12 | Versions = assembly.GetName().Version.ToString(); 13 | } 14 | } -------------------------------------------------------------------------------- /src/Gotrays.Rcl/Components/About.razor.css: -------------------------------------------------------------------------------- 1 |  2 | body { 3 | font-family: Arial, sans-serif; 4 | margin: 20px; 5 | text-align: center; 6 | } 7 | 8 | h1 { 9 | color: #333; 10 | } 11 | 12 | p { 13 | margin-bottom: 10px; 14 | } 15 | 16 | ul { 17 | list-style-type: none; 18 | padding: 0; 19 | } 20 | 21 | li { 22 | margin-bottom: 5px; 23 | } 24 | 25 | a { 26 | color: #007bff; 27 | text-decoration: none; 28 | } 29 | 30 | a:hover { 31 | text-decoration: underline; 32 | } 33 | -------------------------------------------------------------------------------- /src/Gotrays.Rcl/Components/AddChannel.razor: -------------------------------------------------------------------------------- 1 | @inject IChannelService ChannelService 2 | 3 | 10 | 11 | 12 | 17 | 18 | 19 | 24 | 25 | 26 | 31 | 32 | 33 | 38 | 39 | 40 | 45 | 46 | 47 | 54 | 55 | 56 | @if (exception != null) 57 | { 58 | 59 | @exception.Message 60 | 61 | } 62 | 63 | 64 | 65 | @code { 66 | 67 | readonly List model = new() { "gpt-3.5-turbo", "gpt-4", "gpt-4-1106-preview", "gpt-4-vision-preview" }; 68 | 69 | private ChannelDto ChannelDto = new(); 70 | 71 | [Parameter] 72 | public bool Value { get; set; } 73 | 74 | [Parameter] 75 | public EventCallback ValueChanged { get; set; } 76 | 77 | [Parameter] 78 | public EventCallback OnSucceed { get; set; } 79 | 80 | private bool throwException; 81 | private Exception exception; 82 | 83 | private async Task HandleOnSave(ModalActionEventArgs args) 84 | { 85 | try 86 | { 87 | await ChannelService.AddAsync(ChannelDto); 88 | ChannelDto = new ChannelDto(); 89 | await ValueChanged.InvokeAsync(false); 90 | await OnSucceed.InvokeAsync(); 91 | } 92 | catch (Exception e) 93 | { 94 | args.Cancel(); 95 | exception = e; 96 | } 97 | } 98 | 99 | private async Task HandleOnCancel() 100 | { 101 | await ValueChanged.InvokeAsync(false); 102 | exception = null; 103 | ChannelDto = new ChannelDto(); 104 | } 105 | 106 | } -------------------------------------------------------------------------------- /src/Gotrays.Rcl/Components/BuyAProduct.razor: -------------------------------------------------------------------------------- 1 | @inject IChatProductService ChatProductService 2 | @inject GotraysInterop GotraysInterop 3 | @inject IPayService PayService 4 | 5 | @foreach (var data in Values) 6 | { 7 | 8 | 9 | 10 | 11 | @data.Name 12 | 13 | 14 |
15 | @data.ActualPrice 16 |
17 |
18 | @data.OriginalPrice 19 |
20 | @((MarkupString)string.Join("
", data.Description.Split(","))) 21 |
22 |
23 |
24 | 25 | 购买 26 | 27 |
28 | } 29 | 30 | @if (payment) 31 | { 32 | 37 |
38 | 39 |
40 |
41 | } -------------------------------------------------------------------------------- /src/Gotrays.Rcl/Components/BuyAProduct.razor.cs: -------------------------------------------------------------------------------- 1 | using Gotrays.Contract.Dtos.Products; 2 | using GotraysService.Contracts.Dtos.Products; 3 | 4 | namespace Gotrays.Rcl.Components; 5 | 6 | public partial class BuyAProduct 7 | { 8 | private bool payment; 9 | 10 | private List Values = new(); 11 | 12 | protected override async Task OnInitializedAsync() 13 | { 14 | Values = await ChatProductService.GetListAsync(); 15 | } 16 | 17 | private async Task BuyAsync(GetProductListDto item) 18 | { 19 | payment = true; 20 | 21 | var result = await PayService.StartPayAsync(new StartPayPayload() 22 | { 23 | ProductId = item.Id, 24 | }); 25 | 26 | await GotraysInterop.QrCode("qr-code", result.qr); 27 | } 28 | } -------------------------------------------------------------------------------- /src/Gotrays.Rcl/Components/ChatMessage.razor: -------------------------------------------------------------------------------- 1 | @inject IChatMessageService ChatMessageService 2 | @inject IChatService ChatService 3 | @inject GotraysInterop GotraysInterop 4 | @inject IPopupService PopupService 5 | @inject IUserService UserService 6 | @inject IKeyLoadEventBus KeyLoadEventBus 7 | 8 |
9 |
10 | @_selectChannel?.Title 11 | 模型:@_selectChannel?.Model 12 | 13 | 剩余token: 14 | @token 15 | 16 |
17 |
18 | @foreach (var chatMessage in _chatMessages) 19 | { 20 |
21 | @chatMessage.CreatedTime.ToString("yyyy-MM-dd HH:mm:ss") 22 |
23 |
24 |
25 | 26 | 27 | 28 |
29 |
30 | 31 |
32 |
33 | 34 | 36 | 37 | 38 | mdi-dots-vertical 39 | 40 | 41 | 42 |
43 | 复制 44 |
45 |
46 | 删除 47 |
48 |
49 | 编辑 50 |
51 |
52 |
53 |
54 |
55 | } 56 |
57 | 58 | 63 |
-------------------------------------------------------------------------------- /src/Gotrays.Rcl/Components/ChatMessage.razor.cs: -------------------------------------------------------------------------------- 1 | using BlazorComponent; 2 | using Gotrays.Contract.Dtos.Chats; 3 | using Gotrays.Contract.Dtos.Users; 4 | using Gotrays.Shared; 5 | using Masa.Blazor.Presets; 6 | using Microsoft.AspNetCore.Components; 7 | using Microsoft.AspNetCore.Components.Web; 8 | using Microsoft.JSInterop; 9 | 10 | namespace Gotrays.Rcl.Components; 11 | 12 | public partial class ChatMessage : IDisposable 13 | { 14 | private ChannelDto _selectChannel; 15 | 16 | private string Id; 17 | 18 | /// 19 | /// 当前token数量 20 | /// 21 | private int token; 22 | 23 | [CascadingParameter(Name = nameof(GetUserDto))] 24 | public GetUserDto userDto { get; set; } 25 | 26 | [CascadingParameter(Name = nameof(SelectChannel))] 27 | public ChannelDto SelectChannel 28 | { 29 | get => _selectChannel; 30 | set 31 | { 32 | if (value == null) 33 | { 34 | _selectChannel = null; 35 | return; 36 | } 37 | 38 | if (_selectChannel == value) 39 | { 40 | return; 41 | } 42 | 43 | _chatMessages.Clear(); 44 | _page = 1; 45 | _selectChannel = value; 46 | _ = LoadMessage(_selectChannel.Id); 47 | } 48 | } 49 | 50 | private List _chatMessages = new(); 51 | 52 | private DotNetObjectReference _dotNet; 53 | 54 | private int _page = 1; 55 | 56 | private int _pageSize = 6; 57 | 58 | private string _value; 59 | 60 | private async Task LoadMessage(Guid channelId) 61 | { 62 | var result = await ChatMessageService.GetListAsync(channelId, _page++, _pageSize); 63 | foreach (var messageDto in result) 64 | { 65 | InitEvent(messageDto); 66 | } 67 | 68 | _chatMessages.InsertRange(0, result); 69 | 70 | // 如果数据为空则不进行分页递增 71 | if (result.Count == 0) 72 | { 73 | _page--; 74 | } 75 | } 76 | 77 | private void InitEvent(ChatMessageDto messageDto) 78 | { 79 | messageDto.OnCopy += async () => { await Copy(messageDto); }; 80 | 81 | messageDto.OnDelete += async () => { await Delete(messageDto); }; 82 | 83 | messageDto.OnUpdate += async () => { await Update(messageDto); }; 84 | } 85 | 86 | private async Task Update(ChatMessageDto messageDto) 87 | { 88 | } 89 | 90 | private async Task Delete(ChatMessageDto messageDto) 91 | { 92 | await ChatMessageService.DeleteAsync(messageDto.Id); 93 | 94 | _chatMessages.Remove(messageDto); 95 | await PopupService.EnqueueSnackbarAsync(new SnackbarOptions("删除成功!", AlertTypes.Success)); 96 | } 97 | 98 | private async Task Copy(ChatMessageDto messageDto) 99 | { 100 | await GotraysInterop.CopyText(messageDto.Message); 101 | await PopupService.EnqueueSnackbarAsync(new SnackbarOptions("复制成功!", AlertTypes.Success)); 102 | } 103 | 104 | private async Task OnMousedown(KeyboardEventArgs e) 105 | { 106 | if (e is { ShiftKey: false, Key: "Enter" }) 107 | { 108 | await OnSendAsync(); 109 | } 110 | } 111 | 112 | private async Task OnSendAsync() 113 | { 114 | if (_value.IsNullOrWhiteSpace()) 115 | { 116 | return; 117 | } 118 | 119 | var curren = new ChatMessageDto() 120 | { 121 | Id = Guid.NewGuid(), 122 | Message = _value, 123 | Curren = true, 124 | CreatedTime = DateTime.Now, 125 | ChannelId = SelectChannel.Id, 126 | Type = ChatMessageType.Text, 127 | }; 128 | 129 | InitEvent(curren); 130 | 131 | _chatMessages.Add(curren); 132 | 133 | await ChatMessageService.CreateAsync(curren); 134 | 135 | _value = string.Empty; 136 | 137 | var chatAi = new ChatMessageDto() 138 | { 139 | Id = Guid.NewGuid(), 140 | Message = string.Empty, 141 | CreatedTime = DateTime.Now, 142 | ChannelId = curren.ChannelId, 143 | Type = curren.Type, 144 | Curren = false, 145 | }; 146 | 147 | InitEvent(chatAi); 148 | 149 | _chatMessages.Add(chatAi); 150 | 151 | var input = new ChatCompletionDto() 152 | { 153 | model = SelectChannel.Model, 154 | temperature = 0, 155 | top_p = 0, 156 | }; 157 | 158 | // 如果角色设定不为空则添加到消息 159 | if (!SelectChannel.Role.IsNullOrWhiteSpace()) 160 | { 161 | input.messages.Add(new ChatCompletionRequestMessage() 162 | { 163 | name = "system", 164 | content = SelectChannel.Role, 165 | role = "system" 166 | }); 167 | } 168 | 169 | if (SelectChannel.MaxHistory > 0) 170 | { 171 | input.messages.AddRange(_chatMessages.Skip(Math.Max(0, _chatMessages.Count - SelectChannel.MaxHistory)) 172 | .Select(x => new ChatCompletionRequestMessage 173 | { 174 | role = x.Curren ? "user" : "assistant", 175 | name = x.Curren ? "user" : "assistant", 176 | content = x.Message 177 | })); 178 | } 179 | 180 | // 将自己发送内容添加到消息 181 | input.messages.Add(new ChatCompletionRequestMessage() 182 | { 183 | name = "user", 184 | content = curren.Message, 185 | role = "user" 186 | }); 187 | 188 | await GotraysInterop.ScrollBottom(Id); 189 | 190 | await ChatService.ChatAsync(input, async message => 191 | { 192 | chatAi.Message += message + Environment.NewLine; 193 | _ = InvokeAsync(StateHasChanged); 194 | await GotraysInterop.ScrollBottom(Id); 195 | }); 196 | 197 | await ChatMessageService.CreateAsync(chatAi); 198 | 199 | await GetToken(); 200 | } 201 | 202 | private async Task GetToken() 203 | { 204 | var result = await UserService.GetDayDosageAsync(); 205 | 206 | token = result.free + result.money; 207 | _ = InvokeAsync(StateHasChanged); 208 | } 209 | 210 | private string GetChatMessageClass(ChatMessageDto chatMessage) 211 | { 212 | if (chatMessage.Curren) 213 | { 214 | return "self"; 215 | } 216 | 217 | return ""; 218 | } 219 | 220 | protected override void OnInitialized() 221 | { 222 | _dotNet = DotNetObjectReference.Create(this); 223 | Id = Guid.NewGuid().ToString("N"); 224 | KeyLoadEventBus.Subscription(Constant.LoadEventBus.Notifications, (async o => 225 | { 226 | if (o is string str) 227 | { 228 | await PopupService.EnqueueSnackbarAsync(new SnackbarOptions(str, AlertTypes.Info)); 229 | } 230 | })); 231 | } 232 | 233 | [JSInvokable("OnScroll")] 234 | public async Task OnScroll(int scrollTop) 235 | { 236 | if (scrollTop == 0) 237 | { 238 | await LoadMessage(_selectChannel.Id); 239 | _ = InvokeAsync(StateHasChanged); 240 | } 241 | } 242 | 243 | public async Task ClearAsync() 244 | { 245 | _page = 1; 246 | _chatMessages.Clear(); 247 | await LoadMessage(_selectChannel.Id); 248 | } 249 | 250 | 251 | protected override async Task OnAfterRenderAsync(bool firstRender) 252 | { 253 | if (firstRender) 254 | { 255 | _ = Task.Run(async () => 256 | { 257 | await Task.Delay(500); 258 | 259 | await GotraysInterop.OnScroll(Id, _dotNet, nameof(OnScroll)); 260 | 261 | await GotraysInterop.ScrollBottom(Id); 262 | }); 263 | await GetToken(); 264 | } 265 | } 266 | 267 | public void Dispose() 268 | { 269 | _dotNet.Dispose(); 270 | KeyLoadEventBus.Remove(Constant.LoadEventBus.Notifications); 271 | } 272 | } -------------------------------------------------------------------------------- /src/Gotrays.Rcl/Components/PurchaseHistory.razor: -------------------------------------------------------------------------------- 1 | @using Gotrays.Contract.Dtos.Pays 2 | @inject IPayService PayService 3 | 4 | 5 | 11 | 12 | -------------------------------------------------------------------------------- /src/Gotrays.Rcl/Components/PurchaseHistory.razor.cs: -------------------------------------------------------------------------------- 1 | using BlazorComponent; 2 | using Gotrays.Contract.Dtos.Pays; 3 | using Masa.Utils.Models; 4 | 5 | namespace Gotrays.Rcl.Components; 6 | 7 | public partial class PurchaseHistory 8 | { 9 | private List> _headers = new List> 10 | { 11 | new () 12 | { 13 | Text= "用户名", 14 | Value= nameof(ProductListDto.UserName) 15 | }, 16 | new (){ Text= "支付平台", Value= nameof(ProductListDto.PayType)}, 17 | new (){ Text= "产品名称", Value= nameof(ProductListDto.ProductName)}, 18 | new (){ Text= "原价", Value= nameof(ProductListDto.OriginalPrice)}, 19 | new (){ Text= "实际支付价格", Value= nameof(ProductListDto.ActualPayment)}, 20 | new (){ Text= "支付状态", Value= nameof(ProductListDto.PayState)}, 21 | new (){ Text= "支付时间", Value= nameof(ProductListDto.CreationTime)} 22 | }; 23 | 24 | private PaginatedListBase Items = new(); 25 | 26 | private int Page = 1; 27 | 28 | protected override async Task OnInitializedAsync() 29 | { 30 | await LoadAsync(); 31 | } 32 | 33 | private async Task LoadAsync() 34 | { 35 | Items = await PayService.PayHistoryAsync(Page, 10); 36 | } 37 | 38 | private async Task ValueChanged(int page) 39 | { 40 | Page = page; 41 | await LoadAsync(); 42 | } 43 | 44 | private int GetLength() 45 | { 46 | return (int)Math.Ceiling((double)Items.Total / 10); 47 | } 48 | } -------------------------------------------------------------------------------- /src/Gotrays.Rcl/Components/UpdateChannel.razor: -------------------------------------------------------------------------------- 1 | @inject IChannelService ChannelService 2 | 3 | 10 | 11 | 12 | 17 | 18 | 19 | 24 | 25 | 26 | 31 | 32 | 33 | 38 | 39 | 40 | 45 | 46 | 47 | 54 | 55 | @if (exception != null) 56 | { 57 | 58 | @exception.Message 59 | 60 | } 61 | 62 | 63 | 64 | @code { 65 | 66 | readonly List model = new() { "gpt-3.5-turbo", "gpt-4", "gpt-4-1106-preview","gpt-4-vision-preview"}; 67 | 68 | [Parameter] 69 | public ChannelDto ChannelDto { get; set; } 70 | 71 | [Parameter] 72 | public bool Value { get; set; } 73 | 74 | [Parameter] 75 | public EventCallback ValueChanged { get; set; } 76 | 77 | [Parameter] 78 | public EventCallback OnSucceed { get; set; } 79 | 80 | private bool throwException; 81 | private Exception exception; 82 | 83 | private async Task HandleOnSave(ModalActionEventArgs args) 84 | { 85 | try 86 | { 87 | await ChannelService.UpdateAsync(ChannelDto); 88 | await ValueChanged.InvokeAsync(false); 89 | await OnSucceed.InvokeAsync(); 90 | } 91 | catch (Exception e) 92 | { 93 | args.Cancel(); 94 | exception = e; 95 | } 96 | } 97 | 98 | private async Task HandleOnCancel() 99 | { 100 | await ValueChanged.InvokeAsync(false); 101 | exception = null; 102 | } 103 | 104 | } -------------------------------------------------------------------------------- /src/Gotrays.Rcl/Components/UpdateVersion.razor: -------------------------------------------------------------------------------- 1 | @inject IHttpClientFactory HttpClientFactory; 2 | @inject IPopupService PopupService 3 | 4 | 8 | 9 | 10 |

@GiteeReleaseDto.tag_name

11 |
12 | @GiteeReleaseDto.body 13 |
14 |
15 | @if (Update) 16 | { 17 | 18 | @($"{context}%") 19 | 20 | } 21 | 22 | 更新 23 | 24 |
-------------------------------------------------------------------------------- /src/Gotrays.Rcl/Components/UpdateVersion.razor.cs: -------------------------------------------------------------------------------- 1 | using System.Buffers; 2 | using System.Diagnostics; 3 | using BlazorComponent; 4 | using Gotrays.Contract.Dtos.Systems; 5 | using Masa.Blazor; 6 | using Microsoft.AspNetCore.Components; 7 | 8 | namespace Gotrays.Rcl.Components; 9 | 10 | public partial class UpdateVersion 11 | { 12 | [Parameter] public bool Value { get; set; } 13 | 14 | [Parameter] public EventCallback ValueChanged { get; set; } 15 | 16 | /// 17 | /// 新版本信息 18 | /// 19 | [Parameter] 20 | public GiteeReleaseDto GiteeReleaseDto { get; set; } 21 | 22 | public double skill { get; set; } 23 | 24 | /// 25 | /// 是否更新 26 | /// 27 | public bool Update { get; set; } 28 | 29 | private async Task UpdateAsync() 30 | { 31 | Update = true; 32 | var client = HttpClientFactory.CreateClient(nameof(UpdateVersion)); 33 | 34 | var download = GiteeReleaseDto.assets.FirstOrDefault(); 35 | var response = await client.GetAsync(download.browser_download_url, 36 | HttpCompletionOption.ResponseHeadersRead); 37 | 38 | var path = Path.Combine(AppContext.BaseDirectory, "Update_" + download.name); 39 | 40 | try 41 | { 42 | await PopupService.EnqueueSnackbarAsync("正在更新", AlertTypes.Success); 43 | 44 | var totalBytes = response.Content.Headers.ContentLength.GetValueOrDefault(); 45 | 46 | await using var stream = await response.Content.ReadAsStreamAsync(); 47 | 48 | // 保证下载的是可执行程序 49 | await using var fileStream = new FileStream(path, FileMode.Create, 50 | FileAccess.Write, FileShare.None, 8192, true); 51 | 52 | var totalReadBytes = 0L; 53 | var buffer = new byte[8192]; 54 | var isMoreToRead = true; 55 | do 56 | { 57 | var read = await stream.ReadAsync(buffer, 0, buffer.Length); 58 | if (read == 0) 59 | { 60 | isMoreToRead = false; 61 | } 62 | else 63 | { 64 | await fileStream.WriteAsync(buffer, 0, read); 65 | 66 | totalReadBytes += read; 67 | skill = (int)((double)totalReadBytes / totalBytes * 100); 68 | 69 | _ = InvokeAsync(StateHasChanged); 70 | } 71 | } while (isMoreToRead); 72 | 73 | fileStream.Close(); 74 | 75 | // 创建一个新的进程对象 76 | Process process = new Process(); 77 | 78 | try 79 | { 80 | // 设置进程的启动信息 81 | process.StartInfo.FileName = path; 82 | 83 | // 启动进程 84 | process.Start(); 85 | } 86 | catch (Exception ex) 87 | { 88 | Console.WriteLine("启动进程时出错:" + ex.Message); 89 | } 90 | finally 91 | { 92 | // 释放进程资源 93 | process.Dispose(); 94 | } 95 | 96 | await Task.Delay(3000); 97 | Environment.Exit(0); 98 | } 99 | finally 100 | { 101 | } 102 | } 103 | } -------------------------------------------------------------------------------- /src/Gotrays.Rcl/GlobalUsing.cs: -------------------------------------------------------------------------------- 1 | global using CoreFlex.Module; -------------------------------------------------------------------------------- /src/Gotrays.Rcl/Gotrays.Rcl.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/Gotrays.Rcl/GotraysAuthenticationStateProvider.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components.Authorization; 2 | using System.Security.Claims; 3 | using Gotrays.Contract.Services; 4 | using Gotrays.Shared; 5 | 6 | namespace Gotrays.Rcl; 7 | 8 | public class GotraysAuthenticationStateProvider : AuthenticationStateProvider 9 | { 10 | private readonly IStorageService _storageService; 11 | 12 | public GotraysAuthenticationStateProvider(IStorageService storageService) 13 | { 14 | _storageService = storageService; 15 | } 16 | 17 | private ClaimsPrincipal User { get; set; } 18 | 19 | public override Task GetAuthenticationStateAsync() 20 | { 21 | if (User != null) 22 | { 23 | return Task.FromResult(new AuthenticationState(User)); 24 | } 25 | 26 | var token = _storageService.Get(Constant.HttpClientOptions.Token); 27 | 28 | var identity = new ClaimsIdentity(); 29 | User = new ClaimsPrincipal(identity); 30 | if (!token.IsNullOrWhiteSpace()) 31 | { 32 | identity.AddClaim(new Claim(ClaimTypes.Name, "token")); 33 | NotifyAuthenticationStateChanged( 34 | Task.FromResult(new AuthenticationState(User))); 35 | return Task.FromResult(new AuthenticationState(User)); 36 | } 37 | 38 | return Task.FromResult(new AuthenticationState(new ClaimsPrincipal())); 39 | 40 | } 41 | 42 | public void AuthenticateUser(string token) 43 | { 44 | var identity = new ClaimsIdentity(new[] 45 | { 46 | new Claim(ClaimTypes.Name, "token"), 47 | }, "GotraysAuthentication"); 48 | 49 | User = new ClaimsPrincipal(identity); 50 | 51 | NotifyAuthenticationStateChanged( 52 | Task.FromResult(new AuthenticationState(User))); 53 | } 54 | } -------------------------------------------------------------------------------- /src/Gotrays.Rcl/GotraysRclModule.cs: -------------------------------------------------------------------------------- 1 | using BlazorComponent; 2 | using Gotrays.Contract; 3 | using Microsoft.AspNetCore.Components.Authorization; 4 | using Microsoft.Extensions.DependencyInjection; 5 | using Microsoft.Extensions.DependencyInjection.Extensions; 6 | using Token.Extensions; 7 | 8 | namespace Gotrays.Rcl; 9 | 10 | [DependOns(typeof(GotraysContractModule))] 11 | public class GotraysRclModule : CoreFlexModule 12 | { 13 | public override void ConfigureServices(CoreFlexServiceContext context) 14 | { 15 | context.Services.AddMasaBlazor(options => { options.Locale = new Locale("zh-CN", "en-US"); }); 16 | context.Services.AddAuthorizationCore(); 17 | context.Services.TryAddSingleton(); 18 | 19 | context.Services.AddEventBus(); 20 | } 21 | 22 | public override void OnApplicationShutdown(CoreFlexBuilder app) 23 | { 24 | RclContext.SetServiceProvider(app.Services); 25 | } 26 | } -------------------------------------------------------------------------------- /src/Gotrays.Rcl/Interops/GotraysInterop.cs: -------------------------------------------------------------------------------- 1 | using BlazorComponent.JSInterop; 2 | using Microsoft.JSInterop; 3 | 4 | namespace Gotrays.Rcl.Interops; 5 | 6 | public class GotraysInterop : JSModule, IScopedDependency 7 | { 8 | public GotraysInterop(IJSRuntime js) : base(js, "/_content/Gotrays.Rcl/js/gotrays.js") 9 | { 10 | } 11 | 12 | public async ValueTask CopyText(string text) 13 | { 14 | await InvokeVoidAsync("copyText", text); 15 | } 16 | 17 | public async ValueTask QrCode(string id, string code) 18 | { 19 | await InvokeVoidAsync("qrCode", id, code); 20 | } 21 | 22 | public async ValueTask OnScroll(string id, DotNetObjectReference dotNet, string name) where T : class 23 | { 24 | await InvokeVoidAsync("onScroll", id, dotNet, name); 25 | } 26 | 27 | public async ValueTask ScrollBottom(string id) 28 | { 29 | await InvokeVoidAsync("scrollBottom", id); 30 | } 31 | } -------------------------------------------------------------------------------- /src/Gotrays.Rcl/Interops/JsEventBusInterop.cs: -------------------------------------------------------------------------------- 1 | using Gotrays.Shared; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using Microsoft.JSInterop; 4 | using Token.Events; 5 | 6 | namespace Gotrays.Rcl; 7 | 8 | public class JsEventBusInterop 9 | { 10 | [JSInvokable] 11 | public static async Task Notifications(string message) 12 | { 13 | var eventBus = RclContext.ServiceProvider.GetService(); 14 | 15 | await eventBus.PushAsync(Constant.LoadEventBus.Notifications, message); 16 | } 17 | 18 | /// 19 | /// base64编码 20 | /// 21 | /// 22 | /// 23 | [JSInvokable] 24 | public static string Base64Encode(string plainText) 25 | { 26 | byte[] plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText); 27 | return Convert.ToBase64String(plainTextBytes); 28 | } 29 | 30 | /// 31 | /// base64解码 32 | /// 33 | /// 34 | /// 35 | [JSInvokable] 36 | public static string Base64Decode(string base64EncodedText) 37 | { 38 | byte[] base64EncodedBytes = Convert.FromBase64String(base64EncodedText); 39 | return System.Text.Encoding.UTF8.GetString(base64EncodedBytes); 40 | } 41 | } -------------------------------------------------------------------------------- /src/Gotrays.Rcl/Main.razor: -------------------------------------------------------------------------------- 1 | @using System.Security.Claims 2 | @inject AuthenticationStateProvider AuthenticationStateProvider 3 | @inject NavigationManager NavigationManager 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |

Sorry, there's nothing at this address.

20 |
21 |
22 |
23 |
24 | @code { 25 | 26 | protected override async Task OnInitializedAsync() 27 | { 28 | var result = await AuthenticationStateProvider.GetAuthenticationStateAsync(); 29 | if (!result.User.Claims.Any()) 30 | { 31 | NavigationManager.NavigateTo("/pages/login"); 32 | } 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /src/Gotrays.Rcl/Pages/Authentication/Login.razor: -------------------------------------------------------------------------------- 1 | @page "/pages/login" 2 | @inject IUserService UserService 3 | @inject AuthenticationStateProvider AuthenticationStateProvider 4 | @layout EmptyLayout 5 | @inject NavigationManager NavigationManager 6 | @inject IWindowService WindowService 7 | 8 | 9 |
10 | 11 |
12 |
13 | 14 | 15 | 16 | 17 | 18 |
欢迎使用TokenAI 👋
19 | 20 | 25 | 26 | 34 | 35 | 36 | 忘记密码? 37 | 38 | 登录 39 | 40 |
41 | 没用账号?   42 | 注册账号 43 |
44 |
45 |
46 | 47 |
48 |
-------------------------------------------------------------------------------- /src/Gotrays.Rcl/Pages/Authentication/Login.razor.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | using Gotrays.Contract.Dtos.Auth; 3 | 4 | namespace Gotrays.Rcl.Pages.Authentication; 5 | 6 | public partial class Login 7 | { 8 | private bool _show; 9 | 10 | private LoginPayload _payload = new (); 11 | 12 | protected override void OnInitialized() 13 | { 14 | WindowService.UpdateTitle("登录页面"); 15 | } 16 | 17 | private async Task OnLogin() 18 | { 19 | var result = await UserService.Login(_payload); 20 | 21 | if (!result.IsNullOrWhiteSpace()) 22 | { 23 | ((GotraysAuthenticationStateProvider)AuthenticationStateProvider).AuthenticateUser(result); 24 | NavigationManager.NavigateTo("/"); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /src/Gotrays.Rcl/Pages/Index.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 | @inject IChatMessageService ChatMessageService 4 | @inject IChannelService ChannelService 5 | @layout MainLayout 6 | 7 | 8 |
9 | 10 | 11 | 16 | 17 | 18 | 20 | @foreach (var item in _channels) 21 | { 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | @item.Title 30 | 31 | 32 | 33 | 35 | 36 | 37 | mdi-dots-vertical 38 | 39 | 40 | 41 | 42 | 43 | 删除 44 | 45 | 46 | 清空 47 | 48 | 49 | 编辑 50 | 51 | 52 | 53 | 54 | 55 | 56 | } 57 | 58 | 59 |
60 |
61 | 62 |
63 | 64 | 65 |
-------------------------------------------------------------------------------- /src/Gotrays.Rcl/Pages/Index.razor.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using BlazorComponent; 3 | using Gotrays.Contract.Dtos.Chats; 4 | using Gotrays.Contract.Dtos.Systems; 5 | using Gotrays.Rcl.Components; 6 | 7 | namespace Gotrays.Rcl.Pages; 8 | 9 | public partial class Index 10 | { 11 | private List _channels = new(); 12 | 13 | public ChannelDto UpdateChannelDto { get; set; } 14 | 15 | 16 | private StringNumber _selectedItem; 17 | 18 | private ChatMessage ChatMessage; 19 | 20 | private bool addChannel; 21 | private bool updateChannel; 22 | private bool updateVersion; 23 | private StringNumber SelectedItem 24 | { 25 | get => _selectedItem; 26 | set 27 | { 28 | _selectedItem = value; 29 | if (_selectedItem != null) 30 | { 31 | SelectChannel = _channels.FirstOrDefault(x => x.Id.ToString() == value.ToString()); 32 | } 33 | else 34 | { 35 | _selectedItem = _channels.FirstOrDefault()?.Id.ToString(); 36 | } 37 | } 38 | } 39 | 40 | private ChannelDto SelectChannel; 41 | 42 | private string _search = string.Empty; 43 | 44 | private async Task SearchChanged(string search) 45 | { 46 | _search = search; 47 | await LoadChannel(); 48 | } 49 | 50 | protected override async Task OnInitializedAsync() 51 | { 52 | await LoadChannel(); 53 | 54 | if (_channels.Count == 0) 55 | { 56 | var dto = new ChannelDto() 57 | { 58 | Id = Guid.NewGuid(), 59 | Title = "智能助手", 60 | Role = string.Empty, 61 | CreatedTime = DateTime.Now, 62 | Sort = 0, 63 | Model = "gpt-3.5-turbo", 64 | Description = "默认创建的频道", 65 | MaxHistory = 0, 66 | }; 67 | await ChannelService.AddAsync(dto); 68 | _channels.Add(dto); 69 | } 70 | 71 | SelectedItem = _channels.FirstOrDefault()?.Id.ToString(); 72 | } 73 | 74 | private void CreateAsync() 75 | { 76 | addChannel = true; 77 | } 78 | 79 | private async Task LoadChannel() 80 | { 81 | _channels = await ChannelService.GetListAsync(_search); 82 | 83 | SelectedItem = _channels.FirstOrDefault()?.Id.ToString(); 84 | } 85 | 86 | private async Task DeleteChannel(Guid id) 87 | { 88 | if (_channels.Count == 1) 89 | { 90 | return; 91 | } 92 | await ChannelService.DeleteAsync(id); 93 | await LoadChannel(); 94 | } 95 | 96 | private void UpdateChannel(ChannelDto item) 97 | { 98 | UpdateChannelDto = (ChannelDto)item.Clone(); 99 | updateChannel = true; 100 | } 101 | 102 | private async Task ClearChannel(Guid id) 103 | { 104 | await ChatMessageService.DeleteAsync(id); 105 | await ChatMessage.ClearAsync(); 106 | } 107 | } -------------------------------------------------------------------------------- /src/Gotrays.Rcl/Pages/Shopping.razor: -------------------------------------------------------------------------------- 1 | @page "/pages/shopping" 2 | @layout MainLayout 3 |
4 | 5 | 9 | 购买产品 10 | 购买记录 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
-------------------------------------------------------------------------------- /src/Gotrays.Rcl/Pages/Shopping.razor.css: -------------------------------------------------------------------------------- 1 |  2 | .rcl-body { 3 | margin-left: 55px; /* 左边和中间栏的宽度总和 */ 4 | background-color: #e8e8e8; 5 | height: 100vh; 6 | } -------------------------------------------------------------------------------- /src/Gotrays.Rcl/Pages/System/Setting.razor: -------------------------------------------------------------------------------- 1 | @page "/pages/Setting" 2 | @layout MainLayout 3 |
4 | 5 | 6 | 关于 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
-------------------------------------------------------------------------------- /src/Gotrays.Rcl/Pages/System/Setting.razor.cs: -------------------------------------------------------------------------------- 1 | using BlazorComponent; 2 | 3 | namespace Gotrays.Rcl.Pages.System; 4 | 5 | public partial class Setting 6 | { 7 | 8 | StringNumber tab; 9 | } 10 | -------------------------------------------------------------------------------- /src/Gotrays.Rcl/Pages/System/Setting.razor.css: -------------------------------------------------------------------------------- 1 |  2 | .rcl-body { 3 | margin-left: 55px; /* 左边和中间栏的宽度总和 */ 4 | background-color: #e8e8e8; 5 | height: 100vh; 6 | } -------------------------------------------------------------------------------- /src/Gotrays.Rcl/RclContext.cs: -------------------------------------------------------------------------------- 1 | namespace Gotrays.Rcl; 2 | 3 | public class RclContext 4 | { 5 | private static IServiceProvider _serviceProvider; 6 | 7 | public static IServiceProvider ServiceProvider => _serviceProvider; 8 | 9 | public static void SetServiceProvider(IServiceProvider serviceProvider) 10 | { 11 | _serviceProvider = serviceProvider; 12 | } 13 | } -------------------------------------------------------------------------------- /src/Gotrays.Rcl/Shared/EmptyLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 | 4 | 5 | @Body 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/Gotrays.Rcl/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @using Gotrays.Contract.Dtos.Users 2 | @inherits LayoutComponentBase 3 | @inject IUserService UserService 4 | @inject IWindowService WindowService 5 | @inject IAppService AppService 6 | @inject NavigationManager NavigationManager 7 | @inject AuthenticationStateProvider AuthenticationStateProvider 8 | 9 | 10 | 11 |
12 |
13 |
14 | 15 | 16 | 17 | 23 | mdi-chat-processing-outline 24 | 25 | 31 | mdi-shopping-outline 32 | 33 |
34 |
35 | 40 | mdi-cog-outline 41 | 42 |
43 | 44 |
45 | 46 | @Body 47 | 48 |
49 | 50 |
51 | 52 |
-------------------------------------------------------------------------------- /src/Gotrays.Rcl/Shared/MainLayout.razor.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | using System.Reflection; 3 | using System.Security.Claims; 4 | using Gotrays.Contract.Dtos.Chats; 5 | using Gotrays.Contract.Dtos.Systems; 6 | using Gotrays.Contract.Dtos.Users; 7 | using Gotrays.Rcl.Components; 8 | 9 | namespace Gotrays.Rcl.Shared; 10 | 11 | public partial class MainLayout 12 | { 13 | private GetUserDto userDto; 14 | 15 | private string currentMenuId = Home; 16 | 17 | private const string Home = "/"; 18 | 19 | private const string Setting = "/pages/Setting"; 20 | 21 | private const string Shopping = "/pages/shopping"; 22 | 23 | public GiteeReleaseDto GiteeReleaseDto { get; set; } 24 | private bool updateVersion; 25 | 26 | protected override async Task OnInitializedAsync() 27 | { 28 | WindowService.UpdateTitle("智能聊天首页"); 29 | await UpdateAsync(); 30 | WindowService.SetWindowSize(new Size(1080, 720)); 31 | var result = await AuthenticationStateProvider.GetAuthenticationStateAsync(); 32 | 33 | // 当登录才获取信息 34 | if (result.User.Claims.Any(x => x.Type == ClaimTypes.Name)) 35 | userDto = await UserService.GetAsync(); 36 | } 37 | 38 | private async Task UpdateAsync() 39 | { 40 | try 41 | { 42 | GiteeReleaseDto = await AppService.GetApp(); 43 | 44 | if (GiteeReleaseDto.tag_name != typeof(About).Assembly.GetName().Version.ToString()) 45 | { 46 | updateVersion = true; 47 | await InvokeAsync(StateHasChanged); 48 | } 49 | } 50 | catch (Exception e) 51 | { 52 | // TODO: Gitee的Api可能存在限流不一定每次都获取成功 53 | } 54 | } 55 | 56 | private void SelectMenu(string id) 57 | { 58 | if (id == currentMenuId) 59 | { 60 | return; 61 | } 62 | 63 | currentMenuId = id; 64 | 65 | NavigationManager.NavigateTo(id); 66 | } 67 | 68 | private string GetClass(string id) 69 | { 70 | if (id == currentMenuId) 71 | { 72 | return "rcl-menu-select"; 73 | } 74 | 75 | return ""; 76 | } 77 | } -------------------------------------------------------------------------------- /src/Gotrays.Rcl/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Components.Web 2 | @using Microsoft.AspNetCore.Components.Forms 3 | @using Microsoft.AspNetCore.Components.Routing 4 | @using Microsoft.AspNetCore.Components.Web.Virtualization 5 | @using Microsoft.JSInterop 6 | @using BlazorComponent 7 | @using Masa.Blazor 8 | @using Gotrays.Rcl.Shared 9 | @using Gotrays.Contract.Services 10 | @using Masa.Blazor.Presets 11 | @using Microsoft.AspNetCore.Authorization 12 | @using Microsoft.AspNetCore.Components.Authorization 13 | @using Gotrays.Rcl.Components 14 | @using Gotrays.Rcl.Interops 15 | @using Token.Events 16 | @using Gotrays.Contract.Dtos.Chats 17 | -------------------------------------------------------------------------------- /src/Gotrays.Rcl/wwwroot/css/gotrays.rcl.css: -------------------------------------------------------------------------------- 1 | * { 2 | box-sizing: border-box; 3 | } 4 | 5 | html { 6 | overflow: hidden; 7 | } 8 | 9 | body { 10 | margin: 0; 11 | padding: 0; 12 | } 13 | 14 | .rcl-container { 15 | width: 100%; 16 | overflow: hidden; /* 清除浮动 */ 17 | } 18 | 19 | .rcl-left { 20 | float: left; 21 | display: flex; 22 | flex-direction: column; 23 | justify-content: space-between; 24 | align-items: center; 25 | width: 55px; 26 | padding: 0px 0px 0px 10px; 27 | background-color: #FFFFFF; 28 | height: 100vh; 29 | } 30 | 31 | .rcl-left-top { 32 | margin: 10px; /* 设置icon之间的间距 */ 33 | } 34 | 35 | .rcl-left-top, .rcl-left-bottom { 36 | width: 50px; /* 设置icon的宽度 */ 37 | height: 50px; /* 设置icon的高度 */ 38 | } 39 | .rcl-menu-select { 40 | background-color: #a6a3a3; 41 | } 42 | 43 | .rcl-middle { 44 | float: left; 45 | width: 250px; 46 | background-color: #f9f9f9; 47 | height: 100vh; 48 | padding: 8px; 49 | } 50 | 51 | .theme--light.m-list{ 52 | background-color: #f9f9f9 !important; 53 | } 54 | 55 | .rcl-right { 56 | margin-left: 305px; /* 左边和中间栏的宽度总和 */ 57 | background-color: #e8e8e8; 58 | height: 100vh; 59 | } 60 | 61 | .chat-message-container { 62 | display: flex; 63 | flex-direction: column; 64 | height: 100vh; /* 设置容器高度为视口高度 */ 65 | } 66 | 67 | .chat-message-content { 68 | flex: 1; /* 上部内容占据剩余空间 */ 69 | overflow-y: auto; 70 | padding: 10px; 71 | } 72 | 73 | .chat-message-footer { 74 | height: 145px; /* 设置底部高度为130px */ 75 | padding: 8px; 76 | } 77 | 78 | .chat-input{ 79 | border: none; 80 | outline: none; 81 | width: 100%; 82 | resize: none; 83 | height: 60%; 84 | word-wrap: break-word; 85 | } 86 | 87 | ::-webkit-scrollbar { 88 | width: 0; 89 | } 90 | 91 | ::-webkit-scrollbar-track { 92 | background-color: #f1f1f1; 93 | } 94 | 95 | ::-webkit-scrollbar-thumb { 96 | background-color: #888; 97 | } 98 | 99 | ::-webkit-scrollbar-thumb:hover { 100 | background-color: #555; 101 | } 102 | 103 | .message { 104 | display: flex; 105 | margin-bottom: 10px; 106 | } 107 | 108 | .message-content { 109 | background-color: #f1f0f0; 110 | padding: 8px; 111 | border-radius: 8px; 112 | flex-wrap: wrap; 113 | max-width: 70%; 114 | word-wrap: break-word; 115 | width: auto; 116 | } 117 | 118 | .message-time { 119 | font-size: 12px; 120 | color: #999; 121 | margin: 5px; 122 | text-align: center; 123 | } 124 | 125 | .self .message-content { 126 | background-color: #dcf8c6; 127 | align-self: flex-start; 128 | } 129 | 130 | .m-markdown-it code{ 131 | white-space: pre-wrap; 132 | overflow-x: auto; 133 | 134 | } 135 | 136 | .chat-send-but{ 137 | background-color: #FFFFFF; 138 | } 139 | 140 | .message-function{ 141 | margin: 5px; 142 | } 143 | 144 | .theme--light.m-application code{ 145 | background-color:transparent; 146 | } -------------------------------------------------------------------------------- /src/Gotrays.Rcl/wwwroot/img/chatgpt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/239573049/Suspension/28d830e96ffe519d77da7762c93aed11ab55d91c/src/Gotrays.Rcl/wwwroot/img/chatgpt.png -------------------------------------------------------------------------------- /src/Gotrays.Rcl/wwwroot/js/gotrays.js: -------------------------------------------------------------------------------- 1 |  2 | function onScroll(id, DotNetHelper, name) { 3 | var dom = document.getElementById(id); 4 | dom.addEventListener('scroll', async function (e) { 5 | console.log(dom.scrollTop, dom.scrollTop === 0); 6 | if (dom.scrollTop === 0) { 7 | await DotNetHelper.invokeMethodAsync(name, dom.scrollTop); 8 | } 9 | }); 10 | } 11 | 12 | function scrollBottom(id){ 13 | const element = document.getElementById(id); 14 | if(element) 15 | element.scrollTop = element.scrollHeight; 16 | } 17 | 18 | function copyText(text) { 19 | /* 获取要复制的内容 */ 20 | /* 创建一个临时的textarea元素 */ 21 | var tempInput = document.createElement("textarea"); 22 | tempInput.value = text; 23 | document.body.appendChild(tempInput); 24 | 25 | /* 选择并复制文本 */ 26 | tempInput.select(); 27 | document.execCommand("copy"); 28 | 29 | /* 删除临时元素 */ 30 | document.body.removeChild(tempInput); 31 | 32 | } 33 | 34 | function qrCode(id, value) { 35 | 36 | const qr = new QRCode(document.getElementById(id), { 37 | width: 300, 38 | height: 300 39 | }); 40 | 41 | qr.makeCode(value); 42 | } 43 | export { 44 | onScroll, 45 | scrollBottom, 46 | copyText, 47 | qrCode 48 | } -------------------------------------------------------------------------------- /src/Gotrays.Rcl/wwwroot/js/markdow.js: -------------------------------------------------------------------------------- 1 | window.MasaBlazor.extendMarkdownIt = function (parser) { 2 | 3 | const { md, scope } = parser; 4 | if (window.markdownitEmoji) { 5 | md.use(window.markdownitEmoji); 6 | } 7 | 8 | md.renderer.rules.code_block = renderCode(md.renderer.rules.code_block, md.options); 9 | md.renderer.rules.fence = renderCode(md.renderer.rules.fence, md.options); 10 | } 11 | function renderCode(origRule, options) { 12 | return (...args) => { 13 | const [tokens, idx] = args; 14 | const content = tokens[idx].content 15 | .replaceAll('"', '"') 16 | .replaceAll("'", "<"); 17 | const origRendered = origRule(...args); 18 | 19 | if (content.length === 0) 20 | return origRendered; 21 | 22 | return ` 23 |
24 | ${origRendered} 25 | 28 |
29 | `; 30 | }; 31 | } 32 | 33 | window.copy = async (e) => { 34 | navigator.clipboard.writeText(base64Decode(e)) 35 | await DotNet.invokeMethodAsync('Gotrays.Rcl', 'Notifications', "复制成功") 36 | } 37 | 38 | // Base64编码 39 | function base64Encode(str) { 40 | let base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; 41 | let result = ""; 42 | let i = 0; 43 | let chr1, chr2, chr3, enc1, enc2, enc3, enc4; 44 | 45 | while (i < str.length) { 46 | chr1 = str.charCodeAt(i++); 47 | chr2 = str.charCodeAt(i++); 48 | chr3 = str.charCodeAt(i++); 49 | 50 | enc1 = chr1 >> 2; 51 | enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); 52 | enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); 53 | enc4 = chr3 & 63; 54 | 55 | if (isNaN(chr2)) { 56 | enc3 = enc4 = 64; 57 | } else if (isNaN(chr3)) { 58 | enc4 = 64; 59 | } 60 | 61 | result += 62 | base64Chars.charAt(enc1) + 63 | base64Chars.charAt(enc2) + 64 | base64Chars.charAt(enc3) + 65 | base64Chars.charAt(enc4); 66 | } 67 | 68 | return result; 69 | } 70 | 71 | // Base64解码 72 | function base64Decode(str) { 73 | let base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; 74 | let result = ""; 75 | let i = 0; 76 | let chr1, chr2, chr3; 77 | let enc1, enc2, enc3, enc4; 78 | 79 | str = str.replace(/[^A-Za-z0-9+/=]/g, ""); 80 | 81 | while (i < str.length) { 82 | enc1 = base64Chars.indexOf(str.charAt(i++)); 83 | enc2 = base64Chars.indexOf(str.charAt(i++)); 84 | enc3 = base64Chars.indexOf(str.charAt(i++)); 85 | enc4 = base64Chars.indexOf(str.charAt(i++)); 86 | 87 | chr1 = (enc1 << 2) | (enc2 >> 4); 88 | chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); 89 | chr3 = ((enc3 & 3) << 6) | enc4; 90 | 91 | result += String.fromCharCode(chr1); 92 | 93 | if (enc3 !== 64) { 94 | result += String.fromCharCode(chr2); 95 | } 96 | if (enc4 !== 64) { 97 | result += String.fromCharCode(chr3); 98 | } 99 | } 100 | 101 | return result; 102 | } -------------------------------------------------------------------------------- /src/Gotrays.Rcl/wwwroot/js/qrcode.js: -------------------------------------------------------------------------------- 1 | var QRCode; !function () { function a(a) { this.mode = c.MODE_8BIT_BYTE, this.data = a, this.parsedData = []; for (var b = [], d = 0, e = this.data.length; e > d; d++) { var f = this.data.charCodeAt(d); f > 65536 ? (b[0] = 240 | (1835008 & f) >>> 18, b[1] = 128 | (258048 & f) >>> 12, b[2] = 128 | (4032 & f) >>> 6, b[3] = 128 | 63 & f) : f > 2048 ? (b[0] = 224 | (61440 & f) >>> 12, b[1] = 128 | (4032 & f) >>> 6, b[2] = 128 | 63 & f) : f > 128 ? (b[0] = 192 | (1984 & f) >>> 6, b[1] = 128 | 63 & f) : b[0] = f, this.parsedData = this.parsedData.concat(b) } this.parsedData.length != this.data.length && (this.parsedData.unshift(191), this.parsedData.unshift(187), this.parsedData.unshift(239)) } function b(a, b) { this.typeNumber = a, this.errorCorrectLevel = b, this.modules = null, this.moduleCount = 0, this.dataCache = null, this.dataList = [] } function i(a, b) { if (void 0 == a.length) throw new Error(a.length + "/" + b); for (var c = 0; c < a.length && 0 == a[c];)c++; this.num = new Array(a.length - c + b); for (var d = 0; d < a.length - c; d++)this.num[d] = a[d + c] } function j(a, b) { this.totalCount = a, this.dataCount = b } function k() { this.buffer = [], this.length = 0 } function m() { return "undefined" != typeof CanvasRenderingContext2D } function n() { var a = !1, b = navigator.userAgent; return /android/i.test(b) && (a = !0, aMat = b.toString().match(/android ([0-9]\.[0-9])/i), aMat && aMat[1] && (a = parseFloat(aMat[1]))), a } function r(a, b) { for (var c = 1, e = s(a), f = 0, g = l.length; g >= f; f++) { var h = 0; switch (b) { case d.L: h = l[f][0]; break; case d.M: h = l[f][1]; break; case d.Q: h = l[f][2]; break; case d.H: h = l[f][3] }if (h >= e) break; c++ } if (c > l.length) throw new Error("Too long data"); return c } function s(a) { var b = encodeURI(a).toString().replace(/\%[0-9a-fA-F]{2}/g, "a"); return b.length + (b.length != a ? 3 : 0) } a.prototype = { getLength: function () { return this.parsedData.length }, write: function (a) { for (var b = 0, c = this.parsedData.length; c > b; b++)a.put(this.parsedData[b], 8) } }, b.prototype = { addData: function (b) { var c = new a(b); this.dataList.push(c), this.dataCache = null }, isDark: function (a, b) { if (0 > a || this.moduleCount <= a || 0 > b || this.moduleCount <= b) throw new Error(a + "," + b); return this.modules[a][b] }, getModuleCount: function () { return this.moduleCount }, make: function () { this.makeImpl(!1, this.getBestMaskPattern()) }, makeImpl: function (a, c) { this.moduleCount = 4 * this.typeNumber + 17, this.modules = new Array(this.moduleCount); for (var d = 0; d < this.moduleCount; d++) { this.modules[d] = new Array(this.moduleCount); for (var e = 0; e < this.moduleCount; e++)this.modules[d][e] = null } this.setupPositionProbePattern(0, 0), this.setupPositionProbePattern(this.moduleCount - 7, 0), this.setupPositionProbePattern(0, this.moduleCount - 7), this.setupPositionAdjustPattern(), this.setupTimingPattern(), this.setupTypeInfo(a, c), this.typeNumber >= 7 && this.setupTypeNumber(a), null == this.dataCache && (this.dataCache = b.createData(this.typeNumber, this.errorCorrectLevel, this.dataList)), this.mapData(this.dataCache, c) }, setupPositionProbePattern: function (a, b) { for (var c = -1; 7 >= c; c++)if (!(-1 >= a + c || this.moduleCount <= a + c)) for (var d = -1; 7 >= d; d++)-1 >= b + d || this.moduleCount <= b + d || (this.modules[a + c][b + d] = c >= 0 && 6 >= c && (0 == d || 6 == d) || d >= 0 && 6 >= d && (0 == c || 6 == c) || c >= 2 && 4 >= c && d >= 2 && 4 >= d ? !0 : !1) }, getBestMaskPattern: function () { for (var a = 0, b = 0, c = 0; 8 > c; c++) { this.makeImpl(!0, c); var d = f.getLostPoint(this); (0 == c || a > d) && (a = d, b = c) } return b }, createMovieClip: function (a, b, c) { var d = a.createEmptyMovieClip(b, c), e = 1; this.make(); for (var f = 0; f < this.modules.length; f++)for (var g = f * e, h = 0; h < this.modules[f].length; h++) { var i = h * e, j = this.modules[f][h]; j && (d.beginFill(0, 100), d.moveTo(i, g), d.lineTo(i + e, g), d.lineTo(i + e, g + e), d.lineTo(i, g + e), d.endFill()) } return d }, setupTimingPattern: function () { for (var a = 8; a < this.moduleCount - 8; a++)null == this.modules[a][6] && (this.modules[a][6] = 0 == a % 2); for (var b = 8; b < this.moduleCount - 8; b++)null == this.modules[6][b] && (this.modules[6][b] = 0 == b % 2) }, setupPositionAdjustPattern: function () { for (var a = f.getPatternPosition(this.typeNumber), b = 0; b < a.length; b++)for (var c = 0; c < a.length; c++) { var d = a[b], e = a[c]; if (null == this.modules[d][e]) for (var g = -2; 2 >= g; g++)for (var h = -2; 2 >= h; h++)this.modules[d + g][e + h] = -2 == g || 2 == g || -2 == h || 2 == h || 0 == g && 0 == h ? !0 : !1 } }, setupTypeNumber: function (a) { for (var b = f.getBCHTypeNumber(this.typeNumber), c = 0; 18 > c; c++) { var d = !a && 1 == (1 & b >> c); this.modules[Math.floor(c / 3)][c % 3 + this.moduleCount - 8 - 3] = d } for (var c = 0; 18 > c; c++) { var d = !a && 1 == (1 & b >> c); this.modules[c % 3 + this.moduleCount - 8 - 3][Math.floor(c / 3)] = d } }, setupTypeInfo: function (a, b) { for (var c = this.errorCorrectLevel << 3 | b, d = f.getBCHTypeInfo(c), e = 0; 15 > e; e++) { var g = !a && 1 == (1 & d >> e); 6 > e ? this.modules[e][8] = g : 8 > e ? this.modules[e + 1][8] = g : this.modules[this.moduleCount - 15 + e][8] = g } for (var e = 0; 15 > e; e++) { var g = !a && 1 == (1 & d >> e); 8 > e ? this.modules[8][this.moduleCount - e - 1] = g : 9 > e ? this.modules[8][15 - e - 1 + 1] = g : this.modules[8][15 - e - 1] = g } this.modules[this.moduleCount - 8][8] = !a }, mapData: function (a, b) { for (var c = -1, d = this.moduleCount - 1, e = 7, g = 0, h = this.moduleCount - 1; h > 0; h -= 2)for (6 == h && h--; ;) { for (var i = 0; 2 > i; i++)if (null == this.modules[d][h - i]) { var j = !1; g < a.length && (j = 1 == (1 & a[g] >>> e)); var k = f.getMask(b, d, h - i); k && (j = !j), this.modules[d][h - i] = j, e--, -1 == e && (g++, e = 7) } if (d += c, 0 > d || this.moduleCount <= d) { d -= c, c = -c; break } } } }, b.PAD0 = 236, b.PAD1 = 17, b.createData = function (a, c, d) { for (var e = j.getRSBlocks(a, c), g = new k, h = 0; h < d.length; h++) { var i = d[h]; g.put(i.mode, 4), g.put(i.getLength(), f.getLengthInBits(i.mode, a)), i.write(g) } for (var l = 0, h = 0; h < e.length; h++)l += e[h].dataCount; if (g.getLengthInBits() > 8 * l) throw new Error("code length overflow. (" + g.getLengthInBits() + ">" + 8 * l + ")"); for (g.getLengthInBits() + 4 <= 8 * l && g.put(0, 4); 0 != g.getLengthInBits() % 8;)g.putBit(!1); for (; ;) { if (g.getLengthInBits() >= 8 * l) break; if (g.put(b.PAD0, 8), g.getLengthInBits() >= 8 * l) break; g.put(b.PAD1, 8) } return b.createBytes(g, e) }, b.createBytes = function (a, b) { for (var c = 0, d = 0, e = 0, g = new Array(b.length), h = new Array(b.length), j = 0; j < b.length; j++) { var k = b[j].dataCount, l = b[j].totalCount - k; d = Math.max(d, k), e = Math.max(e, l), g[j] = new Array(k); for (var m = 0; m < g[j].length; m++)g[j][m] = 255 & a.buffer[m + c]; c += k; var n = f.getErrorCorrectPolynomial(l), o = new i(g[j], n.getLength() - 1), p = o.mod(n); h[j] = new Array(n.getLength() - 1); for (var m = 0; m < h[j].length; m++) { var q = m + p.getLength() - h[j].length; h[j][m] = q >= 0 ? p.get(q) : 0 } } for (var r = 0, m = 0; m < b.length; m++)r += b[m].totalCount; for (var s = new Array(r), t = 0, m = 0; d > m; m++)for (var j = 0; j < b.length; j++)m < g[j].length && (s[t++] = g[j][m]); for (var m = 0; e > m; m++)for (var j = 0; j < b.length; j++)m < h[j].length && (s[t++] = h[j][m]); return s }; for (var c = { MODE_NUMBER: 1, MODE_ALPHA_NUM: 2, MODE_8BIT_BYTE: 4, MODE_KANJI: 8 }, d = { L: 1, M: 0, Q: 3, H: 2 }, e = { PATTERN000: 0, PATTERN001: 1, PATTERN010: 2, PATTERN011: 3, PATTERN100: 4, PATTERN101: 5, PATTERN110: 6, PATTERN111: 7 }, f = { PATTERN_POSITION_TABLE: [[], [6, 18], [6, 22], [6, 26], [6, 30], [6, 34], [6, 22, 38], [6, 24, 42], [6, 26, 46], [6, 28, 50], [6, 30, 54], [6, 32, 58], [6, 34, 62], [6, 26, 46, 66], [6, 26, 48, 70], [6, 26, 50, 74], [6, 30, 54, 78], [6, 30, 56, 82], [6, 30, 58, 86], [6, 34, 62, 90], [6, 28, 50, 72, 94], [6, 26, 50, 74, 98], [6, 30, 54, 78, 102], [6, 28, 54, 80, 106], [6, 32, 58, 84, 110], [6, 30, 58, 86, 114], [6, 34, 62, 90, 118], [6, 26, 50, 74, 98, 122], [6, 30, 54, 78, 102, 126], [6, 26, 52, 78, 104, 130], [6, 30, 56, 82, 108, 134], [6, 34, 60, 86, 112, 138], [6, 30, 58, 86, 114, 142], [6, 34, 62, 90, 118, 146], [6, 30, 54, 78, 102, 126, 150], [6, 24, 50, 76, 102, 128, 154], [6, 28, 54, 80, 106, 132, 158], [6, 32, 58, 84, 110, 136, 162], [6, 26, 54, 82, 110, 138, 166], [6, 30, 58, 86, 114, 142, 170]], G15: 1335, G18: 7973, G15_MASK: 21522, getBCHTypeInfo: function (a) { for (var b = a << 10; f.getBCHDigit(b) - f.getBCHDigit(f.G15) >= 0;)b ^= f.G15 << f.getBCHDigit(b) - f.getBCHDigit(f.G15); return (a << 10 | b) ^ f.G15_MASK }, getBCHTypeNumber: function (a) { for (var b = a << 12; f.getBCHDigit(b) - f.getBCHDigit(f.G18) >= 0;)b ^= f.G18 << f.getBCHDigit(b) - f.getBCHDigit(f.G18); return a << 12 | b }, getBCHDigit: function (a) { for (var b = 0; 0 != a;)b++, a >>>= 1; return b }, getPatternPosition: function (a) { return f.PATTERN_POSITION_TABLE[a - 1] }, getMask: function (a, b, c) { switch (a) { case e.PATTERN000: return 0 == (b + c) % 2; case e.PATTERN001: return 0 == b % 2; case e.PATTERN010: return 0 == c % 3; case e.PATTERN011: return 0 == (b + c) % 3; case e.PATTERN100: return 0 == (Math.floor(b / 2) + Math.floor(c / 3)) % 2; case e.PATTERN101: return 0 == b * c % 2 + b * c % 3; case e.PATTERN110: return 0 == (b * c % 2 + b * c % 3) % 2; case e.PATTERN111: return 0 == (b * c % 3 + (b + c) % 2) % 2; default: throw new Error("bad maskPattern:" + a) } }, getErrorCorrectPolynomial: function (a) { for (var b = new i([1], 0), c = 0; a > c; c++)b = b.multiply(new i([1, g.gexp(c)], 0)); return b }, getLengthInBits: function (a, b) { if (b >= 1 && 10 > b) switch (a) { case c.MODE_NUMBER: return 10; case c.MODE_ALPHA_NUM: return 9; case c.MODE_8BIT_BYTE: return 8; case c.MODE_KANJI: return 8; default: throw new Error("mode:" + a) } else if (27 > b) switch (a) { case c.MODE_NUMBER: return 12; case c.MODE_ALPHA_NUM: return 11; case c.MODE_8BIT_BYTE: return 16; case c.MODE_KANJI: return 10; default: throw new Error("mode:" + a) } else { if (!(41 > b)) throw new Error("type:" + b); switch (a) { case c.MODE_NUMBER: return 14; case c.MODE_ALPHA_NUM: return 13; case c.MODE_8BIT_BYTE: return 16; case c.MODE_KANJI: return 12; default: throw new Error("mode:" + a) } } }, getLostPoint: function (a) { for (var b = a.getModuleCount(), c = 0, d = 0; b > d; d++)for (var e = 0; b > e; e++) { for (var f = 0, g = a.isDark(d, e), h = -1; 1 >= h; h++)if (!(0 > d + h || d + h >= b)) for (var i = -1; 1 >= i; i++)0 > e + i || e + i >= b || (0 != h || 0 != i) && g == a.isDark(d + h, e + i) && f++; f > 5 && (c += 3 + f - 5) } for (var d = 0; b - 1 > d; d++)for (var e = 0; b - 1 > e; e++) { var j = 0; a.isDark(d, e) && j++, a.isDark(d + 1, e) && j++, a.isDark(d, e + 1) && j++, a.isDark(d + 1, e + 1) && j++, (0 == j || 4 == j) && (c += 3) } for (var d = 0; b > d; d++)for (var e = 0; b - 6 > e; e++)a.isDark(d, e) && !a.isDark(d, e + 1) && a.isDark(d, e + 2) && a.isDark(d, e + 3) && a.isDark(d, e + 4) && !a.isDark(d, e + 5) && a.isDark(d, e + 6) && (c += 40); for (var e = 0; b > e; e++)for (var d = 0; b - 6 > d; d++)a.isDark(d, e) && !a.isDark(d + 1, e) && a.isDark(d + 2, e) && a.isDark(d + 3, e) && a.isDark(d + 4, e) && !a.isDark(d + 5, e) && a.isDark(d + 6, e) && (c += 40); for (var k = 0, e = 0; b > e; e++)for (var d = 0; b > d; d++)a.isDark(d, e) && k++; var l = Math.abs(100 * k / b / b - 50) / 5; return c += 10 * l } }, g = { glog: function (a) { if (1 > a) throw new Error("glog(" + a + ")"); return g.LOG_TABLE[a] }, gexp: function (a) { for (; 0 > a;)a += 255; for (; a >= 256;)a -= 255; return g.EXP_TABLE[a] }, EXP_TABLE: new Array(256), LOG_TABLE: new Array(256) }, h = 0; 8 > h; h++)g.EXP_TABLE[h] = 1 << h; for (var h = 8; 256 > h; h++)g.EXP_TABLE[h] = g.EXP_TABLE[h - 4] ^ g.EXP_TABLE[h - 5] ^ g.EXP_TABLE[h - 6] ^ g.EXP_TABLE[h - 8]; for (var h = 0; 255 > h; h++)g.LOG_TABLE[g.EXP_TABLE[h]] = h; i.prototype = { get: function (a) { return this.num[a] }, getLength: function () { return this.num.length }, multiply: function (a) { for (var b = new Array(this.getLength() + a.getLength() - 1), c = 0; c < this.getLength(); c++)for (var d = 0; d < a.getLength(); d++)b[c + d] ^= g.gexp(g.glog(this.get(c)) + g.glog(a.get(d))); return new i(b, 0) }, mod: function (a) { if (this.getLength() - a.getLength() < 0) return this; for (var b = g.glog(this.get(0)) - g.glog(a.get(0)), c = new Array(this.getLength()), d = 0; d < this.getLength(); d++)c[d] = this.get(d); for (var d = 0; d < a.getLength(); d++)c[d] ^= g.gexp(g.glog(a.get(d)) + b); return new i(c, 0).mod(a) } }, j.RS_BLOCK_TABLE = [[1, 26, 19], [1, 26, 16], [1, 26, 13], [1, 26, 9], [1, 44, 34], [1, 44, 28], [1, 44, 22], [1, 44, 16], [1, 70, 55], [1, 70, 44], [2, 35, 17], [2, 35, 13], [1, 100, 80], [2, 50, 32], [2, 50, 24], [4, 25, 9], [1, 134, 108], [2, 67, 43], [2, 33, 15, 2, 34, 16], [2, 33, 11, 2, 34, 12], [2, 86, 68], [4, 43, 27], [4, 43, 19], [4, 43, 15], [2, 98, 78], [4, 49, 31], [2, 32, 14, 4, 33, 15], [4, 39, 13, 1, 40, 14], [2, 121, 97], [2, 60, 38, 2, 61, 39], [4, 40, 18, 2, 41, 19], [4, 40, 14, 2, 41, 15], [2, 146, 116], [3, 58, 36, 2, 59, 37], [4, 36, 16, 4, 37, 17], [4, 36, 12, 4, 37, 13], [2, 86, 68, 2, 87, 69], [4, 69, 43, 1, 70, 44], [6, 43, 19, 2, 44, 20], [6, 43, 15, 2, 44, 16], [4, 101, 81], [1, 80, 50, 4, 81, 51], [4, 50, 22, 4, 51, 23], [3, 36, 12, 8, 37, 13], [2, 116, 92, 2, 117, 93], [6, 58, 36, 2, 59, 37], [4, 46, 20, 6, 47, 21], [7, 42, 14, 4, 43, 15], [4, 133, 107], [8, 59, 37, 1, 60, 38], [8, 44, 20, 4, 45, 21], [12, 33, 11, 4, 34, 12], [3, 145, 115, 1, 146, 116], [4, 64, 40, 5, 65, 41], [11, 36, 16, 5, 37, 17], [11, 36, 12, 5, 37, 13], [5, 109, 87, 1, 110, 88], [5, 65, 41, 5, 66, 42], [5, 54, 24, 7, 55, 25], [11, 36, 12], [5, 122, 98, 1, 123, 99], [7, 73, 45, 3, 74, 46], [15, 43, 19, 2, 44, 20], [3, 45, 15, 13, 46, 16], [1, 135, 107, 5, 136, 108], [10, 74, 46, 1, 75, 47], [1, 50, 22, 15, 51, 23], [2, 42, 14, 17, 43, 15], [5, 150, 120, 1, 151, 121], [9, 69, 43, 4, 70, 44], [17, 50, 22, 1, 51, 23], [2, 42, 14, 19, 43, 15], [3, 141, 113, 4, 142, 114], [3, 70, 44, 11, 71, 45], [17, 47, 21, 4, 48, 22], [9, 39, 13, 16, 40, 14], [3, 135, 107, 5, 136, 108], [3, 67, 41, 13, 68, 42], [15, 54, 24, 5, 55, 25], [15, 43, 15, 10, 44, 16], [4, 144, 116, 4, 145, 117], [17, 68, 42], [17, 50, 22, 6, 51, 23], [19, 46, 16, 6, 47, 17], [2, 139, 111, 7, 140, 112], [17, 74, 46], [7, 54, 24, 16, 55, 25], [34, 37, 13], [4, 151, 121, 5, 152, 122], [4, 75, 47, 14, 76, 48], [11, 54, 24, 14, 55, 25], [16, 45, 15, 14, 46, 16], [6, 147, 117, 4, 148, 118], [6, 73, 45, 14, 74, 46], [11, 54, 24, 16, 55, 25], [30, 46, 16, 2, 47, 17], [8, 132, 106, 4, 133, 107], [8, 75, 47, 13, 76, 48], [7, 54, 24, 22, 55, 25], [22, 45, 15, 13, 46, 16], [10, 142, 114, 2, 143, 115], [19, 74, 46, 4, 75, 47], [28, 50, 22, 6, 51, 23], [33, 46, 16, 4, 47, 17], [8, 152, 122, 4, 153, 123], [22, 73, 45, 3, 74, 46], [8, 53, 23, 26, 54, 24], [12, 45, 15, 28, 46, 16], [3, 147, 117, 10, 148, 118], [3, 73, 45, 23, 74, 46], [4, 54, 24, 31, 55, 25], [11, 45, 15, 31, 46, 16], [7, 146, 116, 7, 147, 117], [21, 73, 45, 7, 74, 46], [1, 53, 23, 37, 54, 24], [19, 45, 15, 26, 46, 16], [5, 145, 115, 10, 146, 116], [19, 75, 47, 10, 76, 48], [15, 54, 24, 25, 55, 25], [23, 45, 15, 25, 46, 16], [13, 145, 115, 3, 146, 116], [2, 74, 46, 29, 75, 47], [42, 54, 24, 1, 55, 25], [23, 45, 15, 28, 46, 16], [17, 145, 115], [10, 74, 46, 23, 75, 47], [10, 54, 24, 35, 55, 25], [19, 45, 15, 35, 46, 16], [17, 145, 115, 1, 146, 116], [14, 74, 46, 21, 75, 47], [29, 54, 24, 19, 55, 25], [11, 45, 15, 46, 46, 16], [13, 145, 115, 6, 146, 116], [14, 74, 46, 23, 75, 47], [44, 54, 24, 7, 55, 25], [59, 46, 16, 1, 47, 17], [12, 151, 121, 7, 152, 122], [12, 75, 47, 26, 76, 48], [39, 54, 24, 14, 55, 25], [22, 45, 15, 41, 46, 16], [6, 151, 121, 14, 152, 122], [6, 75, 47, 34, 76, 48], [46, 54, 24, 10, 55, 25], [2, 45, 15, 64, 46, 16], [17, 152, 122, 4, 153, 123], [29, 74, 46, 14, 75, 47], [49, 54, 24, 10, 55, 25], [24, 45, 15, 46, 46, 16], [4, 152, 122, 18, 153, 123], [13, 74, 46, 32, 75, 47], [48, 54, 24, 14, 55, 25], [42, 45, 15, 32, 46, 16], [20, 147, 117, 4, 148, 118], [40, 75, 47, 7, 76, 48], [43, 54, 24, 22, 55, 25], [10, 45, 15, 67, 46, 16], [19, 148, 118, 6, 149, 119], [18, 75, 47, 31, 76, 48], [34, 54, 24, 34, 55, 25], [20, 45, 15, 61, 46, 16]], j.getRSBlocks = function (a, b) { var c = j.getRsBlockTable(a, b); if (void 0 == c) throw new Error("bad rs block @ typeNumber:" + a + "/errorCorrectLevel:" + b); for (var d = c.length / 3, e = [], f = 0; d > f; f++)for (var g = c[3 * f + 0], h = c[3 * f + 1], i = c[3 * f + 2], k = 0; g > k; k++)e.push(new j(h, i)); return e }, j.getRsBlockTable = function (a, b) { switch (b) { case d.L: return j.RS_BLOCK_TABLE[4 * (a - 1) + 0]; case d.M: return j.RS_BLOCK_TABLE[4 * (a - 1) + 1]; case d.Q: return j.RS_BLOCK_TABLE[4 * (a - 1) + 2]; case d.H: return j.RS_BLOCK_TABLE[4 * (a - 1) + 3]; default: return void 0 } }, k.prototype = { get: function (a) { var b = Math.floor(a / 8); return 1 == (1 & this.buffer[b] >>> 7 - a % 8) }, put: function (a, b) { for (var c = 0; b > c; c++)this.putBit(1 == (1 & a >>> b - c - 1)) }, getLengthInBits: function () { return this.length }, putBit: function (a) { var b = Math.floor(this.length / 8); this.buffer.length <= b && this.buffer.push(0), a && (this.buffer[b] |= 128 >>> this.length % 8), this.length++ } }; var l = [[17, 14, 11, 7], [32, 26, 20, 14], [53, 42, 32, 24], [78, 62, 46, 34], [106, 84, 60, 44], [134, 106, 74, 58], [154, 122, 86, 64], [192, 152, 108, 84], [230, 180, 130, 98], [271, 213, 151, 119], [321, 251, 177, 137], [367, 287, 203, 155], [425, 331, 241, 177], [458, 362, 258, 194], [520, 412, 292, 220], [586, 450, 322, 250], [644, 504, 364, 280], [718, 560, 394, 310], [792, 624, 442, 338], [858, 666, 482, 382], [929, 711, 509, 403], [1003, 779, 565, 439], [1091, 857, 611, 461], [1171, 911, 661, 511], [1273, 997, 715, 535], [1367, 1059, 751, 593], [1465, 1125, 805, 625], [1528, 1190, 868, 658], [1628, 1264, 908, 698], [1732, 1370, 982, 742], [1840, 1452, 1030, 790], [1952, 1538, 1112, 842], [2068, 1628, 1168, 898], [2188, 1722, 1228, 958], [2303, 1809, 1283, 983], [2431, 1911, 1351, 1051], [2563, 1989, 1423, 1093], [2699, 2099, 1499, 1139], [2809, 2213, 1579, 1219], [2953, 2331, 1663, 1273]], o = function () { var a = function (a, b) { this._el = a, this._htOption = b }; return a.prototype.draw = function (a) { function g(a, b) { var c = document.createElementNS("http://www.w3.org/2000/svg", a); for (var d in b) b.hasOwnProperty(d) && c.setAttribute(d, b[d]); return c } var b = this._htOption, c = this._el, d = a.getModuleCount(); Math.floor(b.width / d), Math.floor(b.height / d), this.clear(); var h = g("svg", { viewBox: "0 0 " + String(d) + " " + String(d), width: "100%", height: "100%", fill: b.colorLight }); h.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:xlink", "http://www.w3.org/1999/xlink"), c.appendChild(h), h.appendChild(g("rect", { fill: b.colorDark, width: "1", height: "1", id: "template" })); for (var i = 0; d > i; i++)for (var j = 0; d > j; j++)if (a.isDark(i, j)) { var k = g("use", { x: String(i), y: String(j) }); k.setAttributeNS("http://www.w3.org/1999/xlink", "href", "#template"), h.appendChild(k) } }, a.prototype.clear = function () { for (; this._el.hasChildNodes();)this._el.removeChild(this._el.lastChild) }, a }(), p = "svg" === document.documentElement.tagName.toLowerCase(), q = p ? o : m() ? function () { function a() { this._elImage.src = this._elCanvas.toDataURL("image/png"), this._elImage.style.display = "block", this._elCanvas.style.display = "none" } function d(a, b) { var c = this; if (c._fFail = b, c._fSuccess = a, null === c._bSupportDataURI) { var d = document.createElement("img"), e = function () { c._bSupportDataURI = !1, c._fFail && _fFail.call(c) }, f = function () { c._bSupportDataURI = !0, c._fSuccess && c._fSuccess.call(c) }; return d.onabort = e, d.onerror = e, d.onload = f, d.src = "data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", void 0 } c._bSupportDataURI === !0 && c._fSuccess ? c._fSuccess.call(c) : c._bSupportDataURI === !1 && c._fFail && c._fFail.call(c) } if (this._android && this._android <= 2.1) { var b = 1 / window.devicePixelRatio, c = CanvasRenderingContext2D.prototype.drawImage; CanvasRenderingContext2D.prototype.drawImage = function (a, d, e, f, g, h, i, j) { if ("nodeName" in a && /img/i.test(a.nodeName)) for (var l = arguments.length - 1; l >= 1; l--)arguments[l] = arguments[l] * b; else "undefined" == typeof j && (arguments[1] *= b, arguments[2] *= b, arguments[3] *= b, arguments[4] *= b); c.apply(this, arguments) } } var e = function (a, b) { this._bIsPainted = !1, this._android = n(), this._htOption = b, this._elCanvas = document.createElement("canvas"), this._elCanvas.width = b.width, this._elCanvas.height = b.height, a.appendChild(this._elCanvas), this._el = a, this._oContext = this._elCanvas.getContext("2d"), this._bIsPainted = !1, this._elImage = document.createElement("img"), this._elImage.style.display = "none", this._el.appendChild(this._elImage), this._bSupportDataURI = null }; return e.prototype.draw = function (a) { var b = this._elImage, c = this._oContext, d = this._htOption, e = a.getModuleCount(), f = d.width / e, g = d.height / e, h = Math.round(f), i = Math.round(g); b.style.display = "none", this.clear(); for (var j = 0; e > j; j++)for (var k = 0; e > k; k++) { var l = a.isDark(j, k), m = k * f, n = j * g; c.strokeStyle = l ? d.colorDark : d.colorLight, c.lineWidth = 1, c.fillStyle = l ? d.colorDark : d.colorLight, c.fillRect(m, n, f, g), c.strokeRect(Math.floor(m) + .5, Math.floor(n) + .5, h, i), c.strokeRect(Math.ceil(m) - .5, Math.ceil(n) - .5, h, i) } this._bIsPainted = !0 }, e.prototype.makeImage = function () { this._bIsPainted && d.call(this, a) }, e.prototype.isPainted = function () { return this._bIsPainted }, e.prototype.clear = function () { this._oContext.clearRect(0, 0, this._elCanvas.width, this._elCanvas.height), this._bIsPainted = !1 }, e.prototype.round = function (a) { return a ? Math.floor(1e3 * a) / 1e3 : a }, e }() : function () { var a = function (a, b) { this._el = a, this._htOption = b }; return a.prototype.draw = function (a) { for (var b = this._htOption, c = this._el, d = a.getModuleCount(), e = Math.floor(b.width / d), f = Math.floor(b.height / d), g = [''], h = 0; d > h; h++) { g.push(""); for (var i = 0; d > i; i++)g.push(''); g.push("") } g.push("
"), c.innerHTML = g.join(""); var j = c.childNodes[0], k = (b.width - j.offsetWidth) / 2, l = (b.height - j.offsetHeight) / 2; k > 0 && l > 0 && (j.style.margin = l + "px " + k + "px") }, a.prototype.clear = function () { this._el.innerHTML = "" }, a }(); QRCode = function (a, b) { if (this._htOption = { width: 256, height: 256, typeNumber: 4, colorDark: "#000000", colorLight: "#ffffff", correctLevel: d.H }, "string" == typeof b && (b = { text: b }), b) for (var c in b) this._htOption[c] = b[c]; "string" == typeof a && (a = document.getElementById(a)), this._android = n(), this._el = a, this._oQRCode = null, this._oDrawing = new q(this._el, this._htOption), this._htOption.text && this.makeCode(this._htOption.text) }, QRCode.prototype.makeCode = function (a) { this._oQRCode = new b(r(a, this._htOption.correctLevel), this._htOption.correctLevel), this._oQRCode.addData(a), this._oQRCode.make(), this._el.title = a, this._oDrawing.draw(this._oQRCode), this.makeImage() }, QRCode.prototype.makeImage = function () { "function" == typeof this._oDrawing.makeImage && (!this._android || this._android >= 3) && this._oDrawing.makeImage() }, QRCode.prototype.clear = function () { this._oDrawing.clear() }, QRCode.CorrectLevel = d }(); -------------------------------------------------------------------------------- /src/Gotrays.Shared/ChatMessageType.cs: -------------------------------------------------------------------------------- 1 | namespace Gotrays.Shared; 2 | 3 | public enum ChatMessageType 4 | { 5 | Text, 6 | Image, 7 | } -------------------------------------------------------------------------------- /src/Gotrays.Shared/Constant.cs: -------------------------------------------------------------------------------- 1 | namespace Gotrays.Shared; 2 | 3 | public static class Constant 4 | { 5 | private const string Default = "Gotrays:"; 6 | 7 | public class HttpClientOptions 8 | { 9 | private const string Default = Constant.Default + "HttpClientOptions:"; 10 | 11 | public const string OpenService = Default + "OpenService"; 12 | 13 | public const string Token = Default + "Token"; 14 | } 15 | 16 | public class LoadEventBus 17 | { 18 | private const string Default = Constant.Default + "LoadEventBus:"; 19 | 20 | public const string Notifications = Default + "Notifications"; 21 | } 22 | } -------------------------------------------------------------------------------- /src/Gotrays.Shared/Gotrays.Shared.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | --------------------------------------------------------------------------------