Skip to content

Commit 69d42c9

Browse files
committed
2.4
- 音量调节,每个壁纸单独保存音量 - Webview2客户端外壳,防止浏览器过旧无法使用 - 本地壁纸和设置将打开离线页面,完全无广告,白嫖使我们相遇 - 一键下载到分组(线上网站还未发布,暂时不可用) - 刷新页面后也能看见下载进度 - 增加繁体 - 修复某些情况本地封面生成异常bug - 增加关于页面
1 parent 8e7d6f7 commit 69d42c9

File tree

227 files changed

+2098
-8918
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

227 files changed

+2098
-8918
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ BundleArtifacts
1313
/LiveWallpaperEngineRender/lib/mpv-1.dll
1414
/LiveWallpaperEngineRender/lib/mpv-1-x64.dll
1515
/LiveWallpaper.App/*.cache
16+
/livewallpaper-client-ui/yarn.lock

Docs/README_zh.md

+7-13
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,17 @@
88

99
---
1010

11-
### 壁纸切换
11+
### 使用教程
12+
[Bilibili](https://www.bilibili.com/video/BV1ph411872V/)
1213

13-
![切换壁纸](https://github.com/giant-app/LiveWallpaper/blob/master/screenshots/changewallpaper.gif?raw=true)
14+
### 图片
15+
![LocalWallpaper](https://github.com/giant-app/LiveWallpaper/blob/master/screenshots/1.png?raw=true)
1416

15-
### 壁纸下载
17+
![Wallpaper Community](https://github.com/giant-app/LiveWallpaper/blob/master/screenshots/2.png?raw=true)
1618

17-
![一键下载](https://github.com/giant-app/LiveWallpaper/blob/master/screenshots/download.gif?raw=true)
19+
![Setting Page](https://github.com/giant-app/LiveWallpaper/blob/master/screenshots/3.png?raw=true)
1820

19-
### 应用特色:
20-
21-
- 轻量客户端
22-
- 纯网页控制
23-
- 壁纸上传
24-
- 壁纸一键下载
25-
- 离线使用
26-
- 客户端无任何弹窗广告
27-
- 没有 VIP,免费使用
21+
![Notify Icon](https://github.com/giant-app/LiveWallpaper/blob/master/screenshots/4.png?raw=true)
2822

2923
### 编译环境:
3024

LiveWallpaper.App/Package.appxmanifest

+24-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<Package xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5" xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" IgnorableNamespaces="uap mp rescap">
3-
<Identity Name="24765mscoder.107453A6A4A17" Publisher="CN=49BC8659-1B4C-4520-B1FB-ED98CFA366C4" Version="2.3.93.0" />
2+
<Package
3+
xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"
4+
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
5+
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
6+
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
7+
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
8+
xmlns:com="http://schemas.microsoft.com/appx/manifest/com/windows10"
9+
xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"
10+
IgnorableNamespaces="uap mp rescap com desktop">
11+
<Identity Name="24765mscoder.107453A6A4A17" Publisher="CN=49BC8659-1B4C-4520-B1FB-ED98CFA366C4" Version="2.4.102.0" />
412
<Properties>
513
<DisplayName>ms-resource:Resources/PackageDisplayName</DisplayName>
614
<PublisherDisplayName>Giantapp Studio</PublisherDisplayName>
@@ -30,6 +38,20 @@
3038
<uap:Logo>Images\logo.png</uap:Logo>
3139
</uap:Protocol>
3240
</uap:Extension>
41+
42+
<!--Specify which CLSID to activate when toast clicked-->
43+
<desktop:Extension Category="windows.toastNotificationActivation">
44+
<desktop:ToastNotificationActivation ToastActivatorCLSID="dec74eb7-0834-4c07-9656-e510e7d71f7a" />
45+
</desktop:Extension>
46+
47+
<!--Register COM CLSID LocalServer32 registry key-->
48+
<com:Extension Category="windows.comServer">
49+
<com:ComServer>
50+
<com:ExeServer Executable="LiveWallpaper\LiveWallpaper.exe" Arguments="-ToastActivated" DisplayName="Toast activator">
51+
<com:Class Id="dec74eb7-0834-4c07-9656-e510e7d71f7a" DisplayName="Toast activator"/>
52+
</com:ExeServer>
53+
</com:ComServer>
54+
</com:Extension>
3355
</Extensions>
3456
</Application>
3557
</Applications>

LiveWallpaper.LocalServer/AppManager.cs

+178-12
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,85 @@
33
using Giantapp.LiveWallpaper.Engine;
44
using LiveWallpaper.LocalServer.Models;
55
using LiveWallpaper.LocalServer.Utils;
6+
using Microsoft.Toolkit.Uwp.Notifications;
67
using System;
78
using System.IO;
89
using System.Reflection;
10+
using System.Threading;
911
using System.Threading.Tasks;
12+
using Windows.ApplicationModel;
13+
using Windows.Storage;
14+
using Windows.UI.Notifications;
1015

1116
namespace LiveWallpaper.LocalServer
1217
{
1318
public class AppManager
1419
{
1520
private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
16-
private static readonly string _runningDataFilePath;
17-
private static readonly string _userSettingFilePath;
21+
public static string RunningDataFilePath { get; private set; }
22+
public static string UserSettingFilePath { get; private set; }
23+
public static string CacheDir { get; private set; }
24+
public static string ConfigDir { get; private set; }
25+
public static string LogDir { get; private set; }
1826
private static IStartupManager _startupManager = null;
1927

20-
2128
static AppManager()
2229
{
23-
//MyDocuments这个路径不会虚拟化,方便从Dart端读取 (Flutter 方案已放弃,注释先留着)
24-
_runningDataFilePath = $"{Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)}\\{AppName}\\runningData.json";
25-
_userSettingFilePath = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\\{AppName}\\Config\\userSetting.json";
30+
//_runningDataFilePath = $"{Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)}\\{AppName}\\runningData.json";
31+
//runningdata目录修改为和配置一个目录2021.9.30
32+
DesktopBridge.Helpers helpers = new();
33+
if (helpers.IsRunningAsUwp())
34+
{
35+
//uwp放在包里面,卸载时可以清理干净
36+
ConfigDir = Path.Combine(ApplicationData.Current.LocalCacheFolder.Path, $"Local\\{AppName}\\");
37+
}
38+
else
39+
{
40+
ConfigDir = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\\{AppName}\\";
41+
}
42+
CacheDir = $"{ConfigDir}Cache\\";
43+
RunningDataFilePath = $"{ConfigDir}Config\\runningData.json";
44+
UserSettingFilePath = $"{ConfigDir}Config\\userSetting.json";
45+
LogDir = $"{ConfigDir}/Logs";
46+
ToastNotificationManagerCompat.OnActivated += ToastNotificationManagerCompat_OnActivated;
47+
}
48+
49+
private static async void ToastNotificationManagerCompat_OnActivated(ToastNotificationActivatedEventArgsCompat e)
50+
{
51+
// Obtain the arguments from the notification
52+
ToastArguments args = ToastArguments.Parse(e.Argument);
53+
string actionString = "action";
54+
if (args.Contains(actionString))
55+
{
56+
string action = args.Get(actionString);
57+
switch (action)
58+
{
59+
case "review":
60+
try
61+
{
62+
await OpenStoreReview();
63+
RunningData = await JsonHelper.JsonDeserializeFromFileAsync<RunningData>(RunningDataFilePath);
64+
RunningData.CurrentVersionReviewed = true;
65+
await JsonHelper.JsonSerializeAsync(RunningData, RunningDataFilePath);
66+
}
67+
catch (Exception ex)
68+
{
69+
System.Diagnostics.Debug.WriteLine(ex);
70+
}
71+
break;
72+
}
73+
}
74+
ToastNotificationManagerCompat.History.Clear();
75+
76+
// Obtain any user input (text boxes, menu selections) from the notification
77+
//ValueSet userInput = toastArgs.UserInput;
78+
79+
//// Need to dispatch to UI thread if performing UI operations
80+
//Application.Current.Dispatcher.Invoke(delegate
81+
//{
82+
// // TODO: Show the corresponding content
83+
// MessageBox.Show("Toast activated. Args: " + toastArgs.Argument);
84+
//});
2685
}
2786

2887
#region properties
@@ -74,26 +133,68 @@ public static FileDownloader PlayerDownloader
74133
public static event EventHandler CultureChanged;
75134
#endregion
76135

136+
public static async Task<bool> OpenStoreReview()
137+
{
138+
try
139+
{
140+
//旧方法,不推荐的方式.但是推荐的方式获取不到ID
141+
var pfn = Package.Current.Id.FamilyName;
142+
var uri = new Uri($"ms-windows-store://review/?PFN={pfn}");
143+
bool success = await Windows.System.Launcher.LaunchUriAsync(uri);
144+
return success;
145+
//var id = Package.Current.Id.ProductId;
146+
//bool ok = await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-windows-store://review/?ProductId=9WZDNCRFHVJL"));
147+
}
148+
catch (Exception ex)
149+
{
150+
System.Diagnostics.Debug.WriteLine(ex);
151+
return false;
152+
}
153+
}
154+
77155
public static async Task Initialize(int hostPort)
78156
{
79157
try
80158
{
81159
//应用程序数据
82-
RunningData = await JsonHelper.JsonDeserializeFromFileAsync<RunningData>(_runningDataFilePath);
160+
RunningData = await JsonHelper.JsonDeserializeFromFileAsync<RunningData>(RunningDataFilePath);
83161
if (RunningData == null)
84162
{
85163
//生成默认运行数据
86164
RunningData = new RunningData();
87165
}
88166
//更新端口号
89167
RunningData.HostPort = hostPort;
90-
await JsonHelper.JsonSerializeAsync(RunningData, _runningDataFilePath);
168+
var version = Assembly.GetEntryAssembly().GetName().Version.ToString();
169+
170+
if (RunningData.CurrentVersion == null)
171+
{
172+
_ = ShowGuidToastAsync();//第一次启动
173+
}
174+
175+
if (RunningData.CurrentVersion != version)
176+
{
177+
RunningData.CurrentVersion = version;
178+
RunningData.CurrentVersionLaunchedCount = 0;
179+
RunningData.CurrentVersionReviewed = false;
180+
}
181+
else
182+
{
183+
RunningData.CurrentVersionLaunchedCount++;
184+
}
185+
186+
await JsonHelper.JsonSerializeAsync(RunningData, RunningDataFilePath);
187+
188+
if (!RunningData.CurrentVersionReviewed && RunningData.CurrentVersionLaunchedCount > 0 && RunningData.CurrentVersionLaunchedCount % 30 == 0)
189+
{
190+
ShowReviewToast();
191+
}
91192

92193
if (UserSetting == null)
93194
await LoadUserSetting();
94195

95196
//开机启动
96-
DesktopBridge.Helpers helpers = new DesktopBridge.Helpers();
197+
DesktopBridge.Helpers helpers = new();
97198
if (helpers.IsRunningAsUwp())
98199
_startupManager = new DesktopBridgeStartupManager(AppName);
99200
else
@@ -123,6 +224,71 @@ public static async Task Initialize(int hostPort)
123224
}
124225
}
125226

227+
public static async Task ShowGuidToastAsync()
228+
{
229+
string appDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
230+
string imgPath = Path.Combine(appDir, "Assets\\guide.gif");
231+
new ToastContentBuilder()
232+
.AddText(await GetText("client.started"))
233+
.AddHeroImage(new Uri(imgPath))
234+
.AddButton(new ToastButtonDismiss(await GetText("common.ok")))
235+
.Show();
236+
}
237+
238+
private static async void ShowReviewToast()
239+
{
240+
var toastContent = new ToastContent()
241+
{
242+
Visual = new ToastVisual()
243+
{
244+
BindingGeneric = new ToastBindingGeneric()
245+
{
246+
Children =
247+
{
248+
new AdaptiveText()
249+
{
250+
Text =await GetText("common.reviewTitle")
251+
},
252+
new AdaptiveText()
253+
{
254+
Text = await GetText("common.reviewContent")
255+
}
256+
}
257+
}
258+
},
259+
Actions = new ToastActionsCustom()
260+
{
261+
Buttons =
262+
{
263+
new ToastButton(await GetText("common.thumbUp"), "action=review")
264+
{
265+
ActivationType = ToastActivationType.Background
266+
},
267+
new ToastButtonDismiss(await GetText("common.close"))
268+
}
269+
},
270+
Launch = "action=viewEvent&eventId=63851"
271+
};
272+
273+
// Create the toast notification
274+
var toastNotif = new ToastNotification(toastContent.GetXml());
275+
276+
// And send the notification
277+
ToastNotificationManagerCompat.CreateToastNotifier().Show(toastNotif);
278+
}
279+
280+
public static async Task<string> GetText(string key)
281+
{
282+
if (UserSetting == null)
283+
{
284+
await LoadUserSetting();
285+
}
286+
string culture = UserSetting.General.CurrentLan ?? Thread.CurrentThread.CurrentCulture.Name;
287+
var r = await LanService.Instance.GetTextAsync(key, culture);
288+
return r;
289+
}
290+
291+
126292
public static async Task WaitInitialized()
127293
{
128294
while (!Initialized)
@@ -131,7 +297,7 @@ public static async Task WaitInitialized()
131297

132298
public static async Task LoadUserSetting()
133299
{
134-
UserSetting = await JsonHelper.JsonDeserializeFromFileAsync<UserSetting>(_userSettingFilePath);
300+
UserSetting = await JsonHelper.JsonDeserializeFromFileAsync<UserSetting>(UserSettingFilePath);
135301
if (UserSetting == null)
136302
UserSetting = new UserSetting();
137303
UserSetting.Wallpaper.FixScreenOptions();
@@ -147,7 +313,7 @@ internal static async Task<BaseApiResult> SaveUserSetting(UserSetting setting)
147313
{
148314
try
149315
{
150-
await JsonHelper.JsonSerializeAsync(setting, _userSettingFilePath);
316+
await JsonHelper.JsonSerializeAsync(setting, UserSettingFilePath);
151317

152318
bool lanChanged = false;
153319
if (UserSetting.General.CurrentLan != setting.General.CurrentLan)
@@ -174,7 +340,7 @@ internal static async Task SaveRunningData(RunningData data)
174340
{
175341
try
176342
{
177-
await JsonHelper.JsonSerializeAsync(data, _runningDataFilePath);
343+
await JsonHelper.JsonSerializeAsync(data, RunningDataFilePath);
178344
//更新内存对象
179345
RunningData = data;
180346

0 commit comments

Comments
 (0)