diff --git a/.gitignore b/.gitignore index 6c8bef1..67605fb 100644 --- a/.gitignore +++ b/.gitignore @@ -31,7 +31,8 @@ .pub/ /server/ /build/ - +/wallpaper_engine_workshop_downloader/ +/data/ # Web related lib/generated_plugin_registrant.dart @@ -48,4 +49,5 @@ app.*.map.json # 不需要的测试文件 /old/projects/ -/old/*.tmp \ No newline at end of file +/old/*.tmp +wallpaper_engine_workshop_downloader.zip diff --git a/7z.exe b/7z.exe new file mode 100644 index 0000000..872133e Binary files /dev/null and b/7z.exe differ diff --git "a/QQ\346\210\252\345\233\27620201212152230.png" "b/QQ\346\210\252\345\233\27620201212152230.png" index de8b10a..6cc72b3 100644 Binary files "a/QQ\346\210\252\345\233\27620201212152230.png" and "b/QQ\346\210\252\345\233\27620201212152230.png" differ diff --git "a/QQ\346\210\252\345\233\27620201212152332.png" "b/QQ\346\210\252\345\233\27620201212152332.png" index 8a78d49..83e9821 100644 Binary files "a/QQ\346\210\252\345\233\27620201212152332.png" and "b/QQ\346\210\252\345\233\27620201212152332.png" differ diff --git a/README.md b/README.md index 44f195c..0b55c1c 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Wallpaper_Engine -一个便捷的创意工坊下载器 +一个便捷的创意工坊下载器,基于steamCMD ## 开源说明 -本项目旨在练习golang 和 flutter 并减少劳动力。 +本项目旨在练习 flutter 并减少劳动力。 flutter build windows @@ -10,16 +10,29 @@ flutter build windows ## 使用方法 -**需要Chrome** -下载地址:https://github.com/user1121114685/Wallpaper_Engine/raw/main/old/steamdownload.zip +下载地址:https://github.com/user1121114685/Wallpaper_Engine/releases/latest/download/wallpaper_engine_workshop_downloader.zip -下载前请选择 wallpaper64.exe 的位置 +**首先**:你需要以**管理员权限运行程序**(只是第一次运行或者初始化)! ![目录](https://github.com/user1121114685/Wallpaper_Engine/blob/main/QQ%E6%88%AA%E5%9B%BE20201212152332.png?raw=true) + +--- + + -![使用](https://github.com/user1121114685/Wallpaper_Engine/blob/main/QQ%E6%88%AA%E5%9B%BE20201212152230.png?raw=true) +**其次**:你需要输入你的Steam账号和密码并保存,这一步并不会验证你是否输入正确密码,这是SteamCMD该做的事情。 + +![使用](https://github.com/user1121114685/Wallpaper_Engine/blob/main/QQ%E6%88%AA%E5%9B%BE20201212152230.png?raw=true) --- + + + +**现在你输入连接即可开始下载,首次使用可能会要求输入验证码 SteamCMD 提示 :Steam Guard code: **查看你的邮箱将验证码填入,只需验证一次。 + + + ## 如果对你有所帮助,也可以对我进行捐赠。那撒我也不废话,下面是二维码。 + ![微信](https://gitee.com/shaoxia1991/Blog/raw/master/me/%E5%BE%AE%E4%BF%A1%E6%94%B6%E6%AC%BE.png) ![支付宝](https://gitee.com/shaoxia1991/Blog/raw/master/me/%E6%94%AF%E4%BB%98%E5%AE%9D%E6%94%B6%E6%AC%BE.jpg) diff --git a/Release.zip b/Release.zip deleted file mode 100644 index 544e4e9..0000000 Binary files a/Release.zip and /dev/null differ diff --git a/assets/aria2c.exe b/assets/aria2c.exe deleted file mode 100644 index 38caa6a..0000000 Binary files a/assets/aria2c.exe and /dev/null differ diff --git a/assets/steamcmd/steamcmd.exe b/assets/steamcmd/steamcmd.exe new file mode 100644 index 0000000..e62349c Binary files /dev/null and b/assets/steamcmd/steamcmd.exe differ diff --git a/assets/steamdownload.dll b/assets/steamdownload.dll deleted file mode 100644 index 9b95fe2..0000000 Binary files a/assets/steamdownload.dll and /dev/null differ diff --git a/assets/steamdownload.h b/assets/steamdownload.h deleted file mode 100644 index 8de874c..0000000 --- a/assets/steamdownload.h +++ /dev/null @@ -1,75 +0,0 @@ -/* Code generated by cmd/cgo; DO NOT EDIT. */ - -/* package steamdownload */ - - -#line 1 "cgo-builtin-export-prolog" - -#include /* for ptrdiff_t below */ - -#ifndef GO_CGO_EXPORT_PROLOGUE_H -#define GO_CGO_EXPORT_PROLOGUE_H - -#ifndef GO_CGO_GOSTRING_TYPEDEF -typedef struct { const char *p; ptrdiff_t n; } _GoString_; -#endif - -#endif - -/* Start of preamble from import "C" comments. */ - - - - -/* End of preamble from import "C" comments. */ - - -/* Start of boilerplate cgo prologue. */ -#line 1 "cgo-gcc-export-header-prolog" - -#ifndef GO_CGO_PROLOGUE_H -#define GO_CGO_PROLOGUE_H - -typedef signed char GoInt8; -typedef unsigned char GoUint8; -typedef short GoInt16; -typedef unsigned short GoUint16; -typedef int GoInt32; -typedef unsigned int GoUint32; -typedef long long GoInt64; -typedef unsigned long long GoUint64; -typedef GoInt64 GoInt; -typedef GoUint64 GoUint; -typedef __SIZE_TYPE__ GoUintptr; -typedef float GoFloat32; -typedef double GoFloat64; -typedef float _Complex GoComplex64; -typedef double _Complex GoComplex128; - -/* - static assertion to make sure the file is being used on architecture - at least with matching size of GoInt. -*/ -typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1]; - -#ifndef GO_CGO_GOSTRING_TYPEDEF -typedef _GoString_ GoString; -#endif -typedef void *GoMap; -typedef void *GoChan; -typedef struct { void *t; void *v; } GoInterface; -typedef struct { void *data; GoInt len; GoInt cap; } GoSlice; - -#endif - -/* End of boilerplate cgo prologue. */ - -#ifdef __cplusplus -extern "C" { -#endif - -extern __declspec(dllexport) char* GetAPI(); - -#ifdef __cplusplus -} -#endif diff --git a/build1.bat b/build1.bat new file mode 100644 index 0000000..36201f0 --- /dev/null +++ b/build1.bat @@ -0,0 +1,2 @@ +del %~dp0wallpaper_engine_workshop_downloader.zip +%~dp07z.exe a -r %~dp0\wallpaper_engine_workshop_downloader.zip %~dp0build\windows\runner\Release\* \ No newline at end of file diff --git a/lib/API/go.mod b/lib/API/go.mod deleted file mode 100644 index 0ec8038..0000000 --- a/lib/API/go.mod +++ /dev/null @@ -1,31 +0,0 @@ -module getapi - -go 1.17 - -require ( - github.com/chromedp/cdproto v0.0.0-20211025030258-2570df970243 - github.com/chromedp/chromedp v0.7.4 - github.com/dustin/go-humanize v1.0.0 - github.com/gogf/gf v1.16.6 -) - -require ( - github.com/BurntSushi/toml v0.3.1 // indirect - github.com/chromedp/sysutil v1.0.0 // indirect - github.com/clbanning/mxj v1.8.5-0.20200714211355-ff02cfb8ea28 // indirect - github.com/fsnotify/fsnotify v1.4.9 // indirect - github.com/gobwas/httphead v0.1.0 // indirect - github.com/gobwas/pool v0.2.1 // indirect - github.com/gobwas/ws v1.1.0 // indirect - github.com/google/go-querystring v1.0.0 // indirect - github.com/josharian/intern v1.0.0 // indirect - github.com/leancloud/go-sdk v0.3.1 // indirect - github.com/levigross/grequests v0.0.0-20180715163950-d0df86deffcb // indirect - github.com/mailru/easyjson v0.7.7 // indirect - go.opentelemetry.io/otel v1.0.0-RC2 // indirect - go.opentelemetry.io/otel/trace v1.0.0-RC2 // indirect - golang.org/x/net v0.0.0-20210520170846-37e1c6afe023 // indirect - golang.org/x/sys v0.0.0-20210525143221-35b2ab0089ea // indirect - golang.org/x/text v0.3.6 // indirect - gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect -) diff --git a/lib/API/go.sum b/lib/API/go.sum deleted file mode 100644 index 464803a..0000000 --- a/lib/API/go.sum +++ /dev/null @@ -1,90 +0,0 @@ -github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/chromedp/cdproto v0.0.0-20210713064928-7d28b402946a/go.mod h1:At5TxYYdxkbQL0TSefRjhLE3Q0lgvqKKMSFUglJ7i1U= -github.com/chromedp/cdproto v0.0.0-20211025030258-2570df970243 h1:09MpdVvSYOhIByW2Z1kWYkh0cjui9k9Imx28pk01KXA= -github.com/chromedp/cdproto v0.0.0-20211025030258-2570df970243/go.mod h1:At5TxYYdxkbQL0TSefRjhLE3Q0lgvqKKMSFUglJ7i1U= -github.com/chromedp/chromedp v0.7.4 h1:U+0d3WbB/Oj4mDuBOI0P7S3PJEued5UZIl5AJ3QulwU= -github.com/chromedp/chromedp v0.7.4/go.mod h1:dBj+SXuQHznp6ZPwZeDDEBZKwclUwDLbZ0hjMialMYs= -github.com/chromedp/sysutil v1.0.0 h1:+ZxhTpfpZlmchB58ih/LBHX52ky7w2VhQVKQMucy3Ic= -github.com/chromedp/sysutil v1.0.0/go.mod h1:kgWmDdq8fTzXYcKIBqIYvRRTnYb9aNS9moAV0xufSww= -github.com/clbanning/mxj v1.8.5-0.20200714211355-ff02cfb8ea28 h1:LdXxtjzvZYhhUaonAaAKArG3pyC67kGL3YY+6hGG8G4= -github.com/clbanning/mxj v1.8.5-0.20200714211355-ff02cfb8ea28/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng= -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= -github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/fatih/color v1.12.0 h1:mRhaKNwANqRgUBGKmnI5ZxEk7QXmjQeCcuYFMX2bfcc= -github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= -github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= -github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= -github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= -github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU= -github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM= -github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og= -github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= -github.com/gobwas/ws v1.1.0 h1:7RFti/xnNkMJnrK7D1yQ/iCIB5OrrY/54/H930kIbHA= -github.com/gobwas/ws v1.1.0/go.mod h1:nzvNcVha5eUziGrbxFCo6qFIojQHjJV5cLYIbezhfL0= -github.com/gogf/gf v1.16.6 h1:Yp5YfwnGz41d1tiVqxcWXiPXyuzjTb7ax4SnPSXxDE8= -github.com/gogf/gf v1.16.6/go.mod h1:4LoHfEBl2jbVmZpVx+qk2La3zWr1V315FtF2PVZuyQ8= -github.com/gomodule/redigo v1.8.5 h1:nRAxCa+SVsyjSBrtZmG/cqb6VbTmuRzpg/PoTFlpumc= -github.com/gomodule/redigo v1.8.5/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0= -github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= -github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= -github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= -github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/grokify/html-strip-tags-go v0.0.0-20190921062105-daaa06bf1aaf h1:wIOAyJMMen0ELGiFzlmqxdcV1yGbkyHBAB6PolcNbLA= -github.com/grokify/html-strip-tags-go v0.0.0-20190921062105-daaa06bf1aaf/go.mod h1:2Su6romC5/1VXOQMaWL2yb618ARB8iVo6/DR99A6d78= -github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= -github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= -github.com/leancloud/go-sdk v0.3.1 h1:phsGuM4Yofkc5le+GF1Qwj3oFr+lSCa87TWRoyVsgtQ= -github.com/leancloud/go-sdk v0.3.1/go.mod h1:jon7alxvSVz6IQEoVsOi7kSshrLboTfBIJjz8FzSHRM= -github.com/levigross/grequests v0.0.0-20180715163950-d0df86deffcb h1:ah0KveUT2AATyy8fmPGbZoAfsEtLt5HA60innQYZnyM= -github.com/levigross/grequests v0.0.0-20180715163950-d0df86deffcb/go.mod h1:uCZIhROSrVmuF/BPYFPwDeiiQ6juSLp0kikFoEcNcEs= -github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= -github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= -github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= -github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= -github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= -github.com/orisano/pixelmatch v0.0.0-20210112091706-4fa4c7ba91d5 h1:1SoBaSPudixRecmlHXb/GxmaD3fLMtHIDN13QujwQuc= -github.com/orisano/pixelmatch v0.0.0-20210112091706-4fa4c7ba91d5/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -go.opentelemetry.io/otel v1.0.0-RC2 h1:SHhxSjB+omnGZPgGlKe+QMp3MyazcOHdQ8qwo89oKbg= -go.opentelemetry.io/otel v1.0.0-RC2/go.mod h1:w1thVQ7qbAy8MHb0IFj8a5Q2QU0l2ksf8u/CN8m3NOM= -go.opentelemetry.io/otel/oteltest v1.0.0-RC2/go.mod h1:kiQ4tw5tAL4JLTbcOYwK1CWI1HkT5aiLzHovgOVnz/A= -go.opentelemetry.io/otel/trace v1.0.0-RC2 h1:dunAP0qDULMIT82atj34m5RgvsIK6LcsXf1c/MsYg1w= -go.opentelemetry.io/otel/trace v1.0.0-RC2/go.mod h1:JPQ+z6nNw9mqEGT8o3eoPTdnNI+Aj5JcxEsVGREIAy4= -golang.org/x/net v0.0.0-20190110200230-915654e7eabc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20210520170846-37e1c6afe023 h1:ADo5wSpq2gqaCGQWzk7S5vd//0iyyLeAratkEoG5dLE= -golang.org/x/net v0.0.0-20210520170846-37e1c6afe023/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201207223542-d4d67f95c62d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210525143221-35b2ab0089ea h1:+WiDlPBBaO+h9vPNZi8uJ3k4BkKQB7Iow3aqwHVA5hI= -golang.org/x/sys v0.0.0-20210525143221-35b2ab0089ea/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/lib/API/main.go b/lib/API/main.go deleted file mode 100644 index 72aad54..0000000 --- a/lib/API/main.go +++ /dev/null @@ -1,125 +0,0 @@ -package main - -import ( - "C" - "bytes" - "context" - "github.com/gogf/gf/encoding/gjson" - "io/ioutil" - "log" - "net/http" - "os" - "strings" - - "github.com/chromedp/cdproto/network" - "github.com/chromedp/chromedp" - "github.com/gogf/gf/text/gregex" -) - -func main() { - // http.HandleFunc("/api", apiHandler) - // http.ListenAndServe(":9191", nil) - // go build -ldflags="-H windowsgui" - // go build -buildmode=c-shared -o ../../assets/steamdownload.dll -} - -// func apiHandler(w http.ResponseWriter, r *http.Request) { -// api := getAPI() -// fmt.Fprintf(w, api) -// } - -//export GetUUID -func GetUUID(url *C.char,fileid *C.char)*C.char{ - rawStr :="{\"publishedFileId\":"+fileid+",\"collectionId\":null,\"hidden\":false,\"downloadFormat\":\"raw\",\"autodownload\":false}" - resp,err:=http.Post(url,"application/x-www-form-urlencoded",bytes.NewBuffer([]byte(rawStr))) - defer resp.Body.Close() - if err != nil { - return C.CString("error") - } - s, err := ioutil.ReadAll(resp.Body) - if err != nil { - return C.CString("error") - } - var uuid string - if j, err := gjson.DecodeToJson(string(s)); err != nil { - return C.CString("error") - } else { - uuid = j.GetString("uuid") - } - return C.CString(uuid) -} - -//export GetAPI -func GetAPI() *C.char { // 导出的函数要首字大写 getAPI是错的 并且还需加上注释 //export GetAPI - - // 浏览主页 获取api - var apiUrl string - dir, err := ioutil.TempDir("", "chromedp-we") - if err != nil { - panic(err) - } - defer os.RemoveAll(dir) - - opts := append(chromedp.DefaultExecAllocatorOptions[:], - chromedp.DisableGPU, - chromedp.NoDefaultBrowserCheck, - chromedp.Flag("headless", true), - chromedp.Flag("ignore-certificate-errors", true), - chromedp.Flag("window-size", "400,400"), - chromedp.UserDataDir(dir), - ) - - allocCtx, cancel := chromedp.NewExecAllocator(context.Background(), opts...) - defer cancel() - - // also set up a custom logger - taskCtx, cancel := chromedp.NewContext(allocCtx, chromedp.WithLogf(log.Printf)) - defer cancel() - - // ensure that the browser process is started - if err := chromedp.Run(taskCtx); err != nil { - return C.CString("未安装Chrome") - } - //listenForNetworkEvent(taskCtx) - - chromedp.ListenTarget(taskCtx, func(ev interface{}) { - - switch ev := ev.(type) { - - case *network.EventResponseReceived: - resp := ev.Response - if len(resp.Headers) != 0 { - // log.Printf("received headers: %s", resp.Headers) - - if strings.Index(resp.URL, "/download/status") != -1 { - - RespURL, err := gregex.MatchString(`https://.+/api/`, resp.URL) - if err == nil { - apiUrl = RespURL[0] - } else { - - apiUrl = "ApiFailed" - } - // 等待几秒,也算是支持了作者,不至于被白嫖而不堪重负 - - // go func() { - // time.Sleep(time.Second * 5) - // cancel() - // }() - cancel() - - } - } - - } - // other needed network Event - }) - chromedp.Run(taskCtx, - network.Enable(), - chromedp.Navigate(`https://steamworkshopdownloader.io/`), - chromedp.WaitVisible(`body`, chromedp.BySearch), - ) - return C.CString(apiUrl) - -} - diff --git a/lib/main.dart b/lib/main.dart index cb00b64..32a3b95 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,40 +1,31 @@ -import 'dart:convert'; -import 'dart:ffi' as ffi; import 'dart:io'; -import 'package:archive/archive.dart'; -import 'package:dio/dio.dart'; -import 'package:ffi/ffi.dart'; import 'package:file_picker/file_picker.dart'; import 'package:flutter/material.dart'; -import 'package:http/http.dart' as http; +import 'package:process_run/shell.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:url_launcher/url_launcher.dart'; -void main() { +Future main() async { + // await Isolate.spawn((message) {getAPIforDLL();}, num); runApp(const MyApp()); } -typedef GOFunc = ffi.Pointer - Function(); // 这里调用go 函数 没有传入参数 https://www.kikt.top/posts/flutter/ffi/1-first-party/ -typedef GetURL = ffi.Pointer Function(); // 这里是操作的dart的返回接口 调用函数返回 string +// steamcmd +login anonymous +force_install_dir c:\steamcmd\csgoserver +app_update 740 validate +quit +// steamcmd +login AA BB +workshop_download_item 221100 1605653648 +quit // 上面两个必须是同一类型.... // E:\Flutter_project\wallpaper_engine_workshop_downloader\windows\runner\main.cpp 改名字 -String VerSion = "0010"; +String VerSion = "V020"; // List LogText = ["版本号:" + VerSion]; /// 第一步 定义 ValueNotifier List LogText = ["版本号:" + VerSion]; /// 第一步 定义 ValueNotifier ValueNotifier LogsNotifier = ValueNotifier(""); -String ApiURL = ""; -bool restartWE = false; + String wallpaper64 = ""; -bool autoOpenSteamWorkshop = false; -bool autoReDownFailed = false; -bool autoOpened = false; class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @@ -73,38 +64,21 @@ class MyHomePage extends StatefulWidget { TextEditingController urlController = TextEditingController(); class _MyHomePageState extends State { + final TextEditingController _nameController = TextEditingController(); + final TextEditingController _passwdController = TextEditingController(); + @override Widget build(BuildContext context) { - if (autoOpenSteamWorkshop == true && autoOpened == false) { - launchURL("https://steamworkshopdownloader.io/"); - autoOpened = true; - delayedSeconds(2).then((value) => - launchURL("https://steamcommunity.com/app/431960/workshop/")); - } + _launchUrl("https://steamcommunity.com/app/431960/workshop/"); return Scaffold( - // appBar: AppBar( - // title: const Text("Wallpaper Engine 壁纸一键下载"), - // ), body: Container( - padding: const EdgeInsets.all(5), + padding: const EdgeInsets.all(15), child: Column( // mainAxisSize: MainAxisSize.min, children: [ Row( //菜单栏 主要存放菜单数据 children: [ - TextButton( - child: const Text("壁纸资源网址"), - onPressed: () { - launchURL("https://steamcommunity.com/app/431960/workshop/"); - }, - ), - TextButton( - child: const Text("手动下载壁纸网址"), - onPressed: () { - launchURL("https://steamworkshopdownloader.io/"); - }, - ), FutureBuilder( future: getPreferences("wallpaper64.exe"), // initialData: InitialData, @@ -118,16 +92,16 @@ class _MyHomePageState extends State { allowedExtensions: ['exe'], ); // print(result!.files.single.name.toString()); - if (result != null) { - if (result.files.single.name.toString() == - "wallpaper64.exe") { - // obtain shared preferences - final prefs = await SharedPreferences.getInstance(); - prefs.setString('wallpaper64.exe', - result.files.single.path!.toString()); - - setState(() {}); - } + if (result != null && + result.files.single.name.toString() == + "wallpaper64.exe") { + // obtain shared preferences + final prefs = await SharedPreferences.getInstance(); + prefs.setString('wallpaper64.exe', + result.files.single.path!.toString()); + // 重新选择 壁纸路径之后重建软连接 + doLink(true); + setState(() {}); } }, icon: const Icon(Icons.favorite), @@ -138,126 +112,93 @@ class _MyHomePageState extends State { : "未选择wallpaper64.exe")); //此处是三元运算。 }, ), - FutureBuilder( - future: getAPIforDLL().then((value) { - // 得到结果后还是刷新下界面嘛 - setState(() {}); - }), - // initialData: const Text("正在获取API"), - builder: (BuildContext context, AsyncSnapshot snapshot) { - // snapshot 接收 future 返回的值 - return TextButton.icon( - onPressed: () async { - if (snapshot.data.toString() == "未安装Chrome") { - launchURL("https://www.iplaysoft.com/tools/chrome/"); - } - - //https://www.iplaysoft.com/tools/chrome/ - setState(() {}); - }, - icon: const Icon(Icons.laptop_chromebook), - label: Text(snapshot.data.toString() != "未安装Chrome" - ? "已安装Chrome" - : "已安装Chrome")); //此处是三元运算。 - }, - ), - ], - ), - Row( - children: [ - ElevatedButton.icon( - onPressed: () { - launchURL("https://shaoxia.xyz/"); - }, - icon: Icon(Icons.access_alarm_outlined), - label: Text("关于作者")), const SizedBox( - width: 5, + width: 20, ), ElevatedButton.icon( onPressed: () { - launchURL( + _launchUrl( "https://github.com/user1121114685/Wallpaper_Engine"); - // // getAPIforDLL(); - // setState(() {}); }, icon: const Icon(Icons.open_in_new_rounded), label: const Text("开源地址")), const SizedBox( - width: 5, + width: 20, ), - ElevatedButton.icon( - onPressed: () { - ApiURL = ""; - getAPIforDLL(); - setState(() {}); - }, - icon: const Icon(Icons.refresh), - label: const Text("重获api")) + // 因为需要建立软连接 所以需要管理员运行 + Text("首次使用 需要以管理员权限运行!",style:TextStyle( + color: Colors.red[200],fontSize: 23 + ),) ], ), + const SizedBox( + height: 20, + ), + const Divider( + // color: Colors.red, + ), Row( children: [ - const Text("自动打开壁纸资源网址"), - FutureBuilder( - future: getCheckBoxValue("autoOpenSteamWorkshop"), - // initialData: InitialData, - builder: (BuildContext context, AsyncSnapshot snapshot) { - // snapshot 接收 future 返回的值 - return Checkbox( - value: snapshot.data ?? false, - onChanged: (i) async { - // obtain shared preferences - final prefs = await SharedPreferences.getInstance(); - prefs.setBool('autoOpenSteamWorkshop', i!); - setState(() {}); - }); - }, + const Text("Steam账号:"), + SizedBox( + width: 110, + height: 30, + child: TextField( + controller: _nameController, + textInputAction: TextInputAction.done, + decoration: const InputDecoration( + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(width: 2, color: Colors.blue), + ))), + ), + const Text("Steam密码:"), + SizedBox( + width: 110, + height: 30, + child: TextField( + controller: _passwdController, + textInputAction: TextInputAction.done, + obscureText: true, + decoration: const InputDecoration( + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(width: 2, color: Colors.blue), + ))), ), const SizedBox( - width: 5, + width: 20, ), - const Text("自动重启Wallpaper Engine"), - FutureBuilder( - future: getCheckBoxValue("reStartWE"), - // initialData: InitialData, - builder: (BuildContext context, AsyncSnapshot snapshot) { - // snapshot 接收 future 返回的值 - return Checkbox( - value: snapshot.data ?? false, - onChanged: (i) async { - // obtain shared preferences - final prefs = await SharedPreferences.getInstance(); - prefs.setBool('reStartWE', i!); - setState(() {}); - }); - }, + ElevatedButton( + onPressed: () async { + // 将名字保存起来 + final prefs = await SharedPreferences.getInstance(); + prefs.setString('SteamPSWD', _passwdController.text); + prefs.setString('SteamName', _nameController.text); + }, + child: const Text("保存账号密码")), + const SizedBox( + width: 10, ), - // SizedBox( - // width: 5, - // ), - // Text("失败自动重下"), - // FutureBuilder( - // future: getCheckBoxValue("autoReDownFailed"), - // // initialData: InitialData, - // builder: (BuildContext context, AsyncSnapshot snapshot) { - // // snapshot 接收 future 返回的值 - // return Checkbox( - // value: snapshot.data ?? false, - // onChanged: (i) async { - // // obtain shared preferences - // final prefs = await SharedPreferences.getInstance(); - // prefs.setBool('autoReDownFailed', i!); - // setState(() {}); - // }); - // }, - // ), + ElevatedButton( + onPressed: () async { + // 将名字保存起来 + final prefs = await SharedPreferences.getInstance(); + + prefs.remove("SteamPSWD"); + prefs.remove("SteamName"); + }, + child: const Text("清除已保存的账号密码")), ], ), + const SizedBox( + height: 20, + ), + const Divider( + // color: Colors.blue, + ), Row( children: [ SizedBox( - width: 600, + width: 550, child: TextField( autofocus: true, controller: urlController, @@ -274,36 +215,82 @@ class _MyHomePageState extends State { fileid = fileid.substring(3); logTextAdd("ID正确 开始下载..."); - downlaodAndUnzip(fileid.toString()); + // 输入命令 } }, decoration: const InputDecoration( labelText: "输入下载地址(包含id=xxxxxxxx)", hintText: - " 例如 https://steamcommunity.com/sharedfiles/filedetails/?id=1289832516"), + " 例如 https://steamcommunity.com/sharedfiles/filedetails/?id=1289832516", + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(width: 2, color: Colors.blue), + )), ), ), + const SizedBox( + width: 20, + ), SizedBox( height: 50, child: ElevatedButton.icon( - onPressed: () { - RegExp exp = RegExp(r"id=\d+"); - var fileid = exp.stringMatch(urlController.text); + onPressed: () async { + final prefs = await SharedPreferences.getInstance(); - if (fileid == null) { - urlController.clear(); - logTextAdd("请输入正确的ID,连接包含id=xxxxxx"); + var passWD = prefs.get("SteamPSWD"); + var name = prefs.get("SteamName"); + + + if (name != null && passWD != null) { + RegExp exp = RegExp(r"id=\d+"); + var fileid = exp.stringMatch(urlController.text); + + if (fileid == null) { + urlController.clear(); + logTextAdd("请输入正确的ID,连接包含id=xxxxxx"); + } else { + fileid = fileid.substring(3); + logTextAdd("ID正确 开始下载..."); + logTextAdd( + "首次使用Steam 可能需要验证码验证,提示 Steam Guard code: 如果看见此提示 请查看邮箱验证码输入..."); + + + Future _downItem()async{ + // 输入命令 + // steamcmd +login 名字 密码 +force_install_dir Z:\ +workshop_download_item 431960 2798955847 +quit + String run_dir = Directory.current.path; + var script = + "$run_dir\\data\\flutter_assets\\assets\\steamcmd\\steamcmd.exe +login $name $passWD +workshop_download_item 431960 $fileid +quit"; + // var script ="./data/flutter_assets/assets/steamcmd/steamcmd.exe +force_install_dir "+"Z:\\"+" +login "+name.toString()+" "+passWD.toString()+" +workshop_download_item 431960 "+fileid+" +quit"; + var shell = Shell(); + await shell + .run("cmd /c start $script"); + } + doLink(false).then((value) async { + logTextAdd("开始下载 $fileid"); +_downItem() + .then((value) { + urlController.clear(); + logTextAdd("已完成 $fileid 下载"); +// 准备做 自动打开 感觉没必要 就删了 + }); + }); + } } else { - fileid = fileid.substring(3); - logTextAdd("ID正确 开始下载..."); - - downlaodAndUnzip(fileid.toString()); + logTextAdd( + "请先输入Steam账号密码,并且该账号已经购买了Wallpaper Engine"); + logTextAdd( + "请先输入Steam账号密码,并且该账号已经购买了Wallpaper Engine"); + logTextAdd( + "请先输入Steam账号密码,并且该账号已经购买了Wallpaper Engine"); } }, icon: const Icon(Icons.download), label: const Text("下载壁纸"))), ], ), + const SizedBox( + height: 20, + ), ValueListenableBuilder( valueListenable: LogsNotifier, builder: (context, value, child) { @@ -332,269 +319,6 @@ Future getPreferences(String keyword) async { return prefs.getString(keyword).toString(); } -Future getCheckBoxValue(String keyword) async { - final prefs = await SharedPreferences.getInstance(); - if (keyword == "reStartWE") { - restartWE = prefs.getBool(keyword)!; - } -// Try reading data from the counter key. If it doesn't exist, return 0. - if (keyword == "autoOpenSteamWorkshop") { - autoOpenSteamWorkshop = prefs.getBool(keyword)!; - } - //autoReDownFailed - if (keyword == "autoReDownFailed") { - autoReDownFailed = prefs.getBool(keyword)!; - } - return prefs.getBool(keyword); -} - -void launchURL(String url) async => - await canLaunch(url) ? await launch(url) : throw 'Could not launch $url'; - -// Future getAPIurl() async { -// Directory tempDir = await getTemporaryDirectory(); -// String tempPath = tempDir.path; -// print(tempPath); -// await Process.run( -// "E:\\Flutter_project\\wallpaper_engine_workshop_downloader\\lib\\API\\steamdownload.exe", -// []).then((value) async { -// try { -// var resp = await Dio().get("http://127.0.0.1:9191/api"); -// logTextAdd(resp.toString()); - -// ApiURL = resp.toString(); -// } catch (e) { -// print(e); -// } -// }); - -// print(LogText); -// } - -Future getAPIforDLL() async { - if (ApiURL == "") { - var dll = ffi.DynamicLibrary.open( - r'data/flutter_assets/assets/steamdownload.dll'); - // 下面是调试代码 - // var dll = ffi.DynamicLibrary.open( - // r'assets/steamdownload.dll'); -// 把我弄不会了,日了。。。。 看来只能修改pubspec.yaml 这样与实际的不一致的地方了 -// 你以为我想放这里吗?编译的时候直接放进去了。。。data\flutter_assets\assets\steamdownload.dll - // https://www.coder.work/article/7192255 重要得参考 FFI得使用 - // GOLANG中 导出的函数要首字大写 getAPI是错的 并且还需加上注释 //export GetAPI - final GetURL geturl = - dll.lookup>('GetAPI').asFunction(); - var url = geturl(); - - logTextAdd("找到了API " + url.cast().toDartString()); - if (url.cast().toDartString() != "未安装Chrome") { - ApiURL = url.cast().toDartString(); - } - - return url.cast().toDartString(); - } -} - -Future downlaodAndUnzip(String fileid) async { - // String wallpaper64 = getPreferences("wallpaper64.exe").toString(); - if (wallpaper64 != "null") { - try { - // 向服务器发送下载请求 常量与变量才使用+连接,常量与常量可以直接连接 -// https://node04.steamworkshopdownloader.io/prod/api/download/request - // {"publishedFileId":2672939813,"collectionId":null,"hidden":false,"downloadFormat":"raw","autodownload":false} - // List byte = utf8.encode(); - Map idmap = { - "publishedFileId": fileid, - "collectionId": "null", - "hidden": "false", - "downloadFormat": "raw", - "autodownload": "false" - }; - - var postData = "{\"publishedFileId\":" + - fileid + - ",\"collectionId\":null,\"hidden\":false,\"downloadFormat\":raw,\"autodownload\":false}"; - var body = json.encode(postData); - - // var resp = await Dio().post(ApiURL + "download/request", - // data: Stream.value(idmap), - // options: Options( - // headers: {"content-type": "application/x-www-form-urlencoded"})); - - // var request = - // http.Request('POST', Uri.parse(ApiURL + "download/request")); - // request.body = "{\"publishedFileId\":" + - // fileid + - // ",\"collectionId\":null,\"hidden\":false,\"downloadFormat\":raw,\"autodownload\":false}"; - // 得到返回的UUID -// {"uuid":"07e15f2f-c4e2-44f3-a424-f367f1d3c961"} -// {"uuid":"7d866a3d-c948-4c3d-a940-40ef36a6580c"} - - var response = - await http.post(Uri.parse(ApiURL + "download/request"), body: body); - - Map uuid = - jsonDecode(response.body); // 简单的序列化下返回的Json 关键点为 索引的UUID 为string - //resp.data["uuid"]; - String newuuid = uuid["uuid"]; - //查询服务器下载状态 - bool addProgress = false; - while (true) { - try { - Response status = await Dio().post(ApiURL + "download/status", - data: "{\"uuids\":[\"" + newuuid + "\"]}"); - // 返回下载进度 - //{"07e15f2f-c4e2-44f3-a424-f367f1d3c961":{"age":6,"status":"retrieved","progress":100,"progressText":"retrieving: 100%","downloadError":"never transmitted"}} - Map serverStatus = jsonDecode(status.data); - // print(serverStatus[newuuid]["progressText"]); - - if (serverStatus[newuuid]["progressText"] - .toString() - .contains("failed")) { - //包含 failed 下载失败 - logTextAdd(fileid + " 下载失败"); - - break; - } - // print("object"); - // print("下载进度" + serverStatus[newuuid]["progress"]); - if (serverStatus[newuuid]["progress"] > 150) { - logTextAdd(fileid + " 服务器下载成功...开始下载到本地"); - break; - } - // 还是为了直观好看 只显示一行log - if (addProgress == false) { - logTextAdd(fileid + - " 服务器下载进度" + - serverStatus[newuuid]["progress"].toString() + - "%"); - addProgress = true; - } else { - String log = fileid + - " 服务器下载进度" + - serverStatus[newuuid]["progress"].toString() + - "%"; - LogText[0] = log; - LogsNotifier.value = log; - } - } catch (e) { - logTextAdd("服务器下载错误 " + e.toString()); - } - await delayedSeconds(1); - } - // 获取下载路径 - String dlDir = await getPreferences("wallpaper64.exe"); - dlDir = dlDir.replaceAll("wallpaper64.exe", ""); - // 文件下载信息 -// https://node03.steamworkshopdownloader.io/prod/api/details/file -// 存放 文件大小 - String fileSize = ""; - try { - Response detail = - await Dio().post(ApiURL + "details/file", data: "[" + fileid + "]"); - List fileDetails = jsonDecode(detail.data); - fileSize = fileDetails[0]["file_size"].toString(); - if (fileSize != "") { - fileSize = - "/" + (int.parse(fileSize) / 1048576).toStringAsFixed(2) + "M"; - } - } catch (e) { - logTextAdd("获取文件信息错误 " + e.toString()); - } - -// 是否已经单独添加一行log? - bool addDownloadlog = false; - await downloadWithAria2( - ApiURL + "download/transmit?uuid=" + newuuid, fileid, dlDir); - // await Dio().download( - // ApiURL + "download/transmit?uuid=" + newuuid, dlDir + fileid + ".zip", - // // options: Options(//下载提速尝试 - // // headers: { - // // "referer": "https://steamworkshopdownloader.io", - // // "sec-ch-ua-platform": "\"Windows\"", - // // "sec-ch-ua-mobile": "?0", - // // "Cookie": - // // "_ga=GA1.2.1102444544.1607616183; __gads=ID=7021e42601a47098-2226edcc41c50074:T=1607616184:RT=1607616184:S=ALNI_MYHNpqo-R1v2yp7NzmSs0cdEGCKAQ; usprivacy=1YNN; _gid=GA1.2.2059147179.1637834067; cto_bundle=1GLoHl9MWFFzUWh4UXlZVDlwbWRITGJsajBqSVZwJTJGRU5pY0lCd0JXb1d1a1dtS05zY2tXc0k3N1M5OXBwVDA1cWRBR2dRTVBuV2xyUnkwdSUyRjRhWmZFR2FzVHlvNElCaVhUektiVllZSG56c3k2SldFVjZ1OVVVT3FSOTdXZE91U1Y5cG9Ia1FBOGdUYWk2QkNmJTJCUTZPODRwd3NNbEJnNGY4Q0p3UFJCbE56UXhKJTJGdyUzRA; _gat=1", - // // "upgrade-insecure-requests": "1", - // // "dnt": "1", - // // "sec-fetch-site": "same-site", - // // "sec-fetch-mode": "navigate", - // // "sec-fetch-user": "?1", - // // "sec-fetch-dest": "document", - // // "sec-ch-ua": - // // "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"96\", \"Google Chrome\";v=\"96\"", - // // "user-agent": - // // "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36" - // // }), - // onReceiveProgress: (int cont, int _) { - // if (addDownloadlog == true) { - // String log = fileid + - // " 已下载 " + - // (cont / 1048576).toStringAsFixed(2) + - // "M" + - // fileSize; - // LogText[0] = log; - // LogsNotifier.value = log; - // } else { - // logTextAdd(fileid + - // " 已下载 " + - // (cont / 1048576).toStringAsFixed(2) + - // "M" + - // fileSize); - // addDownloadlog = true; - // } - // }); - - logTextAdd("下载完成开始解压....."); - // 解压文件 - // Read the Zip file from disk. - final bytes = File(dlDir + fileid + ".zip").readAsBytesSync(); - - // Decode the Zip file - final archive = ZipDecoder().decodeBytes(bytes); - - // Extract the contents of the Zip archive to disk. - for (final file in archive) { - final filename = file.name; - if (file.isFile) { - logTextAdd( - "正在解压 /projects/defaultprojects/" + fileid + "/" + filename); - final data = file.content as List; - File(dlDir + "/projects/defaultprojects/" + fileid + "/" + filename) - ..createSync(recursive: true) - ..writeAsBytesSync(data); - } else { - Directory(dlDir + - "/projects/defaultprojects/" + - fileid + - "/" + - filename) - .create(recursive: true); - } - } - logTextAdd("已解压完成....."); - //清空输入框 - urlController.clear(); - // 删除临时文件 - File tmpFile = File(dlDir + fileid + ".zip"); - tmpFile.deleteSync(); - // 重启 we软件 - - if (restartWE == true) { - Process.run("taskkill", ["/F", "/IM", "wallpaper64.exe"]) - .then((s) async { - await Process.run(wallpaper64, []); - await delayedSeconds(2).then((value) async { - await Process.run(wallpaper64, []); - }); - }); - } - } catch (e) {} - } else { - logTextAdd("请先选择wallpaper64.exe"); - } -} - Future delayedSeconds(int second) async { await Future.delayed(Duration(seconds: second)); } @@ -606,8 +330,62 @@ Future logTextAdd(String log) async { LogsNotifier.value = log; } -Future downloadWithAria2(String url, String fileID, String dlDIR) async { - await Process.run(r'data/flutter_assets/assets/aria2c.exe', - [url, "-o " + dlDIR + fileID + ".zip"]).then((value) => print("下载成功")); - await Process.run(wallpaper64, []); +void _launchUrl(String url_string) async { + var url = Uri.parse(url_string); + if (!await launchUrl(url)) throw 'Could not launch $url'; +} + +Future doLink(bool relink) async { + //创建链接 https://www.daimajiaoliu.com/daima/479885188100403 + //Link的参数为该链接的Path,create的参数为链接的目标文件夹 + // 获取应用目录 + // String run_dir = (await getApplicationDocumentsDirectory()).path; + String run_dir = Directory.current.path; + + String dlDir = await getPreferences("wallpaper64.exe"); + dlDir = dlDir.replaceAll("wallpaper64.exe", ""); + + +// 这里有问题 不能判断到底是不是 文件夹 连接同样认定为文件夹 + Future _delDir()async{ + var directory_431960 = Directory( + "$run_dir\\data\\flutter_assets\\assets\\steamcmd\\steamapps\\workshop\\content\\431960"); + var exists = await directory_431960.exists(); + if (exists == true) { + // 如果文件夹存在就删除 + logTextAdd("431960文件夹删除中...."); + directory_431960.delete(recursive: true); + } + } + + Future _check_431960() async { + + var file_431960 = File( + "$run_dir\\data\\flutter_assets\\assets\\steamcmd\\steamapps\\workshop\\content\\431960"); + FileSystemEntityType type = FileSystemEntity.typeSync(file_431960.path,followLinks: false); + + var exists = await file_431960.exists(); + if (exists == false&&type.toString()!="link") { + // 如果不存在就创建 连接 + _delDir().then((value) => logTextAdd("431960 连接创建中....")); + + + } else { + // 如果需要重建 + if (relink) { + // 存在 就删除后重新创建 + logTextAdd("431960连接重建中...."); + file_431960.delete(); + + } + } + } + + + _check_431960().then((value){ + Link("$run_dir\\data\\flutter_assets\\assets\\steamcmd\\steamapps\\workshop\\content\\431960").create("$dlDir\\projects\\defaultprojects\\",recursive: true).then((value) =>logTextAdd("连接已建立完毕....") ); + + } ); //建立连接 + + } diff --git a/old/go.mod b/old/go.mod deleted file mode 100644 index 3440fe1..0000000 --- a/old/go.mod +++ /dev/null @@ -1,27 +0,0 @@ -module steamdownload - -go 1.17 - -require ( - github.com/chromedp/cdproto v0.0.0-20211205231339-d2673e93eee4 - github.com/chromedp/chromedp v0.7.6 - github.com/dustin/go-humanize v1.0.0 - github.com/gogf/gf v1.16.6 -) - -require ( - github.com/BurntSushi/toml v0.3.1 // indirect - github.com/chromedp/sysutil v1.0.0 // indirect - github.com/clbanning/mxj v1.8.5-0.20200714211355-ff02cfb8ea28 // indirect - github.com/fsnotify/fsnotify v1.4.9 // indirect - github.com/gobwas/httphead v0.1.0 // indirect - github.com/gobwas/pool v0.2.1 // indirect - github.com/gobwas/ws v1.1.0 // indirect - github.com/josharian/intern v1.0.0 // indirect - github.com/mailru/easyjson v0.7.7 // indirect - go.opentelemetry.io/otel v1.0.0-RC2 // indirect - go.opentelemetry.io/otel/trace v1.0.0-RC2 // indirect - golang.org/x/sys v0.0.0-20211124211545-fe61309f8881 // indirect - golang.org/x/text v0.3.6 // indirect - gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect -) diff --git a/old/go.sum b/old/go.sum deleted file mode 100644 index a7968cd..0000000 --- a/old/go.sum +++ /dev/null @@ -1,83 +0,0 @@ -github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/chromedp/cdproto v0.0.0-20211126220118-81fa0469ad77/go.mod h1:At5TxYYdxkbQL0TSefRjhLE3Q0lgvqKKMSFUglJ7i1U= -github.com/chromedp/cdproto v0.0.0-20211205231339-d2673e93eee4 h1:St4rQbn3gGWL59ygb4NBxchIeAIW0CTz5Kw4m5JTemU= -github.com/chromedp/cdproto v0.0.0-20211205231339-d2673e93eee4/go.mod h1:At5TxYYdxkbQL0TSefRjhLE3Q0lgvqKKMSFUglJ7i1U= -github.com/chromedp/chromedp v0.7.6 h1:2juGaktzjwULlsn+DnvIZXFUckEp5xs+GOBroaea+jA= -github.com/chromedp/chromedp v0.7.6/go.mod h1:ayT4YU/MGAALNfOg9gNrpGSAdnU51PMx+FCeuT1iXzo= -github.com/chromedp/sysutil v1.0.0 h1:+ZxhTpfpZlmchB58ih/LBHX52ky7w2VhQVKQMucy3Ic= -github.com/chromedp/sysutil v1.0.0/go.mod h1:kgWmDdq8fTzXYcKIBqIYvRRTnYb9aNS9moAV0xufSww= -github.com/clbanning/mxj v1.8.5-0.20200714211355-ff02cfb8ea28 h1:LdXxtjzvZYhhUaonAaAKArG3pyC67kGL3YY+6hGG8G4= -github.com/clbanning/mxj v1.8.5-0.20200714211355-ff02cfb8ea28/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng= -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= -github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/fatih/color v1.12.0 h1:mRhaKNwANqRgUBGKmnI5ZxEk7QXmjQeCcuYFMX2bfcc= -github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= -github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= -github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= -github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= -github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU= -github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM= -github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og= -github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= -github.com/gobwas/ws v1.1.0 h1:7RFti/xnNkMJnrK7D1yQ/iCIB5OrrY/54/H930kIbHA= -github.com/gobwas/ws v1.1.0/go.mod h1:nzvNcVha5eUziGrbxFCo6qFIojQHjJV5cLYIbezhfL0= -github.com/gogf/gf v1.16.6 h1:Yp5YfwnGz41d1tiVqxcWXiPXyuzjTb7ax4SnPSXxDE8= -github.com/gogf/gf v1.16.6/go.mod h1:4LoHfEBl2jbVmZpVx+qk2La3zWr1V315FtF2PVZuyQ8= -github.com/gomodule/redigo v1.8.5 h1:nRAxCa+SVsyjSBrtZmG/cqb6VbTmuRzpg/PoTFlpumc= -github.com/gomodule/redigo v1.8.5/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0= -github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= -github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/grokify/html-strip-tags-go v0.0.0-20190921062105-daaa06bf1aaf h1:wIOAyJMMen0ELGiFzlmqxdcV1yGbkyHBAB6PolcNbLA= -github.com/grokify/html-strip-tags-go v0.0.0-20190921062105-daaa06bf1aaf/go.mod h1:2Su6romC5/1VXOQMaWL2yb618ARB8iVo6/DR99A6d78= -github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= -github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= -github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= -github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= -github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= -github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= -github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= -github.com/orisano/pixelmatch v0.0.0-20210112091706-4fa4c7ba91d5 h1:1SoBaSPudixRecmlHXb/GxmaD3fLMtHIDN13QujwQuc= -github.com/orisano/pixelmatch v0.0.0-20210112091706-4fa4c7ba91d5/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -go.opentelemetry.io/otel v1.0.0-RC2 h1:SHhxSjB+omnGZPgGlKe+QMp3MyazcOHdQ8qwo89oKbg= -go.opentelemetry.io/otel v1.0.0-RC2/go.mod h1:w1thVQ7qbAy8MHb0IFj8a5Q2QU0l2ksf8u/CN8m3NOM= -go.opentelemetry.io/otel/oteltest v1.0.0-RC2/go.mod h1:kiQ4tw5tAL4JLTbcOYwK1CWI1HkT5aiLzHovgOVnz/A= -go.opentelemetry.io/otel/trace v1.0.0-RC2 h1:dunAP0qDULMIT82atj34m5RgvsIK6LcsXf1c/MsYg1w= -go.opentelemetry.io/otel/trace v1.0.0-RC2/go.mod h1:JPQ+z6nNw9mqEGT8o3eoPTdnNI+Aj5JcxEsVGREIAy4= -golang.org/x/net v0.0.0-20210520170846-37e1c6afe023 h1:ADo5wSpq2gqaCGQWzk7S5vd//0iyyLeAratkEoG5dLE= -golang.org/x/net v0.0.0-20210520170846-37e1c6afe023/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201207223542-d4d67f95c62d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20211124211545-fe61309f8881 h1:TyHqChC80pFkXWraUUf6RuB5IqFdQieMLwwCJokV2pc= -golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/old/main.go b/old/main.go deleted file mode 100644 index f428e7b..0000000 --- a/old/main.go +++ /dev/null @@ -1,435 +0,0 @@ -package main - -import ( - "archive/zip" - "bytes" - "context" - "fmt" - "io" - "io/ioutil" - "log" - "net/http" - "os" - "os/exec" - "path/filepath" - "strconv" - "strings" - "time" - - "github.com/chromedp/cdproto/network" - "github.com/chromedp/chromedp" - "github.com/gogf/gf/encoding/gjson" - "github.com/gogf/gf/text/gregex" - "github.com/gogf/gf/text/gstr" -) - -// ReDownloadLink 下载失败重下地址 全局存放 -var ReDownloadLink = "" -var storageNode="" -var storagePath="" -var file_size="未知大小" -func UnZip(dst, src string) (err error) { - // 打开压缩文件,这个 zip 包有个方便的 ReadCloser 类型 - // 这个里面有个方便的 OpenReader 函数,可以比 tar 的时候省去一个打开文件的步骤 - zr, err := zip.OpenReader(src) - defer zr.Close() - if err != nil { - return - } - - // 如果解压后不是放在当前目录就按照保存目录去创建目录 - if dst != "" { - if err := os.MkdirAll(dst, 0755); err != nil { - return err - } - } - - // 遍历 zr ,将文件写入到磁盘 - for _, file := range zr.File { - path := filepath.Join(dst, file.Name) - - // 如果是目录,就创建目录 - if file.FileInfo().IsDir() { - if err := os.MkdirAll(path, file.Mode()); err != nil { - return err - } - // 因为是目录,跳过当前循环,因为后面都是文件的处理 - continue - } - - // 获取到 Reader - fr, err := file.Open() - if err != nil { - return err - } - - // 创建要写出的文件对应的 Write - fw, err := os.OpenFile(path, os.O_CREATE|os.O_RDWR|os.O_TRUNC, file.Mode()) - if err != nil { - return err - } - - n, err := io.Copy(fw, fr) - if err != nil { - return err - } - - // 将解压的结果输出 - fmt.Printf("成功解压 %s ,共写入了 %d 个字符的数据\n", path, n) - - // 因为是在循环中,无法使用 defer ,直接放在最后 - // 不过这样也有问题,当出现 err 的时候就不会执行这个了, - // 可以把它单独放在一个函数中,这里是个实验,就这样了 - fw.Close() - fr.Close() - } - return nil -} - -// 下载进度 -type WriteCounter struct { - Total uint64 -} - -func (wc *WriteCounter) Write(p []byte) (int, error) { - n := len(p) - wc.Total += uint64(n) - wc.PrintProgress() - return n, nil -} - -// 下载进度 -func (wc WriteCounter) PrintProgress() { - fmt.Printf("\r%s", strings.Repeat(" ", 35)) - // Format to a string by passing the number and it's base. - // fmt.Sprintf("%.2f",float64(sizeIntVar)/1048576 )+"M" - fmt.Printf("\r正在下载... %sM/ %s", fmt.Sprintf("%.2f",float64(wc.Total)/1048576),file_size) -} - -func DownloadFile(filepath string, url string) error { - out, err := os.Create(filepath + ".tmp") - if err != nil { - return err - } - resp, err := http.Get(url) - if err != nil { - out.Close() - return err - } - defer resp.Body.Close() - counter := &WriteCounter{} - if _, err = io.Copy(out, io.TeeReader(resp.Body, counter)); err != nil { - out.Close() - return err - } - fmt.Print("\n") - out.Close() - if err = os.Rename(filepath+".tmp", filepath); err != nil { - return err - } - return nil -} - -// 下载及解压 -func downloadAndUnzip(url string, fileID string ) { - - fmt.Println("Download Started " + url) - - err := DownloadFile("./"+fileID+".zip", url) - if err != nil { - panic(err) - } - - fmt.Println("下载完成 " + url) - // 文件下载 后通过大小判断 是否失败 - fi, err := os.Stat("./" + fileID + ".zip") - if err == nil { - fmt.Println("校验下载的文件大小为",fmt.Sprintf("%.2f",float64( fi.Size())/1048576),"M") - } - filesize, _ := strconv.ParseInt(fmt.Sprint(fi.Size()), 10, 64) - // progress, _ = strconv.ParseInt(j.GetString(uuid+".progress"), 10, 64) - // 如果压缩包小于1M 就不解压 - if filesize < int64(5120) { - log.Fatalln("文件下载出错(小于512k),请重新下载.....") - var exitScan string - _, _ = fmt.Scan(&exitScan) - } - - // 解压 - if err := UnZip("./projects/defaultprojects/"+fileID, "./"+fileID+".zip"); err != nil { - log.Fatalln(err) - } - err = os.Remove("./" + fileID + ".zip") //删除残留 刚才下载并且解压的的zip - - if err != nil { - log.Fatalln(err) - } -} - -//监听 -func listenForMain(APIUrl string, ReDownLink string) { - // 等待用户输入 - var Link string - - // fmt.Println("当前平台 " + runtime.GOOS) - if ReDownLink == "" { - for { - fmt.Println("请输入包含ID的连接(可 鼠标右键粘贴):") - //当程序只是到fmt.Scanln(&name)程序会停止执行等待用户输入 - fmt.Scanln(&Link) -//Link="https://steamcommunity.com/sharedfiles/filedetails/?id=2650911143&searchtext=" - //Link = "https://steamcommunity.com/sharedfiles/filedetails/?id=2332307710&searchtext=" - //ReDownloadLink = Link - if !gstr.ContainsI(Link, "https://") { - fmt.Println("不是正确的https ID连接,例如 https://steamcommunity.com/sharedfiles/filedetails/?id=2309314482") - continue - } - if !gstr.ContainsI(Link, "?id=") { - fmt.Println("连接不包含ID,例如 https://steamcommunity.com/sharedfiles/filedetails/?id=2309314482") - continue - } - break - } - } else { - // 先将变量放入ReDownloadLink 节约代码 再将ReDownloadLink 还原到默认值。 - fmt.Println("") - fmt.Println("=======即将开始重新下载============") - time.Sleep(time.Second * 6) - Link = ReDownLink - ReDownloadLink = "" - } - - fileID, _ := gregex.MatchString(`id=\d+`, Link) - - fileID, _ = gregex.MatchString(`\d+`, fileID[0]) - fmt.Println("下载的连接的ID是" + fileID[0]) - rawStr :="{\"publishedFileId\":"+fileID[0]+",\"collectionId\":null,\"hidden\":false,\"downloadFormat\":\"raw\",\"autodownload\":false}" - //rawStr := "{" + "\"publishedFileId\":" + fileID[0] + "," + "\"collectionId\":null,\"extract\":true,\"hidden\":false,\"direct\":false,\"autodownload\":false" + "}" - var jsonStr = []byte(rawStr) - r, e := http.NewRequest("POST", APIUrl+"download/request", bytes.NewBuffer(jsonStr)) - - client := &http.Client{} - resp, err := client.Do(r) - if err != nil { - panic(err) - } - defer resp.Body.Close() - - if e != nil { - panic(e) - } else { - // {"uuid":"734f5478-7b66-49df-a6a0-ddbdf4106d61"} - - s, _ := ioutil.ReadAll(resp.Body) //把 body 内容读入字符串 s - fmt.Println(string(s)) - var uuid string - if j, err := gjson.DecodeToJson(string(s)); err != nil { - panic(err) - } else { - uuid = j.GetString("uuid") - } - // 判断是否完成 等进度是100 以上 200 这种才开始结束 - //https://api_01.steamworkshopdownloader.io/api/download/status - // {"uuids":["6df0dc8a-4ccd-4fd2-8532-3c933df4dc80"]} - var progress int64 = 0 - - for progress < int64(100) { - time.Sleep(time.Second * 1) - rawStr = "{\"uuids\":[\"" + uuid + "\"]}" - var jsonStr = []byte(rawStr) - r, e = http.NewRequest("POST", APIUrl+"download/status", bytes.NewBuffer(jsonStr)) - - client = &http.Client{} - - resp, err := client.Do(r) - if err != nil { - panic(err) - } - defer resp.Body.Close() - - s, _ = ioutil.ReadAll(resp.Body) //把 body 内容读入字符串 s - fmt.Println(string(s)) - j, err := gjson.DecodeToJson(string(s)) - if err != nil { - panic(err) - } - progress, _ = strconv.ParseInt(j.GetString(uuid+".progress"), 10, 64) - - if strings.Index(j.GetString(uuid+".progressText"), "failed") != -1 { - // 服务端下载失败 - fmt.Println("服务器端下载失败 稍后后重试。 ") - fmt.Println("请复制原始Link 开始重新下载(即将重试) " + Link) - - ReDownloadLink = Link - break //跳出 上级for循环 for progress < int64(150) { - } - fmt.Println("服务器下载进度 " + strconv.FormatInt(progress, 10)) - // {"820a3912-91f3-4174-9edd-40676a1559f4":{"age":76,"status":"error","progress":0,"progressText":"download failed: no steam client available, try again in a minute","downloadError":"never transmitted"}} - - if progress >= int64(100){ - r, e = http.NewRequest("POST", APIUrl+"download/status", bytes.NewBuffer(jsonStr)) - - client = &http.Client{} - - resp, err := client.Do(r) - if err != nil { - panic(err) - } - defer resp.Body.Close() - s, _ = ioutil.ReadAll(resp.Body) //把 body 内容读入字符串 s - fmt.Println(string(s)) - j, err := gjson.DecodeToJson(string(s)) - if err != nil { - panic(err) - } - storageNode=j.GetString(uuid+".storageNode") - storagePath=j.GetString(uuid+".storagePath") - } - } - // 如果服务器没有下载失败,则开始下载 - if ReDownloadLink == "" { -// https://node03.steamworkshopdownloader.io/prod//storage/784150/2002476771/1605174013/2002476771_road_sign_pack.raw.download.zip?uuid=18e11061-dd7c-4bad-a926-4731c36f6dec - fileDownload := "https://"+storageNode + "/prod/storage/"+storagePath+"?uuid="+uuid - // var jsonStr = - r, e = http.NewRequest("POST", APIUrl+"details/file", bytes.NewBuffer([]byte("["+fileID[0]+"]"))) - - client = &http.Client{} - - resp, err := client.Do(r) - if err != nil { - panic(err) - } - defer resp.Body.Close() - s, _ = ioutil.ReadAll(resp.Body) //把 body 内容读入字符串 s - fmt.Println(string(s)) - j, err := gjson.DecodeToJson(string(s)) - if err != nil { - fmt.Println(err) - - } - - - size:=j.GetString("0.file_size")// 1048576 - sizeIntVar, err := strconv.Atoi(size) - if err != nil { - file_size="获取大小出错" - }else { - - file_size=fmt.Sprintf("%.2f",float64(sizeIntVar)/1048576 )+"M" - } - downloadAndUnzip(fileDownload, fileID[0]) - } - } - -} - - - -func Decimal(value float64) float64 { - value, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", value), 64) - return value -} - -func main() { - - // 判断版本更新 - - // 判断是否在正确的文件夹下 - _, err := os.Lstat("./wallpaper64.exe") - if err != nil { - fmt.Println("当前目录下没有 wallpaper64.exe ,请将本程序放入 wallpaper64.exe 同目录下运行。") - var exitScan string - _, _ = fmt.Scan(&exitScan) - os.Exit(1) - } - // 友情提示 - println("Wallpaper Engine资源位置 https://steamcommunity.com/app/431960/workshop/") - // 自动弹出资源网页,免得手动复制。。。。 懒出新高度 - exec.Command(`cmd`, `/c`, `start`, `https://steamcommunity.com/app/431960/workshop/`).Start() - println("下载网站 1 https://steamworkshopdownloader.io/") - println("") - println("正在使用Chrome获取API......") - // 浏览主页 获取api - var APIUrl string - dir, err := ioutil.TempDir("", "chromedp-example") - if err != nil { - panic(err) - } - defer os.RemoveAll(dir) - - opts := append(chromedp.DefaultExecAllocatorOptions[:], - chromedp.DisableGPU, - chromedp.NoDefaultBrowserCheck, - chromedp.Flag("headless", true), - chromedp.Flag("ignore-certificate-errors", true), - chromedp.Flag("window-size", "400,400"), - chromedp.UserDataDir(dir), - ) - - allocCtx, cancel := chromedp.NewExecAllocator(context.Background(), opts...) - defer cancel() - - // also set up a custom logger - taskCtx, cancel := chromedp.NewContext(allocCtx, chromedp.WithLogf(log.Printf)) - defer cancel() - - // ensure that the browser process is started - if err := chromedp.Run(taskCtx); err != nil { - panic(err) - } - //listenForNetworkEvent(taskCtx) - - chromedp.ListenTarget(taskCtx, func(ev interface{}) { - switch ev := ev.(type) { - - case *network.EventResponseReceived: - resp := ev.Response - if len(resp.Headers) != 0 { - // log.Printf("received headers: %s", resp.Headers) - - if strings.Index(resp.URL, "/download/status") != -1 { - fmt.Println("找到API啦!! " + resp.URL) - - RespURL, err := gregex.MatchString(`https://.+/api/`, resp.URL) - if err == nil { - APIUrl = RespURL[0] - } else { - fmt.Println("API 提取错误。。 请GitHub联系 " + resp.URL) - println("软件开源地址:https://github.com/user1121114685/Wallpaper_Engine") - var exitScan string - _, _ = fmt.Scan(&exitScan) - } - cancel() - } - } - - } - // other needed network Event - }) - chromedp.Run(taskCtx, - network.Enable(), - chromedp.Navigate(`https://steamworkshopdownloader.io/`), - chromedp.WaitVisible(`body`, chromedp.BySearch), - ) - for { - listenForMain(APIUrl, ReDownloadLink) - // 当不需要重下的时候 才开始重启 - if ReDownloadLink == "" { - // 自动重启壁纸软件 - exec.Command(`taskkill`, `/F`, `/IM`, `wallpaper64.exe`).Run() - dir, _ := os.Getwd() - //fmt.Println("当前路径:", dir) - exec.Command(dir + `\wallpaper64.exe`).Start() - time.Sleep(time.Second * 2) - exec.Command(dir + `\wallpaper64.exe`).Start() - //exec.Command(`start`, dir+`\wallpaper64.exe`).Run() - println("") - println("软件开源地址:https://github.com/user1121114685/Wallpaper_Engine") - println("执行完毕........已重启 Wallpaper Engine (如遇未运行,请手动打开).....") - println("") - println("........本软件可以多开,不需要等等下载完成.....") - println("") - } - } - -} \ No newline at end of file diff --git a/old/steamdownload.exe b/old/steamdownload.exe deleted file mode 100644 index 0a89fba..0000000 Binary files a/old/steamdownload.exe and /dev/null differ diff --git a/old/steamdownload.zip b/old/steamdownload.zip deleted file mode 100644 index 51dc17b..0000000 Binary files a/old/steamdownload.zip and /dev/null differ diff --git a/old/wallpaper64.exe b/old/wallpaper64.exe deleted file mode 100644 index e69de29..0000000 diff --git a/pubspec.lock b/pubspec.lock index 0132a3a..abb3fc4 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,20 +1,20 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: - archive: - dependency: "direct main" + args: + dependency: transitive description: - name: archive + name: args url: "https://pub.dartlang.org" source: hosted - version: "3.1.6" + version: "2.3.1" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.1" + version: "2.8.2" boolean_selector: dependency: transitive description: @@ -28,7 +28,7 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" charcode: dependency: transitive description: @@ -49,14 +49,7 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" - crypto: - dependency: transitive - description: - name: crypto - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.1" + version: "1.16.0" cupertino_icons: dependency: "direct main" description: @@ -64,27 +57,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.4" - dio: - dependency: "direct main" - description: - name: dio - url: "https://pub.dartlang.org" - source: hosted - version: "4.0.4" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0" ffi: dependency: transitive description: name: ffi url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "1.2.1" file: dependency: transitive description: @@ -98,7 +84,7 @@ packages: name: file_picker url: "https://pub.dartlang.org" source: hosted - version: "4.2.7" + version: "4.6.0" flutter: dependency: "direct main" description: flutter @@ -110,14 +96,14 @@ packages: name: flutter_lints url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "2.0.1" flutter_plugin_android_lifecycle: dependency: transitive description: name: flutter_plugin_android_lifecycle url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "2.0.6" flutter_test: dependency: "direct dev" description: flutter @@ -128,83 +114,69 @@ packages: description: flutter source: sdk version: "0.0.0" - http: - dependency: "direct main" - description: - name: http - url: "https://pub.dartlang.org" - source: hosted - version: "0.13.4" - http_parser: - dependency: transitive - description: - name: http_parser - url: "https://pub.dartlang.org" - source: hosted - version: "4.0.0" js: dependency: transitive description: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.3" + version: "0.6.4" lints: dependency: transitive description: name: lints url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "2.0.0" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10" - meta: + version: "0.12.11" + material_color_utilities: dependency: transitive description: - name: meta + name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" - nested: + version: "0.1.4" + meta: dependency: transitive description: - name: nested + name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.7.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" path_provider_linux: dependency: transitive description: name: path_provider_linux url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "2.1.7" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.4" path_provider_windows: dependency: transitive description: name: path_provider_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.4" + version: "2.0.7" platform: dependency: transitive description: @@ -218,7 +190,7 @@ packages: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.1.2" process: dependency: transitive description: @@ -226,48 +198,55 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.2.4" - provider: + process_run: dependency: "direct main" description: - name: provider + name: process_run url: "https://pub.dartlang.org" source: hosted - version: "6.0.1" + version: "0.12.3+2" + pub_semver: + dependency: transitive + description: + name: pub_semver + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" shared_preferences: dependency: "direct main" description: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "2.0.9" + version: "2.0.15" shared_preferences_android: dependency: transitive description: name: shared_preferences_android url: "https://pub.dartlang.org" source: hosted - version: "2.0.9" + version: "2.0.12" shared_preferences_ios: dependency: transitive description: name: shared_preferences_ios url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.1.1" shared_preferences_linux: dependency: transitive description: name: shared_preferences_linux url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.1.1" shared_preferences_macos: dependency: transitive description: name: shared_preferences_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.0.4" shared_preferences_platform_interface: dependency: transitive description: @@ -281,14 +260,14 @@ packages: name: shared_preferences_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.0.4" shared_preferences_windows: dependency: transitive description: name: shared_preferences_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.1.1" sky_engine: dependency: transitive description: flutter @@ -300,7 +279,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" stack_trace: dependency: transitive description: @@ -322,6 +301,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.0" + synchronized: + dependency: transitive + description: + name: synchronized + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0+2" term_glyph: dependency: transitive description: @@ -335,91 +321,91 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.2" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" + version: "0.4.9" url_launcher: dependency: "direct main" description: name: url_launcher url: "https://pub.dartlang.org" source: hosted - version: "6.0.17" + version: "6.1.2" url_launcher_android: dependency: transitive description: name: url_launcher_android url: "https://pub.dartlang.org" source: hosted - version: "6.0.13" + version: "6.0.17" url_launcher_ios: dependency: transitive description: name: url_launcher_ios url: "https://pub.dartlang.org" source: hosted - version: "6.0.13" + version: "6.0.17" url_launcher_linux: dependency: transitive description: name: url_launcher_linux url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "3.0.1" url_launcher_macos: dependency: transitive description: name: url_launcher_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "3.0.1" url_launcher_platform_interface: dependency: transitive description: name: url_launcher_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.4" + version: "2.0.5" url_launcher_web: dependency: transitive description: name: url_launcher_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "2.0.11" url_launcher_windows: dependency: transitive description: name: url_launcher_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "3.0.1" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.2" win32: dependency: transitive description: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.3.1" + version: "2.6.1" xdg_directories: dependency: transitive description: name: xdg_directories url: "https://pub.dartlang.org" source: hosted - version: "0.2.0" + version: "0.2.0+1" + yaml: + dependency: transitive + description: + name: yaml + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.1" sdks: - dart: ">=2.14.0 <3.0.0" - flutter: ">=2.5.0" + dart: ">=2.17.0 <3.0.0" + flutter: ">=2.10.0" diff --git a/pubspec.yaml b/pubspec.yaml index 2fc42d3..c025d29 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -37,11 +37,7 @@ dependencies: url_launcher: ^6.0.12 file_picker: ^4.1.6 shared_preferences: ^2.0.8 - dio: ^4.0.1 - archive: ^3.1.6 - provider: ^6.0.1 - http: ^0.13.4 - + process_run: ^0.12.3+2 @@ -56,7 +52,7 @@ dev_dependencies: # activated in the `analysis_options.yaml` file located at the root of your # package. See that file for information about deactivating specific lint # rules and activating additional ones. - flutter_lints: ^1.0.0 + flutter_lints: ^2.0.1 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec @@ -71,8 +67,8 @@ flutter: # To add assets to your application, add an assets section, like this: assets: - - assets/steamdownload.dll - - assets/aria2c.exe + - assets/steamcmd/steamcmd.exe + # - images/a_dot_ham.jpeg # An image asset can refer to one or more resolution-specific "variants", see diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 411af46..88b22e5 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -6,6 +6,9 @@ list(APPEND FLUTTER_PLUGIN_LIST url_launcher_windows ) +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + set(PLUGIN_BUNDLED_LIBRARIES) foreach(plugin ${FLUTTER_PLUGIN_LIST}) @@ -14,3 +17,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST}) list(APPEND PLUGIN_BUNDLED_LIBRARIES $) list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/windows/runner/CMakeLists.txt b/windows/runner/CMakeLists.txt index 0b899a0..c3efe3e 100644 --- a/windows/runner/CMakeLists.txt +++ b/windows/runner/CMakeLists.txt @@ -1,6 +1,5 @@ cmake_minimum_required(VERSION 3.15) project(runner LANGUAGES CXX) - add_executable(${BINARY_NAME} WIN32 "flutter_window.cpp" "main.cpp" diff --git a/windows/runner/main.cpp b/windows/runner/main.cpp index 26f5c46..8cd585f 100644 --- a/windows/runner/main.cpp +++ b/windows/runner/main.cpp @@ -27,7 +27,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, FlutterWindow window(project); Win32Window::Point origin(10, 10); Win32Window::Size size(780, 520); - if (!window.CreateAndShow(L"WEdownloader", origin, size)) { + if (!window.CreateAndShow(L"Wallpaper Engineֽһ", origin, size)) { return EXIT_FAILURE; } window.SetQuitOnClose(true);