注释掉很多之前为了兼容旧数据的脚本(数据量大会导致启动时耗时很久)
增加重置密码功能
This commit is contained in:
+21
-6
@@ -28,14 +28,15 @@ namespace dy.net
|
||||
// 配置主机
|
||||
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();
|
||||
// 配置中间件
|
||||
ConfigureMiddleware(app, builder.Environment);
|
||||
Log.Debug($"dy.sync app is started successfully on {DefaultListenUrl}");
|
||||
// 初始化应用服务
|
||||
await InitApplicationServices(app, isDevelopment);
|
||||
await InitApplicationServices(app, isDevelopment, dbPath);
|
||||
Console.WriteLine();
|
||||
|
||||
await app.RunAsync();
|
||||
@@ -201,7 +202,7 @@ namespace dy.net
|
||||
/// <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();
|
||||
var services = scope.ServiceProvider;
|
||||
@@ -211,6 +212,20 @@ namespace dy.net
|
||||
// 初始化用户
|
||||
var userService = services.GetRequiredService<AdminUserService>();
|
||||
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>();
|
||||
|
||||
// 更新视频类型--兼容老版本--不再需要
|
||||
@@ -218,8 +233,8 @@ namespace dy.net
|
||||
// 重置博主作品同步状态为未同步
|
||||
//commonService.UpdateAllCookieSyncedToZero();
|
||||
|
||||
await commonService.UpdateFollowedSavePathAsync();
|
||||
await commonService.UpdateImageVideoSavePath();
|
||||
//await commonService.UpdateFollowedSavePathAsync();
|
||||
//await commonService.UpdateImageVideoSavePath();
|
||||
|
||||
// 初始化Cookie
|
||||
var cookieService = services.GetRequiredService<DouyinCookieService>();
|
||||
@@ -232,7 +247,7 @@ namespace dy.net
|
||||
var config = commonService.InitConfig();
|
||||
|
||||
//Serilog.Log.Debug("isRestart1=" + config.IsFirstRunning);
|
||||
await cookieService.UpdateCookieToSupportOldVersionAsync();
|
||||
//await cookieService.UpdateCookieToSupportOldVersionAsync();
|
||||
|
||||
if (!isDevelopment)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
<!-- 顶部Logo区域 - 边框圈精准贴合Logo内容 -->
|
||||
<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">
|
||||
<!-- 缩小边框容器尺寸,适配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">
|
||||
<img src="/logo.png" alt="抖小云logo" class="w-18 h-18 md:w-20 h-20 object-contain" />
|
||||
</div>
|
||||
@@ -55,6 +54,12 @@
|
||||
<span class="text-xs md:text-sm">记住密码</span>
|
||||
</a-checkbox>
|
||||
</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>
|
||||
|
||||
<!-- 登录按钮 -->
|
||||
@@ -65,6 +70,34 @@
|
||||
</a-form>
|
||||
</div>
|
||||
</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>
|
||||
|
||||
<script lang="ts" setup>
|
||||
@@ -80,6 +113,8 @@ const showPassword = ref(false);
|
||||
const rememberPassword = ref(false);
|
||||
// 加载状态
|
||||
const loading = ref(false);
|
||||
// 忘记密码弹窗显示状态
|
||||
const forgotModalVisible = ref(false);
|
||||
|
||||
// 表单状态(用于输入框验证反馈)
|
||||
const form = reactive({
|
||||
@@ -159,10 +194,10 @@ async function login(params: LoginFormProps) {
|
||||
}
|
||||
}
|
||||
|
||||
// 忘记密码处理
|
||||
// 忘记密码处理 - 打开弹窗
|
||||
function handleForgotPassword() {
|
||||
forgotModalVisible.value = true;
|
||||
emit('forgot-password');
|
||||
message.info('忘记密码功能即将上线');
|
||||
}
|
||||
|
||||
// 注册处理
|
||||
@@ -285,6 +320,26 @@ body {
|
||||
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;
|
||||
|
||||
@@ -106,5 +106,15 @@ namespace dy.net.repository
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using dy.net.model.dto;
|
||||
using dy.net.model.entity;
|
||||
using dy.net.repository;
|
||||
using dy.net.utils;
|
||||
|
||||
namespace dy.net.service
|
||||
{
|
||||
@@ -40,5 +41,10 @@ namespace dy.net.service
|
||||
};
|
||||
return _userRepository.InitUser(userInfo);
|
||||
}
|
||||
|
||||
public bool ResetPwd(string pwd)
|
||||
{
|
||||
return _userRepository.ResetPwd(pwd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user