├── .gitignore ├── .metadata ├── README.md ├── analysis_options.yaml ├── android ├── .gitignore ├── app │ ├── build.gradle │ └── src │ │ ├── debug │ │ └── AndroidManifest.xml │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── kotlin │ │ │ └── com │ │ │ │ └── lucky │ │ │ │ └── short_video_spider_client │ │ │ │ └── MainActivity.kt │ │ └── res │ │ │ ├── drawable-v21 │ │ │ └── launch_background.xml │ │ │ ├── drawable │ │ │ └── launch_background.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── values-night │ │ │ └── styles.xml │ │ │ └── values │ │ │ └── styles.xml │ │ └── profile │ │ └── AndroidManifest.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties └── settings.gradle ├── ios ├── .gitignore ├── Flutter │ ├── AppFrameworkInfo.plist │ ├── Debug.xcconfig │ └── Release.xcconfig ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ └── WorkspaceSettings.xcsettings └── Runner │ ├── AppDelegate.swift │ ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── Icon-App-1024x1024@1x.png │ │ ├── Icon-App-20x20@1x.png │ │ ├── Icon-App-20x20@2x.png │ │ ├── Icon-App-20x20@3x.png │ │ ├── Icon-App-29x29@1x.png │ │ ├── Icon-App-29x29@2x.png │ │ ├── Icon-App-29x29@3x.png │ │ ├── Icon-App-40x40@1x.png │ │ ├── Icon-App-40x40@2x.png │ │ ├── Icon-App-40x40@3x.png │ │ ├── Icon-App-60x60@2x.png │ │ ├── Icon-App-60x60@3x.png │ │ ├── Icon-App-76x76@1x.png │ │ ├── Icon-App-76x76@2x.png │ │ └── Icon-App-83.5x83.5@2x.png │ └── LaunchImage.imageset │ │ ├── Contents.json │ │ ├── LaunchImage.png │ │ ├── LaunchImage@2x.png │ │ ├── LaunchImage@3x.png │ │ └── README.md │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ └── Runner-Bridging-Header.h ├── lib ├── config │ └── constants.dart ├── main.dart ├── model │ ├── douyin_list.dart │ ├── douyin_single.dart │ └── douyin_single_images.dart ├── pages │ ├── home │ │ └── home_page.dart │ ├── mobile │ │ └── download_page.dart │ └── widget │ │ ├── copy_text.dart │ │ └── dialog │ │ └── dialog.dart └── utils │ ├── dio_util.dart │ ├── file_util.dart │ ├── keyboard_util.dart │ ├── screen_util.dart │ ├── short_video_util.dart │ ├── sp_util.dart │ ├── toast_util.dart │ └── widget_util.dart ├── linux ├── .gitignore ├── CMakeLists.txt ├── flutter │ ├── CMakeLists.txt │ ├── generated_plugin_registrant.cc │ ├── generated_plugin_registrant.h │ └── generated_plugins.cmake ├── main.cc ├── my_application.cc └── my_application.h ├── macos ├── .gitignore ├── Flutter │ ├── Flutter-Debug.xcconfig │ ├── Flutter-Release.xcconfig │ └── GeneratedPluginRegistrant.swift ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── Runner │ ├── AppDelegate.swift │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── app_icon_1024.png │ │ ├── app_icon_128.png │ │ ├── app_icon_16.png │ │ ├── app_icon_256.png │ │ ├── app_icon_32.png │ │ ├── app_icon_512.png │ │ └── app_icon_64.png │ ├── Base.lproj │ └── MainMenu.xib │ ├── Configs │ ├── AppInfo.xcconfig │ ├── Debug.xcconfig │ ├── Release.xcconfig │ └── Warnings.xcconfig │ ├── DebugProfile.entitlements │ ├── Info.plist │ ├── MainFlutterWindow.swift │ ├── Release.entitlements │ └── RunnerDebug.entitlements ├── pubspec.lock ├── pubspec.yaml ├── screenshots ├── android_1.png ├── android_2.png ├── ios_1.png ├── ios_2.png ├── macos.png └── windows.png ├── test └── widget_test.dart ├── web ├── favicon.png ├── icons │ ├── Icon-192.png │ ├── Icon-512.png │ ├── Icon-maskable-192.png │ └── Icon-maskable-512.png ├── index.html └── manifest.json └── windows ├── .gitignore ├── CMakeLists.txt ├── flutter ├── CMakeLists.txt ├── generated_plugin_registrant.cc ├── generated_plugin_registrant.h └── generated_plugins.cmake └── runner ├── CMakeLists.txt ├── Runner.rc ├── flutter_window.cpp ├── flutter_window.h ├── main.cpp ├── resource.h ├── resources └── app_icon.ico ├── runner.exe.manifest ├── utils.cpp ├── utils.h ├── win32_window.cpp └── win32_window.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | **/doc/api/ 26 | **/ios/Flutter/.last_build_id 27 | .dart_tool/ 28 | .flutter-plugins 29 | .flutter-plugins-dependencies 30 | .packages 31 | .pub-cache/ 32 | .pub/ 33 | /build/ 34 | 35 | # Web related 36 | lib/generated_plugin_registrant.dart 37 | 38 | # Symbolication related 39 | app.*.symbols 40 | 41 | # Obfuscation related 42 | app.*.map.json 43 | 44 | # Android Studio will place build artifacts here 45 | /android/app/debug 46 | /android/app/profile 47 | /android/app/release 48 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled. 5 | 6 | version: 7 | revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 8 | channel: stable 9 | 10 | project_type: app 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 17 | base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 18 | - platform: android 19 | create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 20 | base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 21 | - platform: ios 22 | create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 23 | base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 24 | - platform: linux 25 | create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 26 | base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 27 | - platform: macos 28 | create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 29 | base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 30 | - platform: web 31 | create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 32 | base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 33 | - platform: windows 34 | create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 35 | base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 36 | 37 | # User provided section 38 | 39 | # List of Local paths (relative to this file) that should be 40 | # ignored by the migrate tool. 41 | # 42 | # Files that are not part of the templates will be ignored by default. 43 | unmanaged_files: 44 | - 'lib/main.dart' 45 | - 'ios/Runner.xcodeproj/project.pbxproj' 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 短视频下载器客户端 2 | 3 | 需要配合服务端一起使用,可以下载单个视频,也支持下载用户下的多个视频。客户端已集成线上地址,服务器是用Python去抓取真实地址的,想看服务器代码,请点[这里](https://github.com/LuckyLi706/ShortVideoSpider),并且提供提供api接口。客户端支持Android、Windows、Macos、IOS(没有签名文件,需要自己打包),Linux(没适配) 4 | 5 | ## 说明 6 | 7 | 1. 个人服务器到期了,服务暂时停了。 8 | 2. 抖音现在需要Cookie验证了,可以自己搭建服务器。服务器地址:[ShortVideoSpider](https://github.com/LuckyLi706/ShortVideoSpider) 9 | 10 | ## 支持平台 11 | + 抖音(支持单个下载和多个下载) 12 | + tiktok(支持支持单个下载,请先在设置里面设置代理服务器) 13 | 14 | ## 编译环境 15 | 16 | + Flutter版本:3.0.1 17 | + Dart版本:2.17.1 18 | 19 | ## 功能 20 | 21 | + 设置功能 右上角的设置,可以提供url和存储路径的配置。 22 | + 单个和多个选择框 23 | - 单个 下载单个视频,复制单个视频的分享地址到下面的地址栏中。 24 | - 多个 可以下载多个视频,web进入用户的主页,然后复制到下面的地址栏中,移动端可以通过分享主页复制到下面的地址栏中,下面的max_cursor的输入框可以不管。 25 | + 获取下载地址 点击该按钮去获取真实的视频地址。 26 | + 下载视频 获取真实地址成功之后可以点击这个按钮去下载视频。 27 | + 清除日志 清除日志信息。 28 | 29 | ## 编译 30 | 31 | ``` 32 | flutter build apk --no-sound-null-safety 编译apk 33 | flutter build ios --no-sound-null-safety 编译ipa 34 | flutter build windows --no-sound-null-safety 编译windows 35 | flutter build macos --no-sound-null-safety 编译Mac 36 | ``` 37 | 38 | ## 截图 39 | 40 | + Windows 41 | ![](screenshots/windows.png) 42 | + Android 43 | 44 |
45 | 46 | 47 |
48 | 49 | + macOS 50 | ![](screenshots/macos.png) 51 | + IOS 52 | 53 |
54 | 55 | 56 |
57 | 58 | + Linux 59 | 60 | 应该没啥人使用Linux吧,哈哈哈,所以没适配。 61 | 62 | ## 免责声明 63 | 64 | 本仓库只为学习研究,如涉及侵犯个人或者团体利益,请与我取得联系,我将主动删除一切相关资料,谢谢! 65 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at 17 | # https://dart-lang.github.io/linter/lints/index.html. 18 | # 19 | # Instead of disabling a lint rule for the entire project in the 20 | # section below, it can also be suppressed for a single line of code 21 | # or a specific dart file by using the `// ignore: name_of_lint` and 22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 23 | # producing the lint. 24 | rules: 25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 27 | 28 | # Additional information about this file can be found at 29 | # https://dart.dev/guides/language/analysis-options 30 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion flutter.compileSdkVersion 30 | ndkVersion flutter.ndkVersion 31 | 32 | compileOptions { 33 | sourceCompatibility JavaVersion.VERSION_1_8 34 | targetCompatibility JavaVersion.VERSION_1_8 35 | } 36 | 37 | kotlinOptions { 38 | jvmTarget = '1.8' 39 | } 40 | 41 | sourceSets { 42 | main.java.srcDirs += 'src/main/kotlin' 43 | } 44 | 45 | defaultConfig { 46 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 47 | applicationId "com.lucky.short_video_spider_client" 48 | // You can update the following values to match your application needs. 49 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. 50 | minSdkVersion flutter.minSdkVersion 51 | targetSdkVersion flutter.targetSdkVersion 52 | versionCode flutterVersionCode.toInteger() 53 | versionName flutterVersionName 54 | } 55 | 56 | buildTypes { 57 | release { 58 | // TODO: Add your own signing config for the release build. 59 | // Signing with the debug keys for now, so `flutter run --release` works. 60 | signingConfig signingConfigs.debug 61 | } 62 | } 63 | } 64 | 65 | flutter { 66 | source '../..' 67 | } 68 | 69 | dependencies { 70 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 71 | } 72 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 13 | 21 | 25 | 28 | 29 | 30 | 31 | 32 | 33 | 35 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/lucky/short_video_spider_client/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.lucky.short_video_spider_client 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.6.10' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.1.2' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | mavenCentral() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | task clean(type: Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | extra-front-end-options=--no-sound-null-safety -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip 7 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | -------------------------------------------------------------------------------- /ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 9.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NSPhotoLibraryUsageDescription 6 | 授予读写图片权限 7 | CFBundleDevelopmentRegion 8 | $(DEVELOPMENT_LANGUAGE) 9 | CFBundleDisplayName 10 | 短视频下载器 11 | CFBundleExecutable 12 | $(EXECUTABLE_NAME) 13 | CFBundleIdentifier 14 | $(PRODUCT_BUNDLE_IDENTIFIER) 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | short_video_spider_client 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | $(FLUTTER_BUILD_NAME) 23 | CFBundleSignature 24 | ???? 25 | CFBundleVersion 26 | $(FLUTTER_BUILD_NUMBER) 27 | LSRequiresIPhoneOS 28 | 29 | UILaunchStoryboardName 30 | LaunchScreen 31 | UIMainStoryboardFile 32 | Main 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | UIViewControllerBasedStatusBarAppearance 47 | 48 | CADisableMinimumFrameDurationOnPhone 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /lib/config/constants.dart: -------------------------------------------------------------------------------- 1 | class Constants { 2 | static const String SP_KEY_BASE_URL = "BASE_URL"; 3 | static const String SP_KEY_PROXY_URL = "PROXY_URL"; 4 | static const String SP_KEY_CACHE_PATH = "CACHE_PATH"; 5 | static const String SP_KEY_APP_VERSION = "APP_VERSION"; 6 | 7 | static const String APP_NAME = "短视频下载器"; 8 | 9 | static String BASE_URL = "http://81.68.122.109:8080"; 10 | static String PROXY_URL = "10.1.2.244:7890"; 11 | static String CACHE_PATH = ""; 12 | static String APP_VERSION = "1.1.5"; 13 | } 14 | -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:dio/dio.dart'; 5 | import 'package:short_video_spider_client/config/constants.dart'; 6 | import 'package:short_video_spider_client/pages/home/home_page.dart'; 7 | import 'package:short_video_spider_client/utils/file_util.dart'; 8 | import 'package:short_video_spider_client/utils/keyboard_util.dart'; 9 | import 'package:short_video_spider_client/utils/sp_util.dart'; 10 | 11 | var dio = Dio(); 12 | 13 | void main() { 14 | WidgetsFlutterBinding.ensureInitialized(); 15 | HttpOverrides.global = MyHttpOverrides(); 16 | Injection.init(); 17 | runApp(const MyApp()); 18 | } 19 | 20 | class MyApp extends StatelessWidget { 21 | const MyApp({Key? key}) : super(key: key); 22 | 23 | @override 24 | Widget build(BuildContext context) { 25 | return MaterialApp( 26 | debugShowCheckedModeBanner: false, 27 | builder: (context, child) => Scaffold( 28 | // 全局点击隐藏软键盘 29 | body: GestureDetector( 30 | onTap: () { 31 | KeyboardUtils.hideKeyboard(context); 32 | }, 33 | child: child, 34 | ), 35 | ), 36 | home: const HomePage(), 37 | ); 38 | } 39 | } 40 | 41 | ///提前注入 42 | ///存储和请求初始化 43 | class Injection { 44 | static Future init() async { 45 | String? baseUrl = await SpUtil.getBaseUrl(); 46 | if (baseUrl == null) { 47 | SpUtil.updateBaseUrl(Constants.BASE_URL); 48 | } else { 49 | Constants.BASE_URL = baseUrl; 50 | } 51 | 52 | String? proxyUrl = await SpUtil.getProxyUrl(); 53 | if (proxyUrl == null) { 54 | SpUtil.updateProxyUrl(Constants.PROXY_URL); 55 | } else { 56 | Constants.PROXY_URL = proxyUrl; 57 | } 58 | 59 | if (Platform.isIOS) { 60 | String dir = await FileUtils.getFileDirectory(); 61 | Constants.CACHE_PATH = dir; 62 | return; 63 | } 64 | String? cachePath = await SpUtil.getCachePath(); 65 | if (cachePath == null) { 66 | String dir = await FileUtils.getFileDirectory(); 67 | SpUtil.updateCachePath(dir); 68 | Constants.CACHE_PATH = dir; 69 | } else { 70 | Constants.CACHE_PATH = cachePath; 71 | } 72 | 73 | String? appVersion = await SpUtil.getAppVersion(); 74 | if (appVersion == null) { 75 | SpUtil.updateAppVersion(Constants.APP_VERSION); 76 | } else { 77 | if (Constants.APP_VERSION != appVersion) { 78 | //可以做一些更新配置的操作 79 | SpUtil.updateAppVersion(Constants.APP_VERSION); 80 | } 81 | } 82 | } 83 | } 84 | 85 | class MyHttpOverrides extends HttpOverrides{ 86 | @override 87 | HttpClient createHttpClient(SecurityContext? context){ 88 | return super.createHttpClient(context) 89 | ..badCertificateCallback = (X509Certificate cert, String host, int port)=> true; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /lib/model/douyin_list.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | DouYinList fromJson(String str) => DouYinList.fromJson(json.decode(str)); 4 | 5 | String toJson(DouYinList data) => json.encode(data.toJson()); 6 | 7 | class DouYinList { 8 | DouYinList({ 9 | this.code, 10 | this.coverImageUrlList = const [], 11 | this.hasMore, 12 | this.maxCursor, 13 | this.secUid, 14 | this.videoUrlList = const [], 15 | this.videoDescList = const [], 16 | }); 17 | 18 | int? code; 19 | List coverImageUrlList = []; 20 | List videoDescList = []; 21 | bool? hasMore; 22 | int? maxCursor; 23 | List videoUrlList = []; 24 | String? secUid; 25 | 26 | factory DouYinList.fromJson(Map json) => DouYinList( 27 | code: json["code"], 28 | coverImageUrlList: 29 | List.from(json["cover_image_url_list"].map((x) => x)), 30 | videoDescList: List.from(json["video_desc_list"].map((x) => x)), 31 | hasMore: json["has_more"], 32 | maxCursor: json["max_cursor"], 33 | videoUrlList: List.from(json["video_url_list"].map((x) => x)), 34 | secUid: json["sec_uid"]); 35 | 36 | Map toJson() => { 37 | "code": code, 38 | "cover_image_url_list": 39 | List.from(coverImageUrlList.map((x) => x)), 40 | "has_more": hasMore, 41 | "max_cursor": maxCursor, 42 | "sec_uid": secUid, 43 | "video_url_list": List.from(videoUrlList.map((x) => x)), 44 | "video_desc_list": List.from(videoDescList.map((x) => x)), 45 | }; 46 | } 47 | -------------------------------------------------------------------------------- /lib/model/douyin_single.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | DouYinSingle fromJson(String str) => DouYinSingle.fromJson(json.decode(str)); 4 | 5 | String toJson(DouYinSingle data) => json.encode(data.toJson()); 6 | 7 | class DouYinSingle { 8 | DouYinSingle({ 9 | this.code, 10 | this.coverImageUrl, 11 | this.videoUrl, 12 | this.videoDesc, 13 | }); 14 | 15 | int? code; 16 | String? coverImageUrl; 17 | String? videoUrl; 18 | String? videoDesc; 19 | 20 | factory DouYinSingle.fromJson(Map json) => DouYinSingle( 21 | code: json["code"], 22 | coverImageUrl: json["cover_image_url"], 23 | videoUrl: json["video_url"], 24 | videoDesc: json["video_desc"]); 25 | 26 | Map toJson() => { 27 | "code": code, 28 | "cover_image_url": coverImageUrl, 29 | "video_url": videoUrl, 30 | "video_desc": videoDesc, 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /lib/model/douyin_single_images.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | DouYinSingleImages fromJson(String str) => 4 | DouYinSingleImages.fromJson(json.decode(str)); 5 | 6 | String toJson(DouYinSingleImages data) => json.encode(data.toJson()); 7 | 8 | class DouYinSingleImages { 9 | DouYinSingleImages({this.code, this.coverImageUrlList = const [], this.desc}); 10 | 11 | int? code; 12 | List coverImageUrlList = []; 13 | String? desc; 14 | 15 | factory DouYinSingleImages.fromJson(Map json) => 16 | DouYinSingleImages( 17 | code: json["code"], 18 | desc: json["image_desc"], 19 | coverImageUrlList: 20 | List.from(json["image_url_list"].map((x) => x))); 21 | 22 | Map toJson() => { 23 | "code": code, 24 | "image_url_list": List.from(coverImageUrlList.map((x) => x)), 25 | "desc": desc 26 | }; 27 | } 28 | -------------------------------------------------------------------------------- /lib/pages/home/home_page.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:dio/dio.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:permission_handler/permission_handler.dart'; 6 | import 'package:short_video_spider_client/model/douyin_single_images.dart'; 7 | import 'package:short_video_spider_client/pages/mobile/download_page.dart'; 8 | import 'package:short_video_spider_client/utils/dio_util.dart'; 9 | import 'package:short_video_spider_client/utils/file_util.dart'; 10 | import 'package:short_video_spider_client/utils/short_video_util.dart'; 11 | import 'package:short_video_spider_client/utils/widget_util.dart'; 12 | 13 | import '../../config/constants.dart'; 14 | import '../../model/douyin_list.dart'; 15 | import '../../model/douyin_single.dart'; 16 | import '../../utils/screen_util.dart'; 17 | import '../widget/dialog/dialog.dart'; 18 | 19 | var imageList = []; 20 | var urlDownloadList = []; 21 | var videoDescList = []; 22 | 23 | class HomePage extends StatefulWidget { 24 | const HomePage({Key? key}) : super(key: key); 25 | 26 | @override 27 | State createState() { 28 | return HomePageState(); 29 | } 30 | } 31 | 32 | //获取当前的界面大小 33 | _getWidthHeight(BuildContext context) { 34 | final size = MediaQuery.of(context).size; 35 | ScreenUtils.width = size.width; 36 | ScreenUtils.height = size.height; 37 | } 38 | 39 | class HomePageState extends State { 40 | @override 41 | void initState() { 42 | super.initState(); 43 | _initShortVideoDownloadType(); 44 | } 45 | 46 | @override 47 | Widget build(BuildContext context) { 48 | _getWidthHeight(context); 49 | return Scaffold( 50 | resizeToAvoidBottomInset: false, 51 | appBar: AppBar( 52 | title: Text("${Constants.APP_NAME} v${Constants.APP_VERSION}"), 53 | actions: [ 54 | IconButton( 55 | onPressed: () { 56 | showSettingDialog(context); 57 | }, 58 | icon: const Icon(Icons.settings), 59 | tooltip: "设置", 60 | ), 61 | IconButton( 62 | onPressed: () { 63 | showInfoDialog(context); 64 | }, 65 | icon: const Icon(Icons.info_outline_rounded), 66 | tooltip: "关于", 67 | ) 68 | ], 69 | ), 70 | body: _getBodyWidget()); 71 | } 72 | 73 | Widget _getBodyWidget() { 74 | if (!Platform.isAndroid && !Platform.isIOS) { 75 | return Row(children: [ 76 | Expanded( 77 | child: WidgetUtils.getListView( 78 | imageList, videoDescList, urlDownloadList), 79 | ), 80 | Expanded( 81 | child: Padding( 82 | padding: const EdgeInsets.all(20), 83 | child: Container( 84 | child: _getBehaviorWidget(), 85 | ), 86 | )), 87 | ]); 88 | } else { 89 | return Column(children: [ 90 | Expanded( 91 | flex: 3, 92 | child: Padding( 93 | padding: const EdgeInsets.all(20), 94 | child: Container( 95 | child: _getBehaviorWidget(), 96 | ), 97 | )), 98 | ]); 99 | } 100 | } 101 | 102 | final TextEditingController _logTextController = TextEditingController(); 103 | final ScrollController _scrollController = ScrollController(); 104 | 105 | final TextEditingController _maxCursorTextController = 106 | TextEditingController(text: "0"); 107 | final TextEditingController _shareUrlTextController = TextEditingController(); 108 | 109 | String globalUrl = ""; //全局url,为了验证当前url是否改变 110 | 111 | void mobileRequestPerm() async { 112 | if (Platform.isAndroid || Platform.isIOS) { 113 | var status = await Permission.storage.status; 114 | if (status.isDenied) { 115 | Map statuses = await [ 116 | Permission.storage, 117 | ].request(); 118 | PermissionStatus status = statuses[Permission.storage]!; 119 | if (status.isDenied) { 120 | showLog("存储权限被拒绝,请授予该权限"); 121 | } 122 | } 123 | } 124 | } 125 | 126 | Widget _getBehaviorWidget() { 127 | return Column( 128 | //mainAxisSize: MainAxisSize.min, 129 | children: [ 130 | DropdownButton( 131 | isExpanded: true, 132 | value: currentShortVideoDownloadType, 133 | onChanged: (String? newValue) { 134 | setState(() { 135 | currentShortVideoDownloadType = newValue!; 136 | }); 137 | }, 138 | items: shortVideoDownloadDdmi, 139 | ), 140 | const SizedBox( 141 | height: 20, 142 | ), 143 | TextField( 144 | controller: _shareUrlTextController, 145 | keyboardType: TextInputType.multiline, 146 | maxLines: 1, 147 | // 长按输入的文本, 设置是否显示剪切,复制,粘贴按钮, 默认是显示的 148 | enableInteractiveSelection: true, 149 | style: const TextStyle(fontSize: 16), 150 | decoration: InputDecoration( 151 | labelText: "分享的地址", 152 | border: OutlineInputBorder( 153 | borderRadius: BorderRadius.circular(5.0), 154 | borderSide: const BorderSide()), 155 | ), 156 | onChanged: (value) { 157 | setState(() { 158 | _maxCursorTextController.text = "0"; 159 | }); 160 | }, 161 | ), 162 | const SizedBox( 163 | height: 20, 164 | ), 165 | TextField( 166 | controller: _maxCursorTextController, 167 | keyboardType: TextInputType.multiline, 168 | maxLines: 1, 169 | // 长按输入的文本, 设置是否显示剪切,复制,粘贴按钮, 默认是显示的 170 | enableInteractiveSelection: true, 171 | style: const TextStyle(fontSize: 16), 172 | decoration: InputDecoration( 173 | labelText: "max_cursor", 174 | border: OutlineInputBorder( 175 | borderRadius: BorderRadius.circular(5.0), 176 | borderSide: const BorderSide()), 177 | ), 178 | ), 179 | const SizedBox( 180 | height: 10, 181 | ), 182 | Row(children: [ 183 | Expanded( 184 | child: TextButton( 185 | onPressed: () async { 186 | mobileRequestPerm(); //移动端去请求权限 187 | 188 | String shareUrlText = _shareUrlTextController.text; 189 | if (Constants.BASE_URL.isEmpty) { 190 | showLog("BASE_URL不能为空,请先在设置里面去配置"); 191 | return; 192 | } 193 | if (shareUrlText.isEmpty) { 194 | showLog("分享的地址不能为空"); 195 | return; 196 | } 197 | 198 | //创建douyin和tiktok的目录 199 | String folderTiktok = Constants.CACHE_PATH + 200 | Platform.pathSeparator + 201 | ShortVideoUtil.TIK_TOK; 202 | String folderDouYin = Constants.CACHE_PATH + 203 | Platform.pathSeparator + 204 | ShortVideoUtil.DOU_YIN; 205 | if (!Directory(folderDouYin).existsSync()) { 206 | Directory(folderDouYin).create(); 207 | } 208 | if (!Directory(folderTiktok).existsSync()) { 209 | Directory(folderTiktok).create(); 210 | } 211 | 212 | if (currentShortVideoDownloadType == 213 | shortVideoDownloadType[0]) { 214 | //单个视频 215 | String requestUrl = 216 | ShortVideoUtil.getRequestUrl(0, shareUrlText); 217 | globalUrl = shareUrlText; 218 | if (requestUrl.isEmpty) { 219 | showLog("解析URL失败,请重新复制"); 220 | return; 221 | } 222 | if (requestUrl.contains("tiktok")) { 223 | String awemeId = 224 | requestUrl.split("video/")[1].split('?')[0]; 225 | String tiktokBaseUrl = 226 | "https://api.tiktokv.com/aweme/v1/aweme/detail/?aweme_id=$awemeId"; 227 | print(tiktokBaseUrl); 228 | Response response = await DioUtils.getDioProxy() 229 | .get(tiktokBaseUrl) 230 | .catchError((e) { 231 | showLog("请求异常:$e"); 232 | }); 233 | setState(() { 234 | imageList.clear(); 235 | urlDownloadList.clear(); 236 | videoDescList.clear(); 237 | if (response.data['status_code'] == 0) { 238 | /** 239 | video_url = json_response["aweme_detail"]["video"]["play_addr"]["url_list"][0] 240 | origin_cover_imager_url = json_response['aweme_detail']['video']['dynamic_cover']['url_list'][0] 241 | video_desc = json_response['aweme_detail']['desc'].replace(' ', '') 242 | */ 243 | videoDescList.add(folderTiktok + 244 | Platform.pathSeparator + 245 | FileUtils.replaceFileName(response 246 | .data['aweme_detail']['desc'] 247 | .replaceAll(' ', ''))); 248 | urlDownloadList.add(response.data["aweme_detail"] 249 | ["video"]["play_addr"]["url_list"][0]); 250 | imageList.add(response.data['aweme_detail']['video'] 251 | ['dynamic_cover']['url_list'][0]); 252 | showLog("获取视频地址成功"); 253 | } else { 254 | showLog("获取视频地址失败:${response.data['status_code']}"); 255 | } 256 | }); 257 | } else { 258 | Response result = await DioUtils.getDio() 259 | .get(requestUrl) 260 | .catchError((e) { 261 | showLog("请求异常:$e"); 262 | }); 263 | setState(() { 264 | imageList.clear(); 265 | urlDownloadList.clear(); 266 | videoDescList.clear(); 267 | if (result.data.toString().contains("200")) { 268 | //解析图片信息 269 | if (result.data 270 | .toString() 271 | .contains('image_url_list')) { 272 | DouYinSingleImages singleImages = 273 | DouYinSingleImages.fromJson(result.data); 274 | for (int i = 0; 275 | i < singleImages.coverImageUrlList.length; 276 | i++) { 277 | videoDescList.add(folderDouYin + 278 | Platform.pathSeparator + 279 | FileUtils.replaceFileName( 280 | '${singleImages.desc}_$i.jpeg')); 281 | urlDownloadList 282 | .add(singleImages.coverImageUrlList[i]); 283 | imageList 284 | .add(singleImages.coverImageUrlList[i]); 285 | showLog("获取图片地址成功"); 286 | } 287 | return; 288 | } 289 | //单个视频信息 290 | DouYinSingle single = 291 | DouYinSingle.fromJson(result.data); 292 | videoDescList.add(folderDouYin + 293 | Platform.pathSeparator + 294 | FileUtils.replaceFileName(single.videoDesc!)); 295 | urlDownloadList.add(single.videoUrl!); 296 | imageList.add(single.coverImageUrl!); 297 | showLog("获取视频地址成功"); 298 | } else { 299 | showLog("获取视频地址失败:${result.data.toString()}"); 300 | } 301 | }); 302 | } 303 | } else if (currentShortVideoDownloadType == 304 | shortVideoDownloadType[1]) { 305 | String maxCursor = _maxCursorTextController.text; 306 | if (maxCursor.isEmpty) { 307 | showLog("max_cursor不能为空"); 308 | return; 309 | } 310 | String requestUrl = ShortVideoUtil.getRequestUrl( 311 | 1, shareUrlText, 312 | maxCursor: maxCursor); 313 | if (requestUrl.isEmpty) { 314 | showLog("解析URL失败,请重新复制"); 315 | return; 316 | } 317 | Response result = await DioUtils.getDio() 318 | .get(requestUrl) 319 | .catchError((e) { 320 | showLog("请求异常:$e"); 321 | }); 322 | setState(() { 323 | if (globalUrl != shareUrlText) { 324 | imageList.clear(); 325 | urlDownloadList.clear(); 326 | videoDescList.clear(); 327 | } 328 | globalUrl = shareUrlText; 329 | if (result.data.toString().contains("200")) { 330 | DouYinList list = DouYinList.fromJson(result.data); 331 | if (list.videoUrlList.isNotEmpty) { 332 | String secUid = list.secUid!; 333 | String folderDouYinSecUid = 334 | folderDouYin + Platform.pathSeparator + secUid; 335 | 336 | //创建对呀secuid的目录 337 | if (!Directory(folderDouYinSecUid).existsSync()) { 338 | Directory(folderDouYinSecUid).create(); 339 | } 340 | _maxCursorTextController.text = 341 | list.maxCursor.toString(); 342 | for (int i = 0; 343 | i < list.coverImageUrlList.length; 344 | i++) { 345 | videoDescList.add(folderDouYinSecUid + 346 | Platform.pathSeparator + 347 | FileUtils.replaceFileName( 348 | list.videoDescList[i])); 349 | urlDownloadList.add(list.videoUrlList[i]); 350 | imageList.add(list.coverImageUrlList[i]); 351 | } 352 | showLog("获取视频地址成功,目前${urlDownloadList.length}个视频"); 353 | } 354 | if (list.hasMore!) { 355 | showLog("有更多数据,可以继续添加列表"); 356 | } else { 357 | showLog("已经没有更多数据啦~"); 358 | } 359 | } else { 360 | showLog("获取视频地址失败:${result.data.toString()}"); 361 | } 362 | }); 363 | } 364 | }, 365 | child: const Text("获取下载地址"))), 366 | Expanded( 367 | child: TextButton( 368 | onPressed: () async { 369 | if (!isFinish) { 370 | showDownloadDialog(context); 371 | return; 372 | } 373 | if (Constants.CACHE_PATH.isEmpty) { 374 | showLog("缓存地址为空,请先去设置进行配置"); 375 | return; 376 | } 377 | if (urlDownloadList.isEmpty) { 378 | showLog("请先获取视频地址"); 379 | return; 380 | } 381 | if (Platform.isAndroid || Platform.isIOS) { 382 | Navigator.push(context, 383 | MaterialPageRoute(builder: (context) { 384 | return DownloadPage( 385 | imageList, urlDownloadList, videoDescList); 386 | })); 387 | return; 388 | } 389 | for (int i = 0; i < urlDownloadList.length; i++) { 390 | isFinish = false; 391 | if (videoDescList[i].toString().endsWith('jpeg')) { 392 | if (File(videoDescList[i]).existsSync()) { 393 | showLog( 394 | "一共${urlDownloadList.length}个图片:第${i + 1}个图片已存在,跳过"); 395 | if (i == urlDownloadList.length - 1) { 396 | isFinish = true; 397 | } 398 | continue; 399 | } 400 | await DioUtils.getDio() 401 | .download(urlDownloadList[i], videoDescList[i], 402 | onReceiveProgress: (int count, int total) { 403 | showLog( 404 | "一共${urlDownloadList.length}个图片:\n正在下载第${i + 1}个图片:${(count / total * 100).toInt()}%", 405 | isAppend: false); 406 | if (i == urlDownloadList.length - 1 && 407 | count == total) { 408 | showLog("所有图片下载完成"); 409 | isFinish = true; 410 | } 411 | }).catchError((e) { 412 | showLog("出现异常:${e.toString()}"); 413 | isFinish = true; 414 | }); 415 | } else { 416 | String end = 417 | urlDownloadList[i].toString().endsWith("mp3") 418 | ? "mp3" 419 | : "mp4"; 420 | String filePath = "${videoDescList[i]}.$end"; 421 | if (File(filePath).existsSync()) { 422 | showLog( 423 | "一共${urlDownloadList.length}个视频:第${i + 1}个视频已存在,跳过"); 424 | if (i == urlDownloadList.length - 1) { 425 | isFinish = true; 426 | } 427 | continue; 428 | } 429 | await DioUtils.getDio() 430 | .download(urlDownloadList[i], filePath, 431 | onReceiveProgress: (int count, int total) { 432 | showLog( 433 | "一共${urlDownloadList.length}个视频:\n正在下载第${i + 1}个视频:${(count / total * 100).toInt()}%", 434 | isAppend: false); 435 | if (i == urlDownloadList.length - 1 && 436 | count == total) { 437 | showLog("所有视频下载完成"); 438 | isFinish = true; 439 | } 440 | }).catchError((e) { 441 | showLog("出现异常:${e.toString()}"); 442 | isFinish = true; 443 | }); 444 | } 445 | } 446 | }, 447 | child: const Text("下载视频"))), 448 | Expanded( 449 | child: TextButton( 450 | onPressed: () { 451 | _logTextController.text = ""; 452 | showLogText = ""; 453 | }, 454 | child: const Text("清除日志"))) 455 | ]), 456 | Expanded( 457 | child: 458 | WidgetUtils.getLogWidget(_scrollController, _logTextController)) 459 | ], 460 | ); 461 | } 462 | 463 | bool isFinish = true; 464 | 465 | String showLogText = ""; 466 | 467 | void showLog(String msg, {bool isAppend = true}) { 468 | if (msg.isEmpty) { 469 | return; 470 | } 471 | if (!isAppend) { 472 | showLogText = ""; 473 | _logTextController.text = "${msg.trim()}\n"; 474 | return; 475 | } 476 | if (showLogText.isEmpty) { 477 | showLogText = ">>>>>>>$showLogText${msg.trim()}"; 478 | } else { 479 | showLogText = "$showLogText\n>>>>>>>${msg.trim()}"; 480 | } 481 | _logTextController.text = showLogText; 482 | Future.delayed(const Duration(milliseconds: 200), () { 483 | _scrollController.animateTo( 484 | _scrollController.position.maxScrollExtent, //滚动到底部 485 | //滚动到底部 486 | duration: const Duration(milliseconds: 300), 487 | curve: Curves.easeOut, 488 | ); 489 | //FocusScope.of(leftPanelState.context).requestFocus(leftPanelFocus); 490 | }); 491 | } 492 | 493 | TextEditingController downLoadUrlController = TextEditingController(); 494 | 495 | var shortVideoDownloadType = ["单个", "多个"]; 496 | List> shortVideoDownloadDdmi = []; 497 | var currentShortVideoDownloadType = ''; 498 | 499 | //初始化短视频下载类型 500 | _initShortVideoDownloadType() { 501 | for (var element in shortVideoDownloadType) { 502 | shortVideoDownloadDdmi.add(DropdownMenuItem( 503 | value: element, 504 | child: Text( 505 | element, 506 | // style: _dropDownTextStyle(), 507 | ))); 508 | } 509 | currentShortVideoDownloadType = shortVideoDownloadType[0]; 510 | return shortVideoDownloadDdmi; 511 | } 512 | } 513 | -------------------------------------------------------------------------------- /lib/pages/mobile/download_page.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:image_gallery_saver/image_gallery_saver.dart'; 5 | import 'package:short_video_spider_client/config/constants.dart'; 6 | import 'package:short_video_spider_client/utils/dio_util.dart'; 7 | import 'package:short_video_spider_client/utils/widget_util.dart'; 8 | 9 | import '../../utils/toast_util.dart'; 10 | import '../widget/dialog/dialog.dart'; 11 | 12 | var imageList = []; 13 | var urlDownloadList = []; 14 | var videoDescList = []; 15 | 16 | class DownloadPage extends StatefulWidget { 17 | DownloadPage(var imageListD, var urlDownloadListD, var videoDescListD, 18 | {Key? key}) 19 | : super(key: key) { 20 | imageList = imageListD; 21 | urlDownloadList = urlDownloadListD; 22 | videoDescList = videoDescListD; 23 | } 24 | 25 | @override 26 | State createState() { 27 | return DownloadPageState(); 28 | } 29 | } 30 | 31 | class DownloadPageState extends State { 32 | @override 33 | Widget build(BuildContext context) { 34 | return WillPopScope( 35 | //必须放在状态可变的组件下面 36 | onWillPop: () async { 37 | if (!isFinish) { 38 | ToastUtils.showToast("当前下载未完成,请等待下载完成"); 39 | return false; 40 | } 41 | Navigator.pop(context); 42 | return true; 43 | }, 44 | child: Scaffold( 45 | appBar: AppBar( 46 | automaticallyImplyLeading: false, 47 | leading: IconButton( 48 | onPressed: () { 49 | if (!isFinish) { 50 | ToastUtils.showToast("当前下载未完成,请等待下载完成"); 51 | return; 52 | } 53 | Navigator.pop(context); 54 | }, 55 | icon: const Icon(Icons.arrow_back)), 56 | ), 57 | body: _getBodyWidget(context), 58 | ), 59 | ); 60 | } 61 | 62 | @override 63 | void initState() { 64 | super.initState(); 65 | } 66 | 67 | @override 68 | void dispose() { 69 | super.dispose(); 70 | _logDownloadTextController.text = ""; 71 | showLogTextD = ""; 72 | } 73 | } 74 | 75 | bool isFinish = true; 76 | 77 | final TextEditingController _logDownloadTextController = 78 | TextEditingController(); 79 | final ScrollController _scrollDownloadController = ScrollController(); 80 | String showLogTextD = ""; 81 | 82 | void showLog(String msg, {bool isAppend = true}) { 83 | if (msg.isEmpty) { 84 | return; 85 | } 86 | if (!isAppend) { 87 | _logDownloadTextController.text = "${msg.trim()}\n"; 88 | return; 89 | } 90 | if (showLogTextD.isEmpty) { 91 | showLogTextD = ">>>>>>>$showLogTextD${msg.trim()}"; 92 | } else { 93 | showLogTextD = "$showLogTextD\n>>>>>>>${msg.trim()}"; 94 | } 95 | _logDownloadTextController.text = showLogTextD; 96 | Future.delayed(const Duration(milliseconds: 200), () { 97 | _scrollDownloadController.animateTo( 98 | _scrollDownloadController.position.maxScrollExtent, //滚动到底部 99 | //滚动到底部 100 | duration: const Duration(milliseconds: 300), 101 | curve: Curves.easeOut, 102 | ); 103 | //FocusScope.of(leftPanelState.context).requestFocus(leftPanelFocus); 104 | }); 105 | } 106 | 107 | Widget _getBodyWidget(BuildContext context) { 108 | return Column(children: [ 109 | Expanded( 110 | flex: 2, 111 | child: Padding( 112 | padding: const EdgeInsets.all(10), 113 | child: Container( 114 | child: WidgetUtils.getListView( 115 | imageList, videoDescList, urlDownloadList), 116 | ), 117 | )), 118 | TextButton( 119 | onPressed: () async { 120 | if (!isFinish) { 121 | showDownloadDialog(context); 122 | return; 123 | } 124 | for (int i = 0; i < urlDownloadList.length; i++) { 125 | isFinish = false; 126 | if (videoDescList[i].toString().endsWith('jpeg')) { 127 | if (File(videoDescList[i]).existsSync()) { 128 | showLog("一共${urlDownloadList.length}个图片:第${i + 1}个图片已存在,跳过"); 129 | if (i == urlDownloadList.length - 1) { 130 | isFinish = true; 131 | } 132 | continue; 133 | } 134 | await DioUtils.getDio() 135 | .download(urlDownloadList[i], videoDescList[i], 136 | onReceiveProgress: (int count, int total) { 137 | showLog( 138 | "一共${urlDownloadList.length}个图片:\n正在下载第${i + 1}个图片:${(count / total * 100).toInt()}%", 139 | isAppend: false); 140 | if (i == urlDownloadList.length - 1 && count == total) { 141 | showLog("所有图片下载完成"); 142 | isFinish = true; 143 | } 144 | }).catchError((e) { 145 | showLog("出现异常:${e.toString()}"); 146 | isFinish = true; 147 | }); 148 | final result = 149 | await ImageGallerySaver.saveFile(videoDescList[i]); //保存到相册里面去 150 | print(result); 151 | } else { 152 | String end = 153 | urlDownloadList[i].toString().endsWith("mp3") ? "mp3" : "mp4"; 154 | String filePath = Constants.CACHE_PATH + 155 | Platform.pathSeparator + 156 | videoDescList[i]; 157 | //安卓文件路径有限制,大约127个字符 158 | //参考:https://stackoverflow.com/questions/13204807/max-file-name-length-in-android 159 | if (filePath.length > 120) { 160 | filePath = "${filePath.substring(0, 120)}.$end"; 161 | } else { 162 | filePath = "$filePath.$end"; 163 | } 164 | if (File(filePath).existsSync()) { 165 | showLog("一共${urlDownloadList.length}个视频:第${i + 1}个视频已存在,跳过"); 166 | if (i == urlDownloadList.length - 1) { 167 | isFinish = true; 168 | } 169 | continue; 170 | } 171 | await DioUtils.getDio().download(urlDownloadList[i], filePath, 172 | onReceiveProgress: (int count, int total) { 173 | isFinish = false; 174 | showLog( 175 | "一共${urlDownloadList.length}个视频:\n正在下载第${i + 1}个视频:${(count / total * 100).toInt()}%", 176 | isAppend: false); 177 | if (i == urlDownloadList.length - 1) { 178 | isFinish = true; 179 | showLog("所有视频下载完成", isAppend: false); 180 | } 181 | }).catchError((e) { 182 | isFinish = true; 183 | showLog("出现异常:${e.toString()}"); 184 | }); 185 | final result = 186 | await ImageGallerySaver.saveFile(filePath); //保存到相册里面去 187 | print(result); 188 | } 189 | } 190 | }, 191 | child: const Text("开始下载")), 192 | Expanded( 193 | flex: 1, 194 | child: Padding( 195 | padding: const EdgeInsets.only(left: 20, right: 20, bottom: 5), 196 | child: WidgetUtils.getLogWidget( 197 | _scrollDownloadController, _logDownloadTextController), 198 | )), 199 | ]); 200 | } 201 | -------------------------------------------------------------------------------- /lib/pages/widget/copy_text.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class CopyText extends SelectableText { 4 | const CopyText( 5 | String text, { 6 | Key? key, 7 | }) : super(text, 8 | key: key, 9 | toolbarOptions: const ToolbarOptions( 10 | copy: true, paste: false, cut: false, selectAll: true)); 11 | } 12 | -------------------------------------------------------------------------------- /lib/pages/widget/dialog/dialog.dart: -------------------------------------------------------------------------------- 1 | import 'package:file_picker/file_picker.dart'; 2 | import 'package:flutter/gestures.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:url_launcher/url_launcher.dart'; 5 | 6 | import '../../../config/constants.dart'; 7 | import '../../../utils/screen_util.dart'; 8 | import '../../../utils/sp_util.dart'; 9 | 10 | void showDownloadDialog(BuildContext context) { 11 | showDialog( 12 | barrierDismissible: false, //表示点击灰色背景的时候是否消失弹出框 13 | context: context, 14 | builder: (context) { 15 | return AlertDialog( 16 | title: const Text("下载"), 17 | content: const Text("当前正在下载,请等待下载完成。"), 18 | actions: [ 19 | TextButton( 20 | child: const Text("确定"), 21 | onPressed: () { 22 | Navigator.pop(context); 23 | }, 24 | ) 25 | ], 26 | ); 27 | }); 28 | } 29 | 30 | Future _launchUrl(Uri uri) async { 31 | if (!await launchUrl(uri)) { 32 | print("链接无法跳转"); 33 | } 34 | } 35 | 36 | showInfoDialog(BuildContext context) { 37 | showDialog( 38 | context: context, 39 | barrierDismissible: false, 40 | builder: (context) { 41 | return UnconstrainedBox( 42 | //在Dialog的外层添加一层UnconstrainedBox 43 | //constrainedAxis: Axis.vertical, 44 | child: SizedBox( 45 | //再用SizeBox指定宽度new Dialog( 46 | child: AlertDialog( 47 | scrollable: true, 48 | actions: [ 49 | TextButton( 50 | child: const Text('确定'), 51 | onPressed: () { 52 | Navigator.pop(context); 53 | }, 54 | ) 55 | ], 56 | title: const Text("关于", style: TextStyle(fontSize: 20)), 57 | content: SizedBox( 58 | width: 0.5 * ScreenUtils.width, 59 | height: 0.3 * ScreenUtils.height, 60 | child: Column( 61 | children: [ 62 | Row( 63 | mainAxisAlignment: MainAxisAlignment.center, 64 | children: [ 65 | Text("当前版本:${Constants.APP_VERSION}"), 66 | ], 67 | ), 68 | const SizedBox( 69 | height: 10, 70 | ), 71 | Row( 72 | mainAxisAlignment: MainAxisAlignment.start, 73 | children: [ 74 | Expanded( 75 | child: RichText( 76 | text: TextSpan( 77 | children: [ 78 | const TextSpan( 79 | text: '客户端地址: ', 80 | style: TextStyle(color: Colors.black), 81 | ), 82 | TextSpan( 83 | text: 84 | '\nhttps://github.com/LuckyLi706/short_video_spider_client', 85 | style: const TextStyle(color: Colors.blue), 86 | recognizer: TapGestureRecognizer() 87 | ..onTap = () { 88 | _launchUrl(Uri.parse( 89 | "https://github.com/LuckyLi706/short_video_spider_client")); 90 | }, 91 | ), 92 | ], 93 | ), 94 | )), 95 | ], 96 | ), 97 | const SizedBox( 98 | height: 10, 99 | ), 100 | Row( 101 | mainAxisAlignment: MainAxisAlignment.center, 102 | children: [ 103 | Expanded( 104 | child: RichText( 105 | text: TextSpan( 106 | children: [ 107 | const TextSpan( 108 | text: '服务端地址: ', 109 | style: TextStyle(color: Colors.black), 110 | ), 111 | TextSpan( 112 | text: 113 | '\nhttps://github.com/LuckyLi706/ShortVideoSpider', 114 | style: const TextStyle(color: Colors.blue), 115 | recognizer: TapGestureRecognizer() 116 | ..onTap = () { 117 | _launchUrl(Uri.parse( 118 | "https://github.com/LuckyLi706/ShortVideoSpider")); 119 | }, 120 | ), 121 | ], 122 | ), 123 | )), 124 | ], 125 | ), 126 | ], 127 | )), 128 | ), 129 | ), 130 | ); 131 | }); 132 | } 133 | 134 | TextEditingController cacheController = TextEditingController(); 135 | TextEditingController urlController = TextEditingController(); 136 | TextEditingController proxyController = TextEditingController(); 137 | 138 | void showSettingDialog(BuildContext context) async { 139 | cacheController.text = await SpUtil.getCachePath() ?? ''; 140 | urlController.text = await SpUtil.getBaseUrl() ?? ''; 141 | proxyController.text = await SpUtil.getProxyUrl() ?? ''; 142 | showDialog( 143 | context: context, 144 | barrierDismissible: false, 145 | builder: (context) { 146 | return UnconstrainedBox( 147 | //在Dialog的外层添加一层UnconstrainedBox 148 | //constrainedAxis: Axis.vertical, 149 | child: SizedBox( 150 | //再用SizeBox指定宽度new Dialog( 151 | child: AlertDialog( 152 | scrollable: true, 153 | actions: [ 154 | TextButton( 155 | child: const Text('取消'), 156 | onPressed: () { 157 | Navigator.of(context).pop(); 158 | }, 159 | ), 160 | TextButton( 161 | child: const Text('确定'), 162 | onPressed: () { 163 | if (urlController.text.isNotEmpty) { 164 | SpUtil.updateBaseUrl(urlController.text); 165 | Constants.BASE_URL = urlController.text; 166 | } 167 | if (cacheController.text.isNotEmpty) { 168 | SpUtil.updateCachePath(cacheController.text); 169 | Constants.CACHE_PATH = cacheController.text; 170 | } 171 | if(proxyController.text.isNotEmpty){ 172 | SpUtil.updateProxyUrl(proxyController.text); 173 | Constants.PROXY_URL = proxyController.text; 174 | } 175 | Navigator.of(context).pop(); 176 | }, 177 | ) 178 | ], 179 | title: const Text("设置", style: TextStyle(fontSize: 20)), 180 | content: Center( 181 | child: SizedBox( 182 | width: 0.5 * ScreenUtils.width, 183 | height: 0.45 * ScreenUtils.height, 184 | child: Column( 185 | children: [ 186 | Row( 187 | children: [ 188 | TextButton( 189 | onPressed: () async { 190 | String? selectedDirectory = await FilePicker 191 | .platform 192 | .getDirectoryPath(); 193 | if (selectedDirectory == null) { 194 | } else { 195 | cacheController.text = selectedDirectory; 196 | } 197 | }, 198 | child: const Text("手动选择存储目录")), 199 | ], 200 | ), 201 | const SizedBox( 202 | height: 10, 203 | ), 204 | Row( 205 | mainAxisAlignment: MainAxisAlignment.center, 206 | crossAxisAlignment: CrossAxisAlignment.center, 207 | children: [ 208 | Expanded( 209 | child: TextField( 210 | controller: cacheController, 211 | maxLines: 1, 212 | enableInteractiveSelection: true, 213 | decoration: const InputDecoration( 214 | labelText: 'CACHE_PATH', 215 | border: OutlineInputBorder( 216 | borderSide: BorderSide( 217 | color: Colors.pink, 218 | ), 219 | ), 220 | ), 221 | )), 222 | ], 223 | ), 224 | const SizedBox( 225 | height: 20, 226 | ), 227 | Row( 228 | mainAxisAlignment: MainAxisAlignment.center, 229 | crossAxisAlignment: CrossAxisAlignment.center, 230 | children: [ 231 | Expanded( 232 | child: TextField( 233 | controller: urlController, 234 | maxLines: 1, 235 | enableInteractiveSelection: true, 236 | decoration: const InputDecoration( 237 | enabled: true, 238 | labelText: 'BASE_URL', 239 | // 长按输入的文本, 设置是否显示剪切,复制,粘贴按钮, 默认是显示的 240 | border: OutlineInputBorder( 241 | borderSide: BorderSide( 242 | color: Colors.pink, 243 | ), 244 | ), 245 | ), 246 | )), 247 | ], 248 | ), 249 | const SizedBox( 250 | height: 20, 251 | ), 252 | Row( 253 | mainAxisAlignment: MainAxisAlignment.center, 254 | crossAxisAlignment: CrossAxisAlignment.center, 255 | children: [ 256 | Expanded( 257 | child: TextField( 258 | controller: proxyController, 259 | maxLines: 1, 260 | enableInteractiveSelection: true, 261 | decoration: const InputDecoration( 262 | enabled: true, 263 | labelText: '代理服务器(ip:port)', 264 | // 长按输入的文本, 设置是否显示剪切,复制,粘贴按钮, 默认是显示的 265 | border: OutlineInputBorder( 266 | borderSide: BorderSide( 267 | color: Colors.pink, 268 | ), 269 | ), 270 | ), 271 | )), 272 | ], 273 | ), 274 | ], 275 | ))), 276 | ), 277 | ), 278 | ); 279 | }); 280 | } 281 | -------------------------------------------------------------------------------- /lib/utils/dio_util.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | import 'package:dio/adapter.dart'; 3 | import 'package:short_video_spider_client/config/constants.dart'; 4 | 5 | class DioUtils { 6 | static Dio? dio; 7 | static Dio? dioProxy; 8 | 9 | static String proxyUrl = ""; 10 | 11 | static Dio getDio() { 12 | dio ??= Dio(BaseOptions(headers: { 13 | "user-agent": 14 | "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36" 15 | }, connectTimeout: 5000, sendTimeout: 5000)); 16 | return dio!; 17 | } 18 | 19 | static Dio getDioProxy() { 20 | dioProxy = Dio(BaseOptions(headers: { 21 | "user-agent": 22 | "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36" 23 | }, connectTimeout: 5000, sendTimeout: 5000)); 24 | 25 | (dioProxy?.httpClientAdapter as DefaultHttpClientAdapter) 26 | .onHttpClientCreate = (client) { 27 | // config the http client 28 | client.findProxy = (uri) { 29 | //proxy all request to localhost:8888 30 | return 'PROXY ${Constants.PROXY_URL}'; 31 | }; 32 | // you can also create a new HttpClient to dio 33 | // return HttpClient(); 34 | }; 35 | return dioProxy!; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /lib/utils/file_util.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:path_provider/path_provider.dart'; 4 | 5 | class FileUtils { 6 | static Future getFileDirectory() async { 7 | if (Platform.isAndroid) { 8 | //存储位置/storage/emulated/0/Android/data/myapp.name/files 9 | Directory? dir = await getExternalStorageDirectory(); 10 | return dir!.path; 11 | } else if (Platform.isIOS) { 12 | Directory? dir = await getTemporaryDirectory(); 13 | return dir.path; 14 | } else { 15 | Directory dir = await getApplicationDocumentsDirectory(); 16 | return dir.path; 17 | } 18 | } 19 | 20 | static String replaceFileName(String text) { 21 | return text 22 | .replaceAll("\n", "") 23 | .replaceAll("?", "") 24 | .replaceAll(">", "") 25 | .replaceAll(" ", "") 26 | .replaceAll("\\", "") 27 | .replaceAll("\\", "") 28 | .replaceAll("*", "") 29 | .replaceAll(":", "") 30 | .replaceAll("<", "") 31 | .replaceAll("|", "") 32 | .replaceAll(",", "") 33 | .replaceAll("\"", ""); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/utils/keyboard_util.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | 3 | class KeyboardUtils{ 4 | 5 | 6 | ///隐藏软键盘 7 | ///[context] 上下文 8 | static hideKeyboard(BuildContext context) { 9 | FocusScopeNode currentFocus = FocusScope.of(context); 10 | if (!currentFocus.hasPrimaryFocus && currentFocus.focusedChild != null) { 11 | FocusManager.instance.primaryFocus?.unfocus(); 12 | } 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /lib/utils/screen_util.dart: -------------------------------------------------------------------------------- 1 | class ScreenUtils { 2 | static double width = 0.0; 3 | static double height = 0.0; 4 | } 5 | -------------------------------------------------------------------------------- /lib/utils/short_video_util.dart: -------------------------------------------------------------------------------- 1 | import '../config/constants.dart'; 2 | 3 | class ShortVideoUtil { 4 | static String _analyseUrl(String url) { 5 | if (url.contains(DOU_YIN)) { 6 | List text = url.split(" "); 7 | for (var element in text) { 8 | if (element.startsWith("http") && element.contains("douyin")) { 9 | url = element; 10 | break; 11 | } 12 | } 13 | } 14 | return url; 15 | } 16 | 17 | static const String DOU_YIN = "douyin"; 18 | static const String TIK_TOK = "tiktok"; 19 | 20 | // @status 0表示单个,1表示多个 21 | static String getRequestUrl(int status, String url, {String maxCursor = ""}) { 22 | String realUrl = _analyseUrl(url); 23 | if (realUrl.isEmpty) { 24 | return ""; 25 | } 26 | if (status == 0) { 27 | if (url.contains(DOU_YIN)) { 28 | return "${Constants.BASE_URL}/douyin/single?url=$realUrl"; 29 | } else if (url.contains(TIK_TOK)) { 30 | return "${Constants.BASE_URL}/tiktok/single?url=$realUrl"; 31 | } 32 | return ""; 33 | } else { 34 | if (url.contains(DOU_YIN)) { 35 | return "${Constants.BASE_URL}/douyin/list?url=$realUrl&max_cursor=$maxCursor"; 36 | } 37 | return ""; 38 | } 39 | } 40 | } 41 | 42 | // enum ShortVideo{ 43 | // 44 | // } 45 | -------------------------------------------------------------------------------- /lib/utils/sp_util.dart: -------------------------------------------------------------------------------- 1 | import 'package:shared_preferences/shared_preferences.dart'; 2 | 3 | import '../config/constants.dart'; 4 | 5 | /// @description :键值对存储 6 | class SpUtil { 7 | static updateBaseUrl(String baseUrl) async { 8 | SharedPreferences prefs = await SharedPreferences.getInstance(); 9 | prefs.remove(Constants.SP_KEY_BASE_URL); 10 | prefs.setString(Constants.SP_KEY_BASE_URL, baseUrl); 11 | } 12 | 13 | static Future getBaseUrl() async { 14 | SharedPreferences prefs = await SharedPreferences.getInstance(); 15 | var baseUrl = prefs.getString(Constants.SP_KEY_BASE_URL); 16 | return baseUrl; 17 | } 18 | 19 | static updateProxyUrl(String baseUrl) async { 20 | SharedPreferences prefs = await SharedPreferences.getInstance(); 21 | prefs.remove(Constants.SP_KEY_PROXY_URL); 22 | prefs.setString(Constants.SP_KEY_PROXY_URL, baseUrl); 23 | } 24 | 25 | static Future getProxyUrl() async { 26 | SharedPreferences prefs = await SharedPreferences.getInstance(); 27 | var baseUrl = prefs.getString(Constants.SP_KEY_PROXY_URL); 28 | return baseUrl; 29 | } 30 | 31 | static updateCachePath(String cachePath) async { 32 | SharedPreferences prefs = await SharedPreferences.getInstance(); 33 | prefs.remove(Constants.SP_KEY_CACHE_PATH); 34 | prefs.setString(Constants.SP_KEY_CACHE_PATH, cachePath); 35 | } 36 | 37 | static Future getCachePath() async { 38 | SharedPreferences prefs = await SharedPreferences.getInstance(); 39 | String? cachePath = prefs.getString(Constants.SP_KEY_CACHE_PATH); 40 | return cachePath; 41 | } 42 | 43 | static updateAppVersion(String appVersion) async { 44 | SharedPreferences prefs = await SharedPreferences.getInstance(); 45 | prefs.remove(Constants.SP_KEY_APP_VERSION); 46 | prefs.setString(Constants.SP_KEY_APP_VERSION, appVersion); 47 | } 48 | 49 | static Future getAppVersion() async { 50 | SharedPreferences prefs = await SharedPreferences.getInstance(); 51 | String? cachePath = prefs.getString(Constants.SP_KEY_APP_VERSION); 52 | return cachePath; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /lib/utils/toast_util.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:fluttertoast/fluttertoast.dart'; 3 | 4 | class ToastUtils { 5 | static showToast(String message) { 6 | Fluttertoast.showToast( 7 | msg: message, 8 | toastLength: Toast.LENGTH_SHORT, 9 | gravity: ToastGravity.BOTTOM, 10 | timeInSecForIosWeb: 1, 11 | backgroundColor: Colors.white, 12 | textColor: Colors.black, 13 | fontSize: 16.0); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /lib/utils/widget_util.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | import '../config/constants.dart'; 7 | import '../pages/widget/copy_text.dart'; 8 | 9 | class WidgetUtils { 10 | static Widget getListView( 11 | var imageList, var videoDescList, var urlDownloadList) { 12 | return ListView.builder( 13 | itemCount: imageList.length, 14 | //列表项构造器 15 | itemBuilder: (BuildContext context, int index) { 16 | return Card( 17 | elevation: 1.0, 18 | margin: const EdgeInsets.all(10), 19 | child: Column( 20 | crossAxisAlignment: CrossAxisAlignment.start, 21 | children: [ 22 | Padding( 23 | padding: const EdgeInsets.only(left: 10), 24 | child: Text("第${index + 1}个视频")), 25 | Container( 26 | height: 200, 27 | margin: const EdgeInsets.all(10), 28 | child: Image.network( 29 | imageList[index], 30 | fit: BoxFit.cover, 31 | ), 32 | ), 33 | Padding( 34 | padding: const EdgeInsets.only(left: 10), 35 | child: CopyText( 36 | "存储位置:${getCacheText(urlDownloadList, videoDescList, index)}"), 37 | ), 38 | Padding( 39 | padding: const EdgeInsets.only(left: 10), 40 | child: CopyText("文件真实地址:${urlDownloadList[index]}")), 41 | ], 42 | ), 43 | ); 44 | }, 45 | //分割器构造器 46 | ); 47 | } 48 | 49 | static String getCacheText( 50 | var urlDownloadList, var videoDescList, int index) { 51 | if (videoDescList[index].toString().endsWith('jpeg')) { 52 | return "${Constants.CACHE_PATH}${Platform.pathSeparator}${videoDescList[index]}"; 53 | } else { 54 | return "${Constants.CACHE_PATH}${Platform.pathSeparator}${videoDescList[index]}.${urlDownloadList[index].toString().endsWith("mp3") ? "mp3" : "mp4"}"; 55 | } 56 | } 57 | 58 | static Widget getLogWidget(var scrollController, var logTextController) { 59 | return Stack( 60 | alignment: Alignment.topLeft, 61 | //fit: StackFit.expand, //未定位widget占满Stack整个空间 62 | children: [ 63 | Positioned( 64 | top: 20.0, 65 | bottom: 0, 66 | left: 0, 67 | right: 0, 68 | child: TextField( 69 | scrollController: scrollController, 70 | controller: logTextController, 71 | keyboardType: TextInputType.multiline, 72 | maxLines: null, 73 | //不限制行数 74 | autofocus: false, 75 | // 长按输入的文本, 设置是否显示剪切,复制,粘贴按钮, 默认是显示的 76 | enableInteractiveSelection: true, 77 | style: const TextStyle(fontSize: 16), 78 | decoration: InputDecoration( 79 | labelText: "日志信息", 80 | border: OutlineInputBorder( 81 | borderRadius: BorderRadius.circular(5.0), 82 | borderSide: const BorderSide()), 83 | ), 84 | ), 85 | ) 86 | ], 87 | ); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /linux/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.10) 3 | project(runner LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "short_video_spider_client") 8 | # The unique GTK application identifier for this application. See: 9 | # https://wiki.gnome.org/HowDoI/ChooseApplicationID 10 | set(APPLICATION_ID "com.lucky.short_video_spider_client") 11 | 12 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 13 | # versions of CMake. 14 | cmake_policy(SET CMP0063 NEW) 15 | 16 | # Load bundled libraries from the lib/ directory relative to the binary. 17 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 18 | 19 | # Root filesystem for cross-building. 20 | if(FLUTTER_TARGET_PLATFORM_SYSROOT) 21 | set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) 22 | set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) 23 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 24 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 25 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 26 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 27 | endif() 28 | 29 | # Define build configuration options. 30 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 31 | set(CMAKE_BUILD_TYPE "Debug" CACHE 32 | STRING "Flutter build mode" FORCE) 33 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 34 | "Debug" "Profile" "Release") 35 | endif() 36 | 37 | # Compilation settings that should be applied to most targets. 38 | # 39 | # Be cautious about adding new options here, as plugins use this function by 40 | # default. In most cases, you should add new options to specific targets instead 41 | # of modifying this function. 42 | function(APPLY_STANDARD_SETTINGS TARGET) 43 | target_compile_features(${TARGET} PUBLIC cxx_std_14) 44 | target_compile_options(${TARGET} PRIVATE -Wall -Werror) 45 | target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") 46 | target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") 47 | endfunction() 48 | 49 | # Flutter library and tool build rules. 50 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 51 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 52 | 53 | # System-level dependencies. 54 | find_package(PkgConfig REQUIRED) 55 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 56 | 57 | add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") 58 | 59 | # Define the application target. To change its name, change BINARY_NAME above, 60 | # not the value here, or `flutter run` will no longer work. 61 | # 62 | # Any new source files that you add to the application should be added here. 63 | add_executable(${BINARY_NAME} 64 | "main.cc" 65 | "my_application.cc" 66 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 67 | ) 68 | 69 | # Apply the standard set of build settings. This can be removed for applications 70 | # that need different build settings. 71 | apply_standard_settings(${BINARY_NAME}) 72 | 73 | # Add dependency libraries. Add any application-specific dependencies here. 74 | target_link_libraries(${BINARY_NAME} PRIVATE flutter) 75 | target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) 76 | 77 | # Run the Flutter tool portions of the build. This must not be removed. 78 | add_dependencies(${BINARY_NAME} flutter_assemble) 79 | 80 | # Only the install-generated bundle's copy of the executable will launch 81 | # correctly, since the resources must in the right relative locations. To avoid 82 | # people trying to run the unbundled copy, put it in a subdirectory instead of 83 | # the default top-level location. 84 | set_target_properties(${BINARY_NAME} 85 | PROPERTIES 86 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" 87 | ) 88 | 89 | # Generated plugin build rules, which manage building the plugins and adding 90 | # them to the application. 91 | include(flutter/generated_plugins.cmake) 92 | 93 | 94 | # === Installation === 95 | # By default, "installing" just makes a relocatable bundle in the build 96 | # directory. 97 | set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") 98 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 99 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 100 | endif() 101 | 102 | # Start with a clean build bundle directory every time. 103 | install(CODE " 104 | file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") 105 | " COMPONENT Runtime) 106 | 107 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 108 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") 109 | 110 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 111 | COMPONENT Runtime) 112 | 113 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 114 | COMPONENT Runtime) 115 | 116 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 117 | COMPONENT Runtime) 118 | 119 | foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) 120 | install(FILES "${bundled_library}" 121 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 122 | COMPONENT Runtime) 123 | endforeach(bundled_library) 124 | 125 | # Fully re-copy the assets directory on each build to avoid having stale files 126 | # from a previous install. 127 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 128 | install(CODE " 129 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 130 | " COMPONENT Runtime) 131 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 132 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 133 | 134 | # Install the AOT library on non-Debug builds only. 135 | if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") 136 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 137 | COMPONENT Runtime) 138 | endif() 139 | -------------------------------------------------------------------------------- /linux/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.10) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | 12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 13 | # which isn't available in 3.10. 14 | function(list_prepend LIST_NAME PREFIX) 15 | set(NEW_LIST "") 16 | foreach(element ${${LIST_NAME}}) 17 | list(APPEND NEW_LIST "${PREFIX}${element}") 18 | endforeach(element) 19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 20 | endfunction() 21 | 22 | # === Flutter Library === 23 | # System-level dependencies. 24 | find_package(PkgConfig REQUIRED) 25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 28 | 29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 30 | 31 | # Published to parent scope for install step. 32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 36 | 37 | list(APPEND FLUTTER_LIBRARY_HEADERS 38 | "fl_basic_message_channel.h" 39 | "fl_binary_codec.h" 40 | "fl_binary_messenger.h" 41 | "fl_dart_project.h" 42 | "fl_engine.h" 43 | "fl_json_message_codec.h" 44 | "fl_json_method_codec.h" 45 | "fl_message_codec.h" 46 | "fl_method_call.h" 47 | "fl_method_channel.h" 48 | "fl_method_codec.h" 49 | "fl_method_response.h" 50 | "fl_plugin_registrar.h" 51 | "fl_plugin_registry.h" 52 | "fl_standard_message_codec.h" 53 | "fl_standard_method_codec.h" 54 | "fl_string_codec.h" 55 | "fl_value.h" 56 | "fl_view.h" 57 | "flutter_linux.h" 58 | ) 59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 60 | add_library(flutter INTERFACE) 61 | target_include_directories(flutter INTERFACE 62 | "${EPHEMERAL_DIR}" 63 | ) 64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 65 | target_link_libraries(flutter INTERFACE 66 | PkgConfig::GTK 67 | PkgConfig::GLIB 68 | PkgConfig::GIO 69 | ) 70 | add_dependencies(flutter flutter_assemble) 71 | 72 | # === Flutter tool backend === 73 | # _phony_ is a non-existent file to force this command to run every time, 74 | # since currently there's no way to get a full input/output list from the 75 | # flutter tool. 76 | add_custom_command( 77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 79 | COMMAND ${CMAKE_COMMAND} -E env 80 | ${FLUTTER_TOOL_ENVIRONMENT} 81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 83 | VERBATIM 84 | ) 85 | add_custom_target(flutter_assemble DEPENDS 86 | "${FLUTTER_LIBRARY}" 87 | ${FLUTTER_LIBRARY_HEADERS} 88 | ) 89 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | 11 | void fl_register_plugins(FlPluginRegistry* registry) { 12 | g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = 13 | fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); 14 | url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); 15 | } 16 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void fl_register_plugins(FlPluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | url_launcher_linux 7 | ) 8 | 9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 10 | ) 11 | 12 | set(PLUGIN_BUNDLED_LIBRARIES) 13 | 14 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 19 | endforeach(plugin) 20 | 21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 24 | endforeach(ffi_plugin) 25 | -------------------------------------------------------------------------------- /linux/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /linux/my_application.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | #include 4 | #ifdef GDK_WINDOWING_X11 5 | #include 6 | #endif 7 | 8 | #include "flutter/generated_plugin_registrant.h" 9 | 10 | struct _MyApplication { 11 | GtkApplication parent_instance; 12 | char** dart_entrypoint_arguments; 13 | }; 14 | 15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) 16 | 17 | // Implements GApplication::activate. 18 | static void my_application_activate(GApplication* application) { 19 | MyApplication* self = MY_APPLICATION(application); 20 | GtkWindow* window = 21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 22 | 23 | // Use a header bar when running in GNOME as this is the common style used 24 | // by applications and is the setup most users will be using (e.g. Ubuntu 25 | // desktop). 26 | // If running on X and not using GNOME then just use a traditional title bar 27 | // in case the window manager does more exotic layout, e.g. tiling. 28 | // If running on Wayland assume the header bar will work (may need changing 29 | // if future cases occur). 30 | gboolean use_header_bar = TRUE; 31 | #ifdef GDK_WINDOWING_X11 32 | GdkScreen* screen = gtk_window_get_screen(window); 33 | if (GDK_IS_X11_SCREEN(screen)) { 34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); 35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) { 36 | use_header_bar = FALSE; 37 | } 38 | } 39 | #endif 40 | if (use_header_bar) { 41 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); 42 | gtk_widget_show(GTK_WIDGET(header_bar)); 43 | gtk_header_bar_set_title(header_bar, "short_video_spider_client"); 44 | gtk_header_bar_set_show_close_button(header_bar, TRUE); 45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); 46 | } else { 47 | gtk_window_set_title(window, "short_video_spider_client"); 48 | } 49 | 50 | gtk_window_set_default_size(window, 1280, 720); 51 | gtk_widget_show(GTK_WIDGET(window)); 52 | 53 | g_autoptr(FlDartProject) project = fl_dart_project_new(); 54 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); 55 | 56 | FlView* view = fl_view_new(project); 57 | gtk_widget_show(GTK_WIDGET(view)); 58 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 59 | 60 | fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 61 | 62 | gtk_widget_grab_focus(GTK_WIDGET(view)); 63 | } 64 | 65 | // Implements GApplication::local_command_line. 66 | static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { 67 | MyApplication* self = MY_APPLICATION(application); 68 | // Strip out the first argument as it is the binary name. 69 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 70 | 71 | g_autoptr(GError) error = nullptr; 72 | if (!g_application_register(application, nullptr, &error)) { 73 | g_warning("Failed to register: %s", error->message); 74 | *exit_status = 1; 75 | return TRUE; 76 | } 77 | 78 | g_application_activate(application); 79 | *exit_status = 0; 80 | 81 | return TRUE; 82 | } 83 | 84 | // Implements GObject::dispose. 85 | static void my_application_dispose(GObject* object) { 86 | MyApplication* self = MY_APPLICATION(object); 87 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 88 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 89 | } 90 | 91 | static void my_application_class_init(MyApplicationClass* klass) { 92 | G_APPLICATION_CLASS(klass)->activate = my_application_activate; 93 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; 94 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 95 | } 96 | 97 | static void my_application_init(MyApplication* self) {} 98 | 99 | MyApplication* my_application_new() { 100 | return MY_APPLICATION(g_object_new(my_application_get_type(), 101 | "application-id", APPLICATION_ID, 102 | "flags", G_APPLICATION_NON_UNIQUE, 103 | nullptr)); 104 | } 105 | -------------------------------------------------------------------------------- /linux/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import path_provider_macos 9 | import shared_preferences_macos 10 | import url_launcher_macos 11 | 12 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 13 | PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) 14 | SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) 15 | UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) 16 | } 17 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "app_icon_16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "app_icon_32.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "app_icon_32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "app_icon_64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "app_icon_128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "app_icon_256.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "app_icon_256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "app_icon_512.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "app_icon_512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "app_icon_1024.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = short_video_spider_client 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.lucky.shortVideoSpiderClient 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2022 com.lucky. All rights reserved. 15 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.client 10 | 11 | com.apple.security.network.server 12 | 13 | com.apple.security.files.user-selected.read-write 14 | 15 | com.apple.security.app-sandbox 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | AppIcon.icns 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | $(PRODUCT_COPYRIGHT) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController.init() 7 | 8 | let screenFrame=NSScreen.screens[0].frame; //获取第一块屏幕的大小 9 | let scrWidth=screenFrame.size.width 10 | let scrHeight=screenFrame.size.height 11 | let windowWidth=scrWidth/3*2 12 | let windowHeight=scrHeight/3*2 13 | let pointX=(scrWidth-windowWidth)/2 14 | let pointY=(scrHeight-windowHeight)/2 15 | 16 | var windowFrame = self.frame 17 | windowFrame.size.height=windowHeight 18 | windowFrame.size.width=windowWidth 19 | windowFrame.origin.x=pointX 20 | windowFrame.origin.y=pointY 21 | self.contentViewController = flutterViewController 22 | self.setFrame(windowFrame, display: true) 23 | 24 | RegisterGeneratedPlugins(registry: flutterViewController) 25 | 26 | super.awakeFromNib() 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.client 10 | 11 | com.apple.security.network.server 12 | 13 | com.apple.security.files.user-selected.read-write 14 | 15 | com.apple.security.app-sandbox 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /macos/Runner/RunnerDebug.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.client 10 | 11 | com.apple.security.network.server 12 | 13 | com.apple.security.files.user-selected.read-write 14 | 15 | com.apple.security.app-sandbox 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | url: "https://pub.dartlang.org" 9 | source: hosted 10 | version: "2.9.0" 11 | boolean_selector: 12 | dependency: transitive 13 | description: 14 | name: boolean_selector 15 | url: "https://pub.dartlang.org" 16 | source: hosted 17 | version: "2.1.0" 18 | characters: 19 | dependency: transitive 20 | description: 21 | name: characters 22 | url: "https://pub.dartlang.org" 23 | source: hosted 24 | version: "1.2.1" 25 | charcode: 26 | dependency: transitive 27 | description: 28 | name: charcode 29 | url: "https://pub.dartlang.org" 30 | source: hosted 31 | version: "1.3.1" 32 | clock: 33 | dependency: transitive 34 | description: 35 | name: clock 36 | url: "https://pub.dartlang.org" 37 | source: hosted 38 | version: "1.1.1" 39 | collection: 40 | dependency: transitive 41 | description: 42 | name: collection 43 | url: "https://pub.dartlang.org" 44 | source: hosted 45 | version: "1.16.0" 46 | convert: 47 | dependency: transitive 48 | description: 49 | name: convert 50 | url: "https://pub.dartlang.org" 51 | source: hosted 52 | version: "2.1.1" 53 | crypto: 54 | dependency: "direct main" 55 | description: 56 | name: crypto 57 | url: "https://pub.dartlang.org" 58 | source: hosted 59 | version: "2.1.5" 60 | cupertino_icons: 61 | dependency: "direct main" 62 | description: 63 | name: cupertino_icons 64 | url: "https://pub.dartlang.org" 65 | source: hosted 66 | version: "1.0.5" 67 | dio: 68 | dependency: "direct main" 69 | description: 70 | name: dio 71 | url: "https://pub.dartlang.org" 72 | source: hosted 73 | version: "4.0.6" 74 | fake_async: 75 | dependency: transitive 76 | description: 77 | name: fake_async 78 | url: "https://pub.dartlang.org" 79 | source: hosted 80 | version: "1.3.1" 81 | ffi: 82 | dependency: transitive 83 | description: 84 | name: ffi 85 | url: "https://pub.dartlang.org" 86 | source: hosted 87 | version: "1.2.1" 88 | file: 89 | dependency: transitive 90 | description: 91 | name: file 92 | url: "https://pub.dartlang.org" 93 | source: hosted 94 | version: "6.1.4" 95 | file_picker: 96 | dependency: "direct main" 97 | description: 98 | name: file_picker 99 | url: "https://pub.dartlang.org" 100 | source: hosted 101 | version: "4.6.1" 102 | flutter: 103 | dependency: "direct main" 104 | description: flutter 105 | source: sdk 106 | version: "0.0.0" 107 | flutter_lints: 108 | dependency: "direct dev" 109 | description: 110 | name: flutter_lints 111 | url: "https://pub.dartlang.org" 112 | source: hosted 113 | version: "2.0.1" 114 | flutter_plugin_android_lifecycle: 115 | dependency: transitive 116 | description: 117 | name: flutter_plugin_android_lifecycle 118 | url: "https://pub.dartlang.org" 119 | source: hosted 120 | version: "2.0.7" 121 | flutter_screenutil: 122 | dependency: "direct main" 123 | description: 124 | name: flutter_screenutil 125 | url: "https://pub.dartlang.org" 126 | source: hosted 127 | version: "5.6.0" 128 | flutter_test: 129 | dependency: "direct dev" 130 | description: flutter 131 | source: sdk 132 | version: "0.0.0" 133 | flutter_web_plugins: 134 | dependency: transitive 135 | description: flutter 136 | source: sdk 137 | version: "0.0.0" 138 | fluttertoast: 139 | dependency: "direct main" 140 | description: 141 | name: fluttertoast 142 | url: "https://pub.dartlang.org" 143 | source: hosted 144 | version: "8.1.1" 145 | http_parser: 146 | dependency: transitive 147 | description: 148 | name: http_parser 149 | url: "https://pub.dartlang.org" 150 | source: hosted 151 | version: "4.0.2" 152 | image_gallery_saver: 153 | dependency: "direct main" 154 | description: 155 | name: image_gallery_saver 156 | url: "https://pub.dartlang.org" 157 | source: hosted 158 | version: "1.7.1" 159 | js: 160 | dependency: transitive 161 | description: 162 | name: js 163 | url: "https://pub.dartlang.org" 164 | source: hosted 165 | version: "0.6.4" 166 | lints: 167 | dependency: transitive 168 | description: 169 | name: lints 170 | url: "https://pub.dartlang.org" 171 | source: hosted 172 | version: "2.0.1" 173 | matcher: 174 | dependency: transitive 175 | description: 176 | name: matcher 177 | url: "https://pub.dartlang.org" 178 | source: hosted 179 | version: "0.12.12" 180 | material_color_utilities: 181 | dependency: transitive 182 | description: 183 | name: material_color_utilities 184 | url: "https://pub.dartlang.org" 185 | source: hosted 186 | version: "0.1.5" 187 | meta: 188 | dependency: transitive 189 | description: 190 | name: meta 191 | url: "https://pub.dartlang.org" 192 | source: hosted 193 | version: "1.8.0" 194 | path: 195 | dependency: transitive 196 | description: 197 | name: path 198 | url: "https://pub.dartlang.org" 199 | source: hosted 200 | version: "1.8.2" 201 | path_provider: 202 | dependency: "direct main" 203 | description: 204 | name: path_provider 205 | url: "https://pub.dartlang.org" 206 | source: hosted 207 | version: "2.0.11" 208 | path_provider_android: 209 | dependency: transitive 210 | description: 211 | name: path_provider_android 212 | url: "https://pub.dartlang.org" 213 | source: hosted 214 | version: "2.0.21" 215 | path_provider_ios: 216 | dependency: transitive 217 | description: 218 | name: path_provider_ios 219 | url: "https://pub.dartlang.org" 220 | source: hosted 221 | version: "2.0.11" 222 | path_provider_linux: 223 | dependency: transitive 224 | description: 225 | name: path_provider_linux 226 | url: "https://pub.dartlang.org" 227 | source: hosted 228 | version: "2.1.7" 229 | path_provider_macos: 230 | dependency: transitive 231 | description: 232 | name: path_provider_macos 233 | url: "https://pub.dartlang.org" 234 | source: hosted 235 | version: "2.0.6" 236 | path_provider_platform_interface: 237 | dependency: transitive 238 | description: 239 | name: path_provider_platform_interface 240 | url: "https://pub.dartlang.org" 241 | source: hosted 242 | version: "2.0.5" 243 | path_provider_windows: 244 | dependency: transitive 245 | description: 246 | name: path_provider_windows 247 | url: "https://pub.dartlang.org" 248 | source: hosted 249 | version: "2.0.7" 250 | permission_handler: 251 | dependency: "direct main" 252 | description: 253 | name: permission_handler 254 | url: "https://pub.dartlang.org" 255 | source: hosted 256 | version: "10.2.0" 257 | permission_handler_android: 258 | dependency: transitive 259 | description: 260 | name: permission_handler_android 261 | url: "https://pub.dartlang.org" 262 | source: hosted 263 | version: "10.2.0" 264 | permission_handler_apple: 265 | dependency: transitive 266 | description: 267 | name: permission_handler_apple 268 | url: "https://pub.dartlang.org" 269 | source: hosted 270 | version: "9.0.7" 271 | permission_handler_platform_interface: 272 | dependency: transitive 273 | description: 274 | name: permission_handler_platform_interface 275 | url: "https://pub.dartlang.org" 276 | source: hosted 277 | version: "3.9.0" 278 | permission_handler_windows: 279 | dependency: transitive 280 | description: 281 | name: permission_handler_windows 282 | url: "https://pub.dartlang.org" 283 | source: hosted 284 | version: "0.1.2" 285 | platform: 286 | dependency: transitive 287 | description: 288 | name: platform 289 | url: "https://pub.dartlang.org" 290 | source: hosted 291 | version: "3.1.0" 292 | plugin_platform_interface: 293 | dependency: transitive 294 | description: 295 | name: plugin_platform_interface 296 | url: "https://pub.dartlang.org" 297 | source: hosted 298 | version: "2.1.3" 299 | process: 300 | dependency: transitive 301 | description: 302 | name: process 303 | url: "https://pub.dartlang.org" 304 | source: hosted 305 | version: "4.2.4" 306 | shared_preferences: 307 | dependency: "direct main" 308 | description: 309 | name: shared_preferences 310 | url: "https://pub.dartlang.org" 311 | source: hosted 312 | version: "2.0.15" 313 | shared_preferences_android: 314 | dependency: transitive 315 | description: 316 | name: shared_preferences_android 317 | url: "https://pub.dartlang.org" 318 | source: hosted 319 | version: "2.0.14" 320 | shared_preferences_ios: 321 | dependency: transitive 322 | description: 323 | name: shared_preferences_ios 324 | url: "https://pub.dartlang.org" 325 | source: hosted 326 | version: "2.1.1" 327 | shared_preferences_linux: 328 | dependency: transitive 329 | description: 330 | name: shared_preferences_linux 331 | url: "https://pub.dartlang.org" 332 | source: hosted 333 | version: "2.1.1" 334 | shared_preferences_macos: 335 | dependency: transitive 336 | description: 337 | name: shared_preferences_macos 338 | url: "https://pub.dartlang.org" 339 | source: hosted 340 | version: "2.0.4" 341 | shared_preferences_platform_interface: 342 | dependency: transitive 343 | description: 344 | name: shared_preferences_platform_interface 345 | url: "https://pub.dartlang.org" 346 | source: hosted 347 | version: "2.1.0" 348 | shared_preferences_web: 349 | dependency: transitive 350 | description: 351 | name: shared_preferences_web 352 | url: "https://pub.dartlang.org" 353 | source: hosted 354 | version: "2.0.4" 355 | shared_preferences_windows: 356 | dependency: transitive 357 | description: 358 | name: shared_preferences_windows 359 | url: "https://pub.dartlang.org" 360 | source: hosted 361 | version: "2.1.1" 362 | sky_engine: 363 | dependency: transitive 364 | description: flutter 365 | source: sdk 366 | version: "0.0.99" 367 | source_span: 368 | dependency: transitive 369 | description: 370 | name: source_span 371 | url: "https://pub.dartlang.org" 372 | source: hosted 373 | version: "1.9.0" 374 | stack_trace: 375 | dependency: transitive 376 | description: 377 | name: stack_trace 378 | url: "https://pub.dartlang.org" 379 | source: hosted 380 | version: "1.10.0" 381 | stream_channel: 382 | dependency: transitive 383 | description: 384 | name: stream_channel 385 | url: "https://pub.dartlang.org" 386 | source: hosted 387 | version: "2.1.0" 388 | string_scanner: 389 | dependency: transitive 390 | description: 391 | name: string_scanner 392 | url: "https://pub.dartlang.org" 393 | source: hosted 394 | version: "1.1.1" 395 | term_glyph: 396 | dependency: transitive 397 | description: 398 | name: term_glyph 399 | url: "https://pub.dartlang.org" 400 | source: hosted 401 | version: "1.2.1" 402 | test_api: 403 | dependency: transitive 404 | description: 405 | name: test_api 406 | url: "https://pub.dartlang.org" 407 | source: hosted 408 | version: "0.4.12" 409 | typed_data: 410 | dependency: transitive 411 | description: 412 | name: typed_data 413 | url: "https://pub.dartlang.org" 414 | source: hosted 415 | version: "1.3.1" 416 | url_launcher: 417 | dependency: "direct main" 418 | description: 419 | name: url_launcher 420 | url: "https://pub.dartlang.org" 421 | source: hosted 422 | version: "6.1.6" 423 | url_launcher_android: 424 | dependency: transitive 425 | description: 426 | name: url_launcher_android 427 | url: "https://pub.dartlang.org" 428 | source: hosted 429 | version: "6.0.21" 430 | url_launcher_ios: 431 | dependency: transitive 432 | description: 433 | name: url_launcher_ios 434 | url: "https://pub.dartlang.org" 435 | source: hosted 436 | version: "6.0.17" 437 | url_launcher_linux: 438 | dependency: transitive 439 | description: 440 | name: url_launcher_linux 441 | url: "https://pub.dartlang.org" 442 | source: hosted 443 | version: "3.0.1" 444 | url_launcher_macos: 445 | dependency: transitive 446 | description: 447 | name: url_launcher_macos 448 | url: "https://pub.dartlang.org" 449 | source: hosted 450 | version: "3.0.1" 451 | url_launcher_platform_interface: 452 | dependency: transitive 453 | description: 454 | name: url_launcher_platform_interface 455 | url: "https://pub.dartlang.org" 456 | source: hosted 457 | version: "2.1.1" 458 | url_launcher_web: 459 | dependency: transitive 460 | description: 461 | name: url_launcher_web 462 | url: "https://pub.dartlang.org" 463 | source: hosted 464 | version: "2.0.13" 465 | url_launcher_windows: 466 | dependency: transitive 467 | description: 468 | name: url_launcher_windows 469 | url: "https://pub.dartlang.org" 470 | source: hosted 471 | version: "3.0.1" 472 | vector_math: 473 | dependency: transitive 474 | description: 475 | name: vector_math 476 | url: "https://pub.dartlang.org" 477 | source: hosted 478 | version: "2.1.2" 479 | win32: 480 | dependency: transitive 481 | description: 482 | name: win32 483 | url: "https://pub.dartlang.org" 484 | source: hosted 485 | version: "2.6.1" 486 | xdg_directories: 487 | dependency: transitive 488 | description: 489 | name: xdg_directories 490 | url: "https://pub.dartlang.org" 491 | source: hosted 492 | version: "0.2.0+2" 493 | sdks: 494 | dart: ">=2.17.1 <3.0.0" 495 | flutter: ">=2.10.0" 496 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: short_video_spider_client 2 | description: spider short video 3 | 4 | # The following line prevents the package from being accidentally published to 5 | # pub.dev using `flutter pub publish`. This is preferred for private packages. 6 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev 7 | 8 | # The following defines the version and build number for your application. 9 | # A version number is three numbers separated by dots, like 1.2.43 10 | # followed by an optional build number separated by a +. 11 | # Both the version and the builder number may be overridden in flutter 12 | # build by specifying --build-name and --build-number, respectively. 13 | # In Android, build-name is used as versionName while build-number used as versionCode. 14 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 15 | # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. 16 | # Read more about iOS versioning at 17 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 18 | version: 1.1.2+2 19 | 20 | environment: 21 | sdk: ">=2.17.1 <3.0.0" 22 | 23 | # Dependencies specify other packages that your package needs in order to work. 24 | # To automatically upgrade your package dependencies to the latest versions 25 | # consider running `flutter pub upgrade --major-versions`. Alternatively, 26 | # dependencies can be manually updated by changing the version numbers below to 27 | # the latest version available on pub.dev. To see which dependencies have newer 28 | # versions available, run `flutter pub outdated`. 29 | dependencies: 30 | flutter: 31 | sdk: flutter 32 | 33 | 34 | # The following adds the Cupertino Icons font to your application. 35 | # Use with the CupertinoIcons class for iOS style icons. 36 | cupertino_icons: ^1.0.2 37 | path_provider: ^2.0.11 38 | # 屏幕适配 39 | flutter_screenutil: ^5.0.1 40 | # 网络请求 41 | dio: ^4.0.6 42 | # key-value存储 43 | shared_preferences: ^2.0.15 44 | # 吐司 45 | fluttertoast: ^8.0.9 46 | file_picker: ^4.2.4 47 | crypto: ^2.0.6 #md5加密 48 | image_gallery_saver: ^1.7.1 # 保存到照片里面 49 | permission_handler: ^10.0.0 # 权限申请 50 | url_launcher: ^6.1.5 51 | 52 | 53 | dev_dependencies: 54 | flutter_test: 55 | sdk: flutter 56 | 57 | # The "flutter_lints" package below contains a set of recommended lints to 58 | # encourage good coding practices. The lint set provided by the package is 59 | # activated in the `analysis_options.yaml` file located at the root of your 60 | # package. See that file for information about deactivating specific lint 61 | # rules and activating additional ones. 62 | flutter_lints: ^2.0.0 63 | 64 | # For information on the generic Dart part of this file, see the 65 | # following page: https://dart.dev/tools/pub/pubspec 66 | 67 | # The following section is specific to Flutter packages. 68 | flutter: 69 | 70 | # The following line ensures that the Material Icons font is 71 | # included with your application, so that you can use the icons in 72 | # the material Icons class. 73 | uses-material-design: true 74 | 75 | # To add assets to your application, add an assets section, like this: 76 | # assets: 77 | # - images/a_dot_burr.jpeg 78 | # - images/a_dot_ham.jpeg 79 | 80 | # An image asset can refer to one or more resolution-specific "variants", see 81 | # https://flutter.dev/assets-and-images/#resolution-aware 82 | 83 | # For details regarding adding assets from package dependencies, see 84 | # https://flutter.dev/assets-and-images/#from-packages 85 | 86 | # To add custom fonts to your application, add a fonts section here, 87 | # in this "flutter" section. Each entry in this list should have a 88 | # "family" key with the font family name, and a "fonts" key with a 89 | # list giving the asset and other descriptors for the font. For 90 | # example: 91 | # fonts: 92 | # - family: Schyler 93 | # fonts: 94 | # - asset: fonts/Schyler-Regular.ttf 95 | # - asset: fonts/Schyler-Italic.ttf 96 | # style: italic 97 | # - family: Trajan Pro 98 | # fonts: 99 | # - asset: fonts/TrajanPro.ttf 100 | # - asset: fonts/TrajanPro_Bold.ttf 101 | # weight: 700 102 | # 103 | # For details regarding fonts from package dependencies, 104 | # see https://flutter.dev/custom-fonts/#from-packages 105 | -------------------------------------------------------------------------------- /screenshots/android_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/screenshots/android_1.png -------------------------------------------------------------------------------- /screenshots/android_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/screenshots/android_2.png -------------------------------------------------------------------------------- /screenshots/ios_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/screenshots/ios_1.png -------------------------------------------------------------------------------- /screenshots/ios_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/screenshots/ios_2.png -------------------------------------------------------------------------------- /screenshots/macos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/screenshots/macos.png -------------------------------------------------------------------------------- /screenshots/windows.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/screenshots/windows.png -------------------------------------------------------------------------------- /test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility in the flutter_test package. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter_test/flutter_test.dart'; 10 | 11 | import 'package:short_video_spider_client/main.dart'; 12 | 13 | void main() { 14 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 15 | // Build our app and trigger a frame. 16 | await tester.pumpWidget(const MyApp()); 17 | 18 | // Verify that our counter starts at 0. 19 | expect(find.text('0'), findsOneWidget); 20 | expect(find.text('1'), findsNothing); 21 | 22 | // Tap the '+' icon and trigger a frame. 23 | await tester.tap(find.byIcon(Icons.add)); 24 | await tester.pump(); 25 | 26 | // Verify that our counter has incremented. 27 | expect(find.text('0'), findsNothing); 28 | expect(find.text('1'), findsOneWidget); 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/web/favicon.png -------------------------------------------------------------------------------- /web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/web/icons/Icon-192.png -------------------------------------------------------------------------------- /web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/web/icons/Icon-512.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | short_video_spider_client 33 | 34 | 35 | 39 | 40 | 41 | 42 | 43 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "short_video_spider_client", 3 | "short_name": "short_video_spider_client", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "spider short video", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.14) 3 | project(short_video_spider_client LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "short_video_spider_client") 8 | 9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 10 | # versions of CMake. 11 | cmake_policy(SET CMP0063 NEW) 12 | 13 | # Define build configuration option. 14 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 15 | if(IS_MULTICONFIG) 16 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 17 | CACHE STRING "" FORCE) 18 | else() 19 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 20 | set(CMAKE_BUILD_TYPE "Debug" CACHE 21 | STRING "Flutter build mode" FORCE) 22 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 23 | "Debug" "Profile" "Release") 24 | endif() 25 | endif() 26 | # Define settings for the Profile build mode. 27 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 28 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 29 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 30 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 31 | 32 | # Use Unicode for all projects. 33 | add_definitions(-DUNICODE -D_UNICODE) 34 | 35 | # Compilation settings that should be applied to most targets. 36 | # 37 | # Be cautious about adding new options here, as plugins use this function by 38 | # default. In most cases, you should add new options to specific targets instead 39 | # of modifying this function. 40 | function(APPLY_STANDARD_SETTINGS TARGET) 41 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 42 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 43 | target_compile_options(${TARGET} PRIVATE /EHsc) 44 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 45 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 46 | endfunction() 47 | 48 | # Flutter library and tool build rules. 49 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 50 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 51 | 52 | # Application build; see runner/CMakeLists.txt. 53 | add_subdirectory("runner") 54 | 55 | # Generated plugin build rules, which manage building the plugins and adding 56 | # them to the application. 57 | include(flutter/generated_plugins.cmake) 58 | 59 | 60 | # === Installation === 61 | # Support files are copied into place next to the executable, so that it can 62 | # run in place. This is done instead of making a separate bundle (as on Linux) 63 | # so that building and running from within Visual Studio will work. 64 | set(BUILD_BUNDLE_DIR "$") 65 | # Make the "install" step default, as it's required to run. 66 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 67 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 68 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 69 | endif() 70 | 71 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 72 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 73 | 74 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 75 | COMPONENT Runtime) 76 | 77 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 78 | COMPONENT Runtime) 79 | 80 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 81 | COMPONENT Runtime) 82 | 83 | if(PLUGIN_BUNDLED_LIBRARIES) 84 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 85 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 86 | COMPONENT Runtime) 87 | endif() 88 | 89 | # Fully re-copy the assets directory on each build to avoid having stale files 90 | # from a previous install. 91 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 92 | install(CODE " 93 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 94 | " COMPONENT Runtime) 95 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 96 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 97 | 98 | # Install the AOT library on non-Debug builds only. 99 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 100 | CONFIGURATIONS Profile;Release 101 | COMPONENT Runtime) 102 | -------------------------------------------------------------------------------- /windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.14) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 12 | 13 | # === Flutter Library === 14 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 15 | 16 | # Published to parent scope for install step. 17 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 18 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 19 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 20 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 21 | 22 | list(APPEND FLUTTER_LIBRARY_HEADERS 23 | "flutter_export.h" 24 | "flutter_windows.h" 25 | "flutter_messenger.h" 26 | "flutter_plugin_registrar.h" 27 | "flutter_texture_registrar.h" 28 | ) 29 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 30 | add_library(flutter INTERFACE) 31 | target_include_directories(flutter INTERFACE 32 | "${EPHEMERAL_DIR}" 33 | ) 34 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 35 | add_dependencies(flutter flutter_assemble) 36 | 37 | # === Wrapper === 38 | list(APPEND CPP_WRAPPER_SOURCES_CORE 39 | "core_implementations.cc" 40 | "standard_codec.cc" 41 | ) 42 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 43 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 44 | "plugin_registrar.cc" 45 | ) 46 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 47 | list(APPEND CPP_WRAPPER_SOURCES_APP 48 | "flutter_engine.cc" 49 | "flutter_view_controller.cc" 50 | ) 51 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 52 | 53 | # Wrapper sources needed for a plugin. 54 | add_library(flutter_wrapper_plugin STATIC 55 | ${CPP_WRAPPER_SOURCES_CORE} 56 | ${CPP_WRAPPER_SOURCES_PLUGIN} 57 | ) 58 | apply_standard_settings(flutter_wrapper_plugin) 59 | set_target_properties(flutter_wrapper_plugin PROPERTIES 60 | POSITION_INDEPENDENT_CODE ON) 61 | set_target_properties(flutter_wrapper_plugin PROPERTIES 62 | CXX_VISIBILITY_PRESET hidden) 63 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 64 | target_include_directories(flutter_wrapper_plugin PUBLIC 65 | "${WRAPPER_ROOT}/include" 66 | ) 67 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 68 | 69 | # Wrapper sources needed for the runner. 70 | add_library(flutter_wrapper_app STATIC 71 | ${CPP_WRAPPER_SOURCES_CORE} 72 | ${CPP_WRAPPER_SOURCES_APP} 73 | ) 74 | apply_standard_settings(flutter_wrapper_app) 75 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 76 | target_include_directories(flutter_wrapper_app PUBLIC 77 | "${WRAPPER_ROOT}/include" 78 | ) 79 | add_dependencies(flutter_wrapper_app flutter_assemble) 80 | 81 | # === Flutter tool backend === 82 | # _phony_ is a non-existent file to force this command to run every time, 83 | # since currently there's no way to get a full input/output list from the 84 | # flutter tool. 85 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 86 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 87 | add_custom_command( 88 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 89 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 90 | ${CPP_WRAPPER_SOURCES_APP} 91 | ${PHONY_OUTPUT} 92 | COMMAND ${CMAKE_COMMAND} -E env 93 | ${FLUTTER_TOOL_ENVIRONMENT} 94 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 95 | windows-x64 $ 96 | VERBATIM 97 | ) 98 | add_custom_target(flutter_assemble DEPENDS 99 | "${FLUTTER_LIBRARY}" 100 | ${FLUTTER_LIBRARY_HEADERS} 101 | ${CPP_WRAPPER_SOURCES_CORE} 102 | ${CPP_WRAPPER_SOURCES_PLUGIN} 103 | ${CPP_WRAPPER_SOURCES_APP} 104 | ) 105 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | #include 11 | 12 | void RegisterPlugins(flutter::PluginRegistry* registry) { 13 | PermissionHandlerWindowsPluginRegisterWithRegistrar( 14 | registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin")); 15 | UrlLauncherWindowsRegisterWithRegistrar( 16 | registry->GetRegistrarForPlugin("UrlLauncherWindows")); 17 | } 18 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | permission_handler_windows 7 | url_launcher_windows 8 | ) 9 | 10 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 11 | ) 12 | 13 | set(PLUGIN_BUNDLED_LIBRARIES) 14 | 15 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 16 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 17 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 19 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 20 | endforeach(plugin) 21 | 22 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 23 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 24 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 25 | endforeach(ffi_plugin) 26 | -------------------------------------------------------------------------------- /windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} WIN32 10 | "flutter_window.cpp" 11 | "main.cpp" 12 | "utils.cpp" 13 | "win32_window.cpp" 14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 15 | "Runner.rc" 16 | "runner.exe.manifest" 17 | ) 18 | 19 | # Apply the standard set of build settings. This can be removed for applications 20 | # that need different build settings. 21 | apply_standard_settings(${BINARY_NAME}) 22 | 23 | # Disable Windows macros that collide with C++ standard library functions. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 25 | 26 | # Add dependency libraries and include directories. Add any application-specific 27 | # dependencies here. 28 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 29 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 30 | 31 | # Run the Flutter tool portions of the build. This must not be removed. 32 | add_dependencies(${BINARY_NAME} flutter_assemble) 33 | -------------------------------------------------------------------------------- /windows/runner/Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\app_icon.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #ifdef FLUTTER_BUILD_NUMBER 64 | #define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0 67 | #endif 68 | 69 | #ifdef FLUTTER_BUILD_NAME 70 | #define VERSION_AS_STRING #FLUTTER_BUILD_NAME 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "com.lucky" "\0" 93 | VALUE "FileDescription", "short_video_spider_client" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "short_video_spider_client" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2022 com.lucky. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "short_video_spider_client.exe" "\0" 98 | VALUE "ProductName", "short_video_spider_client" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | return true; 30 | } 31 | 32 | void FlutterWindow::OnDestroy() { 33 | if (flutter_controller_) { 34 | flutter_controller_ = nullptr; 35 | } 36 | 37 | Win32Window::OnDestroy(); 38 | } 39 | 40 | LRESULT 41 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 42 | WPARAM const wparam, 43 | LPARAM const lparam) noexcept { 44 | // Give Flutter, including plugins, an opportunity to handle window messages. 45 | if (flutter_controller_) { 46 | std::optional result = 47 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 48 | lparam); 49 | if (result) { 50 | return *result; 51 | } 52 | } 53 | 54 | switch (message) { 55 | case WM_FONTCHANGE: 56 | flutter_controller_->engine()->ReloadSystemFonts(); 57 | break; 58 | } 59 | 60 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 61 | } 62 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | 21 | flutter::DartProject project(L"data"); 22 | 23 | std::vector command_line_arguments = 24 | GetCommandLineArguments(); 25 | 26 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 27 | 28 | //set current frame center 29 | int scrWidth, scrHeight, xShaft, yShaft,mWidth,mHeight; 30 | 31 | scrWidth = GetSystemMetrics(SM_CXSCREEN); 32 | scrHeight = GetSystemMetrics(SM_CYSCREEN); 33 | 34 | //set current frame size 2/3 screen 35 | mWidth = scrWidth / 3 * 2; 36 | mHeight = scrHeight / 3 * 2; 37 | 38 | //center x y 39 | xShaft = (scrWidth - mWidth) / 2; 40 | yShaft = (scrHeight - mHeight) / 2; 41 | 42 | FlutterWindow window(project); 43 | Win32Window::Point origin(xShaft, yShaft); 44 | Win32Window::Size size(mWidth, mHeight); 45 | if (!window.CreateAndShow(L"", origin, size)) { 46 | return EXIT_FAILURE; 47 | } 48 | window.SetQuitOnClose(true); 49 | 50 | ::MSG msg; 51 | while (::GetMessage(&msg, nullptr, 0, 0)) { 52 | ::TranslateMessage(&msg); 53 | ::DispatchMessage(&msg); 54 | } 55 | 56 | ::CoUninitialize(); 57 | return EXIT_SUCCESS; 58 | } 59 | -------------------------------------------------------------------------------- /windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/short_video_spider_client/9d79ddef5319056de593b9edc37f082737c3e68a/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr); 51 | std::string utf8_string; 52 | if (target_length == 0 || target_length > utf8_string.max_size()) { 53 | return utf8_string; 54 | } 55 | utf8_string.resize(target_length); 56 | int converted_length = ::WideCharToMultiByte( 57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 58 | -1, utf8_string.data(), 59 | target_length, nullptr, nullptr); 60 | if (converted_length == 0) { 61 | return std::string(); 62 | } 63 | return utf8_string; 64 | } 65 | -------------------------------------------------------------------------------- /windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /windows/runner/win32_window.cpp: -------------------------------------------------------------------------------- 1 | #include "win32_window.h" 2 | 3 | #include 4 | 5 | #include "resource.h" 6 | 7 | namespace { 8 | 9 | constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; 10 | 11 | // The number of Win32Window objects that currently exist. 12 | static int g_active_window_count = 0; 13 | 14 | using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); 15 | 16 | // Scale helper to convert logical scaler values to physical using passed in 17 | // scale factor 18 | int Scale(int source, double scale_factor) { 19 | return static_cast(source * scale_factor); 20 | } 21 | 22 | // Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. 23 | // This API is only needed for PerMonitor V1 awareness mode. 24 | void EnableFullDpiSupportIfAvailable(HWND hwnd) { 25 | HMODULE user32_module = LoadLibraryA("User32.dll"); 26 | if (!user32_module) { 27 | return; 28 | } 29 | auto enable_non_client_dpi_scaling = 30 | reinterpret_cast( 31 | GetProcAddress(user32_module, "EnableNonClientDpiScaling")); 32 | if (enable_non_client_dpi_scaling != nullptr) { 33 | enable_non_client_dpi_scaling(hwnd); 34 | FreeLibrary(user32_module); 35 | } 36 | } 37 | 38 | } // namespace 39 | 40 | // Manages the Win32Window's window class registration. 41 | class WindowClassRegistrar { 42 | public: 43 | ~WindowClassRegistrar() = default; 44 | 45 | // Returns the singleton registar instance. 46 | static WindowClassRegistrar* GetInstance() { 47 | if (!instance_) { 48 | instance_ = new WindowClassRegistrar(); 49 | } 50 | return instance_; 51 | } 52 | 53 | // Returns the name of the window class, registering the class if it hasn't 54 | // previously been registered. 55 | const wchar_t* GetWindowClass(); 56 | 57 | // Unregisters the window class. Should only be called if there are no 58 | // instances of the window. 59 | void UnregisterWindowClass(); 60 | 61 | private: 62 | WindowClassRegistrar() = default; 63 | 64 | static WindowClassRegistrar* instance_; 65 | 66 | bool class_registered_ = false; 67 | }; 68 | 69 | WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; 70 | 71 | const wchar_t* WindowClassRegistrar::GetWindowClass() { 72 | if (!class_registered_) { 73 | WNDCLASS window_class{}; 74 | window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); 75 | window_class.lpszClassName = kWindowClassName; 76 | window_class.style = CS_HREDRAW | CS_VREDRAW; 77 | window_class.cbClsExtra = 0; 78 | window_class.cbWndExtra = 0; 79 | window_class.hInstance = GetModuleHandle(nullptr); 80 | window_class.hIcon = 81 | LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); 82 | window_class.hbrBackground = 0; 83 | window_class.lpszMenuName = nullptr; 84 | window_class.lpfnWndProc = Win32Window::WndProc; 85 | RegisterClass(&window_class); 86 | class_registered_ = true; 87 | } 88 | return kWindowClassName; 89 | } 90 | 91 | void WindowClassRegistrar::UnregisterWindowClass() { 92 | UnregisterClass(kWindowClassName, nullptr); 93 | class_registered_ = false; 94 | } 95 | 96 | Win32Window::Win32Window() { 97 | ++g_active_window_count; 98 | } 99 | 100 | Win32Window::~Win32Window() { 101 | --g_active_window_count; 102 | Destroy(); 103 | } 104 | 105 | bool Win32Window::CreateAndShow(const std::wstring& title, 106 | const Point& origin, 107 | const Size& size) { 108 | Destroy(); 109 | 110 | const wchar_t* window_class = 111 | WindowClassRegistrar::GetInstance()->GetWindowClass(); 112 | 113 | const POINT target_point = {static_cast(origin.x), 114 | static_cast(origin.y)}; 115 | HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); 116 | UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); 117 | double scale_factor = dpi / 96.0; 118 | 119 | HWND window = CreateWindow( 120 | window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE, 121 | Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), 122 | Scale(size.width, scale_factor), Scale(size.height, scale_factor), 123 | nullptr, nullptr, GetModuleHandle(nullptr), this); 124 | 125 | if (!window) { 126 | return false; 127 | } 128 | 129 | return OnCreate(); 130 | } 131 | 132 | // static 133 | LRESULT CALLBACK Win32Window::WndProc(HWND const window, 134 | UINT const message, 135 | WPARAM const wparam, 136 | LPARAM const lparam) noexcept { 137 | if (message == WM_NCCREATE) { 138 | auto window_struct = reinterpret_cast(lparam); 139 | SetWindowLongPtr(window, GWLP_USERDATA, 140 | reinterpret_cast(window_struct->lpCreateParams)); 141 | 142 | auto that = static_cast(window_struct->lpCreateParams); 143 | EnableFullDpiSupportIfAvailable(window); 144 | that->window_handle_ = window; 145 | } else if (Win32Window* that = GetThisFromHandle(window)) { 146 | return that->MessageHandler(window, message, wparam, lparam); 147 | } 148 | 149 | return DefWindowProc(window, message, wparam, lparam); 150 | } 151 | 152 | LRESULT 153 | Win32Window::MessageHandler(HWND hwnd, 154 | UINT const message, 155 | WPARAM const wparam, 156 | LPARAM const lparam) noexcept { 157 | switch (message) { 158 | case WM_DESTROY: 159 | window_handle_ = nullptr; 160 | Destroy(); 161 | if (quit_on_close_) { 162 | PostQuitMessage(0); 163 | } 164 | return 0; 165 | 166 | case WM_DPICHANGED: { 167 | auto newRectSize = reinterpret_cast(lparam); 168 | LONG newWidth = newRectSize->right - newRectSize->left; 169 | LONG newHeight = newRectSize->bottom - newRectSize->top; 170 | 171 | SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, 172 | newHeight, SWP_NOZORDER | SWP_NOACTIVATE); 173 | 174 | return 0; 175 | } 176 | case WM_SIZE: { 177 | RECT rect = GetClientArea(); 178 | if (child_content_ != nullptr) { 179 | // Size and position the child window. 180 | MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, 181 | rect.bottom - rect.top, TRUE); 182 | } 183 | return 0; 184 | } 185 | 186 | case WM_ACTIVATE: 187 | if (child_content_ != nullptr) { 188 | SetFocus(child_content_); 189 | } 190 | return 0; 191 | } 192 | 193 | return DefWindowProc(window_handle_, message, wparam, lparam); 194 | } 195 | 196 | void Win32Window::Destroy() { 197 | OnDestroy(); 198 | 199 | if (window_handle_) { 200 | DestroyWindow(window_handle_); 201 | window_handle_ = nullptr; 202 | } 203 | if (g_active_window_count == 0) { 204 | WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); 205 | } 206 | } 207 | 208 | Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { 209 | return reinterpret_cast( 210 | GetWindowLongPtr(window, GWLP_USERDATA)); 211 | } 212 | 213 | void Win32Window::SetChildContent(HWND content) { 214 | child_content_ = content; 215 | SetParent(content, window_handle_); 216 | RECT frame = GetClientArea(); 217 | 218 | MoveWindow(content, frame.left, frame.top, frame.right - frame.left, 219 | frame.bottom - frame.top, true); 220 | 221 | SetFocus(child_content_); 222 | } 223 | 224 | RECT Win32Window::GetClientArea() { 225 | RECT frame; 226 | GetClientRect(window_handle_, &frame); 227 | return frame; 228 | } 229 | 230 | HWND Win32Window::GetHandle() { 231 | return window_handle_; 232 | } 233 | 234 | void Win32Window::SetQuitOnClose(bool quit_on_close) { 235 | quit_on_close_ = quit_on_close; 236 | } 237 | 238 | bool Win32Window::OnCreate() { 239 | // No-op; provided for subclasses. 240 | return true; 241 | } 242 | 243 | void Win32Window::OnDestroy() { 244 | // No-op; provided for subclasses. 245 | } 246 | -------------------------------------------------------------------------------- /windows/runner/win32_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_WIN32_WINDOW_H_ 2 | #define RUNNER_WIN32_WINDOW_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 11 | // inherited from by classes that wish to specialize with custom 12 | // rendering and input handling 13 | class Win32Window { 14 | public: 15 | struct Point { 16 | unsigned int x; 17 | unsigned int y; 18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 19 | }; 20 | 21 | struct Size { 22 | unsigned int width; 23 | unsigned int height; 24 | Size(unsigned int width, unsigned int height) 25 | : width(width), height(height) {} 26 | }; 27 | 28 | Win32Window(); 29 | virtual ~Win32Window(); 30 | 31 | // Creates and shows a win32 window with |title| and position and size using 32 | // |origin| and |size|. New windows are created on the default monitor. Window 33 | // sizes are specified to the OS in physical pixels, hence to ensure a 34 | // consistent size to will treat the width height passed in to this function 35 | // as logical pixels and scale to appropriate for the default monitor. Returns 36 | // true if the window was created successfully. 37 | bool CreateAndShow(const std::wstring& title, 38 | const Point& origin, 39 | const Size& size); 40 | 41 | // Release OS resources associated with window. 42 | void Destroy(); 43 | 44 | // Inserts |content| into the window tree. 45 | void SetChildContent(HWND content); 46 | 47 | // Returns the backing Window handle to enable clients to set icon and other 48 | // window properties. Returns nullptr if the window has been destroyed. 49 | HWND GetHandle(); 50 | 51 | // If true, closing this window will quit the application. 52 | void SetQuitOnClose(bool quit_on_close); 53 | 54 | // Return a RECT representing the bounds of the current client area. 55 | RECT GetClientArea(); 56 | 57 | protected: 58 | // Processes and route salient window messages for mouse handling, 59 | // size change and DPI. Delegates handling of these to member overloads that 60 | // inheriting classes can handle. 61 | virtual LRESULT MessageHandler(HWND window, 62 | UINT const message, 63 | WPARAM const wparam, 64 | LPARAM const lparam) noexcept; 65 | 66 | // Called when CreateAndShow is called, allowing subclass window-related 67 | // setup. Subclasses should return false if setup fails. 68 | virtual bool OnCreate(); 69 | 70 | // Called when Destroy is called. 71 | virtual void OnDestroy(); 72 | 73 | private: 74 | friend class WindowClassRegistrar; 75 | 76 | // OS callback called by message pump. Handles the WM_NCCREATE message which 77 | // is passed when the non-client area is being created and enables automatic 78 | // non-client DPI scaling so that the non-client area automatically 79 | // responsponds to changes in DPI. All other messages are handled by 80 | // MessageHandler. 81 | static LRESULT CALLBACK WndProc(HWND const window, 82 | UINT const message, 83 | WPARAM const wparam, 84 | LPARAM const lparam) noexcept; 85 | 86 | // Retrieves a class instance pointer for |window| 87 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 88 | 89 | bool quit_on_close_ = false; 90 | 91 | // window handle for top level window. 92 | HWND window_handle_ = nullptr; 93 | 94 | // window handle for hosted content. 95 | HWND child_content_ = nullptr; 96 | }; 97 | 98 | #endif // RUNNER_WIN32_WINDOW_H_ 99 | --------------------------------------------------------------------------------