mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-21 00:38:44 +08:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 164133cfe4 | |||
| 6bca078614 | |||
| a4481011eb | |||
| 81d39b5436 | |||
| 4bff8602d1 |
@@ -0,0 +1,189 @@
|
||||
#!/bin/bash
|
||||
run_path=$(dirname "$0")
|
||||
base_path="$(dirname "$run_path")"
|
||||
mkdir -p "$base_path"
|
||||
cd "$base_path" || exit 1
|
||||
appVer_path="$base_path/WattToolkit.AppVer"
|
||||
exec_name="Steam++"
|
||||
tar_name="WattToolkit.tgz"
|
||||
tar_path="$base_path/$tar_name"
|
||||
app_name="Watt Toolkit"
|
||||
PROCESS_NAMES=("$exec_name" "$app_name")
|
||||
export LC_ALL=en_US.UTF-8
|
||||
Install_certutil() {
|
||||
# 判断发行版类型
|
||||
if command -v certutil &>/dev/null; then
|
||||
echo "certutil 工具已安装。"
|
||||
else
|
||||
echo "证书导入以及验证需要使用 certutil 工具。"
|
||||
# 判断包管理器
|
||||
if command -v apt &>/dev/null; then
|
||||
# 使用 apt (Debian/Ubuntu)
|
||||
sudo apt update
|
||||
sudo apt install -y libnss3-tools
|
||||
elif command -v dnf &>/dev/null; then
|
||||
# 使用 dnf (Fedora)
|
||||
sudo dnf install -y nss-tools
|
||||
elif command -v yum &>/dev/null; then
|
||||
# 使用 yum (CentOS/Red Hat)
|
||||
sudo yum install -y nss-tools
|
||||
elif command -v pacman &>/dev/null; then
|
||||
# 使用 pacman (Arch Linux)
|
||||
# sudo pacman -S nss
|
||||
echo "请手动安装 certutil 工具。"
|
||||
exit 1
|
||||
else
|
||||
echo "请手动安装 certutil 工具。"
|
||||
exit 1
|
||||
fi
|
||||
echo "certutil 工具已安装。"
|
||||
fi
|
||||
}
|
||||
certutil_Init() {
|
||||
certutil -d $HOME/.pki/nssdb -L
|
||||
ret=$?
|
||||
if [ $ret -ne 0 ]; then
|
||||
echo "即将初始化 certutil \$HOME/.pki/nssdb"
|
||||
mkdir -p $HOME/.pki
|
||||
mkdir -p $HOME/.pki/nssdb
|
||||
chmod 700 $HOME/.pki/nssdb
|
||||
certutil -d $HOME/.pki/nssdb -N --empty-password
|
||||
else
|
||||
echo "certutil nssdb 正常"
|
||||
fi
|
||||
}
|
||||
Install_jq() {
|
||||
# Check if jq is already installed
|
||||
if command -v jq &>/dev/null; then
|
||||
echo "jq 工具已安装。"
|
||||
else
|
||||
echo "jq 用来解析版本更新。"
|
||||
# Check the package manager
|
||||
if command -v apt &>/dev/null; then
|
||||
# Using apt (Debian/Ubuntu)
|
||||
sudo apt update
|
||||
sudo apt install -y jq
|
||||
elif command -v dnf &>/dev/null; then
|
||||
# Using dnf (Fedora)
|
||||
sudo dnf install -y jq
|
||||
elif command -v yum &>/dev/null; then
|
||||
# Using yum (CentOS/Red Hat)
|
||||
sudo yum install -y jq
|
||||
elif command -v pacman &>/dev/null; then
|
||||
# Using pacman (Arch Linux)
|
||||
sudo pacman -S jq
|
||||
else
|
||||
echo "请手动安装 jq 工具。"
|
||||
exit 1
|
||||
fi
|
||||
echo "请手动安装 jq 工具。"
|
||||
fi
|
||||
}
|
||||
Install_zenity() {
|
||||
# 判断发行版类型
|
||||
if command -v zenity &>/dev/null; then
|
||||
echo "zenity 工具已安装。"
|
||||
else
|
||||
echo "安装过程需要 zenity 工具。"
|
||||
# 判断包管理器
|
||||
if command -v apt &>/dev/null; then
|
||||
# 使用 apt (Debian/Ubuntu)
|
||||
sudo apt update
|
||||
sudo apt install -y zenity
|
||||
elif command -v dnf &>/dev/null; then
|
||||
# 使用 dnf (Fedora)
|
||||
sudo dnf install -y zenity
|
||||
elif command -v yum &>/dev/null; then
|
||||
# 使用 yum (CentOS/Red Hat)
|
||||
sudo yum install -y zenity
|
||||
elif command -v pacman &>/dev/null; then
|
||||
# 使用 pacman (Arch Linux)
|
||||
# sudo pacman -S zenity
|
||||
echo "请手动安装 zenity 工具。"
|
||||
exit 1
|
||||
else
|
||||
echo "请手动安装 zenity 工具。"
|
||||
exit 1
|
||||
fi
|
||||
echo "zenity 工具已安装。"
|
||||
fi
|
||||
}
|
||||
|
||||
Show_Run() {
|
||||
local param1=$1
|
||||
# 显示提示框,询问是否运行程序
|
||||
zenity --question --text="$1" --width=400
|
||||
|
||||
# 获取上一个命令的退出码
|
||||
response=$?
|
||||
|
||||
if [ $response -eq 0 ]; then
|
||||
echo "程序已启动。"
|
||||
exit 0 &
|
||||
# 用户点击了 "运行" 按钮,启动程序
|
||||
/bin/sh -c "$base_path/$exec_name.sh"
|
||||
else
|
||||
# 用户点击了 "关闭" 按钮,退出脚本
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
Kill_Process() {
|
||||
# 尝试的次数
|
||||
Kill_MAX_RETRIES=3
|
||||
|
||||
# 循环尝试终止进程
|
||||
for process_name in "${PROCESS_NAMES[@]}"; do
|
||||
kill_retry=1
|
||||
while [ $kill_retry -le $Kill_MAX_RETRIES ]; do
|
||||
pid=$(pgrep "$process_name")
|
||||
if [ -n "$pid" ]; then
|
||||
echo "尝试 $kill_retry: 进程 $process_name 正在运行中。正在终止..."
|
||||
kill $pid
|
||||
sleep 2
|
||||
else
|
||||
break
|
||||
fi
|
||||
kill_retry=$((kill_retry + 1))
|
||||
done
|
||||
done
|
||||
|
||||
for process_name in "${PROCESS_NAMES[@]}"; do
|
||||
# 检查是否成功终止进程
|
||||
if pgrep -x "$process_name" >/dev/null; then
|
||||
echo "无法终止程序 $process_name。尝试次数已达上限。"
|
||||
exit 1
|
||||
else
|
||||
echo "程序 $process_name 已成功终止。"
|
||||
fi
|
||||
done
|
||||
|
||||
}
|
||||
Install_certutil
|
||||
Install_zenity
|
||||
Install_jq
|
||||
certutil_Init
|
||||
Kill_Process
|
||||
|
||||
dotnet_exec="$dotnet_path/dotnet/dotnet"
|
||||
if [ -x "$dotnet_exec" ]; then
|
||||
echo "文件具有执行权限。"
|
||||
else
|
||||
chmod +x "$dotnet_exec"
|
||||
fi
|
||||
chmod +x "$base_path/$exec_name.sh"
|
||||
# xdg-icon-resource install "$base_path/Icons/Watt-Toolkit.png" --size 128 Watt-Toolkit
|
||||
#添加桌面文件
|
||||
rm -rf "$HOME/Desktop/Watt Toolkit.desktop" 2>/dev/null
|
||||
echo "#!/usr/bin/env xdg-open
|
||||
[Desktop Entry]
|
||||
Name=Watt Toolkit
|
||||
Exec=$base_path/$exec_name.sh
|
||||
Icon=$base_path/Icons/Watt-Toolkit.png
|
||||
Terminal=false
|
||||
Type=Application
|
||||
StartupNotify=false" >"$HOME/Desktop/Watt Toolkit.desktop"
|
||||
chmod +x "$HOME/Desktop/Watt Toolkit.desktop"
|
||||
# update-desktop-database ~/.local/share/applications
|
||||
#运行程序
|
||||
Show_Run "下载安装完成,是否启动程序?"
|
||||
exit 0
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
base_path="$HOME/WattToolkit"
|
||||
export LC_ALL=en_US.UTF-8
|
||||
run_path=$(dirname "$0")
|
||||
base_path="$(dirname "$run_path")"
|
||||
exec_name="Steam++"
|
||||
app_name="Watt Toolkit"
|
||||
AppData="$XDG_DATA_HOME/Steam++"
|
||||
@@ -8,7 +8,37 @@ AppData_t="$HOME/.local/share/Steam++"
|
||||
Cache="$XDG_CACHE_HOME/Steam++"
|
||||
Cache_t="$HOME/.cache/Steam+"
|
||||
PROCESS_NAMES=("$exec_name" "$app_name")
|
||||
export LC_ALL=zn_CN.UTF-8
|
||||
#检查是否存在 Steam++.sh 避免卸载错误
|
||||
file_to_check="$base_path/Steam++.sh"
|
||||
folders_to_check=("dotnet" "modules" "native" "script" "assemblies")
|
||||
if [ -e "$file_to_check" ]; then
|
||||
echo "文件 $file_to_check 存在"
|
||||
else
|
||||
echo "文件 $file_to_check 不存在"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for folder in "${folders_to_check[@]}"; do
|
||||
folder_path="$base_path/$folder"
|
||||
if [ -d "$folder_path" ]; then
|
||||
echo "文件夹 $folder_path 存在"
|
||||
else
|
||||
echo "文件夹 $folder_path 不存在"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
echo "验证该文件夹是 $app_name 安装目录,请确认是否卸载。"
|
||||
|
||||
read -p "所有文件和文件夹都存在,确认卸载吗? (输入 'y' 确认): " confirmation
|
||||
|
||||
if [ "${confirmation,,}" == "y" ]; then
|
||||
echo "开始执行卸载操作"
|
||||
# 在这里添加您的卸载操作
|
||||
else
|
||||
echo "用户取消卸载操作"
|
||||
exit 0
|
||||
fi
|
||||
Kill_Process() {
|
||||
# 尝试的次数
|
||||
Kill_MAX_RETRIES=3
|
||||
|
||||
Submodule ref/WTTS.MicroServices.ClientSDK updated: 24bf5ab24b...be6ab5fda9
+1
-1
Submodule ref/WinAuth updated: a20460165f...29806fdcf8
@@ -11,6 +11,7 @@ sealed class AcceleratorAutoMapperProfile : Profile
|
||||
.ForMember(x => x.Icon, d => d.MapFrom(x => x.IconUrl))
|
||||
.ForMember(x => x.Description, d => d.MapFrom(x => x.Describe))
|
||||
.ForMember(x => x.Enable, d => d.MapFrom(x => !x.Disable))
|
||||
.ForMember(x => x.IsBuild, d => d.MapFrom(x => x.IsCompile))
|
||||
.ForMember(x => x.Id, d => d.MapFrom(x => x.LocalId));
|
||||
CreateMap<Script, ScriptDTO>()
|
||||
.ForMember(x => x.LocalId, d => d.MapFrom(x => x.Id))
|
||||
@@ -18,6 +19,7 @@ sealed class AcceleratorAutoMapperProfile : Profile
|
||||
.ForMember(x => x.Describe, d => d.MapFrom(x => x.Description))
|
||||
.ForMember(x => x.IconUrl, d => d.MapFrom(x => x.Icon))
|
||||
.ForMember(x => x.Disable, d => d.MapFrom(x => !x.Enable))
|
||||
.ForMember(x => x.IsCompile, d => d.MapFrom(x => x.IsBuild))
|
||||
.ForMember(x => x.Id, d => d.MapFrom(x => x.Pid));
|
||||
}
|
||||
}
|
||||
@@ -376,20 +376,6 @@ public sealed class ScriptManager : GeneralHttpClientFactory, IScriptManager
|
||||
var scripts = list.ToList();
|
||||
foreach (var item in list)
|
||||
{
|
||||
//检查缓存文件夹如果不是 IScriptManager.DirName_Build 替换成 IScriptManager.DirName_Build 开头
|
||||
if (!item.CachePath.StartsWith($"{IScriptManager.DirName_Build}{Path.DirectorySeparatorChar}"))
|
||||
{
|
||||
item.CachePath = Path.Combine(IScriptManager.DirName_Build, item.FileName!);
|
||||
var cachePath = Path.Combine(Plugin.Instance.CacheDirectory, item.CachePath);
|
||||
if (File.Exists(cachePath))
|
||||
{
|
||||
File.Delete(cachePath);
|
||||
}
|
||||
await TryReadFileAsync(item, true);
|
||||
//清理 脚本内容 后续 IPC 传递 插件进程读取。
|
||||
item.Content = string.Empty;
|
||||
await scriptRepository.SaveScriptCachePathAsync(item, default);
|
||||
}
|
||||
if (!CheckFile(item))
|
||||
{
|
||||
var temp = await DeleteScriptAsync(item);
|
||||
@@ -404,6 +390,38 @@ public sealed class ScriptManager : GeneralHttpClientFactory, IScriptManager
|
||||
//toast.Show($"脚本:{item.Name}_文件丢失,删除失败去尝试手动删除");
|
||||
Toast.Show(ToastIcon.Error, Strings.Script_NoFileDeleteError_.Format(item.Name));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
//检查缓存文件夹如果不是 IScriptManager.DirName_Build 替换成 IScriptManager.DirName_Build 开头
|
||||
if (!item.CachePath.StartsWith($"{IScriptManager.DirName_Build}{Path.DirectorySeparatorChar}"))
|
||||
{
|
||||
var oldCachePath = Path.Combine(Plugin.Instance.CacheDirectory, item.CachePath);
|
||||
item.CachePath = Path.Combine(IScriptManager.DirName_Build, item.FileName!);
|
||||
if (File.Exists(oldCachePath))
|
||||
{
|
||||
File.Delete(oldCachePath);
|
||||
}
|
||||
await TryReadFileAsync(item, true);
|
||||
//清理 脚本内容 后续 IPC 传递 插件进程读取。
|
||||
item.Content = string.Empty;
|
||||
await scriptRepository.SaveScriptCachePathAsync(item, default);
|
||||
}
|
||||
else
|
||||
{
|
||||
var cachePath = Path.Combine(Plugin.Instance.CacheDirectory, item.CachePath);
|
||||
var file = new FileInfo(cachePath);
|
||||
//检查缓存文件是否为空 为空则 刷新
|
||||
if (file.Exists)
|
||||
{
|
||||
if (file.Length == 0)
|
||||
{
|
||||
file.Delete();
|
||||
await TryReadFileAsync(item, true);
|
||||
//清理 脚本内容 后续 IPC 传递 插件进程读取。
|
||||
item.Content = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return scripts;
|
||||
|
||||
@@ -154,6 +154,7 @@ public static class ThirdPartyLoginHelper
|
||||
AppResources.User_Register);
|
||||
close?.Invoke();
|
||||
Toast.Show(ToastIcon.Success, msg);
|
||||
await UserService.Current.RefreshShopTokenAsync();
|
||||
}
|
||||
|
||||
static IDisposable? serverDisposable;
|
||||
|
||||
@@ -65,10 +65,24 @@ public static class Migrations
|
||||
{
|
||||
MoveAccelerator();
|
||||
}
|
||||
|
||||
//var v_3_0_rc4 = new Version(3, 0, 407);
|
||||
//if (IApplication.IsDesktop() && PreviousVersion < v_3_0_rc4)
|
||||
//{
|
||||
// ClearScriptFile();
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ClearScriptFile()
|
||||
{
|
||||
var scriptDirectory = Path.Combine(IOPath.AppDataDirectory, AssemblyInfo.Plugins, AssemblyInfo.Accelerator, DirName_Scripts);
|
||||
Directory.Delete(scriptDirectory, true);
|
||||
var scriptCacheDirectory = Path.Combine(IOPath.CacheDirectory, AssemblyInfo.Plugins, AssemblyInfo.Accelerator, DirName_BuildScripts);
|
||||
Directory.Delete(scriptCacheDirectory, true);
|
||||
}
|
||||
|
||||
static void MoveDirByScripts(string rootPath, string? newDirName = null)
|
||||
{
|
||||
try
|
||||
@@ -77,11 +91,14 @@ public static class Migrations
|
||||
AssemblyInfo.Plugins,
|
||||
AssemblyInfo.Accelerator,
|
||||
newDirName ?? DirName_Scripts);
|
||||
if (!Directory.Exists(newPath))
|
||||
var dir = new DirectoryInfo(newPath);
|
||||
if (!dir.Exists)
|
||||
{
|
||||
var oldPath = Path.Combine(rootPath, DirName_Scripts);
|
||||
if (Directory.Exists(oldPath))
|
||||
{
|
||||
//创建至父级目录
|
||||
dir.Parent?.Create();
|
||||
Directory.Move(oldPath, newPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,16 @@ sealed class MicroServiceClient : MicroServiceClientBase
|
||||
}
|
||||
}
|
||||
|
||||
public sealed override async Task SaveShopAuthTokenAsync(JWTEntity authToken)
|
||||
{
|
||||
var user = await userManager.GetCurrentUserAsync();
|
||||
if (user != null)
|
||||
{
|
||||
user.ShopAuthToken = authToken;
|
||||
await userManager.SetCurrentUserAsync(user);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed override async Task OnLoginedAsync(
|
||||
IReadOnlyPhoneNumber? phoneNumber,
|
||||
ILoginResponse response)
|
||||
|
||||
@@ -199,6 +199,39 @@ public sealed class UserService : ReactiveObject
|
||||
await RefreshUserAsync(user, refreshCurrentUser);
|
||||
}
|
||||
|
||||
public async Task RefreshShopTokenAsync(bool refreshToken = true)
|
||||
{
|
||||
var currentUser = await userManager.GetCurrentUserAsync();
|
||||
|
||||
if (refreshToken && currentUser != null)
|
||||
{
|
||||
var token = await csc.Shop.GetShopUserTokenAsync();
|
||||
if (token.IsSuccess)
|
||||
{
|
||||
currentUser.ShopAuthToken = token.Content;
|
||||
await userManager.SetCurrentUserAsync(currentUser);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 带登录状态跳转 Url
|
||||
/// </summary>
|
||||
/// <param name="url">跳转地址</param>
|
||||
/// <returns></returns>
|
||||
public async Task OpenAuthUrl(string url)
|
||||
{
|
||||
var token = await userManager.GetAuthTokenAsync();
|
||||
if (token == null)
|
||||
{
|
||||
Browser2.Open(url.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
Browser2.Open(string.Format(Constants.Urls.OfficialWebsite_Fast_Login_, token.AccessToken, HttpUtility.UrlEncode(token.ExpiresIn.ToString()), HttpUtility.UrlEncode(url)));
|
||||
}
|
||||
}
|
||||
|
||||
public async Task RefreshUserAvatarAsync()
|
||||
{
|
||||
if (User != null)
|
||||
|
||||
@@ -45,6 +45,7 @@ public partial class LoginOrRegisterWindowViewModel : WindowViewModel, SendSmsUI
|
||||
var msg = Strings.Success_.Format((rsp?.IsLoginOrRegister ?? false) ? Strings.User_Login : Strings.User_Register);
|
||||
close?.Invoke();
|
||||
Toast.Show(ToastIcon.Success, msg);
|
||||
await UserService.Current.RefreshShopTokenAsync();
|
||||
}
|
||||
|
||||
async Task SendSmsAsync() => await this.SendSmsAsync(() => new()
|
||||
|
||||
Reference in New Issue
Block a user