注释掉很多之前为了兼容旧数据的脚本(数据量大会导致启动时耗时很久)

增加重置密码功能
This commit is contained in:
jianzhichu
2026-05-01 17:54:53 +08:00
parent a21f745eac
commit 432ab60dd0
4 changed files with 95 additions and 9 deletions
+21 -6
View File
@@ -28,14 +28,15 @@ namespace dy.net
// 配置主机 // 配置主机
ConfigureHost(builder, isDevelopment); ConfigureHost(builder, isDevelopment);
// 配置服务--数据库保存路径从命令行参数传入的第一个参数 // 配置服务--数据库保存路径从命令行参数传入的第一个参数
ConfigureServices(builder.Services, builder.Configuration, builder.Environment, args.Length > 0 ? args[0] : ""); string dbPath = args.Length > 0 ? args[0] : "";
ConfigureServices(builder.Services, builder.Configuration, builder.Environment, dbPath);
// 构建应用 // 构建应用
var app = builder.Build(); var app = builder.Build();
// 配置中间件 // 配置中间件
ConfigureMiddleware(app, builder.Environment); ConfigureMiddleware(app, builder.Environment);
Log.Debug($"dy.sync app is started successfully on {DefaultListenUrl}"); Log.Debug($"dy.sync app is started successfully on {DefaultListenUrl}");
// 初始化应用服务 // 初始化应用服务
await InitApplicationServices(app, isDevelopment); await InitApplicationServices(app, isDevelopment, dbPath);
Console.WriteLine(); Console.WriteLine();
await app.RunAsync(); await app.RunAsync();
@@ -201,7 +202,7 @@ namespace dy.net
/// <summary> /// <summary>
/// 初始化应用服务数据 /// 初始化应用服务数据
/// </summary> /// </summary>
private static async Task InitApplicationServices(WebApplication app, bool isDevelopment) private static async Task InitApplicationServices(WebApplication app, bool isDevelopment, string dbPath)
{ {
using var scope = app.Services.CreateScope(); using var scope = app.Services.CreateScope();
var services = scope.ServiceProvider; var services = scope.ServiceProvider;
@@ -211,6 +212,20 @@ namespace dy.net
// 初始化用户 // 初始化用户
var userService = services.GetRequiredService<AdminUserService>(); var userService = services.GetRequiredService<AdminUserService>();
userService.InitUser("douyin", "douyin2026"); userService.InitUser("douyin", "douyin2026");
var pwdTxt = Path.Combine(AppContext.BaseDirectory, "db", "pwd.txt");
if (!string.IsNullOrWhiteSpace(dbPath))
{
pwdTxt = Path.Combine(dbPath, "pwd.txt");
}
if (File.Exists(pwdTxt))
{
var pwd = File.ReadAllText(pwdTxt);
var reset = userService.ResetPwd(pwd);
File.Delete(pwdTxt);
}
var commonService = services.GetRequiredService<DouyinCommonService>(); var commonService = services.GetRequiredService<DouyinCommonService>();
// 更新视频类型--兼容老版本--不再需要 // 更新视频类型--兼容老版本--不再需要
@@ -218,8 +233,8 @@ namespace dy.net
// 重置博主作品同步状态为未同步 // 重置博主作品同步状态为未同步
//commonService.UpdateAllCookieSyncedToZero(); //commonService.UpdateAllCookieSyncedToZero();
await commonService.UpdateFollowedSavePathAsync(); //await commonService.UpdateFollowedSavePathAsync();
await commonService.UpdateImageVideoSavePath(); //await commonService.UpdateImageVideoSavePath();
// 初始化Cookie // 初始化Cookie
var cookieService = services.GetRequiredService<DouyinCookieService>(); var cookieService = services.GetRequiredService<DouyinCookieService>();
@@ -232,7 +247,7 @@ namespace dy.net
var config = commonService.InitConfig(); var config = commonService.InitConfig();
//Serilog.Log.Debug("isRestart1=" + config.IsFirstRunning); //Serilog.Log.Debug("isRestart1=" + config.IsFirstRunning);
await cookieService.UpdateCookieToSupportOldVersionAsync(); //await cookieService.UpdateCookieToSupportOldVersionAsync();
if (!isDevelopment) if (!isDevelopment)
{ {
+58 -3
View File
@@ -8,7 +8,6 @@
<!-- 顶部Logo区域 - 边框圈精准贴合Logo内容 --> <!-- 顶部Logo区域 - 边框圈精准贴合Logo内容 -->
<div class="flex flex-col items-center mb-6 md:mb-8"> <div class="flex flex-col items-center mb-6 md:mb-8">
<div class="w-30 h-30 md:w-36 md:h-36 bg-primary/10 rounded-full flex items-center justify-center mb-4 md:mb-5"> <div class="w-30 h-30 md:w-36 md:h-36 bg-primary/10 rounded-full flex items-center justify-center mb-4 md:mb-5">
<!-- 缩小边框容器尺寸适配img实际内容 style="border: 1.5px solid rgba(79, 70, 229, 0.2); border-radius: 50%;"-->
<div class="w-24 h-24 md:w-28 h-28 rounded-full flex items-center justify-center"> <div class="w-24 h-24 md:w-28 h-28 rounded-full flex items-center justify-center">
<img src="/logo.png" alt="抖小云logo" class="w-18 h-18 md:w-20 h-20 object-contain" /> <img src="/logo.png" alt="抖小云logo" class="w-18 h-18 md:w-20 h-20 object-contain" />
</div> </div>
@@ -55,6 +54,12 @@
<span class="text-xs md:text-sm">记住密码</span> <span class="text-xs md:text-sm">记住密码</span>
</a-checkbox> </a-checkbox>
</a-form-item> </a-form-item>
<a-form-item class="mb-0">
<div class="text-gray-600 hover:text-primary transition-colors duration-300 cursor-pointer" @click="handleForgotPassword">
<span class="text-xs md:text-sm">忘记密码</span>
</div>
</a-form-item>
</div> </div>
<!-- 登录按钮 --> <!-- 登录按钮 -->
@@ -65,6 +70,34 @@
</a-form> </a-form>
</div> </div>
</ThemeProvider> </ThemeProvider>
<!-- 忘记密码弹窗 -->
<a-modal v-model:visible="forgotModalVisible" title="密码重置教程" width="50%" :max-width="500" centered :mask-closable="false" :footer="null" class="forgot-modal">
<div class="p-2">
<!-- 步骤说明 -->
<div class="space-y-4 mb-6">
<div class="flex items-start">
<div class="flex-shrink-0 w-6 h-6 rounded-full bg-primary text-white flex items-center justify-center text-sm mr-3 mt-0.5">1</div>
<div class="flex-1 text-gray-700 text-sm leading-relaxed"> db 目录下新建一个文本文件命名为 <span class="px-2 py-0.5 bg-gray-100 text-primary font-medium rounded text-sm">pwd.txt</span></div>
</div>
<div class="flex items-start">
<div class="flex-shrink-0 w-6 h-6 rounded-full bg-primary text-white flex items-center justify-center text-sm mr-3 mt-0.5">2</div>
<div class="flex-1 text-gray-700 text-sm leading-relaxed">打开文件写入你要设置的新密码留空则自动重置为默认密码<span class="px-2 py-0.5 bg-gray-100 text-primary font-medium rounded text-sm">douyin2026</span></div>
</div>
<div class="flex items-start">
<div class="flex-shrink-0 w-6 h-6 rounded-full bg-primary text-white flex items-center justify-center text-sm mr-3 mt-0.5">3</div>
<div class="flex-1 text-gray-700 text-sm leading-relaxed">重启 docker服务或者飞牛安装的抖小云应用 使用新密码登录即可</div>
</div>
</div>
<!-- 知道了按钮 -->
<div class="flex justify-center">
<a-button type="primary" class="h-10 px-8 rounded-lg" @click="forgotModalVisible = false">
我知道了
</a-button>
</div>
</div>
</a-modal>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@@ -80,6 +113,8 @@ const showPassword = ref(false);
const rememberPassword = ref(false); const rememberPassword = ref(false);
// 加载状态 // 加载状态
const loading = ref(false); const loading = ref(false);
// 忘记密码弹窗显示状态
const forgotModalVisible = ref(false);
// 表单状态(用于输入框验证反馈) // 表单状态(用于输入框验证反馈)
const form = reactive({ const form = reactive({
@@ -159,10 +194,10 @@ async function login(params: LoginFormProps) {
} }
} }
// 忘记密码处理 // 忘记密码处理 - 打开弹窗
function handleForgotPassword() { function handleForgotPassword() {
forgotModalVisible.value = true;
emit('forgot-password'); emit('forgot-password');
message.info('忘记密码功能即将上线');
} }
// 注册处理 // 注册处理
@@ -285,6 +320,26 @@ body {
margin-right: 8px !important; margin-right: 8px !important;
} }
/* 弹窗样式美化 */
::v-deep(.forgot-modal .ant-modal-header) {
border-radius: 12px 12px 0 0;
background: #f9fafb;
border-bottom: 1px solid #e5e7eb;
}
::v-deep(.forgot-modal .ant-modal-title) {
color: #1f2937;
font-weight: 600;
font-size: 16px;
}
::v-deep(.forgot-modal .ant-modal-body) {
padding: 16px 20px;
}
::v-deep(.forgot-modal .ant-modal-content) {
border-radius: 12px;
box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
overflow: hidden;
}
/* 防止点击闪烁和触摸高亮 */ /* 防止点击闪烁和触摸高亮 */
* { * {
-webkit-tap-highlight-color: transparent; -webkit-tap-highlight-color: transparent;
+10
View File
@@ -106,5 +106,15 @@ namespace dy.net.repository
return (res ? 0 : -1, res ? "初始用户成功" : "初始化用户失败"); return (res ? 0 : -1, res ? "初始用户成功" : "初始化用户失败");
} }
} }
public bool ResetPwd(string pwd)
{
if (string.IsNullOrWhiteSpace(pwd)) pwd = "douyin2026";
var password = Md5Util.Md5(pwd);
string sql = $" Update login_user_info SET Password='{password}'";
return this.Db.Ado.ExecuteCommand(sql) > 0;
}
} }
} }
+6
View File
@@ -1,6 +1,7 @@
using dy.net.model.dto; using dy.net.model.dto;
using dy.net.model.entity; using dy.net.model.entity;
using dy.net.repository; using dy.net.repository;
using dy.net.utils;
namespace dy.net.service namespace dy.net.service
{ {
@@ -40,5 +41,10 @@ namespace dy.net.service
}; };
return _userRepository.InitUser(userInfo); return _userRepository.InitUser(userInfo);
} }
public bool ResetPwd(string pwd)
{
return _userRepository.ResetPwd(pwd);
}
} }
} }