diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c32b160f..ae41e059 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,32 +3,32 @@ name: Release on: workflow_dispatch: inputs: - version: - description: '版本号' + version: + description: "版本号" required: true - default: '0.0.0.0' + default: "0.0.0.0" enableX64: - description: '启用x64' + description: "启用x64" required: true default: true type: boolean enableX64Native: - description: '启用x64Native' + description: "启用x64Native" required: true default: true type: boolean enableX86: - description: '启用x86' + description: "启用x86" required: true default: false type: boolean enableArm64: - description: '启用Arm64' + description: "启用Arm64" required: true default: true type: boolean enableArm32: - description: '启用Arm32' + description: "启用Arm32" required: true default: false type: boolean @@ -53,246 +53,241 @@ jobs: nuget_package: biliuwp-lite-nuget-packages.zip steps: - - - name: Configure Pagefile - uses: al-cheb/configure-pagefile-action@v1.2 - with: - minimum-size: 32GB - maximum-size: 32GB - disk-root: "C:" - - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: EchoInput - run: | - echo 启用x64编译 ${{ github.event.inputs.enableX64 }} - echo 启用x86编译 ${{ github.event.inputs.enableX86 }} - echo 启用Arm64编译 ${{ github.event.inputs.enableArm64 }} - echo 启用Arm编译 ${{ github.event.inputs.enableArm32 }} - - - name: Download and process necessary files - run: | - curl --location $env:Webdav_addr --header "$env:Webdav_auth" -o "$env:UWP_Project_Directory/$env:SigningCertificate" --insecure - curl --location $env:nuget_package_addr --header "$env:Webdav_auth" -o "$env:nuget_package" --insecure - Expand-Archive -path $env:nuget_package -DestinationPath ./ - cp -r ./packages ./src/ - - - uses: release-drafter/release-drafter@v5 - name: Create release draft - id: release-drafter - - - name: Setup MSBuild.exe - uses: microsoft/setup-msbuild@v1.0.3 - - - name: Windows SDK Install - uses: ChristopheLav/windows-sdk-install@v1.0.1 - with: - version-sdk: 18362 - features: 'OptionId.WindowsPerformanceToolkit,OptionId.WindowsDesktopDebuggers,OptionId.AvrfExternal,OptionId.NetFxSoftwareDevelopmentKit,OptionId.WindowsSoftwareLogoToolkit,OptionId.IpOverUsb,OptionId.MSIInstallTools,OptionId.SigningTools,OptionId.UWPManaged,OptionId.UWPCPP,OptionId.UWPLocalized,OptionId.DesktopCPPx86,OptionId.DesktopCPPx64,OptionId.DesktopCPParm,OptionId.DesktopCPParm64' - - - name: Update manifest version - run: | - [xml]$manifest = get-content ".\$env:UWP_Project_Directory\Package.appxmanifest" - $manifest.Package.Identity.Version = "${{github.event.inputs.version}}" - $manifest.save(".\$env:UWP_Project_Directory\Package.appxmanifest") - - - name: Create Package Directory - run: New-Item -ItemType Directory -Path C:\Package - - - name: document processing - run: | - git clone https://github.com/ywmoyue/OnlinePageToPDF-Node.git - cd OnlinePageToPDF-Node - npm install - node index.js --waitTime=35000 --pageUrl="http://markdown.muyan233.top:352/?fileUrl=https%3A%2F%2Fraw.githubusercontent.com%2Fywmoyue%2Fbiliuwp-lite%2Fdev%2Fdocument%2Finstall-readme.md" --pdfFilePath="安装教程.pdf" - cd .. - cp ./OnlinePageToPDF-Node/安装教程.pdf C:\Package\安装教程.pdf - - - name: Build x64 - run: | - msbuild $env:UWP_Project_Directory /p:Platform=x64 /p:Configuration=Release /p:PackageCertificateKeyFile=$env:SigningCertificate /p:PackageCertificatePassword=$env:SigningCertificatePasswd /restore - env: - BuildMode: SideloadOnly - Configuration: Release - if: github.event.inputs.enableX64 == 'true' - - - name: copy x64 document - run: cp C:\Package\安装教程.pdf ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x64_Test\安装教程.pdf - if: github.event.inputs.enableX64 == 'true' - - - name: Remove x64 useless files - run: | - cd ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x64_Test - rm -r -fo *.appxsym - cd Dependencies - rm -r -fo arm,arm64,x86 - if: github.event.inputs.enableX64 == 'true' - - - name: Create x64 archive - run: Compress-Archive -Path ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x64_Test -DestinationPath C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_x64.zip - if: github.event.inputs.enableX64 == 'true' - - - name: Update x64 release asset - id: upload-release-asset-x64 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} - if: github.event.inputs.enableX64 == 'true' - with: - upload_url: ${{ steps.release-drafter.outputs.upload_url }} - asset_path: C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_x64.zip - asset_name: ${{env.AppName}}_${{github.event.inputs.version}}_x64.zip - asset_content_type: application/zip - - - - - name: Set x64 native - run: | - rm $env:UWP_Project_Path - cp $env:UWP_X64_Native_Project_Path $env:UWP_Project_Path - if: github.event.inputs.enableX64Native == 'true' - - - name: Build x64 native - run: | - msbuild $env:UWP_Project_Directory /p:Platform=x64 /p:Configuration=Release /p:PackageCertificateKeyFile=$env:SigningCertificate /p:PackageCertificatePassword=$env:SigningCertificatePasswd /restore - env: - BuildMode: SideloadOnly - Configuration: Release - if: github.event.inputs.enableX64Native == 'true' - - - name: copy x64 native document - run: cp C:\Package\安装教程.pdf ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x64_Test\安装教程.pdf - if: github.event.inputs.enableX64Native == 'true' - - - name: Remove x64 native useless files - run: | - cd ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x64_Test - rm -r -fo *.appxsym - cd Dependencies - rm -r -fo arm,arm64,x86 - if: github.event.inputs.enableX64Native == 'true' - - - name: Create x64 native archive - run: Compress-Archive -Path ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x64_Test -DestinationPath C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_x64_native.zip - if: github.event.inputs.enableX64Native == 'true' - - - name: Update x64 native release asset - id: upload-release-asset-x64-native - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} - if: github.event.inputs.enableX64Native == 'true' - with: - upload_url: ${{ steps.release-drafter.outputs.upload_url }} - asset_path: C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_x64_native.zip - asset_name: ${{env.AppName}}_${{github.event.inputs.version}}_x64_native.zip - asset_content_type: application/zip - - - - name: Build x86 - run: msbuild $env:UWP_Project_Directory /p:Platform=x86 /p:Configuration=Release /p:PackageCertificateKeyFile=$env:SigningCertificate /p:PackageCertificatePassword=$env:SigningCertificatePasswd /restore - if: github.event.inputs.enableX86 == 'true' - env: - BuildMode: SideloadOnly - Configuration: Release - - - name: copy x86 document - run: cp C:\Package\安装教程.pdf ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x86_Test\安装教程.pdf - if: github.event.inputs.enableX86 == 'true' - - - name: Remove x86 useless files - run: | - cd ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x86_Test - rm -r -fo *.appxsym - cd Dependencies - rm -r -fo arm,arm64,x64 - if: github.event.inputs.enableX86 == 'true' - - - name: Create x86 archive - run: Compress-Archive -Path ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x86_Test -DestinationPath C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_x86.zip - if: github.event.inputs.enableX86 == 'true' - - - name: Update x86 release asset - id: upload-release-asset-x86 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} - if: github.event.inputs.enableX86 == 'true' - with: - upload_url: ${{ steps.release-drafter.outputs.upload_url }} - asset_path: C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_x86.zip - asset_name: ${{env.AppName}}_${{github.event.inputs.version}}_x86.zip - asset_content_type: application/zip - - - name: Build ARM64 - run: msbuild $env:UWP_Project_Directory /p:Platform=ARM64 /p:Configuration=Release /p:PackageCertificateKeyFile=$env:SigningCertificate /p:PackageCertificatePassword=$env:SigningCertificatePasswd /restore - if: github.event.inputs.enableArm64 == 'true' - env: - BuildMode: SideloadOnly - Configuration: Release - - - name: copy arm64 document - run: cp C:\Package\安装教程.pdf ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_ARM64_Test\安装教程.pdf - if: github.event.inputs.enableArm64 == 'true' - - - name: Remove arm64 useless files - run: | - cd ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_ARM64_Test - rm -r -fo *.appxsym - cd Dependencies - rm -r -fo arm,x64,x86 - if: github.event.inputs.enableArm64 == 'true' - - - name: Create ARM64 archive - run: Compress-Archive -Path ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_ARM64_Test -DestinationPath C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_ARM64.zip - if: github.event.inputs.enableArm64 == 'true' - - - name: Update ARM64 release asset - id: upload-release-asset-ARM64 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} - if: github.event.inputs.enableArm64 == 'true' - with: - upload_url: ${{ steps.release-drafter.outputs.upload_url }} - asset_path: C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_ARM64.zip - asset_name: ${{env.AppName}}_${{github.event.inputs.version}}_ARM64.zip - asset_content_type: application/zip - - - name: Build ARM32 - run: msbuild $env:UWP_Project_Directory /p:Platform=ARM /p:Configuration=Release /p:PackageCertificateKeyFile=$env:SigningCertificate /p:PackageCertificatePassword=$env:SigningCertificatePasswd /restore - if: github.event.inputs.enableArm32 == 'true' - env: - BuildMode: SideloadOnly - Configuration: Release - - - name: copy arm32 document - run: cp C:\Package\安装教程.pdf ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_ARM_Test\安装教程.pdf - if: github.event.inputs.enableArm32 == 'true' - - - name: Remove arm32 useless files - run: | - cd ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_ARM_Test - rm -r -fo *.appxsym - cd Dependencies - rm -r -fo arm64,x64,x86 - if: github.event.inputs.enableArm32 == 'true' - - - name: Create ARM32 archive - run: Compress-Archive -Path ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_ARM_Test -DestinationPath C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_ARM.zip - if: github.event.inputs.enableArm32 == 'true' - - - name: Update ARM32 release asset - id: upload-release-asset-ARM32 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} - if: github.event.inputs.enableArm32 == 'true' - with: - upload_url: ${{ steps.release-drafter.outputs.upload_url }} - asset_path: C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_ARM.zip - asset_name: ${{env.AppName}}_${{github.event.inputs.version}}_ARM.zip - asset_content_type: application/zip + - name: Configure Pagefile + uses: al-cheb/configure-pagefile-action@v1.2 + with: + minimum-size: 32GB + maximum-size: 32GB + disk-root: "C:" + + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: EchoInput + run: | + echo 启用x64编译 ${{ github.event.inputs.enableX64 }} + echo 启用x86编译 ${{ github.event.inputs.enableX86 }} + echo 启用Arm64编译 ${{ github.event.inputs.enableArm64 }} + echo 启用Arm编译 ${{ github.event.inputs.enableArm32 }} + + - name: Download and process necessary files + run: | + curl --location $env:Webdav_addr --header "$env:Webdav_auth" -o "$env:UWP_Project_Directory/$env:SigningCertificate" --insecure + curl --location $env:nuget_package_addr --header "$env:Webdav_auth" -o "$env:nuget_package" --insecure + Expand-Archive -path $env:nuget_package -DestinationPath ./ + cp -r ./packages ./src/ + + - uses: release-drafter/release-drafter@v5 + name: Create release draft + id: release-drafter + + - name: Setup MSBuild.exe + uses: microsoft/setup-msbuild@v1.0.3 + + - name: Windows SDK Install + uses: ChristopheLav/windows-sdk-install@v1.0.1 + with: + version-sdk: 18362 + features: "OptionId.WindowsPerformanceToolkit,OptionId.WindowsDesktopDebuggers,OptionId.AvrfExternal,OptionId.NetFxSoftwareDevelopmentKit,OptionId.WindowsSoftwareLogoToolkit,OptionId.IpOverUsb,OptionId.MSIInstallTools,OptionId.SigningTools,OptionId.UWPManaged,OptionId.UWPCPP,OptionId.UWPLocalized,OptionId.DesktopCPPx86,OptionId.DesktopCPPx64,OptionId.DesktopCPParm,OptionId.DesktopCPParm64" + + - name: Update manifest version + run: | + [xml]$manifest = get-content ".\$env:UWP_Project_Directory\Package.appxmanifest" + $manifest.Package.Identity.Version = "${{github.event.inputs.version}}" + $manifest.save(".\$env:UWP_Project_Directory\Package.appxmanifest") + + - name: Create Package Directory + run: New-Item -ItemType Directory -Path C:\Package + + - name: document processing + run: | + git clone https://github.com/ywmoyue/OnlinePageToPDF-Node.git + cd OnlinePageToPDF-Node + npm install + node index.js --waitTime=35000 --pageUrl="http://markdown.muyan233.top:352/?fileUrl=https%3A%2F%2Fraw.githubusercontent.com%2Fywmoyue%2Fbiliuwp-lite%2Fdev%2Fdocument%2Finstall-readme.md" --pdfFilePath="安装教程.pdf" + cd .. + cp ./OnlinePageToPDF-Node/安装教程.pdf C:\Package\安装教程.pdf + + - name: Build x64 + run: | + msbuild $env:UWP_Project_Directory /p:Platform=x64 /p:Configuration=Release /p:PackageCertificateKeyFile=$env:SigningCertificate /p:PackageCertificatePassword=$env:SigningCertificatePasswd /restore + env: + BuildMode: SideloadOnly + Configuration: Release + if: github.event.inputs.enableX64 == 'true' + + - name: copy x64 document + run: cp C:\Package\安装教程.pdf ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x64_Test\安装教程.pdf + if: github.event.inputs.enableX64 == 'true' + + - name: Remove x64 useless files + run: | + cd ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x64_Test + rm -r -fo *.appxsym + cd Dependencies + rm -r -fo arm,arm64,x86 + if: github.event.inputs.enableX64 == 'true' + + - name: Create x64 archive + run: Compress-Archive -Path ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x64_Test -DestinationPath C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_x64.zip + if: github.event.inputs.enableX64 == 'true' + + - name: Update x64 release asset + id: upload-release-asset-x64 + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} + if: github.event.inputs.enableX64 == 'true' + with: + upload_url: ${{ steps.release-drafter.outputs.upload_url }} + asset_path: C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_x64.zip + asset_name: ${{env.AppName}}_${{github.event.inputs.version}}_x64.zip + asset_content_type: application/zip + + - name: Set x64 native + run: | + ./scripts/setNative.ps1 -csprojPath $env:UWP_Project_Path + if: github.event.inputs.enableX64Native == 'true' + + - name: Build x64 native + run: | + msbuild $env:UWP_Project_Directory /p:Platform=x64 /p:Configuration=Release /p:PackageCertificateKeyFile=$env:SigningCertificate /p:PackageCertificatePassword=$env:SigningCertificatePasswd /restore /p:Use64BitCompiler=true + env: + BuildMode: SideloadOnly + Configuration: Release + if: github.event.inputs.enableX64Native == 'true' + + - name: copy x64 native document + run: cp C:\Package\安装教程.pdf ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x64_Test\安装教程.pdf + if: github.event.inputs.enableX64Native == 'true' + + - name: Remove x64 native useless files + run: | + cd ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x64_Test + rm -r -fo *.appxsym + cd Dependencies + rm -r -fo arm,arm64,x86 + if: github.event.inputs.enableX64Native == 'true' + + - name: Create x64 native archive + run: Compress-Archive -Path ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x64_Test -DestinationPath C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_x64_native.zip + if: github.event.inputs.enableX64Native == 'true' + + - name: Update x64 native release asset + id: upload-release-asset-x64-native + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} + if: github.event.inputs.enableX64Native == 'true' + with: + upload_url: ${{ steps.release-drafter.outputs.upload_url }} + asset_path: C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_x64_native.zip + asset_name: ${{env.AppName}}_${{github.event.inputs.version}}_x64_native.zip + asset_content_type: application/zip + + - name: Build x86 + run: msbuild $env:UWP_Project_Directory /p:Platform=x86 /p:Configuration=Release /p:PackageCertificateKeyFile=$env:SigningCertificate /p:PackageCertificatePassword=$env:SigningCertificatePasswd /restore + if: github.event.inputs.enableX86 == 'true' + env: + BuildMode: SideloadOnly + Configuration: Release + + - name: copy x86 document + run: cp C:\Package\安装教程.pdf ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x86_Test\安装教程.pdf + if: github.event.inputs.enableX86 == 'true' + + - name: Remove x86 useless files + run: | + cd ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x86_Test + rm -r -fo *.appxsym + cd Dependencies + rm -r -fo arm,arm64,x64 + if: github.event.inputs.enableX86 == 'true' + + - name: Create x86 archive + run: Compress-Archive -Path ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_x86_Test -DestinationPath C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_x86.zip + if: github.event.inputs.enableX86 == 'true' + + - name: Update x86 release asset + id: upload-release-asset-x86 + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} + if: github.event.inputs.enableX86 == 'true' + with: + upload_url: ${{ steps.release-drafter.outputs.upload_url }} + asset_path: C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_x86.zip + asset_name: ${{env.AppName}}_${{github.event.inputs.version}}_x86.zip + asset_content_type: application/zip + + - name: Build ARM64 + run: msbuild $env:UWP_Project_Directory /p:Platform=ARM64 /p:Configuration=Release /p:PackageCertificateKeyFile=$env:SigningCertificate /p:PackageCertificatePassword=$env:SigningCertificatePasswd /restore + if: github.event.inputs.enableArm64 == 'true' + env: + BuildMode: SideloadOnly + Configuration: Release + + - name: copy arm64 document + run: cp C:\Package\安装教程.pdf ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_ARM64_Test\安装教程.pdf + if: github.event.inputs.enableArm64 == 'true' + + - name: Remove arm64 useless files + run: | + cd ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_ARM64_Test + rm -r -fo *.appxsym + cd Dependencies + rm -r -fo arm,x64,x86 + if: github.event.inputs.enableArm64 == 'true' + + - name: Create ARM64 archive + run: Compress-Archive -Path ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_ARM64_Test -DestinationPath C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_ARM64.zip + if: github.event.inputs.enableArm64 == 'true' + + - name: Update ARM64 release asset + id: upload-release-asset-ARM64 + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} + if: github.event.inputs.enableArm64 == 'true' + with: + upload_url: ${{ steps.release-drafter.outputs.upload_url }} + asset_path: C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_ARM64.zip + asset_name: ${{env.AppName}}_${{github.event.inputs.version}}_ARM64.zip + asset_content_type: application/zip + + - name: Build ARM32 + run: msbuild $env:UWP_Project_Directory /p:Platform=ARM /p:Configuration=Release /p:PackageCertificateKeyFile=$env:SigningCertificate /p:PackageCertificatePassword=$env:SigningCertificatePasswd /restore + if: github.event.inputs.enableArm32 == 'true' + env: + BuildMode: SideloadOnly + Configuration: Release + + - name: copy arm32 document + run: cp C:\Package\安装教程.pdf ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_ARM_Test\安装教程.pdf + if: github.event.inputs.enableArm32 == 'true' + + - name: Remove arm32 useless files + run: | + cd ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_ARM_Test + rm -r -fo *.appxsym + cd Dependencies + rm -r -fo arm64,x64,x86 + if: github.event.inputs.enableArm32 == 'true' + + - name: Create ARM32 archive + run: Compress-Archive -Path ${{env.UWP_Project_Directory}}\AppPackages\${{env.AppName}}_${{github.event.inputs.version}}_ARM_Test -DestinationPath C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_ARM.zip + if: github.event.inputs.enableArm32 == 'true' + + - name: Update ARM32 release asset + id: upload-release-asset-ARM32 + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} + if: github.event.inputs.enableArm32 == 'true' + with: + upload_url: ${{ steps.release-drafter.outputs.upload_url }} + asset_path: C:\Package\${{env.AppName}}_${{github.event.inputs.version}}_ARM.zip + asset_name: ${{env.AppName}}_${{github.event.inputs.version}}_ARM.zip + asset_content_type: application/zip diff --git a/BiliLite.sln b/BiliLite.sln index c7201e94..3ab038f3 100644 --- a/BiliLite.sln +++ b/BiliLite.sln @@ -28,6 +28,8 @@ Project("{C7167F0D-BC9F-4E6E-AFE1-012C56B48DB5}") = "BiliLite.Packages", "src\Bi EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BiliLite.Win32Tools", "src\BiliLite.Win32Tools\BiliLite.Win32Tools.csproj", "{B44AD18B-7805-4FFB-A29E-C57D09C8D425}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BackgroundTasks", "src\BackgroundTasks\BackgroundTasks.csproj", "{32288EDB-3F7F-479A-8303-7BB6705E0636}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -200,6 +202,26 @@ Global {B44AD18B-7805-4FFB-A29E-C57D09C8D425}.Release|x64.Build.0 = Release|Any CPU {B44AD18B-7805-4FFB-A29E-C57D09C8D425}.Release|x86.ActiveCfg = Release|Any CPU {B44AD18B-7805-4FFB-A29E-C57D09C8D425}.Release|x86.Build.0 = Release|Any CPU + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Debug|Any CPU.Build.0 = Debug|Any CPU + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Debug|ARM.ActiveCfg = Debug|ARM + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Debug|ARM.Build.0 = Debug|ARM + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Debug|ARM64.Build.0 = Debug|ARM64 + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Debug|x64.ActiveCfg = Debug|x64 + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Debug|x64.Build.0 = Debug|x64 + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Debug|x86.ActiveCfg = Debug|x86 + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Debug|x86.Build.0 = Debug|x86 + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Release|Any CPU.ActiveCfg = Release|Any CPU + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Release|Any CPU.Build.0 = Release|Any CPU + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Release|ARM.ActiveCfg = Release|ARM + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Release|ARM.Build.0 = Release|ARM + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Release|ARM64.ActiveCfg = Release|ARM64 + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Release|ARM64.Build.0 = Release|ARM64 + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Release|x64.ActiveCfg = Release|x64 + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Release|x64.Build.0 = Release|x64 + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Release|x86.ActiveCfg = Release|x86 + {32288EDB-3F7F-479A-8303-7BB6705E0636}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/scripts/setNative.ps1 b/scripts/setNative.ps1 new file mode 100644 index 00000000..f6cc6cef --- /dev/null +++ b/scripts/setNative.ps1 @@ -0,0 +1,47 @@ +param ( + [string]$csprojPath +) + +# Check if the input file exists +if (-not (Test-Path $csprojPath)) { + Write-Error "File not found: $csprojPath" + exit 1 +} + +# Read the content of the csproj file with UTF-8 encoding +$csprojContent = Get-Content -Path $csprojPath -Raw -Encoding UTF8 + +# Define the target PropertyGroup condition +# Use backticks to escape the $ character +$targetCondition = "'`$(Configuration)|`$(Platform)' == 'Release|x64'" + +# Find the PropertyGroup with the target condition +$propertyGroupRegex = [regex]::Escape("") + ".*?" + [regex]::Escape("") +$propertyGroupMatch = [regex]::Match($csprojContent, $propertyGroupRegex, [Text.RegularExpressions.RegexOptions]::Singleline) + +if ($propertyGroupMatch.Success) { + # Extract the PropertyGroup content + $propertyGroupContent = $propertyGroupMatch.Value + + # Check if UseDotNetNativeToolchain exists in the PropertyGroup + $useDotNetNativeToolchainRegex = [regex]::Escape("") + ".*?" + [regex]::Escape("") + $useDotNetNativeToolchainMatch = [regex]::Match($propertyGroupContent, $useDotNetNativeToolchainRegex) + + if ($useDotNetNativeToolchainMatch.Success) { + # Replace the value of UseDotNetNativeToolchain with true + $updatedPropertyGroupContent = $propertyGroupContent -replace $useDotNetNativeToolchainRegex, "true" + } else { + # If UseDotNetNativeToolchain doesn't exist, add it + $updatedPropertyGroupContent = $propertyGroupContent -replace "", "true" + } + + # Replace the original PropertyGroup with the updated one + $csprojContent = $csprojContent -replace [regex]::Escape($propertyGroupContent), $updatedPropertyGroupContent + + # Write the updated content back to the file with UTF-8 encoding + Set-Content -Path $csprojPath -Value $csprojContent -Encoding UTF8 + + Write-Host "Updated UseDotNetNativeToolchain to true in the PropertyGroup with condition '$targetCondition'." +} else { + Write-Warning "PropertyGroup with condition '$targetCondition' not found in the csproj file." +} \ No newline at end of file diff --git a/src/BackgroundTasks/BackgroundTasks.csproj b/src/BackgroundTasks/BackgroundTasks.csproj new file mode 100644 index 00000000..ecad63af --- /dev/null +++ b/src/BackgroundTasks/BackgroundTasks.csproj @@ -0,0 +1,154 @@ + + + + + latest + Debug + AnyCPU + {32288EDB-3F7F-479A-8303-7BB6705E0636} + winmdobj + Properties + BackgroundTasks + BackgroundTasks + zh-CN + UAP + 10.0.22621.0 + 10.0.19041.0 + 14 + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + false + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + prompt + 4 + + + x86 + true + bin\x86\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + false + prompt + + + x86 + bin\x86\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + false + prompt + + + ARM + true + bin\ARM\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + false + prompt + + + ARM + bin\ARM\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + false + prompt + + + ARM64 + true + bin\ARM64\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + false + prompt + + + ARM64 + bin\ARM64\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + false + prompt + + + x64 + true + bin\x64\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + false + prompt + true + + + x64 + bin\x64\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + false + prompt + + + PackageReference + + + + + + + + 6.2.14 + + + + + {8b90b3b3-844b-4610-9dcf-c9b250182ae3} + BiliLite.UWP + + + + 14.0 + + + + + + + \ No newline at end of file diff --git a/src/BackgroundTasks/Properties/AssemblyInfo.cs b/src/BackgroundTasks/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..a8a3fb81 --- /dev/null +++ b/src/BackgroundTasks/Properties/AssemblyInfo.cs @@ -0,0 +1,29 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("BackgroundTasks")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("BackgroundTasks")] +[assembly: AssemblyCopyright("Copyright © 2021")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: ComVisible(false)] \ No newline at end of file diff --git a/src/BackgroundTasks/TileFeedBackgroundTask.cs b/src/BackgroundTasks/TileFeedBackgroundTask.cs new file mode 100644 index 00000000..98a217a8 --- /dev/null +++ b/src/BackgroundTasks/TileFeedBackgroundTask.cs @@ -0,0 +1,23 @@ +using System.Diagnostics; +using Windows.ApplicationModel.Background; +using BiliLite.Extensions.Notifications; + +namespace BackgroundTasks +{ + public sealed class TileFeedBackgroundTask : IBackgroundTask + { + public void Run(IBackgroundTaskInstance taskInstance) + { + Debug.WriteLine("================ debug to updating tiles ================"); + + // Get a deferral, to prevent the task from closing prematurely + // while asynchronous code is still running. + var deferral = taskInstance.GetDeferral(); + + NotificationShowExtensions.Tile(); + + // Inform the system that the task is finished. + deferral.Complete(); + } + } +} \ No newline at end of file diff --git a/src/BiliLite.JSBridge/BiliLite.JSBridge.csproj b/src/BiliLite.JSBridge/BiliLite.JSBridge.csproj index f815d6fb..c11e0309 100644 --- a/src/BiliLite.JSBridge/BiliLite.JSBridge.csproj +++ b/src/BiliLite.JSBridge/BiliLite.JSBridge.csproj @@ -2,6 +2,7 @@ + latest Debug AnyCPU {809C7636-0AF1-4695-9230-22F74D7B1327} diff --git a/src/BiliLite.Packages/Package.appxmanifest b/src/BiliLite.Packages/Package.appxmanifest index 3b9a830e..717d0de8 100644 --- a/src/BiliLite.Packages/Package.appxmanifest +++ b/src/BiliLite.Packages/Package.appxmanifest @@ -61,6 +61,12 @@ + + + + + @@ -72,4 +78,14 @@ + + + + CLRHost.dll + + + + diff --git a/src/BiliLite.UWP/App.xaml b/src/BiliLite.UWP/App.xaml index aff62f40..6b7e7ee8 100644 --- a/src/BiliLite.UWP/App.xaml +++ b/src/BiliLite.UWP/App.xaml @@ -12,10 +12,11 @@ - - - - + + + + + 4 diff --git a/src/BiliLite.UWP/App.xaml.cs b/src/BiliLite.UWP/App.xaml.cs index 187139b9..cc3a42d0 100644 --- a/src/BiliLite.UWP/App.xaml.cs +++ b/src/BiliLite.UWP/App.xaml.cs @@ -1,8 +1,11 @@ using BiliLite.Extensions; +using BiliLite.Extensions.Notifications; using BiliLite.Models.Common; using BiliLite.Models.Events; +using BiliLite.Pages; using BiliLite.Services; using FFmpegInteropX; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Toolkit.Uwp.Helpers; using System; @@ -14,8 +17,6 @@ using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Navigation; -using BiliLite.Pages; -using Microsoft.Extensions.DependencyInjection; namespace BiliLite { @@ -161,7 +162,6 @@ private async void Navigation(object arguments, bool prelaunch = false) rootFrame.NavigationFailed += OnNavigationFailed; - //主题颜色 rootFrame.RequestedTheme = (ElementTheme)SettingService.GetValue(SettingConstants.UI.THEME, 0); @@ -182,7 +182,8 @@ private async void Navigation(object arguments, bool prelaunch = false) } // 确保当前窗口处于活动状态 Window.Current.Activate(); - ExtendAcrylicIntoTitleBar(); + var themeService = ServiceProvider.GetRequiredService(); + themeService.InitTitleBar(); } } @@ -205,6 +206,7 @@ private async void InitBili() // await Task.Delay(200); // 防止初始屏幕闪烁 } } + //圆角 App.Current.Resources["ImageCornerRadius"] = new CornerRadius(SettingService.GetValue(SettingConstants.UI.IMAGE_CORNER_RADIUS, 0)); await AppHelper.SetRegions(); @@ -222,6 +224,16 @@ private async void InitBili() } VideoPlayHistoryHelper.LoadABPlayHistories(true); + try + { + var themeService = ServiceProvider.GetRequiredService(); + themeService.Init(); + } + catch (Exception ex) + { + logger.Error("初始化主题错误", ex); + } + //var pluginService = ServiceProvider.GetRequiredService(); //await pluginService.Start(); } @@ -255,11 +267,6 @@ private void OnSuspending(object sender, SuspendingEventArgs e) deferral.Complete(); } - public static void ExtendAcrylicIntoTitleBar() - { - AppExtensions.HandleTitleTheme(); - } - protected override void OnActivated(IActivatedEventArgs args) { base.OnActivated(args); @@ -287,5 +294,12 @@ private void RegisterService() logger.Error("Start Host Error", ex); } } + + protected override async void OnBackgroundActivated(BackgroundActivatedEventArgs args) + { + //base.OnBackgroundActivated(args); + //IBackgroundTaskInstance taskInstance = args.TaskInstance; + await NotificationShowExtensions.Tile(); + } } } \ No newline at end of file diff --git a/src/BiliLite.UWP/BiliLite.UWP.csproj b/src/BiliLite.UWP/BiliLite.UWP.csproj index 3bc9bf1a..05028001 100644 --- a/src/BiliLite.UWP/BiliLite.UWP.csproj +++ b/src/BiliLite.UWP/BiliLite.UWP.csproj @@ -10,7 +10,7 @@ BiliLite BiliLite zh-cn - 8.0 + latest UAP 10.0.19041.0 10.0.18362.0 @@ -186,6 +186,7 @@ VideoListView.xaml + EditPlaySpeedMenuDialog.xaml @@ -199,6 +200,7 @@ + @@ -262,6 +264,7 @@ + @@ -271,6 +274,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MarkdownViewerPage.xaml @@ -279,8 +331,13 @@ + + + + + @@ -788,9 +845,9 @@ - + - + @@ -799,25 +856,25 @@ - + - + - - + + - + - + - + - + @@ -829,7 +886,7 @@ - + @@ -1457,22 +1514,30 @@ Designer MSBuild:Compile - + MSBuild:Compile Designer - + MSBuild:Compile Designer - + MSBuild:Compile Designer - + MSBuild:Compile Designer + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + @@ -1535,6 +1600,9 @@ 6.1.1 + + 7.1.3 + 6.1.1 @@ -1611,6 +1679,7 @@ + diff --git a/src/BiliLite.UWP/Controls/CommentControl.xaml b/src/BiliLite.UWP/Controls/CommentControl.xaml index c6401b6e..19fa40e7 100644 --- a/src/BiliLite.UWP/Controls/CommentControl.xaml +++ b/src/BiliLite.UWP/Controls/CommentControl.xaml @@ -11,7 +11,7 @@ xmlns:convert="using:BiliLite.Converters" xmlns:modules="using:BiliLite.Modules" xmlns:comment="using:BiliLite.ViewModels.Comment" xmlns:common="using:BiliLite.Models.Common" - xmlns:viewModels="using:BiliLite.ViewModels" + xmlns:viewModels="using:BiliLite.ViewModels" xmlns:muxc="using:Microsoft.UI.Xaml.Controls" d:DesignHeight="300" d:DesignWidth="400" x:Name="CommentControlContent" @@ -49,7 +49,7 @@ - + @@ -59,7 +59,7 @@ - + @@ -388,7 +388,7 @@ - + @@ -462,7 +462,7 @@ - + 加载更多 diff --git a/src/BiliLite.UWP/Controls/Dynamic/DynamicItemControl.xaml b/src/BiliLite.UWP/Controls/Dynamic/DynamicItemControl.xaml index 26e5b54f..88642b80 100644 --- a/src/BiliLite.UWP/Controls/Dynamic/DynamicItemControl.xaml +++ b/src/BiliLite.UWP/Controls/Dynamic/DynamicItemControl.xaml @@ -40,7 +40,7 @@ - + diff --git a/src/BiliLite.UWP/Controls/PlayerControl.xaml b/src/BiliLite.UWP/Controls/PlayerControl.xaml index b123eae1..a710dff8 100644 --- a/src/BiliLite.UWP/Controls/PlayerControl.xaml +++ b/src/BiliLite.UWP/Controls/PlayerControl.xaml @@ -14,6 +14,7 @@ xmlns:common="using:BiliLite.Models.Common" xmlns:player1="using:BiliLite.Models.Common.Player" xmlns:modules="using:BiliLite.Modules" + xmlns:video="using:BiliLite.Models.Common.Video" xmlns:muxc="using:Microsoft.UI.Xaml.Controls" d:DesignHeight="800" d:DesignWidth="1000"> @@ -299,7 +300,7 @@ - + @@ -337,7 +338,7 @@ SelectedItem="{Binding Path=Select,Mode=OneWay}" SelectionChanged="NodeList_SelectionChanged" > - + @@ -605,10 +606,6 @@ 繁体字幕转简体 - @@ -633,10 +630,6 @@ - - - - @@ -701,9 +694,9 @@ - + Maximum="{Binding ElementName=Player,Path=Duration,Mode=OneWay}"> @@ -946,7 +939,7 @@ - + diff --git a/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs b/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs index 1bb8e454..16558e6b 100644 --- a/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs +++ b/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs @@ -1,4 +1,4 @@ -using BiliLite.Modules; +using BiliLite.Modules; using NSDanmaku.Model; using System; using System.Collections.Generic; @@ -54,7 +54,6 @@ public sealed partial class PlayerControl : UserControl, IDisposable private static readonly ILogger _logger = GlobalLogger.FromCurrentType(); private readonly bool m_useNsDanmaku = true; private readonly IDanmakuController m_danmakuController; - private readonly FrostMasterDanmakuController m_assSubtitleController; private readonly VideoDanmakuSettingsControlViewModel m_danmakuSettingsControlViewModel; private readonly PlayControlViewModel m_viewModel; private readonly PlayerToastService m_playerToastService; @@ -177,9 +176,6 @@ public PlayerControl() m_danmakuController = App.ServiceProvider.GetRequiredService(); m_danmakuController.Init(DanmakuCanvas); } - - m_assSubtitleController = App.ServiceProvider.GetRequiredService(); - m_assSubtitleController.Init(SubtitleCanvas); } private void Timer_focus_Tick(object sender, object e) @@ -233,7 +229,6 @@ private void PlayerControl_Unloaded(object sender, RoutedEventArgs e) private async void PlayerControl_Loaded(object sender, RoutedEventArgs e) { m_danmakuController.Clear(); - m_assSubtitleController.Clear(); BtnFoucs.Focus(FocusState.Programmatic); _systemMediaTransportControls = SystemMediaTransportControls.GetForCurrentView(); _systemMediaTransportControls.IsPlayEnabled = true; @@ -604,14 +599,6 @@ private void LoadSutitleSetting() SettingService.SetValue(SettingConstants.Player.SUBTITLE_SIZE, SubtitleSettingSize.Value); UpdateSubtitle(); }); - //外置字幕大小 - //OutsideSubtitleSettingSize.Value = 3;//SettingService.GetValue(SettingConstants.Player.SUBTITLE_SIZE, 40); - //OutsideSubtitleSettingSize.ValueChanged += new RangeBaseValueChangedEventHandler((e, args) => - //{ - // if (miniWin) return; - // //SettingService.SetValue(SettingConstants.Player.SUBTITLE_SIZE, SubtitleSettingSize.Value); - // m_assSubtitleController.SetFontZoom((int)OutsideSubtitleSettingSize.Value); - //}); //字幕描边颜色 SubtitleSettingBorderColor.SelectedIndex = SettingService.GetValue(SettingConstants.Player.SUBTITLE_BORDER_COLOR, 0); SubtitleSettingBorderColor.SelectionChanged += new SelectionChangedEventHandler((e, args) => @@ -840,7 +827,6 @@ private async void DanmuTimer_Tick(object sender, object e) return; } m_danmakuController.UpdateTime(position); - m_assSubtitleController.UpdateTime(position); var needDistinct = DanmuSettingMerge.IsOn; var level = DanmuSettingShieldLevel.Value; @@ -854,7 +840,6 @@ private async void DanmuTimer_Tick(object sender, object e) if (Player.PlayState == PlayState.Pause) { m_danmakuController.Pause(); - m_assSubtitleController.Pause(); } } @@ -1024,15 +1009,6 @@ private async void SetSubTitle(string url) { try { - if (url.EndsWith(".ass")) - { - var content = await playerHelper.GetAssFileContent(url); - m_assSubtitleController.SetFontZoom(1); - m_assSubtitleController.SetAssSubtitle(content); - - return; - } - subtitles = await playerHelper.GetSubtitle(url); if (subtitles != null) { @@ -1050,9 +1026,8 @@ private async void SetSubTitle(string url) subtitleTimer.Start(); } } - catch (Exception ex) + catch (Exception) { - _logger.Error(ex.Message, ex); Notify.ShowMessageToast("加载字幕失败了"); } @@ -1166,7 +1141,6 @@ private async Task GenerateSubtitleItem(string text) /// private void ClearSubTitle() { - m_assSubtitleController.Clear(); if (subtitles != null) { if (subtitleTimer != null) @@ -1614,7 +1588,7 @@ private async Task ChangeQualityPlayVideo(BiliPlayUrlInfo qual if (quality.PlayUrlType == BiliPlayUrlType.DASH) { var realPlayerType = (RealPlayerType)SettingService.GetValue(SettingConstants.Player.USE_REAL_PLAYER_TYPE, (int)SettingConstants.Player.DEFAULT_USE_REAL_PLAYER_TYPE); - if (realPlayerType==RealPlayerType.Native) + if (realPlayerType == RealPlayerType.Native) { result = await Player.PlayerDashUseNative(quality.DashInfo, quality.UserAgent, quality.Referer, positon: _postion); @@ -1701,17 +1675,12 @@ public void FullScreen(bool fullScreen) FullScreenEvent?.Invoke(this, fullScreen); MessageCenter.SetFullscreen(fullScreen); m_danmakuController.SetFullscreen(fullScreen); - m_assSubtitleController.SetFullscreen(fullScreen); if (fullScreen) { BottomBtnExitFull.Visibility = Visibility.Visible; BottomBtnFull.Visibility = Visibility.Collapsed; BottomBtnFullWindows.Visibility = Visibility.Collapsed; BottomBtnExitFullWindows.Visibility = Visibility.Collapsed; - if (SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) > 0) - { - TopControlBar.Margin = new Thickness(0, 48, 0, 0); - } //全屏 if (!view.IsFullScreenMode) @@ -2258,7 +2227,6 @@ private void BottomBtnPlay_Click(object sender, RoutedEventArgs e) { Player.Play(); m_danmakuController.Resume(); - m_assSubtitleController.Resume(); } } @@ -2320,7 +2288,6 @@ private void Player_PlayStateChanged(object sender, PlayState e) BottomBtnPlay.Visibility = Visibility.Collapsed; BottomBtnPause.Visibility = Visibility.Visible; m_danmakuController.Resume(); - m_assSubtitleController.Resume(); break; case PlayState.Pause: KeepScreenOn(false); @@ -2333,7 +2300,6 @@ private void Player_PlayStateChanged(object sender, PlayState e) BottomBtnPlay.Visibility = Visibility.Visible; BottomBtnPause.Visibility = Visibility.Collapsed; m_danmakuController.Pause(); - m_assSubtitleController.Pause(); break; case PlayState.End: KeepScreenOn(false); @@ -2367,7 +2333,6 @@ private void Player_PlayBufferStart(object sender, EventArgs e) TxtBuffering.Text = "正在缓冲..."; BufferingProgress = 0; m_danmakuController.Pause(); - m_assSubtitleController.Pause(); } private void Player_PlayBuffering(object sender, double e) @@ -2383,7 +2348,6 @@ private void Player_PlayBufferEnd(object sender, EventArgs e) GridBuffering.Visibility = Visibility.Collapsed; Buffering = false; m_danmakuController.Resume(); - m_assSubtitleController.Resume(); } private async void Player_PlayMediaEnded(object sender, EventArgs e) @@ -2396,7 +2360,6 @@ private async void Player_PlayMediaEnded(object sender, EventArgs e) return; } m_danmakuController.Pause(); - m_assSubtitleController.Pause(); InteractionChoices.Visibility = Visibility.Visible; return; } @@ -2450,7 +2413,6 @@ private async void Player_PlayMediaEnded(object sender, EventArgs e) { ClearSubTitle(); m_danmakuController.Clear(); - m_assSubtitleController.Clear(); Player.Play(); return; } @@ -2467,7 +2429,6 @@ private async void Player_PlayMediaEnded(object sender, EventArgs e) { ClearSubTitle(); m_danmakuController.Clear(); - m_assSubtitleController.Clear(); Player.Play(); return; } @@ -3014,19 +2975,5 @@ private void ViewPoint_OnTapped(object sender, TappedRoutedEventArgs e) if (!(element.DataContext is PlayerInfoViewPoint viewPoint)) return; SetPosition(viewPoint.From); } - - private async void BtnImportSubFile_OnClick(object sender, RoutedEventArgs e) - { - var path = await playerHelper.GetOutsideSubtitle(); - - if (path == null) return; - - (BottomBtnSelctSubtitle.Flyout as MenuFlyout).Items.Add(new ToggleMenuFlyoutItem() - { - Tag = path, - Name = "外置字幕" - }); - SetSubTitle(path); - } } } diff --git a/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml b/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml index 67f861e6..68daec49 100644 --- a/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml +++ b/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml @@ -200,6 +200,14 @@ + + + + + + + @@ -322,16 +330,24 @@ - - - + + + + + - - - + + + + + + + + diff --git a/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml.cs b/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml.cs index fcb763cb..dd8fc806 100644 --- a/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml.cs +++ b/src/BiliLite.UWP/Controls/Settings/UISettingsControl.xaml.cs @@ -7,8 +7,11 @@ using BiliLite.Models.Common; using BiliLite.Models.Common.Home; using BiliLite.Services; +using Microsoft.Extensions.DependencyInjection; using Microsoft.UI.Xaml.Controls; using Microsoft.Toolkit.Uwp.UI; +using BiliLite.Extensions.Notifications; +using Windows.ApplicationModel.Background; //https://go.microsoft.com/fwlink/?LinkId=234236 上介绍了“用户控件”项模板 @@ -16,8 +19,11 @@ namespace BiliLite.Controls.Settings { public sealed partial class UISettingsControl : UserControl { + private readonly ThemeService m_themeService; + public UISettingsControl() { + m_themeService = App.ServiceProvider.GetRequiredService(); this.InitializeComponent(); LoadUI(); } @@ -29,25 +35,10 @@ private void LoadUI() { cbTheme.SelectionChanged += new SelectionChangedEventHandler((obj, args) => { - SettingService.SetValue(SettingConstants.UI.THEME, cbTheme.SelectedIndex); - Frame rootFrame = Window.Current.Content as Frame; - switch (cbTheme.SelectedIndex) - { - case 1: - rootFrame.RequestedTheme = ElementTheme.Light; - break; - case 2: - rootFrame.RequestedTheme = ElementTheme.Dark; - break; - //case 3: - // // TODO: 切换自定义主题 - // rootFrame.Resources = Application.Current.Resources.ThemeDictionaries["Pink"] as ResourceDictionary; - // break; - default: - rootFrame.RequestedTheme = ElementTheme.Default; - break; - } - App.ExtendAcrylicIntoTitleBar(); + var themeIndex = cbTheme.SelectedIndex; + if (themeIndex > 2) + m_themeService.SetTheme(ElementTheme.Default); + m_themeService.SetTheme((ElementTheme)themeIndex); }); }); @@ -142,6 +133,24 @@ private void LoadUI() }; }; + //动态磁贴 + SwitchTile.IsOn = SettingService.GetValue(SettingConstants.UI.ENABLE_NOTIFICATION_TILES, false); + SwitchTile.Loaded += (sender, e) => + { + SwitchTile.Toggled += (obj, args) => + { + SettingService.SetValue(SettingConstants.UI.ENABLE_NOTIFICATION_TILES, SwitchTile.IsOn); + if (SwitchTile.IsOn) + { + RegisterBackgroundTask(); + } + else + { + // TODO: UnregisterBackgroundTask + } + }; + }; + //图片圆角半径 numImageCornerRadius.Value = SettingService.GetValue(SettingConstants.UI.IMAGE_CORNER_RADIUS, 0); ImageCornerRadiusExample.CornerRadius = new CornerRadius(numImageCornerRadius.Value); @@ -297,6 +306,36 @@ private void LoadUI() }; }; + // 标签最小宽度 + NumTabItemMinWidth.Value = SettingService.GetValue(SettingConstants.UI.TAB_ITEM_MIN_WIDTH, SettingConstants.UI.DEFAULT_TAB_ITEM_MIN_WIDTH); + NumTabItemMinWidth.Loaded += (sender, e) => + { + NumTabItemMinWidth.ValueChanged += (obj, args) => + { + SettingService.SetValue(SettingConstants.UI.TAB_ITEM_MIN_WIDTH, NumTabItemMinWidth.Value); + }; + }; + + // 标签最大宽度 + NumTabItemMaxWidth.Value = SettingService.GetValue(SettingConstants.UI.TAB_ITEM_MAX_WIDTH, SettingConstants.UI.DEFAULT_TAB_ITEM_MAX_WIDTH); + NumTabItemMaxWidth.Loaded += (sender, e) => + { + NumTabItemMaxWidth.ValueChanged += (obj, args) => + { + SettingService.SetValue(SettingConstants.UI.TAB_ITEM_MAX_WIDTH, NumTabItemMaxWidth.Value); + }; + }; + + // 标签高度 + NumTabHeight.Value = SettingService.GetValue(SettingConstants.UI.TAB_HEIGHT, SettingConstants.UI.DEFAULT_TAB_HEIGHT); + NumTabHeight.Loaded += (sender, e) => + { + NumTabHeight.ValueChanged += (obj, args) => + { + SettingService.SetValue(SettingConstants.UI.TAB_HEIGHT, NumTabHeight.Value); + }; + }; + //显示视频底部进度条 SwShowVideoBottomProgress.IsOn = SettingService.GetValue(SettingConstants.UI.SHOW_VIDEO_BOTTOM_VIRTUAL_PROGRESS_BAR, SettingConstants.UI.DEFAULT_SHOW_VIDEO_BOTTOM_VIRTUAL_PROGRESS_BAR); SwShowVideoBottomProgress.Loaded += (sender, e) => @@ -372,5 +411,13 @@ private void menuRemoveHomeItem_Click(object sender, RoutedEventArgs e) ExceptHomeNavItems(); Notify.ShowMessageToast("更改成功,重启生效"); } + + private void RegisterBackgroundTask() + { + NotificationRegisterExtensions.BackgroundTask("DisposableTileFeedBackgroundTask"); + NotificationRegisterExtensions.BackgroundTask("TileFeedBackgroundTask", new TimeTrigger(15, false)); + //NotificationRegisterExtensions.BackgroundTask("TileFeedBackgroundTask", + // "BackgroundTasks.TileFeedBackgroundTask", new TimeTrigger(15, false)); + } } } diff --git a/src/BiliLite.UWP/Controls/VideoListView.xaml b/src/BiliLite.UWP/Controls/VideoListView.xaml index e7012f07..263982f8 100644 --- a/src/BiliLite.UWP/Controls/VideoListView.xaml +++ b/src/BiliLite.UWP/Controls/VideoListView.xaml @@ -5,7 +5,7 @@ xmlns:local="using:BiliLite.Controls" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:muxc="using:Microsoft.Toolkit.Uwp.UI.Controls" + xmlns:muxc="using:Microsoft.UI.Xaml.Controls" xmlns:video="using:BiliLite.ViewModels.Video" xmlns:video1="using:BiliLite.Models.Common.Video" xmlns:common="using:BiliLite.Controls.Common" @@ -33,7 +33,7 @@ ItemsSource="{x:Bind m_viewModel.Sections,Mode=OneWay}"> - diff --git a/src/BiliLite.UWP/Converters/ColorSelectedConvert.cs b/src/BiliLite.UWP/Converters/ColorSelectedConvert.cs index e29abf5e..59ea77bc 100644 --- a/src/BiliLite.UWP/Converters/ColorSelectedConvert.cs +++ b/src/BiliLite.UWP/Converters/ColorSelectedConvert.cs @@ -2,16 +2,20 @@ using Windows.UI; using Windows.UI.Xaml.Data; using Windows.UI.Xaml.Media; +using BiliLite.Services; +using Microsoft.Extensions.DependencyInjection; + namespace BiliLite.Converters { public class ColorSelectedConvert : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { - if (value == null) return new SolidColorBrush((Color)App.Current.Resources["TextColor"]); + var themeService = App.ServiceProvider.GetRequiredService(); + if (value == null) return new SolidColorBrush((Color)themeService.ThemeResource["TextColor"]); return value.ToString() == parameter.ToString() - ? new SolidColorBrush((Color)App.Current.Resources["SystemAccentColor"]) - : new SolidColorBrush((Color)App.Current.Resources["TextColor"]); + ? new SolidColorBrush((Color)themeService.ThemeResource["SystemAccentColor"]) + : new SolidColorBrush((Color)themeService.ThemeResource["TextColor"]); } public object ConvertBack(object value, Type targetType, object parameter, string language) diff --git a/src/BiliLite.UWP/Converters/InverseBooleanConverter.cs b/src/BiliLite.UWP/Converters/InverseBooleanConverter.cs new file mode 100644 index 00000000..3a63bea4 --- /dev/null +++ b/src/BiliLite.UWP/Converters/InverseBooleanConverter.cs @@ -0,0 +1,12 @@ +using System; +using Windows.UI.Xaml.Data; + +namespace BiliLite.Converters +{ + public class InverseBooleanConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, string language) => !(bool)value; + + public object ConvertBack(object value, Type targetType, object parameter, string language) => throw new NotImplementedException(); + } +} diff --git a/src/BiliLite.UWP/Dialogs/CopyOrMoveFavVideoDialog.xaml.cs b/src/BiliLite.UWP/Dialogs/CopyOrMoveFavVideoDialog.xaml.cs index 11142ba1..b5848179 100644 --- a/src/BiliLite.UWP/Dialogs/CopyOrMoveFavVideoDialog.xaml.cs +++ b/src/BiliLite.UWP/Dialogs/CopyOrMoveFavVideoDialog.xaml.cs @@ -1,6 +1,5 @@ using BiliLite.Models; using BiliLite.Models.Requests.Api.User; -using BiliLite.Modules; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; @@ -8,6 +7,7 @@ using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using BiliLite.Extensions; +using BiliLite.Models.Common.Favorites; using BiliLite.Models.Responses; using BiliLite.ViewModels.User; @@ -44,7 +44,7 @@ private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, Conten List ids = new List(); foreach (var videoItem in selectItems) { - ids.Add(videoItem.id); + ids.Add(videoItem.Id); } if (isMove) { diff --git a/src/BiliLite.UWP/Dialogs/DownloadDialog.xaml b/src/BiliLite.UWP/Dialogs/DownloadDialog.xaml index b9acd975..48fbc8e0 100644 --- a/src/BiliLite.UWP/Dialogs/DownloadDialog.xaml +++ b/src/BiliLite.UWP/Dialogs/DownloadDialog.xaml @@ -78,7 +78,7 @@ - + diff --git a/src/BiliLite.UWP/Dialogs/SendCommentDialog.xaml b/src/BiliLite.UWP/Dialogs/SendCommentDialog.xaml index 897b9ef1..b4917c7e 100644 --- a/src/BiliLite.UWP/Dialogs/SendCommentDialog.xaml +++ b/src/BiliLite.UWP/Dialogs/SendCommentDialog.xaml @@ -26,7 +26,7 @@ - + @@ -36,7 +36,7 @@ - + diff --git a/src/BiliLite.UWP/Dialogs/SendDynamicDialog.xaml b/src/BiliLite.UWP/Dialogs/SendDynamicDialog.xaml index afb35b13..e3426cc5 100644 --- a/src/BiliLite.UWP/Dialogs/SendDynamicDialog.xaml +++ b/src/BiliLite.UWP/Dialogs/SendDynamicDialog.xaml @@ -6,7 +6,7 @@ xmlns:modules="using:BiliLite.Modules" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:viewModels="using:BiliLite.ViewModels" + xmlns:viewModels="using:BiliLite.ViewModels" xmlns:muxc="using:Microsoft.UI.Xaml.Controls" mc:Ignorable="d"> @@ -18,7 +18,7 @@ - + @@ -28,7 +28,7 @@ - + @@ -165,7 +165,7 @@ - + 图片上传中... diff --git a/src/BiliLite.UWP/Dialogs/SendDynamicV2Dialog.xaml b/src/BiliLite.UWP/Dialogs/SendDynamicV2Dialog.xaml index ab138b78..5e55a486 100644 --- a/src/BiliLite.UWP/Dialogs/SendDynamicV2Dialog.xaml +++ b/src/BiliLite.UWP/Dialogs/SendDynamicV2Dialog.xaml @@ -6,7 +6,7 @@ xmlns:modules="using:BiliLite.Modules" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:viewModels="using:BiliLite.ViewModels" + xmlns:viewModels="using:BiliLite.ViewModels" xmlns:muxc="using:Microsoft.UI.Xaml.Controls" mc:Ignorable="d"> @@ -18,7 +18,7 @@ - + @@ -28,7 +28,7 @@ - + @@ -165,7 +165,7 @@ - + 图片上传中... diff --git a/src/BiliLite.UWP/Dialogs/SendReviewDialog.xaml.cs b/src/BiliLite.UWP/Dialogs/SendReviewDialog.xaml.cs index 198d36fa..7192c3e8 100644 --- a/src/BiliLite.UWP/Dialogs/SendReviewDialog.xaml.cs +++ b/src/BiliLite.UWP/Dialogs/SendReviewDialog.xaml.cs @@ -1,7 +1,8 @@ using BiliLite.Extensions; -using BiliLite.Modules.Season; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; +using BiliLite.ViewModels.Season; +using Microsoft.Extensions.DependencyInjection; // https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“内容对话框”项模板 @@ -9,12 +10,13 @@ namespace BiliLite.Dialogs { public sealed partial class SendReviewDialog : ContentDialog { - SeasonReviewVM seasonReviewVM; + private readonly SeasonReviewViewModel m_viewModel; + public SendReviewDialog(int mediaId) { + m_viewModel = App.ServiceProvider.GetRequiredService(); + m_viewModel.MediaID = mediaId; this.InitializeComponent(); - seasonReviewVM = new SeasonReviewVM(); - seasonReviewVM.MediaID = mediaId; } private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) @@ -25,7 +27,7 @@ private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, Conten return; } int score = (int)rating.Value * 2; - var result = await seasonReviewVM.SendShortReview(txtBoxContent.Text, checkShare.IsChecked.Value, score); + var result = await m_viewModel.SendShortReview(txtBoxContent.Text, checkShare.IsChecked.Value, score); if (result) { this.Hide(); diff --git a/src/BiliLite.UWP/Extensions/MapperExtensions.cs b/src/BiliLite.UWP/Extensions/MapperExtensions.cs index 8c7df82f..a5561384 100644 --- a/src/BiliLite.UWP/Extensions/MapperExtensions.cs +++ b/src/BiliLite.UWP/Extensions/MapperExtensions.cs @@ -15,7 +15,6 @@ using BiliLite.Models.Common.Season; using BiliLite.Models.Common.Settings; using BiliLite.Models.Common.User; -using BiliLite.Models.Common.User.UserDetails; using BiliLite.Models.Common.UserDynamic; using BiliLite.Models.Common.Video; using BiliLite.Models.Common.Video.Detail; @@ -76,7 +75,11 @@ public static IServiceCollection AddMapper(this IServiceCollection services) expression.CreateMap(); expression.CreateMap(); expression.CreateMap(); - expression.CreateMap(); + expression.CreateMap(); + expression.CreateMap(); + expression.CreateMap(); + expression.CreateMap(); + expression.CreateMap(); expression.CreateMap() .ForMember(dest => dest.Author, opt => opt.MapFrom(src => diff --git a/src/BiliLite.UWP/Extensions/Notifications/NotificationRegisterExtensions.cs b/src/BiliLite.UWP/Extensions/Notifications/NotificationRegisterExtensions.cs new file mode 100644 index 00000000..4611448b --- /dev/null +++ b/src/BiliLite.UWP/Extensions/Notifications/NotificationRegisterExtensions.cs @@ -0,0 +1,99 @@ +using System; +using Windows.ApplicationModel.Background; + +namespace BiliLite.Extensions.Notifications +{ + public class NotificationRegisterExtensions + { + /// + /// 单次执行后台任务 + /// + /// + public static async void BackgroundTask(string taskName) + { + BackgroundExecutionManager.RemoveAccess(); + var backgroundAccessStatus = await BackgroundExecutionManager.RequestAccessAsync(); + if (backgroundAccessStatus == BackgroundAccessStatus.AllowedSubjectToSystemPolicy || + backgroundAccessStatus == BackgroundAccessStatus.AlwaysAllowed) + { + foreach (var task in BackgroundTaskRegistration.AllTasks) + { + if (task.Value.Name == taskName) + { + task.Value.Unregister(true); + } + } + + var taskBuilder = new BackgroundTaskBuilder() + { + Name = taskName, + }; + var trigger = new ApplicationTrigger(); + taskBuilder.SetTrigger(trigger); + taskBuilder.Register(); + await trigger.RequestAsync(); + } + } + + /// + /// 注册进程内后台任务 + /// + /// + /// + public static async void BackgroundTask(string taskName, IBackgroundTrigger trigger) + { + BackgroundExecutionManager.RemoveAccess(); + var backgroundAccessStatus = await BackgroundExecutionManager.RequestAccessAsync(); + if (backgroundAccessStatus == BackgroundAccessStatus.AllowedSubjectToSystemPolicy || + backgroundAccessStatus == BackgroundAccessStatus.AlwaysAllowed) + { + foreach (var task in BackgroundTaskRegistration.AllTasks) + { + if (task.Value.Name == taskName) + { + task.Value.Unregister(true); + } + } + + var taskBuilder = new BackgroundTaskBuilder() + { + Name = taskName, + }; + taskBuilder.SetTrigger(trigger); + taskBuilder.Register(); + } + } + + /// + /// (不可用)注册进程外后台任务 + /// + /// + /// + /// + public static async void BackgroundTask(string taskName, string taskEntryPoint, IBackgroundTrigger trigger) + { + BackgroundExecutionManager.RemoveAccess(); + var backgroundAccessStatus = await BackgroundExecutionManager.RequestAccessAsync(); + if (backgroundAccessStatus == BackgroundAccessStatus.AllowedSubjectToSystemPolicy || + backgroundAccessStatus == BackgroundAccessStatus.AlwaysAllowed) + { + foreach (var task in BackgroundTaskRegistration.AllTasks) + { + if (task.Value.Name == taskName) + { + task.Value.Unregister(true); + } + } + + + var taskBuilder = new BackgroundTaskBuilder() + { + Name = taskName, + TaskEntryPoint = taskEntryPoint + }; + taskBuilder.SetTrigger(trigger); + taskBuilder.Register(); + } + } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Extensions/Notifications/NotificationShowExtensions.cs b/src/BiliLite.UWP/Extensions/Notifications/NotificationShowExtensions.cs new file mode 100644 index 00000000..d42a988a --- /dev/null +++ b/src/BiliLite.UWP/Extensions/Notifications/NotificationShowExtensions.cs @@ -0,0 +1,47 @@ +using System.Threading.Tasks; +using Windows.UI.Notifications; +using BiliLite.Models.Common.Notifications.Template; +using BiliLite.Services.Notification; +using Microsoft.Extensions.DependencyInjection; + +namespace BiliLite.Extensions.Notifications +{ + public class NotificationShowExtensions + { + public static async Task Tile() + { + // Create a tile update manager for the specified syndication feed. + var updater = TileUpdateManager.CreateTileUpdaterForApplication(); + updater.Clear(); + updater.EnableNotificationQueue(true); + + var liveTileHelper = App.ServiceProvider.GetRequiredService(); + + await liveTileHelper.RefreshTile(); + foreach (var tile in liveTileHelper.TileFurnace) + { + var content = TileTemplate.LiveTile(tile); + var notification = new TileNotification(content.GetXml()) + { + Tag = tile.Name, + }; + updater.Update(notification); + } + } + + public static void Dialog() + { + + } + + public static void MessageDialog() + { + + } + + public static void Toast() + { + + } + } +} diff --git a/src/BiliLite.UWP/Extensions/ViewModelExtensions.cs b/src/BiliLite.UWP/Extensions/ViewModelExtensions.cs index 9447e40c..b17762ef 100644 --- a/src/BiliLite.UWP/Extensions/ViewModelExtensions.cs +++ b/src/BiliLite.UWP/Extensions/ViewModelExtensions.cs @@ -1,4 +1,6 @@ -using BiliLite.ViewModels; +using System.Linq; +using BiliLite.Models.Attributes; +using BiliLite.ViewModels; using BiliLite.ViewModels.Comment; using BiliLite.ViewModels.Common; using BiliLite.ViewModels.Download; @@ -12,6 +14,7 @@ using BiliLite.ViewModels.UserDynamic; using BiliLite.ViewModels.Video; using Microsoft.Extensions.DependencyInjection; +using System.Reflection; namespace BiliLite.Extensions { @@ -55,7 +58,28 @@ public static IServiceCollection AddViewModels(this IServiceCollection services) services.AddTransient(); services.AddTransient(); services.AddTransient(); + + services.AddAttributeViewModel(); + return services; } + + private static void AddAttributeViewModel(this IServiceCollection services) + { + var types = Assembly.GetExecutingAssembly().GetTypes(); + + foreach (var type in types) + { + if (type.GetCustomAttributes(typeof(RegisterSingletonViewModelAttribute), false).Any()) + { + services.AddSingleton(type); + } + + if (type.GetCustomAttributes(typeof(RegisterTransientViewModelAttribute), false).Any()) + { + services.AddTransient(type); + } + } + } } } diff --git a/src/BiliLite.UWP/MainPage.xaml b/src/BiliLite.UWP/MainPage.xaml index 01fb1013..4876fd6c 100644 --- a/src/BiliLite.UWP/MainPage.xaml +++ b/src/BiliLite.UWP/MainPage.xaml @@ -25,7 +25,6 @@ PreviewKeyDown="TabView_OnPreviewKeyDown" TabCloseRequested="TabView_TabCloseRequested" TabItemsChanged="tabView_TabItemsChanged" - LayoutUpdated="TabView_OnLayoutUpdated" TabWidthMode="SizeToContent"> diff --git a/src/BiliLite.UWP/MainPage.xaml.cs b/src/BiliLite.UWP/MainPage.xaml.cs index ec5ae0ce..af0ccc58 100644 --- a/src/BiliLite.UWP/MainPage.xaml.cs +++ b/src/BiliLite.UWP/MainPage.xaml.cs @@ -1,4 +1,10 @@ -using BiliLite.Pages; +using BiliLite.Controls; +using BiliLite.Extensions; +using BiliLite.Models.Common; +using BiliLite.Pages; +using BiliLite.Services; +using BiliLite.ViewModels.Common; +using Microsoft.Extensions.DependencyInjection; using Microsoft.UI.Xaml.Controls; using System; using System.Linq; @@ -9,12 +15,6 @@ using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Navigation; -using BiliLite.Controls; -using BiliLite.Models.Common; -using BiliLite.Extensions; -using BiliLite.Services; -using BiliLite.ViewModels.Common; -using Microsoft.Extensions.DependencyInjection; // https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x804 上介绍了“空白页”项模板 @@ -265,6 +265,9 @@ private void ClosePage(TabViewItem tabItem) } private void tabView_Loaded(object sender, RoutedEventArgs e) { + // 根据Tab高度设置图片视图边距 + gridViewer.Margin = new Thickness(0, m_viewModel.TabHeight, 0, 0); + var frame = new MyFrame(); frame.Navigate(typeof(HomePage)); @@ -325,17 +328,19 @@ private void InitTabViewStyle() var styleKvp = dict.FirstOrDefault(x => x.Key.ToString().Contains("TabViewItem")); - if (!(styleKvp.Value is Style style)) return; - style.Setters.Add(new Setter(TabViewItem.MinWidthProperty, m_viewModel.TabItemMinWidth)); - style.Setters.Add(new Setter(TabViewItem.MaxWidthProperty, m_viewModel.TabItemMaxWidth)); - } + if (styleKvp.Value is Style style) + { + style.Setters.Add(new Setter(TabViewItem.MinWidthProperty, m_viewModel.TabItemMinWidth)); + style.Setters.Add(new Setter(TabViewItem.MaxWidthProperty, m_viewModel.TabItemMaxWidth)); + style.Setters.Add(new Setter(TabViewItem.HeightProperty, m_viewModel.TabHeight)); + } - private void TabView_OnLayoutUpdated(object sender, object e) - { - // TODO: LayoutUpdated调用频繁,后续更换其他事件 - var tabList = tabView.FindFirstChildByType(); - if (tabList == null) return; - tabList.MaxWidth = tabView.ActualWidth - 175; + var tabStyleKvp = dict.FirstOrDefault(x => x.Key.ToString().Contains("TabViewListView")); + + if (tabStyleKvp.Value is Style tabStyle) + { + tabStyle.Setters.Add(new Setter(TabViewItem.HeightProperty, m_viewModel.TabHeight)); + } } } } diff --git a/src/BiliLite.UWP/Models/Attributes/RegisterServiceAttributes.cs b/src/BiliLite.UWP/Models/Attributes/RegisterServiceAttributes.cs new file mode 100644 index 00000000..be7ebf04 --- /dev/null +++ b/src/BiliLite.UWP/Models/Attributes/RegisterServiceAttributes.cs @@ -0,0 +1,28 @@ +using System; + +namespace BiliLite.Models.Attributes +{ + [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] + public class RegisterSingletonServiceAttribute : Attribute + { + + } + + [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] + public class RegisterTransientServiceAttribute : Attribute + { + + } + + [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] + public class RegisterSingletonViewModelAttribute : Attribute + { + + } + + [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] + public class RegisterTransientViewModelAttribute : Attribute + { + + } +} diff --git a/src/BiliLite.UWP/Models/Common/Anime/AnimeTimelineItemModel.cs b/src/BiliLite.UWP/Models/Common/Anime/AnimeTimelineItemModel.cs new file mode 100644 index 00000000..5e529b6f --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Anime/AnimeTimelineItemModel.cs @@ -0,0 +1,22 @@ +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Anime; + +public class AnimeTimelineItemModel : ISeasonItem +{ + [JsonProperty("season_id")] + public int SeasonId { get; set; } + + public string Cover { get; set; } + + [JsonProperty("square_cover")] + public string SquareCover { get; set; } + + [JsonProperty("pub_index")] + public string PubIndex { get; set; } + + [JsonProperty("pub_time")] + public string PubTime { get; set; } + + public string Title { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Anime/AnimeTimelineModel.cs b/src/BiliLite.UWP/Models/Common/Anime/AnimeTimelineModel.cs new file mode 100644 index 00000000..0a38117c --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Anime/AnimeTimelineModel.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Anime; + +public class AnimeTimelineModel +{ + public string Week { get; set; } + + [JsonProperty("day_week")] + public int DayWeek { get; set; } + + public string Date { get; set; } + + [JsonProperty("is_today")] + public bool IsToday { get; set; } + + public List Seasons { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Anime/AnimeTypeItem.cs b/src/BiliLite.UWP/Models/Common/Anime/AnimeTypeItem.cs new file mode 100644 index 00000000..bac2153a --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Anime/AnimeTypeItem.cs @@ -0,0 +1,8 @@ +namespace BiliLite.Models.Common.Anime; + +public class AnimeTypeItem +{ + public string Name { get; set; } + + public AnimeType AnimeType { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/ComboBoxItemData.cs b/src/BiliLite.UWP/Models/Common/ComboBoxItemData.cs index 3e5b070a..d2138704 100644 --- a/src/BiliLite.UWP/Models/Common/ComboBoxItemData.cs +++ b/src/BiliLite.UWP/Models/Common/ComboBoxItemData.cs @@ -6,4 +6,11 @@ public class ComboBoxItemData public int Value { get; set; } } + + public class ComboBoxItemData + { + public string Text { get; set; } + + public T Value { get; set; } + } } diff --git a/src/BiliLite.UWP/Models/Common/Enumerates.cs b/src/BiliLite.UWP/Models/Common/Enumerates.cs index 3030c7f0..46011dc6 100644 --- a/src/BiliLite.UWP/Models/Common/Enumerates.cs +++ b/src/BiliLite.UWP/Models/Common/Enumerates.cs @@ -561,4 +561,23 @@ public enum SearchType /// Topic = 7 } + + public enum IndexSeasonType + { + Anime = 1, + Movie = 2, + Documentary = 3, + Guochuang = 4, + TV = 5, + Variety = 7 + } + + public enum DownloadedSortMode + { + Default, + TimeDesc, + TimeAsc, + TitleDesc, + TitleAsc, + } } \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Favorites/FavoriteDetailModel.cs b/src/BiliLite.UWP/Models/Common/Favorites/FavoriteDetailModel.cs new file mode 100644 index 00000000..a45d0d2f --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Favorites/FavoriteDetailModel.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using BiliLite.Modules; + +namespace BiliLite.Models.Common.Favorites; + +public class FavoriteDetailModel +{ + public FavoriteInfoModel Info { get; set; } + + public List Medias { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Favorites/FavoriteInfoModel.cs b/src/BiliLite.UWP/Models/Common/Favorites/FavoriteInfoModel.cs new file mode 100644 index 00000000..41560755 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Favorites/FavoriteInfoModel.cs @@ -0,0 +1,32 @@ +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Favorites; + +public class FavoriteInfoModel +{ + public string Cover { get; set; } + + public int Attr { get; set; } + + public bool Privacy => Attr == 2; + + public string Fid { get; set; } + + public string Id { get; set; } + + [JsonProperty("like_state")] + public int LikeState { get; set; } + + [JsonProperty("fav_state")] + public int FavState { get; set; } + + public string Mid { get; set; } + + public string Title { get; set; } + public int Type { get; set; } + + [JsonProperty("media_count")] + public int MediaCount { get; set; } + + public FavoriteInfoVideoItemUpperModel Upper { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Favorites/FavoriteInfoVideoItemModel.cs b/src/BiliLite.UWP/Models/Common/Favorites/FavoriteInfoVideoItemModel.cs new file mode 100644 index 00000000..74848d7f --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Favorites/FavoriteInfoVideoItemModel.cs @@ -0,0 +1,17 @@ +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Favorites; + +public class FavoriteInfoVideoItemModel +{ + public string Id { get; set; } + + public string Cover { get; set; } + + public string Title { get; set; } + + public FavoriteInfoVideoItemUpperModel Upper { get; set; } + + [JsonProperty("cnt_info")] + public FavoriteInfoVideoItemStatModel CntInfo { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Favorites/FavoriteInfoVideoItemStatModel.cs b/src/BiliLite.UWP/Models/Common/Favorites/FavoriteInfoVideoItemStatModel.cs new file mode 100644 index 00000000..c9853d2b --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Favorites/FavoriteInfoVideoItemStatModel.cs @@ -0,0 +1,16 @@ +namespace BiliLite.Models.Common.Favorites; + +public class FavoriteInfoVideoItemStatModel +{ + public int Coin { get; set; } + + public int Collect { get; set; } + + public int Danmaku { get; set; } + + public int Play { get; set; } + + public int Reply { get; set; } + + public int Share { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Favorites/FavoriteInfoVideoItemUpperModel.cs b/src/BiliLite.UWP/Models/Common/Favorites/FavoriteInfoVideoItemUpperModel.cs new file mode 100644 index 00000000..964a214e --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Favorites/FavoriteInfoVideoItemUpperModel.cs @@ -0,0 +1,10 @@ +namespace BiliLite.Models.Common.Favorites; + +public class FavoriteInfoVideoItemUpperModel +{ + public string Face { get; set; } + + public string Name { get; set; } + + public string Mid { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Home/CinemaHomeBannerModel.cs b/src/BiliLite.UWP/Models/Common/Home/CinemaHomeBannerModel.cs new file mode 100644 index 00000000..08693151 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/CinemaHomeBannerModel.cs @@ -0,0 +1,11 @@ +namespace BiliLite.Models.Common.Home +{ + public class CinemaHomeBannerModel + { + public string Title { get; set; } + + public string Img { get; set; } + + public string Url { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Home/CinemaHomeFallItemModel.cs b/src/BiliLite.UWP/Models/Common/Home/CinemaHomeFallItemModel.cs new file mode 100644 index 00000000..2fefc331 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/CinemaHomeFallItemModel.cs @@ -0,0 +1,17 @@ +namespace BiliLite.Models.Common.Home +{ + public class CinemaHomeFallItemModel + { + public string Cover { get; set; } + + public string Desc { get; set; } + + public string Title { get; set; } + + public string Link { get; set; } + + public long Cursor { get; set; } + + public int Wid { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Home/CinemaHomeFallModel.cs b/src/BiliLite.UWP/Models/Common/Home/CinemaHomeFallModel.cs new file mode 100644 index 00000000..f4121687 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/CinemaHomeFallModel.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; + +namespace BiliLite.Models.Common.Home +{ + public class CinemaHomeFallModel + { + public int Wid { get; set; } + + public string Title { get; set; } + + public bool ShowMore { get; set; } = true; + + public List Items { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Home/CinemaHomeHotItem.cs b/src/BiliLite.UWP/Models/Common/Home/CinemaHomeHotItem.cs new file mode 100644 index 00000000..53ce4a3a --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/CinemaHomeHotItem.cs @@ -0,0 +1,37 @@ +using BiliLite.Models.Common.Anime; +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Home +{ + public class CinemaHomeHotItem : ISeasonItem + { + public string Hat { get; set; } + + public string Cover { get; set; } + + public string Badge { get; set; } + + [JsonProperty("badge_type")] + public int BadgeType { get; set; } + + public bool ShowBadge => !string.IsNullOrEmpty(Badge); + + public string Desc { get; set; } + + public string Title { get; set; } + + public string Link { get; set; } + + [JsonProperty("season_id")] + public int SeasonId { get; set; } + + [JsonProperty("season_type")] + public int SeasonType { get; set; } + + public string Type { get; set; } + + public int Wid { get; set; } + + public CinemaHomeStatModel Stat { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Home/CinemaHomeModel.cs b/src/BiliLite.UWP/Models/Common/Home/CinemaHomeModel.cs new file mode 100644 index 00000000..c53e9132 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/CinemaHomeModel.cs @@ -0,0 +1,33 @@ +using System.Collections.Generic; + +namespace BiliLite.Models.Common.Home +{ + public class CinemaHomeModel + { + public List Banners { get; set; } + + public List Falls { get; set; } + + public List Update { get; set; } + + /// + /// 记录片 87 + /// + public List Documentary { get; set; } + + /// + /// 电影 88 + /// + public List Movie { get; set; } + + /// + /// 电视剧 89 + /// + public List Tv { get; set; } + + /// + /// 综艺 173 + /// + public List Variety { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Home/CinemaHomeStatModel.cs b/src/BiliLite.UWP/Models/Common/Home/CinemaHomeStatModel.cs new file mode 100644 index 00000000..921b4b8f --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/CinemaHomeStatModel.cs @@ -0,0 +1,16 @@ +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Home +{ + public class CinemaHomeStatModel + { + public long View { get; set; } + + [JsonProperty("follow_view")] + public string FollowView { get; set; } + + public long Follow { get; set; } + + public long Danmaku { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Home/HotDataItemModel.cs b/src/BiliLite.UWP/Models/Common/Home/HotDataItemModel.cs new file mode 100644 index 00000000..571f3a2b --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/HotDataItemModel.cs @@ -0,0 +1,56 @@ +using BiliLite.Models.Common.Recommend; +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Home +{ + public class HotDataItemModel + { + [JsonProperty("card_type")] + public string CardType { get; set; } + + [JsonProperty("card_goto")] + public string CardGoto { get; set; } + + public string Param { get; set; } + + public string Cover { get; set; } + + public string Title { get; set; } + + public string Idx { get; set; } + + public string Uri { get; set; } + + [JsonProperty("cover_right_text_1")] + public string CoverRightText1 { get; set; } + + [JsonProperty("right_desc_1")] + public string RightDesc1 { get; set; } + + [JsonProperty("right_desc_2")] + public string RightDesc2 { get; set; } + + [JsonProperty("cover_left_text_1")] + public string CoverLeftText1 { get; set; } + + [JsonProperty("cover_left_text_2")] + public string CoverLeftText2 { get; set; } + + [JsonProperty("cover_left_text_3")] + public string CoverLeftText3 { get; set; } + + public string TextInfo1 => string.IsNullOrEmpty(CoverRightText1) ? CoverLeftText1 : CoverRightText1; + + public string TextInfo2 => string.IsNullOrEmpty(RightDesc1) ? CoverLeftText2 : RightDesc1; + + public string TextInfo3 => string.IsNullOrEmpty(RightDesc2) ? CoverLeftText3 : RightDesc2; + + [JsonProperty("rcmd_reason_style")] + public RecommendRcmdReasonStyleModel RcmdReasonStyle { get; set; } + + [JsonProperty("top_rcmd_reason_style")] + public RecommendRcmdReasonStyleModel TopRcmdReasonStyle { get; set; } + + public RecommendRcmdReasonStyleModel RcmdReason => RcmdReasonStyle ?? TopRcmdReasonStyle; + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Home/HotTopItemModel.cs b/src/BiliLite.UWP/Models/Common/Home/HotTopItemModel.cs new file mode 100644 index 00000000..7cc8a7d1 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/HotTopItemModel.cs @@ -0,0 +1,19 @@ +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Home +{ + public class HotTopItemModel + { + [JsonProperty("entrance_id")] + public int EntranceId { get; set; } + + public string Icon { get; set; } + + [JsonProperty("module_id")] + public string ModuleId { get; set; } + + public string Uri { get; set; } + + public string Title { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Home/LiveHomeAreaModel.cs b/src/BiliLite.UWP/Models/Common/Home/LiveHomeAreaModel.cs new file mode 100644 index 00000000..67ae5e5c --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/LiveHomeAreaModel.cs @@ -0,0 +1,24 @@ +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Home +{ + public class LiveHomeAreaModel + { + public int Id { get; set; } + + [JsonProperty("area_v2_id")] + public int AreaV2Id { get; set; } + + [JsonProperty("area_v2_parent_id")] + public int AreaV2ParentId { get; set; } + + [JsonProperty("tag_type")] + public int TagType { get; set; } + + public string Title { get; set; } + + public string Pic { get; set; } + + public string Link { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Home/LiveHomeBannerModel.cs b/src/BiliLite.UWP/Models/Common/Home/LiveHomeBannerModel.cs new file mode 100644 index 00000000..b3fdde90 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/LiveHomeBannerModel.cs @@ -0,0 +1,13 @@ +namespace BiliLite.Models.Common.Home +{ + public class LiveHomeBannerModel + { + public int Id { get; set; } + + public string Link { get; set; } + + public string Pic { get; set; } + + public string Title { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Home/LiveHomeItemsItemModel.cs b/src/BiliLite.UWP/Models/Common/Home/LiveHomeItemsItemModel.cs new file mode 100644 index 00000000..72b84f83 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/LiveHomeItemsItemModel.cs @@ -0,0 +1,42 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace BiliLite.Models.Common.Home +{ + public class LiveHomeItemsItemModel + { + [JsonProperty("area_v2_id")] + public int AreaV2Id { get; set; } + + [JsonProperty("area_v2_parent_id")] + public int AreaV2ParentId { get; set; } + + [JsonProperty("area_v2_name")] + public string AreaV2Name { get; set; } + + [JsonProperty("area_v2_parent_name")] + public string AreaV2ParentName { get; set; } + + public string Title { get; set; } + + public string Cover { get; set; } + + public int Online { get; set; } + + public string Roomid { get; set; } + + public string Uname { get; set; } + + public string Face { get; set; } + + public string Uid { get; set; } + + [JsonProperty("pendant_Info")] + public JObject PendantInfo { get; set; } + + public LivePendentItemModel Pendent => + PendantInfo.ContainsKey("2") ? JsonConvert.DeserializeObject(PendantInfo["2"].ToString()) : null; + + public bool ShowPendent => Pendent != null; + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Home/LiveHomeItemsModel.cs b/src/BiliLite.UWP/Models/Common/Home/LiveHomeItemsModel.cs new file mode 100644 index 00000000..5f9676ee --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/LiveHomeItemsModel.cs @@ -0,0 +1,13 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Home +{ + public class LiveHomeItemsModel + { + [JsonProperty("module_info")] + public LiveHomeItemsModuleInfoModel ModuleInfo { get; set; } + + public List List { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Home/LiveHomeItemsModuleInfoModel.cs b/src/BiliLite.UWP/Models/Common/Home/LiveHomeItemsModuleInfoModel.cs new file mode 100644 index 00000000..83af3aa8 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/LiveHomeItemsModuleInfoModel.cs @@ -0,0 +1,17 @@ +namespace BiliLite.Models.Common.Home +{ + public class LiveHomeItemsModuleInfoModel + { + public int Id { get; set; } + + public string Link { get; set; } + + public string Pic { get; set; } + + public string Title { get; set; } + + public int Type { get; set; } + + public int Sort { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Home/LivePendentItemModel.cs b/src/BiliLite.UWP/Models/Common/Home/LivePendentItemModel.cs new file mode 100644 index 00000000..c22c8e94 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/LivePendentItemModel.cs @@ -0,0 +1,20 @@ +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Home +{ + public class LivePendentItemModel + { + [JsonProperty("bg_pic")] + public string BgPic { get; set; } + + [JsonProperty("bg_color")] + public string BgColor { get; set; } + + public string Text { get; set; } + + public string Name { get; set; } + + [JsonProperty("type")] + public string Type { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Home/RegionChildrenItem.cs b/src/BiliLite.UWP/Models/Common/Home/RegionChildrenItem.cs new file mode 100644 index 00000000..05384f2d --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/RegionChildrenItem.cs @@ -0,0 +1,22 @@ +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Home +{ + public class RegionChildrenItem + { + public int Tid { get; set; } + + public int Reid { get; set; } + + public string Name { get; set; } + + public string Logo { get; set; } + + public int Type { get; set; } + + [JsonProperty("_goto")] + public string Goto { get; set; } + + public string Param { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Home/RegionItem.cs b/src/BiliLite.UWP/Models/Common/Home/RegionItem.cs new file mode 100644 index 00000000..f315274b --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Home/RegionItem.cs @@ -0,0 +1,28 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Home +{ + public class RegionItem + { + public int Tid { get; set; } + + public int Reid { get; set; } + + public string Name { get; set; } + + public string Logo { get; set; } + + public string Uri { get; set; } + + public int Type { get; set; } + + [JsonProperty("is_bangumi")] + public int IsBangumi { get; set; } + + [JsonProperty("_goto")] + public string Goto { get; set; } + + public List Children { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Live/LiveMessageHandleActionsMap.cs b/src/BiliLite.UWP/Models/Common/Live/LiveMessageHandleActionsMap.cs index e5ae4779..35c85b28 100644 --- a/src/BiliLite.UWP/Models/Common/Live/LiveMessageHandleActionsMap.cs +++ b/src/BiliLite.UWP/Models/Common/Live/LiveMessageHandleActionsMap.cs @@ -91,7 +91,7 @@ private void Danmu(LiveRoomViewModel viewModel, object message) } } - if (viewModel.Messages.Count >= viewModel.CleanCount) viewModel.Messages.RemoveAt(0); + viewModel.CheckClearMessages(); viewModel.Messages.Add(m); AddNewDanmu?.Invoke(null, m); } @@ -137,6 +137,7 @@ private void InteractWord(LiveRoomViewModel viewModel, object message) msg.ShowMedal = info.ShowMedal; } + viewModel.CheckClearMessages(); viewModel.Messages.Add(msg); } diff --git a/src/BiliLite.UWP/Models/Common/Notifications/NotificationTile.cs b/src/BiliLite.UWP/Models/Common/Notifications/NotificationTile.cs new file mode 100644 index 00000000..d41f1401 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Notifications/NotificationTile.cs @@ -0,0 +1,11 @@ +namespace BiliLite.Models.Common.Notifications +{ + public class NotificationTile + { + public string Name { get; set; } + + public string Description { get; set; } + + public string Url { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Notifications/Template/TileTemplate.cs b/src/BiliLite.UWP/Models/Common/Notifications/Template/TileTemplate.cs new file mode 100644 index 00000000..0e6701c3 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Notifications/Template/TileTemplate.cs @@ -0,0 +1,94 @@ +using Microsoft.Toolkit.Uwp.Notifications; + +namespace BiliLite.Models.Common.Notifications.Template +{ + public class TileTemplate + { + public static TileContent LiveTile(NotificationTile notificationTile) => new TileContent() + { + // 创建静态磁贴对象并返回 + Visual = new TileVisual() + { + Branding = TileBranding.NameAndLogo, + TileMedium = new TileBinding() + { + Content = new TileBindingContentAdaptive() + { + Children = + { + new AdaptiveText() + { + Text = notificationTile.Description, + HintMaxLines = 3, + HintWrap = true, + }, + new AdaptiveText() + { + Text = notificationTile.Name, + HintStyle = AdaptiveTextStyle.CaptionSubtle, + HintAlign = AdaptiveTextAlign.Center, + }, + }, + PeekImage = new TilePeekImage() + { + Source = notificationTile.Url, + HintOverlay = 30, + }, + } + }, + TileWide = new TileBinding() + { + Content = new TileBindingContentAdaptive() + { + Children = + { + new AdaptiveText() + { + Text = notificationTile.Description, + HintStyle = AdaptiveTextStyle.Body, + HintMaxLines = 2, + HintWrap = true, + }, + new AdaptiveText() + { + Text = notificationTile.Name, + HintAlign = AdaptiveTextAlign.Center, + }, + }, + BackgroundImage = new TileBackgroundImage() + { + Source = notificationTile.Url, + }, + } + }, + TileLarge = new TileBinding() + { + Content = new TileBindingContentAdaptive() + { + Children = + { + new AdaptiveText() + { + Text = notificationTile.Description, + HintStyle = AdaptiveTextStyle.Subtitle, + HintMaxLines = 5, + HintWrap = true, + }, + new AdaptiveText() {}, + new AdaptiveText() + { + Text = notificationTile.Name, + HintStyle = AdaptiveTextStyle.Base, + HintAlign = AdaptiveTextAlign.Center, + }, + }, + BackgroundImage = new TileBackgroundImage() + { + Source = notificationTile.Url, + }, + } + } + } + }; + } +} diff --git a/src/BiliLite.UWP/Models/Common/Other/FindMoreEntranceModel.cs b/src/BiliLite.UWP/Models/Common/Other/FindMoreEntranceModel.cs new file mode 100644 index 00000000..58601629 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Other/FindMoreEntranceModel.cs @@ -0,0 +1,14 @@ +namespace BiliLite.Models.Common.Other; + +public class FindMoreEntranceModel +{ + public string Name { get; set; } + + public string Desc { get; set; } + + public int Type { get; set; } + + public string Link { get; set; } + + public string Pic { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Region/RegionChildOrderModel.cs b/src/BiliLite.UWP/Models/Common/Region/RegionChildOrderModel.cs new file mode 100644 index 00000000..3fb80164 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Region/RegionChildOrderModel.cs @@ -0,0 +1,15 @@ +namespace BiliLite.Models.Common.Region +{ + public class RegionChildOrderModel + { + public RegionChildOrderModel(string name, string order) + { + this.Name = name; + this.Order = order; + } + + public string Name { get; set; } + + public string Order { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Region/RegionHomeBannerItemModel.cs b/src/BiliLite.UWP/Models/Common/Region/RegionHomeBannerItemModel.cs new file mode 100644 index 00000000..0605777d --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Region/RegionHomeBannerItemModel.cs @@ -0,0 +1,13 @@ +namespace BiliLite.Models.Common.Region +{ + public class RegionHomeBannerItemModel + { + public int Id { get; set; } + + public string Title { get; set; } + + public string Image { get; set; } + + public string Uri { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Region/RegionTagItemModel.cs b/src/BiliLite.UWP/Models/Common/Region/RegionTagItemModel.cs new file mode 100644 index 00000000..0e1e5b25 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Region/RegionTagItemModel.cs @@ -0,0 +1,17 @@ +namespace BiliLite.Models.Common.Region +{ + public class RegionTagItemModel + { + public int Tid { get; set; } + + public int Rid { get; set; } + + public int Reid { get; set; } + + public string Tname { get; set; } + + public string Rname { get; set; } + + public string Rename { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Region/RegionVideoItemModel.cs b/src/BiliLite.UWP/Models/Common/Region/RegionVideoItemModel.cs new file mode 100644 index 00000000..5779e88b --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Region/RegionVideoItemModel.cs @@ -0,0 +1,25 @@ +namespace BiliLite.Models.Common.Region +{ + public class RegionVideoItemModel + { + public int Id { get; set; } + + public string Title { get; set; } + + public string Cover { get; set; } + + public string Param { get; set; } + + public string Name { get; set; } + + public int Play { get; set; } + + public int Danmaku { get; set; } + + public string Rname { get; set; } + + public int Duration { get; set; } + + public int Rid { get; set; } + } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Season/SeasonIndexConditionFilterItemModel.cs b/src/BiliLite.UWP/Models/Common/Season/SeasonIndexConditionFilterItemModel.cs new file mode 100644 index 00000000..48a78251 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Season/SeasonIndexConditionFilterItemModel.cs @@ -0,0 +1,8 @@ +namespace BiliLite.Models.Common.Season; + +public class SeasonIndexConditionFilterItemModel +{ + public string Keyword { get; set; } + + public string Name { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Season/SeasonIndexConditionFilterModel.cs b/src/BiliLite.UWP/Models/Common/Season/SeasonIndexConditionFilterModel.cs new file mode 100644 index 00000000..768df227 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Season/SeasonIndexConditionFilterModel.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; + +namespace BiliLite.Models.Common.Season; + +public class SeasonIndexConditionFilterModel +{ + public string Field { get; set; } + + public string Name { get; set; } + + public SeasonIndexConditionFilterItemModel Current { get; set; } + + public List Values { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Season/SeasonIndexParameter.cs b/src/BiliLite.UWP/Models/Common/Season/SeasonIndexParameter.cs new file mode 100644 index 00000000..56794385 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Season/SeasonIndexParameter.cs @@ -0,0 +1,16 @@ +namespace BiliLite.Models.Common.Season; + +public class SeasonIndexParameter +{ + public IndexSeasonType Type { get; set; } = IndexSeasonType.Anime; + + public string Area { get; set; } = "-1"; + + public string Style { get; set; } = "-1"; + + public string Year { get; set; } = "-1"; + + public string Month { get; set; } = "-1"; + + public string Order { get; set; } = "3"; +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Season/SeasonIndexResultItemModel.cs b/src/BiliLite.UWP/Models/Common/Season/SeasonIndexResultItemModel.cs new file mode 100644 index 00000000..7767441f --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Season/SeasonIndexResultItemModel.cs @@ -0,0 +1,41 @@ +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Season; + +public class SeasonIndexResultItemModel +{ + [JsonProperty("season_id")] + public int SeasonId { get; set; } + + public string Title { get; set; } + + public string Badge { get; set; } + + [JsonProperty("badge_type")] + public int BadgeType { get; set; } + + public bool ShowBadge => !string.IsNullOrEmpty(Badge); + + public string Cover { get; set; } + + [JsonProperty("index_show")] + public string IndexShow { get; set; } + + [JsonProperty("is_finish")] + public int IsFinish { get; set; } + + public string Link { get; set; } + + [JsonProperty("media_id")] + public int MediaId { get; set; } + + public string Order { get; set; } + + [JsonProperty("order_type")] + public string OrderType { get; set; } + + public bool ShowScore => + OrderType == "score"; + + //public SeasonIndexResultItemOrderModel order { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Season/SeasonIndexResultItemOrderModel.cs b/src/BiliLite.UWP/Models/Common/Season/SeasonIndexResultItemOrderModel.cs new file mode 100644 index 00000000..620c2e8b --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Season/SeasonIndexResultItemOrderModel.cs @@ -0,0 +1,40 @@ +using BiliLite.Extensions; +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Season; + +public class SeasonIndexResultItemOrderModel +{ + public string Follow { get; set; } + + public string Play { get; set; } + + public string Score { get; set; } + + [JsonProperty("pub_date")] + public long PubDate { get; set; } + + [JsonProperty("pub_real_time")] + public long PubRealTime { get; set; } + + [JsonProperty("renewal_time")] + public long RenewalTime { get; set; } + + public string Type { get; set; } + + public string BottomText + { + get + { + if (Type == "follow") + { + return Follow; + } + else + { + return RenewalTime.HandelTimestamp() + "更新"; + } + } + } + public bool ShowScore => Type == "score"; +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Season/SeasonRankItemModel.cs b/src/BiliLite.UWP/Models/Common/Season/SeasonRankItemModel.cs new file mode 100644 index 00000000..743ca8db --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Season/SeasonRankItemModel.cs @@ -0,0 +1,35 @@ +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Season; + +public class SeasonRankItemModel +{ + public int Rank { get; set; } + + public string Badge { get; set; } + + public string Desc { get; set; } + + [JsonProperty("season_id")] + public string SeasonId { get; set; } + + public string Title { get; set; } + + public string Url { get; set; } + + public string Cover { get; set; } + + [JsonProperty("badge_type")] + public int BadgeType { get; set; } + + public int Pts { get; set; } + + public bool ShowBadge => !string.IsNullOrEmpty(Badge); + + public bool ShowDanmaku => Stat != null && Stat.Danmaku != 0; + + public SeasonRankItemStatModel Stat { get; set; } + + [JsonProperty("new_ep")] + public SeasonRankItemNewEPModel NewEp { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Season/SeasonRankItemNewEPModel.cs b/src/BiliLite.UWP/Models/Common/Season/SeasonRankItemNewEPModel.cs new file mode 100644 index 00000000..7b60849b --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Season/SeasonRankItemNewEPModel.cs @@ -0,0 +1,11 @@ +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Season; + +public class SeasonRankItemNewEPModel +{ + public string Cover { get; set; } + + [JsonProperty("index_show")] + public string IndexShow { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Season/SeasonRankItemStatModel.cs b/src/BiliLite.UWP/Models/Common/Season/SeasonRankItemStatModel.cs new file mode 100644 index 00000000..5910d83f --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Season/SeasonRankItemStatModel.cs @@ -0,0 +1,10 @@ +namespace BiliLite.Models.Common.Season; + +public class SeasonRankItemStatModel +{ + public long Danmaku { get; set; } + + public long Follow { get; set; } + + public long View { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Season/SeasonShortReviewItemAuthorModel.cs b/src/BiliLite.UWP/Models/Common/Season/SeasonShortReviewItemAuthorModel.cs new file mode 100644 index 00000000..5e8e51c4 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Season/SeasonShortReviewItemAuthorModel.cs @@ -0,0 +1,12 @@ +namespace BiliLite.Models.Common.Season; + +public class SeasonShortReviewItemAuthorModel +{ + public string Avatar { get; set; } + + public string Uname { get; set; } + + public long Mid { get; set; } + + public SeasonShortReviewItemVIPModel Vip { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Season/SeasonShortReviewItemModel.cs b/src/BiliLite.UWP/Models/Common/Season/SeasonShortReviewItemModel.cs new file mode 100644 index 00000000..cac1a1f4 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Season/SeasonShortReviewItemModel.cs @@ -0,0 +1,28 @@ +using Newtonsoft.Json; + +namespace BiliLite.Models.Common.Season; + +public class SeasonShortReviewItemModel +{ + public long Ctime { get; set; } + + public long Mid { get; set; } + + [JsonProperty("review_id")] + public int ReviewId { get; set; } + + public string Content { get; set; } + + public string Progress { get; set; } + + public int Score { get; set; } + + /// + /// 评分,转为5分制 + /// + public int Score5 => Score / 2; + + public SeasonShortReviewItemAuthorModel Author { get; set; } + + public SeasonShortReviewItemStatModel Stat { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Season/SeasonShortReviewItemStatModel.cs b/src/BiliLite.UWP/Models/Common/Season/SeasonShortReviewItemStatModel.cs new file mode 100644 index 00000000..be611771 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Season/SeasonShortReviewItemStatModel.cs @@ -0,0 +1,19 @@ +namespace BiliLite.Models.Common.Season; + +public class SeasonShortReviewItemStatModel +{ + /// + /// 是否已经点踩👎 + /// + public int Disliked { get; set; } + + /// + /// 是否已经点赞👍 + /// + public int Liked { get; set; } + + /// + /// 点赞数量 + /// + public int Likes { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Season/SeasonShortReviewItemVIPModel.cs b/src/BiliLite.UWP/Models/Common/Season/SeasonShortReviewItemVIPModel.cs new file mode 100644 index 00000000..ece8d570 --- /dev/null +++ b/src/BiliLite.UWP/Models/Common/Season/SeasonShortReviewItemVIPModel.cs @@ -0,0 +1,8 @@ +namespace BiliLite.Models.Common.Season; + +public class SeasonShortReviewItemVIPModel +{ + public int VipType { get; set; } + + public int VipStatus { get; set; } +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/SettingConstants.cs b/src/BiliLite.UWP/Models/Common/SettingConstants.cs index 18e3cf0b..68ebef35 100644 --- a/src/BiliLite.UWP/Models/Common/SettingConstants.cs +++ b/src/BiliLite.UWP/Models/Common/SettingConstants.cs @@ -1,7 +1,7 @@ -using System.Collections.Generic; -using BiliLite.Models.Attributes; +using BiliLite.Models.Attributes; using BiliLite.Models.Common.Player; using BiliLite.Services; +using System.Collections.Generic; namespace BiliLite.Models.Common { @@ -233,7 +233,19 @@ public class UI public const string TAB_ITEM_MIN_WIDTH = "TabItemMinWidth"; [SettingDefaultValue] - public const double DEFAULT_TAB_ITEM_MIN_WIDTH = 192; + public const double DEFAULT_TAB_ITEM_MIN_WIDTH = 0; + + [SettingKey(typeof(double))] + public const string TAB_HEIGHT = "TabHeight"; + + [SettingDefaultValue] + public const double DEFAULT_TAB_HEIGHT = 40; + + /// + /// 是否启用动态磁贴 + /// + // 因为要开关时注册磁贴服务,所以不设置SettingKey + public const string ENABLE_NOTIFICATION_TILES = "EnableNotificationTiles"; } public class Account @@ -606,7 +618,7 @@ public class Player [SettingKey(typeof(object))] public const string FfmpegOptions = "FfmpegOptions"; - /// + /// /// 使用外站视频替换无法播放的视频 bool /// [SettingKey(typeof(bool))] diff --git a/src/BiliLite.UWP/Models/Requests/Api/SeasonApi.cs b/src/BiliLite.UWP/Models/Requests/Api/SeasonApi.cs index 809d6314..f6215493 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/SeasonApi.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/SeasonApi.cs @@ -1,11 +1,19 @@ using BiliLite.Services; using System; using BiliLite.Models.Common; +using Microsoft.Extensions.DependencyInjection; namespace BiliLite.Models.Requests.Api { public class SeasonApi : BaseApi { + private readonly CookieService m_cookieService; + + public SeasonApi() + { + m_cookieService = App.ServiceProvider.GetRequiredService(); + } + /// /// 用season_id / ep_id 取番剧信息 /// @@ -63,11 +71,12 @@ public ApiModel ShortReview(int media_id, string next = "", int sort = 0) /// public ApiModel LikeReview(int media_id, int review_id, ReviewType review_type = ReviewType.Short) { + var csrf = m_cookieService.GetCSRFToken(); var api = new ApiModel() { method = HttpMethods.Post, - baseUrl = $"https://bangumi.bilibili.com/review/api/like", - body = $"{ApiHelper.MustParameter(AppKey, true)}&media_id={media_id}&review_id={review_id}&review_type={(int)review_type}" + baseUrl = $"https://api.bilibili.com/pgc/review/action/like", + body = $"{ApiHelper.MustParameter(AppKey, true)}&media_id={media_id}&review_id={review_id}&review_type={(int)review_type}", }; api.body += ApiHelper.GetSign(api.body, AppKey); return api; @@ -82,7 +91,7 @@ public ApiModel DislikeReview(int media_id, int review_id, ReviewType review_typ var api = new ApiModel() { method = HttpMethods.Post, - baseUrl = $"https://bangumi.bilibili.com/review/api/dislike", + baseUrl = $"https://api.bilibili.com/pgc/review/action/dislike", body = $"{ApiHelper.MustParameter(AppKey, true)}&media_id={media_id}&review_id={review_id}&review_type={(int)review_type}" }; api.body += ApiHelper.GetSign(api.body, AppKey); @@ -101,7 +110,7 @@ public ApiModel SendShortReview(int media_id, string content, bool share_feed, i var api = new ApiModel() { method = HttpMethods.Post, - baseUrl = $"https://bangumi.bilibili.com/review/api/short/post", + baseUrl = $"https://api.bilibili.com/pgc/review/action/short/post", body = $"{ApiHelper.MustParameter(AppKey, true)}&media_id={media_id}&content={Uri.EscapeDataString(content)}&share_feed={(share_feed ? 1 : 0)}&score={score}" }; api.body += ApiHelper.GetSign(api.body, AppKey); diff --git a/src/BiliLite.UWP/Modules/Detail/FavoriteDetailVM.cs b/src/BiliLite.UWP/Modules/Detail/FavoriteDetailVM.cs deleted file mode 100644 index 46b77088..00000000 --- a/src/BiliLite.UWP/Modules/Detail/FavoriteDetailVM.cs +++ /dev/null @@ -1,434 +0,0 @@ -using BiliLite.Models; -using BiliLite.Models.Requests.Api.User; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Threading.Tasks; -using System.Windows.Input; -using Windows.UI.Xaml.Controls; -using BiliLite.Extensions; -using BiliLite.Services; - -namespace BiliLite.Modules -{ - public class FavoriteDetailVM : IModules - { - readonly FavoriteApi favoriteApi; - public int Page { get; set; } = 1; - public string Keyword { get; set; } = ""; - public string Id { get; set; } - public int Type { get; set; } - public FavoriteDetailVM() - { - favoriteApi = new FavoriteApi(); - RefreshCommand = new RelayCommand(Refresh); - LoadMoreCommand = new RelayCommand(LoadMore); - CollectCommand = new RelayCommand(DoCollect); - CancelCollectCommand = new RelayCommand(DoCancelCollect); - SelectCommand = new RelayCommand(SetSelectMode); - } - private bool _loading = false; - public bool Loading - { - get { return _loading; } - set { _loading = value; DoPropertyChanged("Loading"); } - } - private FavoriteInfoModel _FavoriteInfo; - public FavoriteInfoModel FavoriteInfo - { - get { return _FavoriteInfo; } - set { _FavoriteInfo = value; DoPropertyChanged("FavoriteInfo"); } - } - private ObservableCollection _videos; - public ObservableCollection Videos - { - get { return _videos; } - set { _videos = value; DoPropertyChanged("Videos"); } - } - - private ListViewSelectionMode _selectionMode = ListViewSelectionMode.None; - public ListViewSelectionMode SelectionMode - { - get { return _selectionMode; } - set { _selectionMode = value; DoPropertyChanged("SelectionMode"); } - } - - private bool _IsItemClickEnabled = true; - public bool IsItemClickEnabled - { - get { return _IsItemClickEnabled; } - set { _IsItemClickEnabled = value; DoPropertyChanged("IsItemClickEnabled"); } - } - public ICommand CollectCommand { get; private set; } - public ICommand CancelCollectCommand { get; private set; } - public ICommand RefreshCommand { get; private set; } - public ICommand LoadMoreCommand { get; private set; } - public ICommand SelectCommand { get; private set; } - private bool _Nothing = false; - public bool Nothing - { - get { return _Nothing; } - set { _Nothing = value; DoPropertyChanged("Nothing"); } - } - - private bool _ShowLoadMore = false; - public bool ShowLoadMore - { - get { return _ShowLoadMore; } - set { _ShowLoadMore = value; DoPropertyChanged("ShowLoadMore"); } - } - private bool _isSelf = false; - public bool IsSelf - { - get { return _isSelf; } - set { _isSelf = value; DoPropertyChanged("IsSelf"); } - } - - private bool _showCollect = false; - public bool ShowCollect - { - get { return _showCollect; } - set { _showCollect = value; DoPropertyChanged("ShowCollect"); } - } - private bool _showCancelCollect = false; - public bool ShowCancelCollect - { - get { return _showCancelCollect; } - set { _showCancelCollect = value; DoPropertyChanged("ShowCancelCollect"); } - } - public async Task LoadFavoriteInfo() - { - try - { - ShowLoadMore = false; - Loading = true; - Nothing = false; - var api = favoriteApi.FavoriteInfo(Id, Keyword, Page); - if (Type == 21) - { - api = favoriteApi.FavoriteSeasonInfo(Id, Keyword, Page); - } - var results = await api.Request(); - if (results.status) - { - var data = await results.GetJson>(); - if (data.success) - { - if (Page == 1) - { - FavoriteInfo = data.data.info; - IsSelf = FavoriteInfo.mid == SettingService.Account.UserID.ToString(); - if (!IsSelf) - { - ShowCollect = FavoriteInfo.fav_state != 1; - ShowCancelCollect = !ShowCollect; - } - - if (data.data.medias == null || data.data.medias.Count == 0) - { - Nothing = true; - return; - } - Videos = data.data.medias; - - } - else - { - if (data.data.medias != null) - { - foreach (var item in data.data.medias) - { - Videos.Add(item); - } - } - } - if (Videos.Count != FavoriteInfo.media_count) - { - ShowLoadMore = true; - Page++; - } - } - else - { - Notify.ShowMessageToast(data.message); - } - } - else - { - Notify.ShowMessageToast(results.message); - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - Loading = false; - } - } - public async Task Delete(List items) - { - try - { - if (!SettingService.Account.Logined && !await Notify.ShowLoginDialog()) - { - Notify.ShowMessageToast("请先登录后再操作"); - return; - } - var results = await favoriteApi.Delete(Id, items.Select(x => x.id).ToList()).Request(); - if (results.status) - { - var data = await results.GetData(); - if (data.success) - { - foreach (var item in items) - { - Videos.Remove(item); - } - } - else - { - Notify.ShowMessageToast(data.message); - } - } - else - { - Notify.ShowMessageToast(results.message); - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - - } - public async Task Clean() - { - try - { - if (!SettingService.Account.Logined && !await Notify.ShowLoginDialog()) - { - Notify.ShowMessageToast("请先登录后再操作"); - return; - } - var results = await favoriteApi.Clean(Id).Request(); - if (results.status) - { - var data = await results.GetData(); - if (data.success) - { - Refresh(); - } - else - { - Notify.ShowMessageToast(data.message); - } - } - else - { - Notify.ShowMessageToast(results.message); - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - - } - public async void Refresh() - { - if (Loading) - { - return; - } - Page = 1; - FavoriteInfo = null; - Videos = null; - await LoadFavoriteInfo(); - } - - public async Task Sort(string sourceId,string targetId) - { - var result= await favoriteApi.SortResource(Id, sourceId, targetId).Request(); - if (!result.status) - { - Notify.ShowMessageToast("排序失败" + result.message); - return; - } - - var data = await result.GetData(); - if (data.success) - { - Notify.ShowMessageToast("排序成功"); - return; - } - Notify.ShowMessageToast("排序失败" + data.message); - } - - public async void LoadMore() - { - if (Loading) - { - return; - } - if (Videos == null || Videos.Count == 0) - { - return; - } - await LoadFavoriteInfo(); - } - public async void Search(string keyword) - { - if (Loading) - { - return; - } - Keyword = keyword; - Page = 1; - FavoriteInfo = null; - Videos = null; - await LoadFavoriteInfo(); - } - private void SetSelectMode(object data) - { - if (data == null) - { - IsItemClickEnabled = true; - SelectionMode = ListViewSelectionMode.None; - } - else - { - IsItemClickEnabled = false; - SelectionMode = ListViewSelectionMode.Multiple; - } - } - public async void DoCollect() - { - if (!SettingService.Account.Logined && !await Notify.ShowLoginDialog()) - { - Notify.ShowMessageToast("请先登录后再操作"); - return; - } - try - { - var results = await favoriteApi.CollectFavorite(FavoriteInfo.id).Request(); - if (results.status) - { - var data = await results.GetJson>(); - if (data.success) - { - ShowCancelCollect = true; - ShowCollect = false; - } - else - { - Notify.ShowMessageToast(data.message); - } - } - else - { - Notify.ShowMessageToast(results.message); - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - - - } - public async void DoCancelCollect() - { - if (!SettingService.Account.Logined && !await Notify.ShowLoginDialog()) - { - Notify.ShowMessageToast("请先登录后再操作"); - return; - } - try - { - var results = await favoriteApi.CacnelCollectFavorite(FavoriteInfo.id).Request(); - if (results.status) - { - var data = await results.GetJson>(); - if (data.success) - { - ShowCancelCollect = false; - ShowCollect = true; - } - else - { - Notify.ShowMessageToast(data.message); - } - } - else - { - Notify.ShowMessageToast(results.message); - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - - - } - } - public class FavoriteDetailModel - { - public FavoriteInfoModel info { get; set; } - public ObservableCollection medias { get; set; } - } - - public class FavoriteInfoModel - { - public string cover { get; set; } - public int attr { get; set; } - public bool privacy - { - get - { - return attr == 2; - } - } - public string fid { get; set; } - public string id { get; set; } - public int like_state { get; set; } - public int fav_state { get; set; } - public string mid { get; set; } - public string title { get; set; } - public int type { get; set; } - public int media_count { get; set; } - public FavoriteInfoVideoItemUpperModel upper { get; set; } - } - - public class FavoriteInfoVideoItemModel - { - public string id { get; set; } - public string cover { get; set; } - public string title { get; set; } - public FavoriteInfoVideoItemUpperModel upper { get; set; } - public FavoriteInfoVideoItemStatModel cnt_info { get; set; } - } - public class FavoriteInfoVideoItemUpperModel - { - public string face { get; set; } - public string name { get; set; } - public string mid { get; set; } - } - public class FavoriteInfoVideoItemStatModel - { - public int coin { get; set; } - public int collect { get; set; } - public int danmaku { get; set; } - public int play { get; set; } - public int reply { get; set; } - public int share { get; set; } - } -} diff --git a/src/BiliLite.UWP/Modules/Home/CinemaVM.cs b/src/BiliLite.UWP/Modules/Home/CinemaVM.cs deleted file mode 100644 index 87c80217..00000000 --- a/src/BiliLite.UWP/Modules/Home/CinemaVM.cs +++ /dev/null @@ -1,380 +0,0 @@ -using BiliLite.Models; -using BiliLite.Models.Requests.Api.Home; -using BiliLite.Models.Requests.Api.User; -using BiliLite.Pages.Bangumi; -using BiliLite.Pages.User; -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Threading.Tasks; -using Windows.UI.Xaml.Controls; -using BiliLite.Extensions; -using BiliLite.Services; -using BiliLite.Models.Common; -using BiliLite.Models.Common.Anime; -using Newtonsoft.Json; - -namespace BiliLite.Modules -{ - public class CinemaVM : IModules - { - readonly FollowAPI followAPI; - readonly CinemaAPI cinemaAPI; - public CinemaVM() - { - cinemaAPI = new CinemaAPI(); - followAPI = new FollowAPI(); - Entrances = new List() { - new PageEntranceModel(){ - Logo="ms-appx:///Assets/Icon/榜单.png", - Name="热门榜单", - NavigationInfo=new NavigationInfo(){ - icon= Symbol.FourBars, - page=typeof(SeasonRankPage), - title="热门榜单", - parameters=2 - } - }, - new PageEntranceModel(){ - Logo="ms-appx:///Assets/Icon/电影.png", - Name="电影索引", - NavigationInfo=new NavigationInfo(){ - icon= Symbol.Filter, - page=typeof(AnimeIndexPage), - title="电影索引", - parameters=new SeasonIndexParameter() - { - type= IndexSeasonType.Movie - } - } - }, - new PageEntranceModel(){ - Logo="ms-appx:///Assets/Icon/电视剧.png", - Name="电视剧索引", - NavigationInfo=new NavigationInfo(){ - icon= Symbol.Filter, - page=typeof(AnimeIndexPage), - title="电视剧索引", - parameters=new SeasonIndexParameter() - { - type= IndexSeasonType.TV - } - } - }, - new PageEntranceModel(){ - Logo="ms-appx:///Assets/Icon/纪录片.png", - Name="纪录片索引", - NavigationInfo=new NavigationInfo(){ - icon= Symbol.Filter, - page=typeof(AnimeIndexPage), - title="纪录片索引", - parameters=new SeasonIndexParameter() - { - type= IndexSeasonType.Documentary - } - } - }, - new PageEntranceModel(){ - Logo="ms-appx:///Assets/Icon/综艺.png", - Name="综艺索引", - NavigationInfo=new NavigationInfo(){ - icon= Symbol.Filter, - page=typeof(AnimeIndexPage), - title="综艺索引", - parameters=new SeasonIndexParameter() - { - type= IndexSeasonType.Variety - } - } - }, - new PageEntranceModel(){ - Logo="ms-appx:///Assets/Icon/我的.png", - Name="我的追剧", - NavigationInfo=new NavigationInfo(){ - icon= Symbol.OutlineStar, - page=typeof(FavoritePage), - title="我的追剧", - parameters=OpenFavoriteType.Cinema - } - }, - }; - } - - - - private bool _showFollows = false; - public bool ShowFollows - { - get { return _showFollows; } - set { _showFollows = value; DoPropertyChanged("ShowFollows"); } - } - - private bool _loading = true; - public bool Loading - { - get { return _loading; } - set { _loading = value; DoPropertyChanged("Loading"); } - } - private bool _loadingFollow = true; - public bool LoadingFollow - { - get { return _loadingFollow; } - set { _loadingFollow = value; DoPropertyChanged("LoadingFollow"); } - } - private ObservableCollection _follows; - - public ObservableCollection Follows - { - get { return _follows; } - set { _follows = value; DoPropertyChanged("Follows"); } - } - - private CinemaHomeModel _homeData; - public CinemaHomeModel HomeData - { - get { return _homeData; } - set { _homeData = value; DoPropertyChanged("HomeData"); } - } - - public List Entrances { get; set; } - public async void SeasonItemClick(object sender, ItemClickEventArgs e) - { - var seasonId = e.ClickedItem.GetType().GetProperty(nameof(ISeasonItem.SeasonId)).GetValue(e.ClickedItem, null); - var title = e.ClickedItem.GetType().GetProperty(nameof(ISeasonItem.SeasonId))?.GetValue(e.ClickedItem, null) ?? ""; - if (seasonId != null && seasonId.ToInt32() != 0) - { - MessageCenter.NavigateToPage(sender, new NavigationInfo() - { - icon = Symbol.Play, - page = typeof(Pages.SeasonDetailPage), - parameters = seasonId, - title = title.ToString() - }); - } - else - { - var weblink = e.ClickedItem.GetType().GetProperty("link").GetValue(e.ClickedItem, null) ?? ""; - var result = await MessageCenter.HandelUrl(weblink.ToString()); - if (!result) Notify.ShowMessageToast("无法打开此链接"); - } - } - public void LinkItemClick(object sender, ItemClickEventArgs e) - { - var weblink = e.ClickedItem.GetType().GetProperty("link").GetValue(e.ClickedItem, null); - var title = e.ClickedItem.GetType().GetProperty("title").GetValue(e.ClickedItem, null) ?? ""; - MessageCenter.NavigateToPage(sender, new NavigationInfo() - { - icon = Symbol.World, - page = typeof(Pages.WebPage), - parameters = weblink, - title = title.ToString() - }); - } - - public async Task GetCinemaHome() - { - try - { - Loading = true; - var api = cinemaAPI.CinemaHome(); - - var results = await api.Request(); - if (results.status) - { - var data = await results.GetJson>(); - if (data.success) - { - HomeData = data.data; - } - else - { - Notify.ShowMessageToast(data.message); - } - } - else - { - Notify.ShowMessageToast(results.message); - - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - Loading = false; - } - } - - public async Task GetFollows() - { - try - { - LoadingFollow = true; - var results = await followAPI.MyFollowCinema().Request(); - if (results.status) - { - var data = await results.GetJson>(); - if (data.success) - { - Follows = await data.result["follow_list"].ToString().DeserializeJson>(); - } - else - { - Notify.ShowMessageToast(data.message); - } - } - else - { - Notify.ShowMessageToast(results.message); - - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - LoadingFollow = false; - } - } - - - public async Task GetFallMore(CinemaHomeFallModel AnimeFallModel) - { - try - { - AnimeFallModel.ShowMore = false; - var results = await cinemaAPI.CinemaFallMore(AnimeFallModel.wid, AnimeFallModel.items.LastOrDefault().cursor).Request(); - if (results.status) - { - var data = await results.GetJson>(); - foreach (var item in data) - { - AnimeFallModel.items.Add(item); - } - - } - else - { - Notify.ShowMessageToast(results.message); - } - } - catch (Exception ex) - { - var handel = HandelError>(ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - AnimeFallModel.ShowMore = true; - } - } - - - } - - - public class CinemaHomeModel - { - public List banners { get; set; } - public List falls { get; set; } - public List update { get; set; } - /// - /// 记录片 87 - /// - public List documentary { get; set; } - /// - /// 电影 88 - /// - public List movie { get; set; } - /// - /// 电视剧 89 - /// - public List tv { get; set; } - /// - /// 综艺 173 - /// - public List variety { get; set; } - } - public class CinemaHomeFallModel : IModules - { - public int wid { get; set; } - public string title { get; set; } - - private bool _showMore = true; - public bool ShowMore - { - get { return _showMore; } - set { _showMore = value; DoPropertyChanged("ShowMore"); DoPropertyChanged("ShowLoading"); } - } - - public ObservableCollection items { get; set; } - } - public class CinemaHomeFallItemModel - { - public string cover { get; set; } - public string desc { get; set; } - public string title { get; set; } - public string link { get; set; } - public long cursor { get; set; } - public int wid { get; set; } - } - public class CinemaHomeBannerModel - { - public string title { get; set; } - public string img { get; set; } - public string url { get; set; } - } - - public class CinemaHomeHotItem : ISeasonItem - { - public string Hat { get; set; } - - public string Cover { get; set; } - - public string Badge { get; set; } - - [JsonProperty("badge_type")] - public int BadgeType { get; set; } - - public bool ShowBadge - { - get - { - return !string.IsNullOrEmpty(Badge); - } - } - - public string Desc { get; set; } - - public string Title { get; set; } - - public string Link { get; set; } - - [JsonProperty("season_id")] - public int SeasonId { get; set; } - - [JsonProperty("season_type")] - public int SeasonType { get; set; } - - public string Type { get; set; } - - public int Wid { get; set; } - - public CinemaHomeStatModel Stat { get; set; } - } - public class CinemaHomeStatModel - { - public long view { get; set; } - public string follow_view { get; set; } - public long follow { get; set; } - public long danmaku { get; set; } - } -} diff --git a/src/BiliLite.UWP/Modules/Home/HotVM.cs b/src/BiliLite.UWP/Modules/Home/HotVM.cs deleted file mode 100644 index ebe34bc0..00000000 --- a/src/BiliLite.UWP/Modules/Home/HotVM.cs +++ /dev/null @@ -1,200 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using System.Collections.ObjectModel; -using Newtonsoft.Json; -using System.Windows.Input; -using BiliLite.Extensions; -using BiliLite.Models.Common.Recommend; -using BiliLite.Models.Requests.Api.Home; -using BiliLite.Pages; -using Microsoft.Extensions.DependencyInjection; - -namespace BiliLite.Modules -{ - public class HotVM : IModules - { - readonly HotAPI hotAPI; - private readonly IMainPage m_mainPage; - - public HotVM() - { - m_mainPage = App.ServiceProvider.GetRequiredService(); - hotAPI = new HotAPI(); - RefreshCommand = new RelayCommand(Refresh); - LoadMoreCommand = new RelayCommand(LoadMore); - } - public ICommand RefreshCommand { get; private set; } - public ICommand LoadMoreCommand { get; private set; } - - private bool _loading = true; - public bool Loading - { - get { return _loading; } - set { _loading = value; DoPropertyChanged("Loading"); } - } - - private ObservableCollection _hotItems; - - public ObservableCollection HotItems - { - get { return _hotItems; } - set { _hotItems = value; DoPropertyChanged("HotItems"); } - } - private List _topItems; - - public List TopItems - { - get { return _topItems; } - set { _topItems = value; DoPropertyChanged("TopItems"); } - } - - public async Task GetPopular(string idx = "0", string last_param = "") - { - try - { - Loading = true; - - var results = await hotAPI.Popular(idx, last_param).Request(); - if (results.status) - { - var data = results.GetJObject(); - if (data["code"].ToInt32() == 0) - { - if (TopItems == null) - { - TopItems = JsonConvert.DeserializeObject>(data["config"]["top_items"].ToString()); - } - var items = JsonConvert.DeserializeObject>(data["data"].ToString()); - for (int i = items.Count - 1; i >= 0; i--) - { - if (items[i].CardGoto != "av") - items.Remove(items[i]); - } - if (HotItems == null) - { - HotItems = items; - } - else - { - foreach (var item in items) - { - HotItems.Add(item); - } - } - } - else - { - Notify.ShowMessageToast(data["message"].ToString()); - } - } - else - { - Notify.ShowMessageToast(results.message); - - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - Loading = false; - } - } - - public async void Refresh() - { - if (Loading) - { - return; - } - TopItems = null; - HotItems = null; - await GetPopular(); - } - public async void LoadMore() - { - // 当前不在首页,不应继续加载 - if (!(m_mainPage.CurrentPage is HomePage)) return; - if (Loading) - { - return; - } - if (HotItems == null || HotItems.Count == 0) - { - return; - } - var last = HotItems.LastOrDefault(); - await GetPopular(last.Idx, last.Param); - } - } - public class HotTopItemModel - { - [JsonProperty("entrance_id")] - public int EntranceId { get; set; } - - public string Icon { get; set; } - - [JsonProperty("module_id")] - public string ModuleId { get; set; } - - public string Uri { get; set; } - - public string Title { get; set; } - } - - public class HotDataItemModel - { - [JsonProperty("card_type")] - public string CardType { get; set; } - - [JsonProperty("card_goto")] - public string CardGoto { get; set; } - - public string Param { get; set; } - - public string Cover { get; set; } - - public string Title { get; set; } - - public string Idx { get; set; } - - public string Uri { get; set; } - - [JsonProperty("cover_right_text_1")] - public string CoverRightText1 { get; set; } - - [JsonProperty("right_desc_1")] - public string RightDesc1 { get; set; } - - [JsonProperty("right_desc_2")] - public string RightDesc2 { get; set; } - - [JsonProperty("cover_left_text_1")] - public string CoverLeftText1 { get; set; } - - [JsonProperty("cover_left_text_2")] - public string CoverLeftText2 { get; set; } - - [JsonProperty("cover_left_text_3")] - public string CoverLeftText3 { get; set; } - - public string TextInfo1 => string.IsNullOrEmpty(CoverRightText1) ? CoverLeftText1 : CoverRightText1; - - public string TextInfo2 => string.IsNullOrEmpty(RightDesc1) ? CoverLeftText2 : RightDesc1; - - public string TextInfo3 => string.IsNullOrEmpty(RightDesc2) ? CoverLeftText3 : RightDesc2; - - [JsonProperty("rcmd_reason_style")] - public RecommendRcmdReasonStyleModel RcmdReasonStyle { get; set; } - - [JsonProperty("top_rcmd_reason_style")] - public RecommendRcmdReasonStyleModel TopRcmdReasonStyle { get; set; } - - public RecommendRcmdReasonStyleModel RcmdReason => RcmdReasonStyle ?? TopRcmdReasonStyle; - } -} diff --git a/src/BiliLite.UWP/Modules/Home/LiveVM.cs b/src/BiliLite.UWP/Modules/Home/LiveVM.cs deleted file mode 100644 index 011a3e19..00000000 --- a/src/BiliLite.UWP/Modules/Home/LiveVM.cs +++ /dev/null @@ -1,242 +0,0 @@ -using BiliLite.Models; -using BiliLite.Models.Requests.Api.Home; -using BiliLite.Modules.Live.LiveCenter; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Windows.ApplicationModel.Appointments; -using Windows.UI.Xaml.Media.Imaging; -using BiliLite.Extensions; - -namespace BiliLite.Modules -{ - public class LiveVM : IModules - { - readonly LiveAPI liveAPI; - public readonly LiveAttentionVM liveAttentionVM; - public LiveVM() - { - liveAPI = new LiveAPI(); - liveAttentionVM = new LiveAttentionVM(); - } - private bool _showFollows = false; - public bool ShowFollows - { - get { return _showFollows; } - set { _showFollows = value; DoPropertyChanged("ShowFollows"); } - } - private bool _loading = true; - public bool Loading - { - get { return _loading; } - set { _loading = value; DoPropertyChanged("Loading"); } - } - private bool _loadingFollow = true; - public bool LoadingFollow - { - get { return _loadingFollow; } - set { _loadingFollow = value; DoPropertyChanged("LoadingFollow"); } - } - - private ObservableCollection _banners; - - public ObservableCollection Banners - { - get { return _banners; } - set { _banners = value; DoPropertyChanged("Banners"); } - } - - private ObservableCollection _areas; - - public ObservableCollection Areas - { - get { return _areas; } - set { _areas = value; DoPropertyChanged("Areas"); } - } - - //private ObservableCollection _Follow; - - //public ObservableCollection Follow - //{ - // get { return _Follow; } - // set { _Follow = value; DoPropertyChanged("Follow"); } - //} - - private List _items; - public List Items - { - get { return _items; } - set { _items = value; DoPropertyChanged("Items"); } - } - - public async Task GetLiveHome() - { - try - { - Loading = true; - var api = liveAPI.LiveHome(); - - var results = await api.Request(); - if (results.status) - { - var data = await results.GetJson>(); - if (data.success) - { - if (data.data["banner"].Any()) - { - Banners = await data.data["banner"][0]["list"].ToString().DeserializeJson>(); - } - - if (data.data["area_entrance_v2"].Any()) - { - Areas = await data.data["area_entrance_v2"][0]["list"].ToString().DeserializeJson>(); - } - await GetLiveHomeItems(); - } - else - { - Notify.ShowMessageToast(data.message); - } - } - else - { - Notify.ShowMessageToast(results.message); - - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - Loading = false; - } - } - public async Task GetLiveHomeItems() - { - try - { - Loading = true; - var api = liveAPI.LiveHomeItems(); - var results = await api.Request(); - if (results.status) - { - var data = await results.GetJson>(); - if (data.success) - { - var items = await data.data["room_list"].ToString().DeserializeJson>(); - - Items = items.Where(x => x.list != null && x.list.Count > 0).ToList(); - } - else - { - Notify.ShowMessageToast(data.message); - } - } - else - { - Notify.ShowMessageToast(results.message); - - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - Loading = false; - } - } - - - - } - public class LiveHomeItemsModel - { - public LiveHomeItemsModuleInfoModel module_info { get; set; } - public List list { get; set; } - } - public class LiveHomeItemsModuleInfoModel - { - public int id { get; set; } - public string link { get; set; } - public string pic { get; set; } - public string title { get; set; } - public int type { get; set; } - public int sort { get; set; } - } - public class LiveHomeItemsItemModel - { - public int area_v2_id { get; set; } - public int area_v2_parent_id { get; set; } - public string area_v2_name { get; set; } - public string area_v2_parent_name { get; set; } - public string title { get; set; } - public string cover { get; set; } - - public int online { get; set; } - public string roomid { get; set; } - public string uname { get; set; } - public string face { get; set; } - public string uid { get; set; } - - public JObject pendant_Info { get; set; } - public LivePendentItemModel pendent - { - get - { - if (pendant_Info.ContainsKey("2")) - { - return JsonConvert.DeserializeObject(pendant_Info["2"].ToString()); - } - else - { - return null; - } - } - } - public bool show_pendent - { - get - { - return pendent != null; - } - } - } - public class LiveHomeBannerModel - { - public int id { get; set; } - public string link { get; set; } - public string pic { get; set; } - public string title { get; set; } - } - public class LiveHomeAreaModel - { - public int id { get; set; } - public int area_v2_id { get; set; } - public int area_v2_parent_id { get; set; } - public int tag_type { get; set; } - public string title { get; set; } - public string pic { get; set; } - public string link { get; set; } - } - - public class LivePendentItemModel - { - public string bg_pic { get; set; } - public string bg_color { get; set; } - public string text { get; set; } - public string name { get; set; } - public string @type { get; set; } - } - -} diff --git a/src/BiliLite.UWP/Modules/Home/RegionVM.cs b/src/BiliLite.UWP/Modules/Home/RegionVM.cs deleted file mode 100644 index 0fa5a5b6..00000000 --- a/src/BiliLite.UWP/Modules/Home/RegionVM.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using BiliLite.Models.Requests.Api; -using BiliLite.Services; -using BiliLite.Extensions; - -namespace BiliLite.Modules.Home -{ - public class RegionVM : IModules - { - readonly RegionAPI regionAPI; - public RegionVM() - { - regionAPI = new RegionAPI(); - } - private bool _loading = true; - public bool Loading - { - get { return _loading; } - set { _loading = value; DoPropertyChanged("Loading"); } - } - private List _Regions; - public List Regions - { - get { return _Regions; } - set { _Regions = value; DoPropertyChanged("Regions"); } - } - public async Task GetRegions() - { - try - { - Loading = true; - if (AppHelper.Regions == null || AppHelper.Regions.Count == 0) - { - await AppHelper.SetRegions(); - } - Regions = AppHelper.Regions; - } - catch (Exception ex) - { - Regions = await AppHelper.GetDefaultRegions(); - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - Loading = false; - } - } - - - } - - public class RegionItem - { - public int tid { get; set; } - public int reid { get; set; } - public string name { get; set; } - public string logo { get; set; } - public string uri { get; set; } - public int type { get; set; } - public int is_bangumi { get; set; } - public string _goto { get; set; } - public List children { get; set; } - } - public class RegionChildrenItem - { - public int tid { get; set; } - public int reid { get; set; } - public string name { get; set; } - public string logo { get; set; } - public int type { get; set; } - - public string _goto { get; set; } - public string param { get; set; } - } -} diff --git a/src/BiliLite.UWP/Modules/Other/FindMoreVM.cs b/src/BiliLite.UWP/Modules/Other/FindMoreVM.cs deleted file mode 100644 index 87a1c744..00000000 --- a/src/BiliLite.UWP/Modules/Other/FindMoreVM.cs +++ /dev/null @@ -1,66 +0,0 @@ -using BiliLite.Models.Requests.Api; -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using BiliLite.Extensions; - -namespace BiliLite.Modules.Other -{ - public class FindMoreVM : IModules - { - readonly GitApi gitApi; - public FindMoreVM() - { - gitApi = new GitApi(); - } - private bool _loading = true; - public bool Loading - { - get { return _loading; } - set { _loading = value; DoPropertyChanged("Loading"); } - } - private List _Items; - public List Items - { - get { return _Items; } - set { _Items = value; DoPropertyChanged("Items"); } - } - public async void LoadEntrance() - { - try - { - Loading = true; - var results = await gitApi.FindMoreEntrance().Request(); - if (results.status) - { - var data = await results.GetJson>(); - await Task.Delay(2000); - Items = data; - } - else - { - Notify.ShowMessageToast(results.message); - - } - } - catch (Exception ex) - { - var handel = HandelError (ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - Loading = false; - } - } - - } - public class FindMoreEntranceModel - { - public string name { get; set; } - public string desc { get; set; } - public int type { get; set; } - public string link { get; set; } - public string pic { get; set; } - } -} diff --git a/src/BiliLite.UWP/Modules/Player/PlayerVM.cs b/src/BiliLite.UWP/Modules/Player/PlayerVM.cs index da1673a7..fad2e140 100644 --- a/src/BiliLite.UWP/Modules/Player/PlayerVM.cs +++ b/src/BiliLite.UWP/Modules/Player/PlayerVM.cs @@ -13,7 +13,6 @@ using BiliLite.Services; using BiliLite.Models.Common.Video; using BiliLite.Models.Common.Video.PlayUrlInfos; -using Windows.Storage.Pickers; namespace BiliLite.Modules { @@ -273,27 +272,6 @@ public async Task GetOnline(string aid, string cid) } return ""; } - - public async Task GetOutsideSubtitle() - { - var filePicker = new FileOpenPicker(); - filePicker.FileTypeFilter.Add(".ass"); - var file = await filePicker.PickSingleFileAsync(); - if (file == null) return null; - - var fileContent = await FileIO.ReadTextAsync(file); - var tempFolder = Windows.Storage.ApplicationData.Current.TemporaryFolder; - var tempFile = await tempFolder.CreateFileAsync($"{Guid.NewGuid().ToString()}.ass", Windows.Storage.CreationCollisionOption.ReplaceExisting); - await FileIO.WriteTextAsync(tempFile, fileContent); - return tempFile.Path; - } - - public async Task GetAssFileContent(string path) - { - var jsonFile = await StorageFile.GetFileFromPathAsync(path); - var content = await FileIO.ReadTextAsync(jsonFile); - return content; - } } diff --git a/src/BiliLite.UWP/Modules/RegionDetailVM.cs b/src/BiliLite.UWP/Modules/RegionDetailVM.cs deleted file mode 100644 index a67bfd95..00000000 --- a/src/BiliLite.UWP/Modules/RegionDetailVM.cs +++ /dev/null @@ -1,447 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using System.Collections.ObjectModel; -using BiliLite.Modules.Home; -using System.Windows.Input; -using BiliLite.Extensions; -using BiliLite.Models; -using Newtonsoft.Json; -using BiliLite.Models.Requests.Api; -using BiliLite.Services; -using BiliLite.ViewModels.Rank; - -namespace BiliLite.Modules -{ - public class RegionDetailVM : IModules - { - public RegionDetailVM() - { - - } - private ObservableCollection _Regions; - public ObservableCollection Regions - { - get { return _Regions; } - set { _Regions = value; DoPropertyChanged("Regions"); } - } - private IRegionVM _SelectRegion; - public IRegionVM SelectRegion - { - get { return _SelectRegion; } - set { _SelectRegion = value; DoPropertyChanged("SelectRegion"); } - } - - public void InitRegion(int id, int tid) - { - var ls = new ObservableCollection(); - var region = AppHelper.Regions.FirstOrDefault(x => x.tid == id); - ls.Add(new RegionDetailHomeVM(region)); - Regions = ls; - foreach (var item in region.children) - { - ls.Add(new RegionDetailChildVM(item)); - } - if (tid == 0) - { - SelectRegion = Regions[0]; - } - else - { - SelectRegion = Regions.FirstOrDefault(x => x.ID == tid); - } - } - - } - public interface IRegionVM - { - ICommand RefreshCommand { get; set; } - ICommand LoadMoreCommand { get; set; } - int ID { get; set; } - string RegionName { get; set; } - bool Loading { get; set; } - } - public class RegionDetailHomeVM : IModules, IRegionVM - { - public int ID { get; set; } - public string RegionName { get; set; } = "推荐"; - - public ICommand RefreshCommand { get; set; } - public ICommand LoadMoreCommand { get; set; } - private bool _loading = false; - public bool Loading - { - get { return _loading; } - set { _loading = value; DoPropertyChanged("Loading"); } - } - - private List _Banners; - - public List Banners - { - get { return _Banners; } - set { _Banners = value; DoPropertyChanged("Banners"); } - } - - private ObservableCollection _regionVideos; - - public ObservableCollection Videos - { - get { return _regionVideos; } - set { _regionVideos = value; DoPropertyChanged("Videos"); } - } - - - private RegionItem _region; - RegionAPI regionAPI; - public RegionDetailHomeVM(RegionItem regionItem) - { - regionAPI = new RegionAPI(); - _region = regionItem; - ID = regionItem.tid; - //RegionName = regionItem.name; - RefreshCommand = new RelayCommand(Refresh); - LoadMoreCommand = new RelayCommand(LoadMore); - } - private string next_id = ""; - public async Task LoadHome() - { - try - { - Loading = true; - var api = regionAPI.RegionDynamic(ID); - if (next_id != "") - { - api = regionAPI.RegionDynamic(ID, next_id); - } - var results = await api.Request(); - - if (results.status) - { - var data = results.GetJObject(); - if (data["code"].ToInt32() == 0) - { - var ls = JsonConvert.DeserializeObject>(data["data"]["new"].ToString()); - if (next_id == "") - { - var recommend = JsonConvert.DeserializeObject>(data["data"]["recommend"]?.ToString() ?? "[]"); - foreach (var item in recommend) - { - ls.Insert(0, item); - } - Banners = JsonConvert.DeserializeObject>(data["data"]["banner"]["top"].ToString()); - Videos = ls; - } - else - { - foreach (var item in ls) - { - Videos.Add(item); - } - } - - next_id = data["data"]["cbottom"].ToString(); - } - else - { - Notify.ShowMessageToast(data["message"].ToString()); - } - } - else - { - Notify.ShowMessageToast(results.message); - - } - } - catch (Exception ex) - { - var handel = HandelError>>(ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - Loading = false; - } - } - - public async void Refresh() - { - next_id = ""; - await LoadHome(); - } - public async void LoadMore() - { - await LoadHome(); - } - } - public class RegionDetailChildVM : IModules, IRegionVM - { - public string RegionName { get; set; } - public int ID { get; set; } - private bool _loading = false; - public bool Loading - { - get { return _loading; } - set { _loading = value; DoPropertyChanged("Loading"); } - } - public ICommand RefreshCommand { get; set; } - public ICommand LoadMoreCommand { get; set; } - private RegionChildrenItem _region; - RegionAPI regionAPI; - public RegionDetailChildVM(RegionChildrenItem regionItem) - { - regionAPI = new RegionAPI(); - Orders = new List() { - //new RegionChildOrderModel("默认排序",""), - new RegionChildOrderModel("最新视频","senddate"), - new RegionChildOrderModel("最多播放","view"), - new RegionChildOrderModel("评论最多","reply"), - new RegionChildOrderModel("弹幕最多","danmaku"), - new RegionChildOrderModel("最多收藏","favorite") - }; - SelectOrder = Orders[0]; - _region = regionItem; - ID = regionItem.tid; - RegionName = regionItem.name; - RefreshCommand = new RelayCommand(Refresh); - LoadMoreCommand = new RelayCommand(LoadMore); - } - public List Orders { get; set; } - - private RegionChildOrderModel _SelectOrder; - - public RegionChildOrderModel SelectOrder - { - get { return _SelectOrder; } - set - { - if (value != null) - { - _SelectOrder = value; - } - } - } - - private RegionTagItemModel _SelectTag; - - public RegionTagItemModel SelectTag - { - get { return _SelectTag; } - set - { - if (value != null) - { - _SelectTag = value; - } - - } - } - - - private List _tag; - public List Tasgs - { - get { return _tag; } - set { _tag = value; DoPropertyChanged("Tasgs"); } - } - - private ObservableCollection _regionVideos; - public ObservableCollection Videos - { - get { return _regionVideos; } - set { _regionVideos = value; DoPropertyChanged("Videos"); } - } - public string next_id = ""; - - public async Task LoadHome() - { - try - { - Loading = true; - var api = regionAPI.RegionChildDynamic(ID, (SelectTag == null) ? 0 : SelectTag.tid); - if (next_id != "") - { - api = regionAPI.RegionChildDynamic(ID, next_id, (SelectTag == null) ? 0 : SelectTag.tid); - } - - var results = await api.Request(); - if (results.status) - { - var data = results.GetJObject(); - if (data["code"].ToInt32() == 0) - { - var ls = JsonConvert.DeserializeObject>(data["data"]["new"].ToString()); - if (next_id == "") - { - var tags = JsonConvert.DeserializeObject>(data["data"]["top_tag"]?.ToString() ?? "[]"); - tags.Insert(0, new RegionTagItemModel() - { - tid = 0, - tname = "全部标签" - }); - if (Tasgs == null || Tasgs.Count == 0) - { - Tasgs = tags; - SelectTag = Tasgs[0]; - } - - Videos = ls; - } - else - { - foreach (var item in ls) - { - Videos.Add(item); - } - } - next_id = data["data"]["cbottom"]?.ToString() ?? ""; - } - else - { - Notify.ShowMessageToast(data["message"].ToString()); - } - } - else - { - Notify.ShowMessageToast(results.message); - - } - } - catch (Exception ex) - { - var handel = HandelError>>(ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - Loading = false; - } - } - public int page = 1; - public async Task LoadList() - { - try - { - Loading = true; - var api = regionAPI.RegionChildList(ID, SelectOrder.order, page, SelectTag.tid); - var results = await api.Request(); - if (results.status) - { - var data = results.GetJObject(); - if (data["code"].ToInt32() == 0) - { - var ls = JsonConvert.DeserializeObject>(data["data"].ToString()); - if (page == 1) - { - Videos = ls; - } - else - { - foreach (var item in ls) - { - Videos.Add(item); - } - } - page++; - } - else - { - Notify.ShowMessageToast(data["message"].ToString()); - } - } - else - { - Notify.ShowMessageToast(results.message); - - } - } - catch (Exception ex) - { - var handel = HandelError>>(ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - Loading = false; - } - } - - public async void Refresh() - { - if (Loading) - { - return; - } - if (SelectOrder == null || SelectOrder.order == "") - { - next_id = ""; - await LoadHome(); - } - else - { - page = 1; - await LoadList(); - } - - } - public async void LoadMore() - { - if (Loading) - { - return; - } - if (SelectOrder == null || SelectOrder.order == "") - { - await LoadHome(); - } - else - { - await LoadList(); - } - } - - } - - - public class RegionHomeBannerItemModel - { - public int id { get; set; } - public string title { get; set; } - public string image { get; set; } - public string uri { get; set; } - } - public class RegionChildOrderModel - { - public RegionChildOrderModel(string name, string order) - { - this.name = name; - this.order = order; - } - public string name { get; set; } - public string order { get; set; } - } - public class RegionTagItemModel - { - public int tid { get; set; } - public int rid { get; set; } - public int reid { get; set; } - public string tname { get; set; } - public string rname { get; set; } - public string rename { get; set; } - } - public class RegionVideoItemModel - { - public int id { get; set; } - public string title { get; set; } - public string cover { get; set; } - public string param { get; set; } - public string name { get; set; } - public int play { get; set; } - public int danmaku { get; set; } - public string rname { get; set; } - public int duration { get; set; } - - public int Rid { get; set; } - } -} diff --git a/src/BiliLite.UWP/Modules/Season/AnimeTimelineVM.cs b/src/BiliLite.UWP/Modules/Season/AnimeTimelineVM.cs deleted file mode 100644 index 5722e908..00000000 --- a/src/BiliLite.UWP/Modules/Season/AnimeTimelineVM.cs +++ /dev/null @@ -1,149 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using BiliLite.Models; -using BiliLite.Extensions; -using BiliLite.Models.Common; -using BiliLite.Models.Common.Anime; -using BiliLite.Models.Requests.Api.Home; -using Newtonsoft.Json; - -namespace BiliLite.Modules -{ - public class AnimeTimelineVM : IModules - { - readonly AnimeAPI animeApi; - public AnimeType animeType { get; set; } - public AnimeTimelineVM(AnimeType type) - { - animeApi = new AnimeAPI(); - AnimeTypeItems = new List() - { - new AnimeTypeItem() - { - Name="番剧", - AnimeType= AnimeType.Bangumi - }, - new AnimeTypeItem() - { - Name="国创", - AnimeType= AnimeType.GuoChuang - } - }; - SelectAnimeType = AnimeTypeItems.FirstOrDefault(x => x.AnimeType == type); - animeType = type; - - } - private bool _loading = true; - public bool Loading - { - get { return _loading; } - set { _loading = value; DoPropertyChanged("Loading"); } - } - - private List _animeTypeItems; - - public List AnimeTypeItems - { - get { return _animeTypeItems; } - set { _animeTypeItems = value; DoPropertyChanged("AnimeTypeItems"); } - } - - - private AnimeTypeItem _selectAnimeType; - - public AnimeTypeItem SelectAnimeType - { - get { return _selectAnimeType; } - set { _selectAnimeType = value; DoPropertyChanged("SelectAnimeType"); } - } - - - private AnimeTimelineModel _today; - - public AnimeTimelineModel Today - { - get { return _today; } - set { _today = value; DoPropertyChanged("Today"); } - } - - private List _timelines; - - public List Timelines - { - get { return _timelines; } - set { _timelines = value; DoPropertyChanged("Timelines"); } - } - - public async Task GetTimeline() - { - try - { - Loading = true; - var api = animeApi.Timeline((int)animeType); - - var results = await api.Request(); - if (results.status) - { - var data = await results.GetJson>>(); - if (data.success) - { - Timelines = data.data; - Today = data.data.FirstOrDefault(x => x.is_today); - } - else - { - Notify.ShowMessageToast(data.message); - } - } - else - { - Notify.ShowMessageToast(results.message); - - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - Loading = false; - } - } - - } - public class AnimeTypeItem - { - public string Name { get; set; } - public AnimeType AnimeType { get; set; } - } - public class AnimeTimelineModel - { - public string week { get; set; } - public int day_week { get; set; } - public string date { get; set; } - public bool is_today { get; set; } - public List seasons { get; set; } - } - public class AnimeTimelineItemModel : ISeasonItem - { - [JsonProperty("season_id")] - public int SeasonId { get; set; } - - public string Cover { get; set; } - - [JsonProperty("square_cover")] - public string SquareCover { get; set; } - - [JsonProperty("pub_index")] - public string PubIndex { get; set; } - - [JsonProperty("pub_time")] - public string PubTime { get; set; } - - public string Title { get; set; } - } -} diff --git a/src/BiliLite.UWP/Modules/Season/SeasonIndexVM.cs b/src/BiliLite.UWP/Modules/Season/SeasonIndexVM.cs deleted file mode 100644 index 5bc34fa5..00000000 --- a/src/BiliLite.UWP/Modules/Season/SeasonIndexVM.cs +++ /dev/null @@ -1,340 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using System.Collections.ObjectModel; -using Newtonsoft.Json; -using System.Windows.Input; -using BiliLite.Extensions; -using BiliLite.Models.Requests.Api; - -namespace BiliLite.Modules -{ - public enum IndexSeasonType - { - Anime = 1, - Movie = 2, - Documentary = 3, - Guochuang = 4, - TV = 5, - Variety = 7 - } - public class SeasonIndexParameter - { - public IndexSeasonType type { get; set; } = IndexSeasonType.Anime; - public string area { get; set; } = "-1"; - public string style { get; set; } = "-1"; - public string year { get; set; } = "-1"; - public string month { get; set; } = "-1"; - public string order { get; set; } = "3"; - } - public class SeasonIndexVM : IModules - { - readonly SeasonIndexAPI seasonIndexAPI; - public SeasonIndexVM() - { - seasonIndexAPI = new SeasonIndexAPI(); - RefreshCommand = new RelayCommand(Refresh); - LoadMoreCommand = new RelayCommand(LoadMore); - } - public SeasonIndexParameter Parameter { get; set; } - - public ICommand RefreshCommand { get; private set; } - public ICommand LoadMoreCommand { get; private set; } - - private bool _loading = true; - public bool Loading - { - get { return _loading; } - set { _loading = value; DoPropertyChanged("Loading"); } - } - - - private bool CanLoadMore = true; - - - private bool _Conditionsloading = true; - public bool ConditionsLoading - { - get { return _Conditionsloading; } - set { _Conditionsloading = value; DoPropertyChanged("ConditionsLoading"); } - } - - private ObservableCollection _Conditions; - public ObservableCollection Conditions - { - get { return _Conditions; } - set { _Conditions = value; DoPropertyChanged("Conditions"); } - } - - private ObservableCollection _result; - public ObservableCollection Result - { - get { return _result; } - set { _result = value; DoPropertyChanged("Result"); } - } - - private int _page = 1; - public int Page - { - get { return _page; } - set { _page = value; } - } - - public async Task LoadConditions() - { - try - { - ConditionsLoading = true; - var results = await seasonIndexAPI.Condition((int)Parameter.type).Request(); - if (results.status) - { - var data = results.GetJObject(); - if (data["code"].ToInt32() == 0) - { - var items = JsonConvert.DeserializeObject>(data["data"]["filter"].ToString()); - foreach (var item in items) - { - if (item.field == "style_id") - { - item.current = item.values.FirstOrDefault(x => x.keyword == Parameter.style); - } - else if (item.field == "area") - { - item.current = item.values.FirstOrDefault(x => x.keyword == Parameter.area); - } - else if (item.field == "pub_date") - { - item.current = item.values.FirstOrDefault(x => x.keyword == Parameter.year); - } - else if (item.field == "season_month") - { - item.current = item.values.FirstOrDefault(x => x.keyword == Parameter.month); - } - else - { - item.current = item.values.FirstOrDefault(); - } - } - var orders = new List(); - - foreach (var item in data["data"]["order"]) - { - orders.Add(new SeasonIndexConditionFilterItemModel() - { - keyword = item["field"].ToString(), - name = item["name"].ToString() - }); - } - - items.Insert(0, new SeasonIndexConditionFilterModel() - { - name = "排序", - values = orders, - field = "order", - current = orders.FirstOrDefault(x => x.name == Parameter.order) ?? orders[0], - }); - Conditions = items; - } - else - { - Notify.ShowMessageToast(data["message"].ToString()); - } - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - ConditionsLoading = false; - } - } - - public async Task LoadResult() - { - try - { - if (Loading) return; - - if (Page == 1) - { - CanLoadMore = true; - Result = null; - } - else - { - if (!CanLoadMore) - { - Loading = false; - return; - } - } - Loading = true; - var con = ""; - foreach (var item in Conditions) - { - con += $"&{item.field}={Uri.EscapeDataString(item.current.keyword)}"; - } - con += $"&sort=0"; - var results = await seasonIndexAPI.Result(Page, (int)Parameter.type, con).Request(); - if (results.status) - { - var data = results.GetJObject(); - if (data["code"].ToInt32() == 0) - { - var items = JsonConvert.DeserializeObject>(data["data"]["list"]?.ToString() ?? "[]"); - if (items != null && items.Count != 0) - { - if (Page == 1) - { - Result = items; - } - else - { - foreach (var item in items) - { - Result.Add(item); - } - } - Page++; - } - else - { - - CanLoadMore = false; - Notify.ShowMessageToast("加载完了"); - } - } - else - { - Notify.ShowMessageToast(data["message"].ToString()); - } - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - Loading = false; - } - } - - public async void Refresh() - { - if (Loading) - { - return; - } - Page = 1; - if (Conditions == null) - { - await LoadConditions(); - } - if (Conditions != null) - { - await LoadResult(); - } - } - public async void LoadMore() - { - if (Loading) - { - return; - } - if (Conditions == null || Conditions.Count == 0 || Result == null || Result.Count == 0) - { - return; - } - await LoadResult(); - } - - } - - public class SeasonIndexConditionFilterModel : IModules - { - public string field { get; set; } - public string name { get; set; } - - private SeasonIndexConditionFilterItemModel _current; - public SeasonIndexConditionFilterItemModel current - { - get { return _current; } - set { _current = value; } - } - public List values { get; set; } - } - public class SeasonIndexConditionFilterItemModel - { - public string keyword { get; set; } - public string name { get; set; } - - } - - public class SeasonIndexResultItemModel - { - public int season_id { get; set; } - public string title { get; set; } - public string badge { get; set; } - public int badge_type { get; set; } - public bool show_badge - { - get - { - return !string.IsNullOrEmpty(badge); - } - } - public string cover { get; set; } - public string index_show { get; set; } - public int is_finish { get; set; } - public string link { get; set; } - public int media_id { get; set; } - public string order { get; set; } - public string order_type { get; set; } - public bool show_score - { - get - { - return order_type == "score"; - } - } - - //public SeasonIndexResultItemOrderModel order { get; set; } - } - public class SeasonIndexResultItemOrderModel - { - public string follow { get; set; } - public string play { get; set; } - public string score { get; set; } - public long pub_date { get; set; } - public long pub_real_time { get; set; } - public long renewal_time { get; set; } - public string type { get; set; } - public string bottom_text - { - get - { - if (type == "follow") - { - return follow; - } - else - { - return renewal_time.HandelTimestamp() + "更新"; - } - } - } - public bool show_score - { - get - { - return type == "score"; - } - } - } -} diff --git a/src/BiliLite.UWP/Modules/Season/SeasonRankVM.cs b/src/BiliLite.UWP/Modules/Season/SeasonRankVM.cs deleted file mode 100644 index 461deb40..00000000 --- a/src/BiliLite.UWP/Modules/Season/SeasonRankVM.cs +++ /dev/null @@ -1,153 +0,0 @@ -using BiliLite.Models; -using BiliLite.Models.Requests.Api; -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using BiliLite.Extensions; - -namespace BiliLite.Modules.Season -{ - public class SeasonRankVM : IModules - { - readonly RankAPI rankAPI; - public SeasonRankVM() - { - rankAPI = new RankAPI(); - } - - private bool _loading = true; - public bool Loading - { - get { return _loading; } - set { _loading = value; DoPropertyChanged("Loading"); } - } - private SeasonRankModel _current; - - public SeasonRankModel Current - { - get { return _current; } - set { _current = value; DoPropertyChanged("Current"); } - } - private List _RegionItems; - public List RegionItems - { - get { return _RegionItems; } - set { _RegionItems = value; DoPropertyChanged("RegionItems"); } - } - - public void LoadRankRegion(int type = 1) - { - RegionItems = new List() - { - new SeasonRankModel() - { - name="热门番剧", - type=1 - }, - new SeasonRankModel() - { - name="热门国创", - type=4 - }, - new SeasonRankModel() - { - name="热门电影", - type=2 - }, - new SeasonRankModel() - { - name="热门纪录片", - type=3 - }, - new SeasonRankModel() - { - name="热门电视剧", - type=5 - }, - new SeasonRankModel() - { - name="热门综艺", - type=7 - }, - }; - Current = RegionItems.FirstOrDefault(x => x.type.Equals(type)); - } - - public async Task LoadRankDetail(SeasonRankModel region) - { - try - { - Loading = true; - var results = await rankAPI.SeasonRank(region.type).Request(); - if (results.status) - { - var data = await results.GetJson>(); - if (data.success) - { - var result = await data.data["list"].ToString().DeserializeJson>(); - region.Items = result; - } - else - { - Notify.ShowMessageToast(data.message); - } - } - else - { - Notify.ShowMessageToast(results.message); - - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - Loading = false; - } - } - } - public class SeasonRankModel : IModules - { - public string name { get; set; } - public int type { get; set; } - - private List _Items; - public List Items - { - get { return _Items; } - set { _Items = value; DoPropertyChanged("Items"); } - } - } - public class SeasonRankItemModel - { - public int rank { get; set; } - public string badge { get; set; } - public string desc { get; set; } - public string season_id { get; set; } - public string title { get; set; } - public string url { get; set; } - public string cover { get; set; } - public int badge_type { get; set; } - public int pts { get; set; } - public bool show_badge { get { return !string.IsNullOrEmpty(badge); } } - public bool show_danmaku { get { return stat != null && stat.danmaku != 0; } } - public SeasonRankItemStatModel stat { get; set; } - public SeasonRankItemNewEPModel new_ep { get; set; } - } - public class SeasonRankItemStatModel - { - public long danmaku { get; set; } - public long follow { get; set; } - public long view { get; set; } - } - public class SeasonRankItemNewEPModel - { - public string cover { get; set; } - public string index_show { get; set; } - } -} diff --git a/src/BiliLite.UWP/Modules/Season/SeasonReviewVM.cs b/src/BiliLite.UWP/Modules/Season/SeasonReviewVM.cs deleted file mode 100644 index 84a4ed10..00000000 --- a/src/BiliLite.UWP/Modules/Season/SeasonReviewVM.cs +++ /dev/null @@ -1,297 +0,0 @@ -using BiliLite.Models; -using BiliLite.Models.Requests.Api; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Threading.Tasks; -using System.Windows.Input; -using BiliLite.Extensions; -using BiliLite.Services; - -namespace BiliLite.Modules.Season -{ - public class SeasonReviewVM : IModules - { - readonly SeasonApi seasonApi; - - public SeasonReviewVM() - { - - Items = new ObservableCollection(); - seasonApi = new SeasonApi(); - RefreshCommand = new RelayCommand(Refresh); - LoadMoreCommand = new RelayCommand(LoadMore); - } - public ObservableCollection Items { get; set; } - public int MediaID { get; set; } - public ICommand RefreshCommand { get; private set; } - public ICommand LoadMoreCommand { get; private set; } - private bool _loading = false; - public bool Loading - { - get { return _loading; } - set { _loading = value; DoPropertyChanged("Loading"); } - } - - private bool _CanLoadMore = false; - public bool CanLoadMore - { - get { return _CanLoadMore; } - set { _CanLoadMore = value; DoPropertyChanged("CanLoadMore"); } - } - - public string Next { get; set; } = ""; - public async Task GetItems() - { - try - { - if (MediaID == 0) { return; } - Loading = true; - CanLoadMore = false; - var results = await seasonApi.ShortReview(MediaID, Next).Request(); - if (results.status) - { - var data = results.GetJObject(); - if (data["code"].ToInt32() == 0) - { - var items = JsonConvert.DeserializeObject>(data["data"]["list"].ToString()); - if (items != null) - { - foreach (var item in items) - { - Items.Add(item); - } - //Items = new IncrementalLoadingCollection(new LiveRecommendItemSource(items, SortType), 30); - if (Items.Count < data["data"]["total"].ToInt32()) - { - Next = data["data"]["next"].ToString(); - CanLoadMore = true; - } - } - } - else - { - Notify.ShowMessageToast(data["message"].ToString()); - } - } - else - { - Notify.ShowMessageToast(results.message); - - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - finally - { - Loading = false; - } - } - - public async void Refresh() - { - if (Loading) - { - return; - } - Items.Clear(); - Next = ""; - await GetItems(); - } - public async void LoadMore() - { - if (Loading) - { - return; - } - await GetItems(); - } - - public async void Like(SeasonShortReviewItemModel item) - { - if (!SettingService.Account.Logined && !await Notify.ShowLoginDialog()) - { - Notify.ShowMessageToast("请先登录后再操作"); - return; - } - try - { - var api = seasonApi.LikeReview(MediaID, item.review_id, ReviewType.Short); - var results = await api.Request(); - if (results.status) - { - var data = await results.GetJson>(); - if (data.success) - { - item.stat.liked = data.result["status"].ToInt32(); - if (item.stat.liked == 1) - { - item.stat.likes += 1; - } - else - { - item.stat.likes -= 1; - } - } - else - { - Notify.ShowMessageToast(data.message); - } - } - else - { - Notify.ShowMessageToast(results.message); - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - - } - - public async void Dislike(SeasonShortReviewItemModel item) - { - if (!SettingService.Account.Logined && !await Notify.ShowLoginDialog()) - { - Notify.ShowMessageToast("请先登录后再操作"); - return; - } - try - { - var api = seasonApi.DislikeReview(MediaID, item.review_id, ReviewType.Short); - var results = await api.Request(); - if (results.status) - { - var data = await results.GetJson>(); - if (data.success) - { - item.stat.disliked = data.result["status"].ToInt32(); - } - else - { - Notify.ShowMessageToast(data.message); - } - } - else - { - Notify.ShowMessageToast(results.message); - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - } - - } - - public async Task SendShortReview(string content, bool share, int score) - { - if (!SettingService.Account.Logined && !await Notify.ShowLoginDialog()) - { - Notify.ShowMessageToast("请先登录后再操作"); - return false; - } - try - { - var api = seasonApi.SendShortReview(MediaID, content, share, score); - var results = await api.Request(); - if (results.status) - { - var data = await results.GetJson>(); - if (data.success) - { - Notify.ShowMessageToast("发表成功"); - return true; - } - else - { - Notify.ShowMessageToast(data.message); - return false; - } - } - else - { - Notify.ShowMessageToast(results.message); - return false; - } - } - catch (Exception ex) - { - var handel = HandelError(ex); - Notify.ShowMessageToast(handel.message); - return false; - } - - } - } - - - public class SeasonShortReviewItemModel - { - public long ctime { get; set; } - public long mid { get; set; } - public int review_id { get; set; } - public string content { get; set; } - public string progress { get; set; } - public int score { get; set; } - /// - /// 评分,转为5分制 - /// - public int score_5 { get { return score / 2; } } - public SeasonShortReviewItemAuthorModel author { get; set; } - public SeasonShortReviewItemStatModel stat { get; set; } - } - public class SeasonShortReviewItemAuthorModel - { - public string avatar { get; set; } - public string uname { get; set; } - public long mid { get; set; } - public SeasonShortReviewItemVIPModel vip { get; set; } - } - public class SeasonShortReviewItemVIPModel - { - public int vipType { get; set; } - public int vipStatus { get; set; } - } - public class SeasonShortReviewItemStatModel : IModules - { - private int _disliked; - /// - /// 是否已经点踩👎 - /// - public int disliked - { - get { return _disliked; } - set { _disliked = value; DoPropertyChanged("disliked"); } - } - - private int _liked; - /// - /// 是否已经点赞👍 - /// - public int liked - { - get { return _liked; } - set { _liked = value; DoPropertyChanged("liked"); } - } - - private int _likes; - /// - /// 点赞数量 - /// - public int likes - { - get { return _likes; } - set { _likes = value; DoPropertyChanged("likes"); } - } - - } -} diff --git a/src/BiliLite.UWP/Package.appxmanifest b/src/BiliLite.UWP/Package.appxmanifest index 8ffbb2a4..9957f3a1 100644 --- a/src/BiliLite.UWP/Package.appxmanifest +++ b/src/BiliLite.UWP/Package.appxmanifest @@ -57,7 +57,7 @@ - + diff --git a/src/BiliLite.UWP/Pages/Bangumi/AnimeIndexPage.xaml b/src/BiliLite.UWP/Pages/Bangumi/AnimeIndexPage.xaml index 1786c526..a67f2f91 100644 --- a/src/BiliLite.UWP/Pages/Bangumi/AnimeIndexPage.xaml +++ b/src/BiliLite.UWP/Pages/Bangumi/AnimeIndexPage.xaml @@ -7,30 +7,33 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" - xmlns:model="using:BiliLite.Modules" xmlns:controls="using:BiliLite.Controls" xmlns:toolkit="using:Microsoft.Toolkit.Uwp.UI.Controls" xmlns:winui="using:Microsoft.UI.Xaml.Controls" - xmlns:fa="using:FontAwesome5" - Background="Transparent"> - + xmlns:fa="using:FontAwesome5" + xmlns:season="using:BiliLite.Models.Common.Season" + Background="Transparent"> - + - + - - + + + @@ -39,10 +42,10 @@ - + @@ -60,7 +63,7 @@ - + @@ -69,17 +72,17 @@ - - + + - - + + - - + + @@ -92,14 +95,14 @@ - + 加载更多 - + - + diff --git a/src/BiliLite.UWP/Pages/Bangumi/AnimeIndexPage.xaml.cs b/src/BiliLite.UWP/Pages/Bangumi/AnimeIndexPage.xaml.cs index fc413e7d..ddf55da8 100644 --- a/src/BiliLite.UWP/Pages/Bangumi/AnimeIndexPage.xaml.cs +++ b/src/BiliLite.UWP/Pages/Bangumi/AnimeIndexPage.xaml.cs @@ -1,11 +1,13 @@ using BiliLite.Extensions; using BiliLite.Models.Common; -using BiliLite.Modules; using BiliLite.Services; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Navigation; +using BiliLite.Models.Common.Season; +using BiliLite.ViewModels.Season; +using Microsoft.Extensions.DependencyInjection; // https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板 @@ -18,13 +20,13 @@ namespace BiliLite.Pages.Bangumi public sealed partial class AnimeIndexPage : BasePage { private SeasonIndexParameter indexParameter; - readonly SeasonIndexVM seasonIndexVM; + private readonly SeasonIndexViewModel m_viewModel; public AnimeIndexPage() { + m_viewModel = App.ServiceProvider.GetRequiredService(); this.InitializeComponent(); Title = "剧集索引"; this.NavigationCacheMode = NavigationCacheMode.Enabled; - seasonIndexVM = new SeasonIndexVM(); } protected async override void OnNavigatedTo(NavigationEventArgs e) { @@ -40,11 +42,11 @@ protected async override void OnNavigatedTo(NavigationEventArgs e) indexParameter=e.Parameter as SeasonIndexParameter; } - seasonIndexVM.Parameter = indexParameter; - await seasonIndexVM.LoadConditions(); - if (seasonIndexVM.Conditions != null) + m_viewModel.Parameter = indexParameter; + await m_viewModel.LoadConditions(); + if (m_viewModel.Conditions != null) { - await seasonIndexVM.LoadResult(); + await m_viewModel.LoadResult(); } } } @@ -56,8 +58,8 @@ private void SeasonIndexResultItemOpen(object sender, SeasonIndexResultItemModel { icon = Symbol.Play, page = typeof(Pages.SeasonDetailPage), - parameters = item.season_id, - title = item.title, + parameters = item.SeasonId, + title = item.Title, dontGoTo = dontGoTo }); } @@ -79,12 +81,12 @@ private void MyAdaptiveGridView_PointerPressed(object sender, PointerRoutedEvent private async void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { var combox = sender as ComboBox; - if (combox.SelectedItem == null || seasonIndexVM.ConditionsLoading|| seasonIndexVM.Loading) + if (combox.SelectedItem == null || m_viewModel.ConditionsLoading|| m_viewModel.Loading) { return; } - seasonIndexVM.Page = 1; - await seasonIndexVM.LoadResult(); + m_viewModel.Page = 1; + await m_viewModel.LoadResult(); } } diff --git a/src/BiliLite.UWP/Pages/Bangumi/SeasonRankPage.xaml b/src/BiliLite.UWP/Pages/Bangumi/SeasonRankPage.xaml index dc5a0090..07b0c21d 100644 --- a/src/BiliLite.UWP/Pages/Bangumi/SeasonRankPage.xaml +++ b/src/BiliLite.UWP/Pages/Bangumi/SeasonRankPage.xaml @@ -9,7 +9,8 @@ mc:Ignorable="d" xmlns:convert="using:BiliLite.Converters" xmlns:toolkit="using:Microsoft.Toolkit.Uwp.UI.Controls" - xmlns:modules="using:BiliLite.Modules.Season" + xmlns:season="using:BiliLite.Models.Common.Season" + xmlns:viewModel="using:BiliLite.ViewModels.Season" Background="Transparent"> @@ -17,11 +18,11 @@ - + - - + + @@ -30,7 +31,7 @@ - + - + @@ -54,20 +55,20 @@ - - - + + + - - + + - - - 弹幕: - 综合评分 + + + 弹幕: + 综合评分 @@ -76,6 +77,6 @@ - + diff --git a/src/BiliLite.UWP/Pages/Bangumi/SeasonRankPage.xaml.cs b/src/BiliLite.UWP/Pages/Bangumi/SeasonRankPage.xaml.cs index b4816aa2..0d32ba40 100644 --- a/src/BiliLite.UWP/Pages/Bangumi/SeasonRankPage.xaml.cs +++ b/src/BiliLite.UWP/Pages/Bangumi/SeasonRankPage.xaml.cs @@ -1,11 +1,13 @@ using BiliLite.Extensions; using BiliLite.Models.Common; -using BiliLite.Modules.Season; using BiliLite.Services; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Navigation; +using BiliLite.Models.Common.Season; +using BiliLite.ViewModels.Season; +using Microsoft.Extensions.DependencyInjection; // https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板 @@ -16,13 +18,14 @@ namespace BiliLite.Pages.Bangumi /// public sealed partial class SeasonRankPage : BasePage { - readonly SeasonRankVM seasonRankVM; + readonly SeasonRankViewModel m_viewModel; + public SeasonRankPage() { + m_viewModel = App.ServiceProvider.GetRequiredService(); this.InitializeComponent(); Title = "热门榜单"; this.NavigationCacheMode = NavigationCacheMode.Enabled; - seasonRankVM = new SeasonRankVM(); } protected override void OnNavigatedTo(NavigationEventArgs e) @@ -30,7 +33,7 @@ protected override void OnNavigatedTo(NavigationEventArgs e) base.OnNavigatedTo(e); if (e.NavigationMode == NavigationMode.New) { - seasonRankVM.LoadRankRegion((int)e.Parameter); + m_viewModel.LoadRankRegion((int)e.Parameter); } } @@ -40,10 +43,10 @@ private async void pivot_SelectionChanged(object sender, SelectionChangedEventAr { return; } - var data = pivot.SelectedItem as SeasonRankModel; + var data = pivot.SelectedItem as SeasonRankDataViewModel; if (data.Items == null || data.Items.Count == 0) { - await seasonRankVM.LoadRankDetail(data); + await m_viewModel.LoadRankDetail(data); } } @@ -54,8 +57,8 @@ private void SeasonRankItemOpen(object sender, SeasonRankItemModel item, bool do { icon = Symbol.Play, page = typeof(SeasonDetailPage), - title = item.title, - parameters = item.season_id, + title = item.Title, + parameters = item.SeasonId, dontGoTo = dontGoTo }); } diff --git a/src/BiliLite.UWP/Pages/Bangumi/TimelinePage.xaml b/src/BiliLite.UWP/Pages/Bangumi/TimelinePage.xaml index f0363440..28b0694b 100644 --- a/src/BiliLite.UWP/Pages/Bangumi/TimelinePage.xaml +++ b/src/BiliLite.UWP/Pages/Bangumi/TimelinePage.xaml @@ -8,28 +8,28 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" xmlns:controls="using:BiliLite.Controls" - xmlns:modules="using:BiliLite.Modules" xmlns:toolkit="using:Microsoft.Toolkit.Uwp.UI.Controls" xmlns:fa="using:FontAwesome5" + xmlns:anime="using:BiliLite.Models.Common.Anime" Background="Transparent"> - + - + - - + + - + @@ -42,7 +42,7 @@ - + @@ -63,7 +63,7 @@ - + @@ -98,6 +98,6 @@ - + diff --git a/src/BiliLite.UWP/Pages/Bangumi/TimelinePage.xaml.cs b/src/BiliLite.UWP/Pages/Bangumi/TimelinePage.xaml.cs index 66624815..31e03839 100644 --- a/src/BiliLite.UWP/Pages/Bangumi/TimelinePage.xaml.cs +++ b/src/BiliLite.UWP/Pages/Bangumi/TimelinePage.xaml.cs @@ -1,11 +1,13 @@ using BiliLite.Extensions; using BiliLite.Models.Common; -using BiliLite.Modules; using BiliLite.Services; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Navigation; +using BiliLite.Models.Common.Anime; +using BiliLite.ViewModels.Season; +using Microsoft.Extensions.DependencyInjection; // https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板 @@ -16,19 +18,22 @@ namespace BiliLite.Pages.Bangumi /// public sealed partial class TimelinePage : BasePage { - Modules.AnimeTimelineVM timelineVM; + private AnimeTimelineViewModel m_viewModel; + public TimelinePage() { this.InitializeComponent(); Title = "番剧时间表"; } + protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if(e.NavigationMode== NavigationMode.New) { - timelineVM = new AnimeTimelineVM((AnimeType)e.Parameter); - this.DataContext = timelineVM; + m_viewModel = App.ServiceProvider.GetRequiredService(); + m_viewModel.Init((AnimeType)e.Parameter); + this.DataContext = m_viewModel; // timeLine.ItemsSource = e.Parameter as List; // timeLine.SelectedItem = (e.Parameter as List).FirstOrDefault(x => x.is_today); } @@ -40,8 +45,8 @@ private async void cbType_SelectionChanged(object sender, SelectionChangedEventA { return; } - timelineVM.animeType = (cbType.SelectedItem as AnimeTypeItem).AnimeType; - await timelineVM.GetTimeline(); + m_viewModel.AnimeType = (cbType.SelectedItem as AnimeTypeItem).AnimeType; + await m_viewModel.GetTimeline(); } private void AdaptiveGridView_ItemClick(object sender, ItemClickEventArgs e) diff --git a/src/BiliLite.UWP/Pages/DownloadPage.xaml b/src/BiliLite.UWP/Pages/DownloadPage.xaml index 0b3d8cde..c9f0f4f5 100644 --- a/src/BiliLite.UWP/Pages/DownloadPage.xaml +++ b/src/BiliLite.UWP/Pages/DownloadPage.xaml @@ -10,7 +10,7 @@ xmlns:controls="using:BiliLite.Controls" xmlns:toolkit="using:Microsoft.Toolkit.Uwp.UI.Controls" xmlns:modules="using:BiliLite.Modules" xmlns:download="using:BiliLite.Models.Common.Download" - xmlns:viewModel="using:BiliLite.ViewModels.Download" + xmlns:viewModel="using:BiliLite.ViewModels.Download" xmlns:muxc="using:Microsoft.UI.Xaml.Controls" Background="Transparent"> @@ -34,6 +34,19 @@ % + + + + + - + @@ -259,7 +272,7 @@ - + 剧集 @@ -289,7 +302,7 @@ GB/GB - + diff --git a/src/BiliLite.UWP/Pages/DownloadPage.xaml.cs b/src/BiliLite.UWP/Pages/DownloadPage.xaml.cs index ee7280fc..e353e3b4 100644 --- a/src/BiliLite.UWP/Pages/DownloadPage.xaml.cs +++ b/src/BiliLite.UWP/Pages/DownloadPage.xaml.cs @@ -31,6 +31,14 @@ public sealed partial class DownloadPage : BasePage, IRefreshablePage private static readonly ILogger logger = GlobalLogger.FromCurrentType(); private readonly DownloadPageViewModel m_viewModel; private readonly DownloadService m_downloadService; + private readonly ComboBoxItemData[] m_sortOptions = new ComboBoxItemData[] + { + new() { Text = "默认", Value = DownloadedSortMode.Default }, + new() { Text = "时间倒序", Value = DownloadedSortMode.TimeDesc }, + new() { Text = "时间顺序", Value = DownloadedSortMode.TimeAsc }, + new() { Text = "标题顺序", Value = DownloadedSortMode.TitleAsc }, + new() { Text = "标题倒序", Value = DownloadedSortMode.TitleDesc }, + }; public DownloadPage() { @@ -46,6 +54,7 @@ protected override void OnNavigatedTo(NavigationEventArgs e) public async Task Refresh() { + CbSortMode.SelectedIndex = 0; m_downloadService.RefreshDownloaded(); } @@ -350,5 +359,16 @@ private void BtnResumeSubItem_OnClick(object sender, RoutedEventArgs e) m_downloadService.ResumeItem(item); } } + + private void BtnClearSearch_OnClick(object sender, RoutedEventArgs e) + { + m_downloadService.SearchDownloaded(""); + DownloadPivot.SelectedIndex = 1; + } + + private void SortOptions_OnSelectionChanged(object sender, SelectionChangedEventArgs e) + { + m_downloadService.SetDownloadedSortMode((DownloadedSortMode)CbSortMode.SelectedValue); + } } } diff --git a/src/BiliLite.UWP/Pages/Home/AnimePage.xaml.cs b/src/BiliLite.UWP/Pages/Home/AnimePage.xaml.cs index 2b4c6cbb..3a7da6d6 100644 --- a/src/BiliLite.UWP/Pages/Home/AnimePage.xaml.cs +++ b/src/BiliLite.UWP/Pages/Home/AnimePage.xaml.cs @@ -1,7 +1,6 @@ using BiliLite.Extensions; using BiliLite.Models; using BiliLite.Models.Common; -using BiliLite.Modules; using BiliLite.Services; using System; using System.Threading.Tasks; @@ -9,6 +8,7 @@ using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Navigation; using BiliLite.Models.Common.Anime; +using BiliLite.Models.Common.Season; using BiliLite.ViewModels.Home; using Microsoft.Extensions.DependencyInjection; @@ -128,7 +128,7 @@ private void btnOpenIndex_Click(object sender, RoutedEventArgs e) title = animeType == AnimeType.Bangumi ? "番剧索引" : "国创索引", parameters = new SeasonIndexParameter() { - type = animeType == AnimeType.Bangumi ? IndexSeasonType.Anime : IndexSeasonType.Guochuang + Type = animeType == AnimeType.Bangumi ? IndexSeasonType.Anime : IndexSeasonType.Guochuang } }); } diff --git a/src/BiliLite.UWP/Pages/Home/HotPage.xaml b/src/BiliLite.UWP/Pages/Home/HotPage.xaml index 12ce322b..5c0069a3 100644 --- a/src/BiliLite.UWP/Pages/Home/HotPage.xaml +++ b/src/BiliLite.UWP/Pages/Home/HotPage.xaml @@ -10,8 +10,9 @@ xmlns:controls="using:BiliLite.Controls" xmlns:covert="using:BiliLite.Converters" xmlns:toolkit="using:Microsoft.Toolkit.Uwp.UI.Controls" - xmlns:winui="using:Microsoft.UI.Xaml.Controls" - Background="Transparent"> + xmlns:winui="using:Microsoft.UI.Xaml.Controls" + xmlns:home="using:BiliLite.Models.Common.Home" + Background="Transparent"> @@ -23,12 +24,12 @@ OneRowModeEnabled="False" Padding="8" StretchContentForSingleRow="False" - ItemsSource="{x:Bind Path=hotVM.HotItems,Mode=OneWay}" + ItemsSource="{x:Bind Path=m_viewModel.HotItems,Mode=OneWay}" ItemHeight="100" DesiredWidth="560" LoadMoreBottomOffset="0" - LoadMoreCommand="{x:Bind Path=hotVM.LoadMoreCommand}" + LoadMoreCommand="{x:Bind Path=m_viewModel.LoadMoreCommand}" CanLoadMore="True" - Loading="{x:Bind Path=hotVM.Loading,Mode=OneWay}" + Loading="{x:Bind Path=m_viewModel.Loading,Mode=OneWay}" SelectionMode="None" IsItemClickEnabled="True"> - + 关注的直播 @@ -66,7 +67,7 @@ MoveOffset="600" AlwayShowButton="False" ItemClick="FollowLive_ItemClick" - ItemsSource="{x:Bind Path=liveVM.liveAttentionVM.Follow,Mode=OneWay}" + ItemsSource="{x:Bind Path=m_viewModel.LiveAttentionVm.Follow,Mode=OneWay}" SelectionMode="None" Margin="-4 0 0 0" ScrollViewer.HorizontalScrollMode="Enabled" @@ -127,17 +128,17 @@ - + - + - + 查看更多 @@ -146,7 +147,7 @@ MoveOffset="600" AlwayShowButton="False" ItemClick="LiveItems_ItemClick" - ItemsSource="{x:Bind Path=list,Mode=OneWay}" + ItemsSource="{x:Bind Path=List,Mode=OneWay}" SelectionMode="None" Margin="-4 0 0 0" ScrollViewer.HorizontalScrollMode="Enabled" @@ -168,7 +169,7 @@ - + @@ -177,7 +178,7 @@ - + @@ -186,22 +187,22 @@ - + - + - - - + + + - - + + @@ -217,7 +218,7 @@ - + diff --git a/src/BiliLite.UWP/Pages/Home/LivePage.xaml.cs b/src/BiliLite.UWP/Pages/Home/LivePage.xaml.cs index 1cbc0d20..423a9750 100644 --- a/src/BiliLite.UWP/Pages/Home/LivePage.xaml.cs +++ b/src/BiliLite.UWP/Pages/Home/LivePage.xaml.cs @@ -1,6 +1,5 @@ using BiliLite.Extensions; using BiliLite.Models.Common; -using BiliLite.Modules; using BiliLite.Modules.Live.LiveCenter; using BiliLite.Pages.Live; using BiliLite.Services; @@ -10,6 +9,9 @@ using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Navigation; +using BiliLite.Models.Common.Home; +using BiliLite.ViewModels.Home; +using Microsoft.Extensions.DependencyInjection; // https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板 @@ -20,11 +22,11 @@ namespace BiliLite.Pages.Home /// public sealed partial class LivePage : Page,IRefreshablePage { - private Modules.LiveVM liveVM; + private LiveViewModel m_viewModel; public LivePage() { this.InitializeComponent(); - liveVM = new Modules.LiveVM(); + m_viewModel = App.ServiceProvider.GetRequiredService(); if (SettingService.GetValue(SettingConstants.UI.CACHE_HOME, true)) { this.NavigationCacheMode = NavigationCacheMode.Enabled; @@ -35,21 +37,21 @@ public LivePage() } } - protected async override void OnNavigatedTo(NavigationEventArgs e) + protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); - if (e.NavigationMode == NavigationMode.New && liveVM.Banners == null) + if (e.NavigationMode == NavigationMode.New && m_viewModel.Banners == null) { await LoadData(); } } private async Task LoadData() { - await liveVM.GetLiveHome(); + await m_viewModel.GetLiveHome(); if (SettingService.Account.Logined) { - liveVM.ShowFollows = true; - await liveVM.liveAttentionVM.GetFollows(); + m_viewModel.ShowFollows = true; + await m_viewModel.LiveAttentionVm.GetFollows(); } } @@ -65,7 +67,7 @@ private async void btnRefresh_Click(object sender, RoutedEventArgs e) private async void BannerItem_Click(object sender, RoutedEventArgs e) { - var result = await MessageCenter.HandelUrl(((sender as HyperlinkButton).DataContext as LiveHomeBannerModel).link); + var result = await MessageCenter.HandelUrl(((sender as HyperlinkButton).DataContext as LiveHomeBannerModel).Link); if (!result) { Notify.ShowMessageToast("不支持打开的链接"); @@ -96,15 +98,15 @@ private void LiveItems_ItemClick(object sender, ItemClickEventArgs e) { icon = Symbol.Video, page = typeof(LiveDetailPage), - title = data.uname + "的直播间", - parameters = data.roomid + title = data.Uname + "的直播间", + parameters = data.Roomid }); } private void loadMore_Click(object sender, RoutedEventArgs e) { var data = (sender as HyperlinkButton).DataContext as LiveHomeItemsModel; - if (data.module_info.title == "推荐直播") + if (data.ModuleInfo.Title == "推荐直播") { MessageCenter.NavigateToPage(this, new NavigationInfo() { @@ -113,18 +115,18 @@ private void loadMore_Click(object sender, RoutedEventArgs e) title = "全部直播" }); } - if (!string.IsNullOrEmpty(data.module_info.link)) + if (!string.IsNullOrEmpty(data.ModuleInfo.Link)) { try { - var match = Regex.Match(data.module_info.link, @"parentAreaId=(\d+)&areaId=(\d+)"); + var match = Regex.Match(data.ModuleInfo.Link, @"parentAreaId=(\d+)&areaId=(\d+)"); if (match.Groups.Count == 3) { MessageCenter.NavigateToPage(this, new NavigationInfo() { icon = Symbol.Document, page = typeof(LiveAreaDetailPage), - title = data.module_info.title, + title = data.ModuleInfo.Title, parameters = new LiveAreaPar() { parent_id = match.Groups[1].Value.ToInt32(), @@ -146,13 +148,13 @@ private void loadMore_Click(object sender, RoutedEventArgs e) private void GridView_ItemClick(object sender, ItemClickEventArgs e) { var area = e.ClickedItem as LiveHomeAreaModel; - if (area.id == 0) + if (area.Id == 0) { MessageCenter.NavigateToPage(this, new NavigationInfo() { icon = Symbol.Document, page = typeof(LiveAreaPage), - title = area.title + title = area.Title }); return; } @@ -160,11 +162,11 @@ private void GridView_ItemClick(object sender, ItemClickEventArgs e) { icon = Symbol.Document, page = typeof(LiveAreaDetailPage), - title = area.title, + title = area.Title, parameters = new LiveAreaPar() { - parent_id = area.area_v2_parent_id, - area_id = area.area_v2_id + parent_id = area.AreaV2ParentId, + area_id = area.AreaV2Id } }); } diff --git a/src/BiliLite.UWP/Pages/Home/MoviePage.xaml b/src/BiliLite.UWP/Pages/Home/MoviePage.xaml index cfd90810..1c20fc2c 100644 --- a/src/BiliLite.UWP/Pages/Home/MoviePage.xaml +++ b/src/BiliLite.UWP/Pages/Home/MoviePage.xaml @@ -12,9 +12,11 @@ xmlns:winui="using:Microsoft.UI.Xaml.Controls" xmlns:fa="using:FontAwesome5" xmlns:models="using:BiliLite.Models" + xmlns:home="using:BiliLite.ViewModels.Home" + xmlns:homeModel="using:BiliLite.Models.Common.Home" Background="Transparent"> - + @@ -32,7 +34,7 @@ - + @@ -44,7 +46,7 @@ - + @@ -62,7 +64,7 @@ - + @@ -84,19 +86,19 @@ - + - + - + - + @@ -112,7 +114,7 @@ - + 我的追剧 @@ -122,8 +124,8 @@ - + @@ -218,7 +220,7 @@ - + @@ -247,7 +249,7 @@ + MoveOffset="600" AlwayShowButton="False" SelectionMode="None" ItemClick="{x:Bind Path=m_viewModel.SeasonItemClick}" ItemsSource="{x:Bind Path=m_viewModel.HomeData.Documentary,Mode=OneWay}" ScrollViewer.VerticalScrollMode="Disabled" ScrollViewer.VerticalScrollBarVisibility="Hidden" ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.HorizontalScrollMode="Disabled" ItemTemplate="{StaticResource HotAnimeItem}" IsItemClickEnabled="True"> - + - - + + @@ -29,6 +29,6 @@ - + diff --git a/src/BiliLite.UWP/Pages/Home/RegionsPage.xaml.cs b/src/BiliLite.UWP/Pages/Home/RegionsPage.xaml.cs index 8c200728..23b96da0 100644 --- a/src/BiliLite.UWP/Pages/Home/RegionsPage.xaml.cs +++ b/src/BiliLite.UWP/Pages/Home/RegionsPage.xaml.cs @@ -1,21 +1,10 @@ using BiliLite.Models.Common; -using BiliLite.Modules; -using BiliLite.Modules.Home; using BiliLite.Services; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; -using Windows.Foundation; -using Windows.Foundation.Collections; -using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Controls.Primitives; -using Windows.UI.Xaml.Data; -using Windows.UI.Xaml.Input; -using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Navigation; +using BiliLite.Models.Common.Home; +using BiliLite.ViewModels.Home; +using Microsoft.Extensions.DependencyInjection; // https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板 @@ -26,11 +15,12 @@ namespace BiliLite.Pages.Home /// public sealed partial class RegionsPage : Page { - RegionVM channelVM; + private readonly RegionViewModel m_viewModel; + public RegionsPage() { + m_viewModel = App.ServiceProvider.GetRequiredService(); this.InitializeComponent(); - channelVM = new RegionVM(); if (SettingService.GetValue(SettingConstants.UI.CACHE_HOME, true)) { this.NavigationCacheMode = NavigationCacheMode.Enabled; @@ -41,12 +31,12 @@ public RegionsPage() } } - protected async override void OnNavigatedTo(NavigationEventArgs e) + protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); - if (e.NavigationMode == NavigationMode.New && channelVM.Regions == null) + if (e.NavigationMode == NavigationMode.New && m_viewModel.Regions == null) { - await channelVM.GetRegions(); + await m_viewModel.GetRegions(); } } @@ -54,74 +44,74 @@ protected async override void OnNavigatedTo(NavigationEventArgs e) private void GridView_ItemClick(object sender, ItemClickEventArgs e) { var item = e.ClickedItem as RegionItem; - if (item.uri.Contains("http")) + if (item.Uri.Contains("http")) { MessageCenter.NavigateToPage(this, new NavigationInfo() { icon = Symbol.World, page = typeof(WebPage), - title = item.name, - parameters = item.uri + title = item.Name, + parameters = item.Uri }); return; } - if (item.children != null) + if (item.Children != null) { MessageCenter.NavigateToPage(this, new NavigationInfo() { icon = Symbol.Document, page = typeof(Pages.RegionDetailPage), - title = item.name, + title = item.Name, parameters = new OpenRegionInfo() { - id = item.tid + id = item.Tid } }); return; } - if (item.name == "番剧") + if (item.Name == "番剧") { MessageCenter.NavigateToPage(this, new NavigationInfo() { icon = Symbol.Home, page = typeof(Pages.Home.AnimePage), - title = item.name, + title = item.Name, parameters = AnimeType.Bangumi }); return; } - if (item.name == "国创") + if (item.Name == "国创") { MessageCenter.NavigateToPage(this, new NavigationInfo() { icon = Symbol.Home, page = typeof(Pages.Home.AnimePage), - title = item.name, + title = item.Name, parameters = AnimeType.Bangumi }); return; } - if (item.name == "放映厅") + if (item.Name == "放映厅") { MessageCenter.NavigateToPage(this, new NavigationInfo() { icon = Symbol.Home, page = typeof(Pages.Home.MoviePage), - title = item.name + title = item.Name }); return; } - if (item.name == "直播") + if (item.Name == "直播") { MessageCenter.NavigateToPage(this, new NavigationInfo() { icon = Symbol.Home, page = typeof(Pages.Home.LivePage), - title = item.name + title = item.Name }); return; } - if (item.name == "全区排行榜") + if (item.Name == "全区排行榜") { MessageCenter.NavigateToPage(this, new NavigationInfo() { diff --git a/src/BiliLite.UWP/Pages/HomePage.xaml b/src/BiliLite.UWP/Pages/HomePage.xaml index d99f3415..0b0b9cd8 100644 --- a/src/BiliLite.UWP/Pages/HomePage.xaml +++ b/src/BiliLite.UWP/Pages/HomePage.xaml @@ -66,15 +66,15 @@ --> - - + + 等级 / - + diff --git a/src/BiliLite.UWP/Pages/Live/LiveCenterPage.xaml b/src/BiliLite.UWP/Pages/Live/LiveCenterPage.xaml index e4ab034e..a46cbea3 100644 --- a/src/BiliLite.UWP/Pages/Live/LiveCenterPage.xaml +++ b/src/BiliLite.UWP/Pages/Live/LiveCenterPage.xaml @@ -6,7 +6,7 @@ xmlns:local="using:BiliLite.Pages.Live" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - mc:Ignorable="d" + mc:Ignorable="d" xmlns:muxc="using:Microsoft.UI.Xaml.Controls" xmlns:control="using:BiliLite.Controls" xmlns:modules="using:BiliLite.Modules.Live.LiveCenter" xmlns:toolkit="using:Microsoft.Toolkit.Uwp.UI.Controls" @@ -24,7 +24,7 @@ - + + 全选/反选 + + - + - - + 加载更多 - + - 这里还什么都没有呢~ + 这里还什么都没有呢~ - + diff --git a/src/BiliLite.UWP/Pages/User/FavoriteDetailPage.xaml.cs b/src/BiliLite.UWP/Pages/User/FavoriteDetailPage.xaml.cs index 98f9bf52..da65a965 100644 --- a/src/BiliLite.UWP/Pages/User/FavoriteDetailPage.xaml.cs +++ b/src/BiliLite.UWP/Pages/User/FavoriteDetailPage.xaml.cs @@ -1,7 +1,6 @@ using BiliLite.Dialogs; using BiliLite.Extensions; using BiliLite.Models.Common; -using BiliLite.Modules; using BiliLite.Services; using System; using System.Collections.Generic; @@ -11,7 +10,10 @@ using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Navigation; +using BiliLite.Models.Common.Favorites; using BiliLite.Models.Common.Video; +using BiliLite.ViewModels.Favourites; +using Microsoft.Extensions.DependencyInjection; // https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板 @@ -27,25 +29,25 @@ public class FavoriteDetailArgs /// public sealed partial class FavoriteDetailPage : BasePage, IRefreshablePage { - FavoriteDetailVM favoriteDetailVM; + private readonly FavoriteDetailViewModel m_viewModel; public FavoriteDetailPage() { + m_viewModel = App.ServiceProvider.GetRequiredService(); this.InitializeComponent(); Title = "收藏夹详情"; - favoriteDetailVM = new FavoriteDetailVM(); } protected async override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); - if (e.NavigationMode == NavigationMode.New && favoriteDetailVM.FavoriteInfo == null) + if (e.NavigationMode == NavigationMode.New && m_viewModel.FavoriteInfo == null) { FavoriteDetailArgs args = e.Parameter as FavoriteDetailArgs; - favoriteDetailVM.Id = args.Id; - favoriteDetailVM.Type = args.Type; - favoriteDetailVM.Page = 1; - favoriteDetailVM.Keyword = ""; - await favoriteDetailVM.LoadFavoriteInfo(); + m_viewModel.Id = args.Id; + m_viewModel.Type = args.Type; + m_viewModel.Page = 1; + m_viewModel.Keyword = ""; + await m_viewModel.LoadFavoriteInfo(); } } @@ -67,8 +69,8 @@ private void FavoriteInfoVideoItemModelOpen(object sender, FavoriteInfoVideoItem { icon = Symbol.Play, page = typeof(VideoDetailPage), - title = item.title, - parameters = item.id, + title = item.Title, + parameters = item.Id, dontGoTo = dontGoTo }); } @@ -83,7 +85,7 @@ private void Video_ItemPressed(object sender, PointerRoutedEventArgs e) private void AutoSuggestBox_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args) { - favoriteDetailVM.Search(searchBox.Text); + m_viewModel.Search(searchBox.Text); } private void CheckBox_Checked(object sender, RoutedEventArgs e) @@ -109,7 +111,7 @@ private async void btnDelete_Click(object sender, RoutedEventArgs e) { ls.Add(item); } - await favoriteDetailVM.Delete(ls); + await m_viewModel.Delete(ls); } } @@ -122,9 +124,9 @@ private async void btnMove_Click(object sender, RoutedEventArgs e) { ls.Add(item); } - CopyOrMoveFavVideoDialog copyOrMoveFavVideoDialog = new CopyOrMoveFavVideoDialog(favoriteDetailVM.Id, favoriteDetailVM.FavoriteInfo.mid, true, ls); + CopyOrMoveFavVideoDialog copyOrMoveFavVideoDialog = new CopyOrMoveFavVideoDialog(m_viewModel.Id, m_viewModel.FavoriteInfo.Mid, true, ls); await copyOrMoveFavVideoDialog.ShowAsync(); - favoriteDetailVM.Refresh(); + m_viewModel.Refresh(); } } @@ -137,7 +139,7 @@ private async void btnCopy_Click(object sender, RoutedEventArgs e) { ls.Add(item); } - CopyOrMoveFavVideoDialog copyOrMoveFavVideoDialog = new CopyOrMoveFavVideoDialog(favoriteDetailVM.Id, favoriteDetailVM.FavoriteInfo.mid, false, ls); + CopyOrMoveFavVideoDialog copyOrMoveFavVideoDialog = new CopyOrMoveFavVideoDialog(m_viewModel.Id, m_viewModel.FavoriteInfo.Mid, false, ls); await copyOrMoveFavVideoDialog.ShowAsync(); } } @@ -149,37 +151,37 @@ private async void btnClean_Click(object sender, RoutedEventArgs e) return; } - await favoriteDetailVM.Clean(); + await m_viewModel.Clean(); } private void AddToWatchLater_Click(object sender, RoutedEventArgs e) { var data = (sender as MenuFlyoutItem).DataContext as FavoriteInfoVideoItemModel; - Modules.User.WatchLaterVM.Instance.AddToWatchlater(data.id); + Modules.User.WatchLaterVM.Instance.AddToWatchlater(data.Id); } private async void PlayAll_Click(object sender, RoutedEventArgs e) { - if (favoriteDetailVM.ShowLoadMore) + if (m_viewModel.ShowLoadMore) { Notify.ShowMessageToast("正在读取全部视频,请稍后"); - while (favoriteDetailVM.ShowLoadMore) + while (m_viewModel.ShowLoadMore) { - await favoriteDetailVM.LoadFavoriteInfo(); + await m_viewModel.LoadFavoriteInfo(); } } List items = new List(); - foreach (var item in favoriteDetailVM.Videos) + foreach (var item in m_viewModel.Videos) { - if (item.title != "已失效视频") + if (item.Title != "已失效视频") { items.Add(new VideoPlaylistItem() { - Cover = item.cover, - Author = item.upper.name, - Id = item.id, - Title = item.title + Cover = item.Cover, + Author = item.Upper.Name, + Id = item.Id, + Title = item.Title }); } @@ -193,29 +195,29 @@ private async void PlayAll_Click(object sender, RoutedEventArgs e) { Index = 0, Playlist = items, - Title = $"收藏夹:{favoriteDetailVM.FavoriteInfo.title}" + Title = $"收藏夹:{m_viewModel.FavoriteInfo.Title}" } }); } public async Task Refresh() { - favoriteDetailVM.Refresh(); + m_viewModel.Refresh(); } private async void FavItemGridView_OnDragItemsCompleted(ListViewBase sender, DragItemsCompletedEventArgs args) { var item = args.Items.FirstOrDefault(); if (!(item is FavoriteInfoVideoItemModel favVideo)) return; - var endIndex = favoriteDetailVM.Videos.IndexOf(favVideo); + var endIndex = m_viewModel.Videos.IndexOf(favVideo); var targetId = ""; if (endIndex != 0) { - var target = favoriteDetailVM.Videos[endIndex - 1]; - targetId = target.id; + var target = m_viewModel.Videos[endIndex - 1]; + targetId = target.Id; } - await favoriteDetailVM.Sort(favVideo.id, targetId); + await m_viewModel.Sort(favVideo.Id, targetId); } } } diff --git a/src/BiliLite.UWP/Pages/UserInfoPage.xaml b/src/BiliLite.UWP/Pages/UserInfoPage.xaml index c1bc0f41..ce265afb 100644 --- a/src/BiliLite.UWP/Pages/UserInfoPage.xaml +++ b/src/BiliLite.UWP/Pages/UserInfoPage.xaml @@ -564,12 +564,12 @@ - + LV - + diff --git a/src/BiliLite.UWP/Pages/VideoDetailPage.xaml b/src/BiliLite.UWP/Pages/VideoDetailPage.xaml index 4782835b..f423f9e8 100644 --- a/src/BiliLite.UWP/Pages/VideoDetailPage.xaml +++ b/src/BiliLite.UWP/Pages/VideoDetailPage.xaml @@ -44,6 +44,7 @@ + diff --git a/src/BiliLite.UWP/Pages/VideoDetailPage.xaml.cs b/src/BiliLite.UWP/Pages/VideoDetailPage.xaml.cs index 7dfefe91..b7029014 100644 --- a/src/BiliLite.UWP/Pages/VideoDetailPage.xaml.cs +++ b/src/BiliLite.UWP/Pages/VideoDetailPage.xaml.cs @@ -449,14 +449,21 @@ private void PlayerControl_FullScreenEvent(object sender, bool e) { if (e) { - this.Margin = new Thickness(0, SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) == 0 ? -48 : -48, 0, 0); + if (SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) <= 0) + { + var marginOffset = SettingService.GetValue(SettingConstants.UI.TAB_HEIGHT, + SettingConstants.UI.DEFAULT_TAB_HEIGHT); + this.Margin = new Thickness(0, marginOffset * -1, 0, 0); + } + m_viewModel.DefaultRightInfoWidth = new GridLength(0, GridUnitType.Pixel); BottomInfo.Height = new GridLength(0, GridUnitType.Pixel); } else { this.Margin = new Thickness(0); - m_viewModel.DefaultRightInfoWidth = new GridLength(SettingService.GetValue(SettingConstants.UI.RIGHT_DETAIL_WIDTH, 320), GridUnitType.Pixel); + m_viewModel.DefaultRightInfoWidth = new GridLength( + SettingService.GetValue(SettingConstants.UI.RIGHT_DETAIL_WIDTH, 320), GridUnitType.Pixel); BottomInfo.Height = GridLength.Auto; } } @@ -746,5 +753,10 @@ private void Pivot_OnPreviewKeyDown(object sender, KeyRoutedEventArgs e) e.OriginalSource.GetType() != typeof(TextBox)) e.Handled = true; } + + private void BtnCopyAvId_OnClick(object sender, RoutedEventArgs e) + { + ("av" + m_viewModel.VideoInfo.Aid).SetClipboard(); + } } } diff --git a/src/BiliLite.UWP/Services/AppHelper.cs b/src/BiliLite.UWP/Services/AppHelper.cs index 300bdaea..034b62ac 100644 --- a/src/BiliLite.UWP/Services/AppHelper.cs +++ b/src/BiliLite.UWP/Services/AppHelper.cs @@ -7,6 +7,7 @@ using Windows.Storage; using BiliLite.Extensions; using BiliLite.Models.Common; +using BiliLite.Models.Common.Home; namespace BiliLite.Services { @@ -14,21 +15,21 @@ public static class AppHelper { private static readonly ILogger logger = GlobalLogger.FromCurrentType(); - public static List Regions { get; set; } + public static List Regions { get; set; } private static RegionAPI regionAPI = new RegionAPI(); - public static async Task> GetDefaultRegions() + public static async Task> GetDefaultRegions() { try { var str = await FileIO.ReadTextAsync( await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/Text/regions.json"))); - return JsonConvert.DeserializeObject>(str); + return JsonConvert.DeserializeObject>(str); } catch (Exception ex) { logger.Log("读取默认分区失败!" + ex.Message, LogType.Error, ex); - return new List(); + return new List(); } } @@ -42,11 +43,11 @@ public static async Task SetRegions() var data = results.GetJObject(); if (data["code"].ToInt32() == 0) { - var ls = JsonConvert.DeserializeObject>(data["data"].ToString() + var ls = JsonConvert.DeserializeObject>(data["data"].ToString() .Replace("goto", "_goto")); foreach (var item in ls.Where(x => - string.IsNullOrEmpty(x.uri) || x.name == "会员购" || x.name == "漫画" || - x.name == "游戏中心" || x.name == "话题中心" || x.name == "音频" || x.name == "原创排行榜") + string.IsNullOrEmpty(x.Uri) || x.Name == "会员购" || x.Name == "漫画" || + x.Name == "游戏中心" || x.Name == "话题中心" || x.Name == "音频" || x.Name == "原创排行榜") .ToList()) { ls.Remove(item); diff --git a/src/BiliLite.UWP/Services/DownloadService.cs b/src/BiliLite.UWP/Services/DownloadService.cs index ff1dbc86..5ff38a92 100644 --- a/src/BiliLite.UWP/Services/DownloadService.cs +++ b/src/BiliLite.UWP/Services/DownloadService.cs @@ -335,6 +335,30 @@ private async Task LoadDownloadFromIndex() m_downloadPageViewModel.DownloadedViewModels = new ObservableCollection(downloadedItems); } + private IEnumerable QueryDownloaded() + { + var query = m_downloadPageViewModel.Downloadeds.AsEnumerable(); + + // 提前处理搜索条件 + var searchKeyword = m_downloadPageViewModel.SearchKeyword?.ToLower(); + if (!string.IsNullOrEmpty(searchKeyword)) + { + query = query.Where(x => x.Title.ToLower().Contains(searchKeyword)); + } + + // 使用 switch 表达式简化排序逻辑 + query = m_downloadPageViewModel.DownloadedSortMode switch + { + DownloadedSortMode.TimeDesc => query.OrderByDescending(x => x.UpdateTime), + DownloadedSortMode.TimeAsc => query.OrderBy(x => x.UpdateTime), + DownloadedSortMode.TitleDesc => query.OrderByDescending(x => x.Title), + DownloadedSortMode.TitleAsc => query.OrderBy(x => x.Title), + _ => query // 默认不排序 + }; + + return query; + } + #endregion #region Public Methods @@ -428,8 +452,10 @@ public void RefreshDownloaded() public void SearchDownloaded(string keyword) { - var searchResult = m_downloadPageViewModel.Downloadeds - .Where(x => x.Title.ToLower().Contains(keyword.ToLower())).ToList(); + m_downloadPageViewModel.SearchKeyword = keyword; + m_downloadPageViewModel.IsSearching = !string.IsNullOrEmpty(keyword); + + var searchResult = QueryDownloaded(); m_downloadPageViewModel.DownloadedViewModels.Clear(); m_downloadPageViewModel.DownloadedViewModels.AddRange(searchResult); } @@ -807,9 +833,16 @@ public void ClearIndex() m_biliLiteDbContext.DownloadedItems.RemoveRange(m_biliLiteDbContext.DownloadedItems); } - #endregion + public void SetDownloadedSortMode(DownloadedSortMode mode) + { + m_downloadPageViewModel.DownloadedSortMode = mode; + m_downloadPageViewModel.DownloadedViewModels.Clear(); + var query = QueryDownloaded(); + m_downloadPageViewModel.DownloadedViewModels.AddRange(query); + } + #endregion } -} +} \ No newline at end of file diff --git a/src/BiliLite.UWP/Services/FrostMasterDanmakuController.cs b/src/BiliLite.UWP/Services/FrostMasterDanmakuController.cs index d599e744..5339ac4d 100644 --- a/src/BiliLite.UWP/Services/FrostMasterDanmakuController.cs +++ b/src/BiliLite.UWP/Services/FrostMasterDanmakuController.cs @@ -6,7 +6,6 @@ using Windows.UI.Xaml.Controls; using Atelier39; using AutoMapper; -using BiliLite.Models.Common; using BiliLite.Models.Common.Danmaku; using BiliLite.Services.Interfaces; using BiliLite.ViewModels.Video; @@ -115,23 +114,7 @@ public override void SetSpeed(int speed) public override void SetTopMargin(double topMargin) { base.SetTopMargin(topMargin); - if (SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) > 0) - { - m_danmakuCanvas.Margin = DanmakuViewModel.Fullscreen ? new Thickness(0, DanmakuViewModel.MarginTop + 16, 0, 0) : new Thickness(0, DanmakuViewModel.MarginTop, 0, 0); - } - else - { - m_danmakuCanvas.Margin = new Thickness(0, topMargin, 0, 0); - } - } - - public override void SetFullscreen(bool fullscreen) - { - base.SetFullscreen(fullscreen); - if (SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) > 0) - { - m_danmakuCanvas.Margin = fullscreen ? new Thickness(0, DanmakuViewModel.MarginTop + 16, 0, 0) : new Thickness(0, DanmakuViewModel.MarginTop, 0, 0); - } + m_danmakuCanvas.Margin = new Thickness(0, topMargin, 0, 0); } public override void SetOpacity(double opacity) @@ -196,11 +179,5 @@ public override void UpdateTime(long position) base.UpdateTime(position); m_danmakuMaster.UpdateTime((uint)position * 1000); } - - public void SetAssSubtitle(string assContent) - { - var subItems = AssParser.GetDanmakuList(assContent); - m_danmakuMaster.SetSubtitleList(subItems); - } } } diff --git a/src/BiliLite.UWP/Services/Notification/LiveTileService.cs b/src/BiliLite.UWP/Services/Notification/LiveTileService.cs new file mode 100644 index 00000000..149ba20b --- /dev/null +++ b/src/BiliLite.UWP/Services/Notification/LiveTileService.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using BiliLite.Models.Common.Notifications; + +namespace BiliLite.Services.Notification +{ + public class LiveTileService + { + public List TileFurnace = new List(); + + public async Task RefreshTile() + { + TileFurnace.Clear(); + // TODO: 取热门/动态/推荐数据 + var sample = new NotificationTile() + { + Name = "BiliLIte", + Description = "", + Url = @"Assets/SplashScreen.png", + }; + TileFurnace.Add(sample); + } + } +} diff --git a/src/BiliLite.UWP/Services/NsDanmakuController.cs b/src/BiliLite.UWP/Services/NsDanmakuController.cs index bb72e099..615210e2 100644 --- a/src/BiliLite.UWP/Services/NsDanmakuController.cs +++ b/src/BiliLite.UWP/Services/NsDanmakuController.cs @@ -12,7 +12,6 @@ using BiliLite.ViewModels.Video; using NSDanmaku.Controls; using NSDanmaku.Model; -using BiliLite.Models.Common; namespace BiliLite.Services { @@ -112,23 +111,7 @@ public override void SetSpeed(int speed) public override void SetTopMargin(double topMargin) { base.SetTopMargin(topMargin); - if (SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) > 0) - { - m_danmakuControl.Margin = DanmakuViewModel.Fullscreen ? new Thickness(0, DanmakuViewModel.MarginTop + 16, 0, 0) : new Thickness(0, DanmakuViewModel.MarginTop, 0, 0); - } - else - { - m_danmakuControl.Margin = new Thickness(0, topMargin, 0, 0); - } - } - - public override void SetFullscreen(bool fullscreen) - { - base.SetFullscreen(fullscreen); - if (SettingService.GetValue(SettingConstants.UI.DISPLAY_MODE, 0) > 0) - { - m_danmakuControl.Margin = fullscreen ? new Thickness(0, DanmakuViewModel.MarginTop + 16, 0, 0) : new Thickness(0, DanmakuViewModel.MarginTop, 0, 0); - } + m_danmakuControl.Margin = new Thickness(0, topMargin, 0, 0); } public override void SetOpacity(double opacity) diff --git a/src/BiliLite.UWP/Services/ThemeService.cs b/src/BiliLite.UWP/Services/ThemeService.cs new file mode 100644 index 00000000..c5a65a02 --- /dev/null +++ b/src/BiliLite.UWP/Services/ThemeService.cs @@ -0,0 +1,71 @@ +using BiliLite.Extensions; +using BiliLite.Models.Common; +using System.Linq; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; + +namespace BiliLite.Services +{ + public class ThemeService + { + private ResourceDictionary m_defaultColorsResource; + private ElementTheme m_theme; + + public ThemeService() + { + m_theme = (ElementTheme)SettingService.GetValue(SettingConstants.UI.THEME, 0); + if (m_theme == ElementTheme.Default) + { + m_theme = (ElementTheme)(App.Current.RequestedTheme + 1); + } + } + + public void Init() => m_defaultColorsResource = Application.Current.Resources.MergedDictionaries.FirstOrDefault(x => x.Source.AbsoluteUri.Contains("Default")); + + public ResourceDictionary ThemeResource + { + get + { + if (m_theme == ElementTheme.Light) return m_defaultColorsResource.ThemeDictionaries["Light"] as ResourceDictionary; + return m_defaultColorsResource.ThemeDictionaries["Dark"] as ResourceDictionary; + } + } + + public void InitTitleBar() + { + AppExtensions.HandleTitleTheme(); + } + + public void SetTheme(ElementTheme theme) + { + m_theme = theme; + SettingService.SetValue(SettingConstants.UI.THEME, (int)theme); + var rootFrame = Window.Current.Content as Frame; + switch (theme) + { + case ElementTheme.Light: + rootFrame.RequestedTheme = ElementTheme.Light; + break; + case ElementTheme.Dark: + rootFrame.RequestedTheme = ElementTheme.Dark; + break; + default: + rootFrame.RequestedTheme = ElementTheme.Default; + break; + } + InitTitleBar(); + } + + public void SetColor() + { + //case 3: + // // TODO: 切换自定义主题 + // rootFrame.Resources = Application.Current.Resources.ThemeDictionaries["Pink"] as ResourceDictionary; + // break; + //case 4: + // // TODO: 切换自定义主题 + // rootFrame.Resources = Application.Current.Resources.ThemeDictionaries["Blue"] as ResourceDictionary; + // break; + } + } +} diff --git a/src/BiliLite.UWP/Startup.cs b/src/BiliLite.UWP/Startup.cs index 1745f0fa..69dc22c7 100644 --- a/src/BiliLite.UWP/Startup.cs +++ b/src/BiliLite.UWP/Startup.cs @@ -1,6 +1,7 @@ using BiliLite.Extensions; using BiliLite.Services; using BiliLite.Services.Biz; +using BiliLite.Services.Notification; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; @@ -15,6 +16,7 @@ public void ConfigureServices(HostBuilderContext context, IServiceCollection ser services.AddSingleton(); services.AddTransient(); + services.AddSingleton(); services.AddMapper(); services.AddViewModels(); services.AddControls(); @@ -32,6 +34,7 @@ public void ConfigureServices(HostBuilderContext context, IServiceCollection ser services.AddSingleton(); services.AddSingleton(); + services.AddSingleton(); } } } diff --git a/src/BiliLite.UWP/Themes/Breakpoint.xaml b/src/BiliLite.UWP/Styles/Breakpoint.xaml similarity index 100% rename from src/BiliLite.UWP/Themes/Breakpoint.xaml rename to src/BiliLite.UWP/Styles/Breakpoint.xaml diff --git a/src/BiliLite.UWP/Themes/Converter.xaml b/src/BiliLite.UWP/Styles/Converter.xaml similarity index 88% rename from src/BiliLite.UWP/Themes/Converter.xaml rename to src/BiliLite.UWP/Styles/Converter.xaml index 49b1fe3c..e07280f5 100644 --- a/src/BiliLite.UWP/Themes/Converter.xaml +++ b/src/BiliLite.UWP/Styles/Converter.xaml @@ -8,4 +8,5 @@ + diff --git a/src/BiliLite.UWP/Themes/Fonts.xaml b/src/BiliLite.UWP/Styles/Fonts.xaml similarity index 100% rename from src/BiliLite.UWP/Themes/Fonts.xaml rename to src/BiliLite.UWP/Styles/Fonts.xaml diff --git a/src/BiliLite.UWP/Styles/TabViewStyle.xaml b/src/BiliLite.UWP/Styles/TabViewStyle.xaml index 2fdb4d6c..4abc4796 100644 --- a/src/BiliLite.UWP/Styles/TabViewStyle.xaml +++ b/src/BiliLite.UWP/Styles/TabViewStyle.xaml @@ -24,16 +24,10 @@ - + - + @@ -74,8 +68,8 @@