Compare commits
10 Commits
12bc6aeee7
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 49240893b5 | |||
| 61728434d3 | |||
| 5736d09dbe | |||
| f4646f1e3a | |||
| 5b3e505e9b | |||
| 624d7fde2f | |||
| a85f2c1b3a | |||
| 7ec97c39a7 | |||
| 67016c4e9a | |||
| 69c3634731 |
@@ -201,15 +201,16 @@ class ReceiveProductSync
|
||||
throw new \Exception('产品创建失败');
|
||||
}
|
||||
}
|
||||
else if (strtotime($product['updated_at']) < strtotime($data['created_at'])) {
|
||||
$product->spu = $data['spu'];
|
||||
$product->name = $data['name'];
|
||||
$product->category_id = $product_category['id'];
|
||||
$product->status = Operate_Of_ReceiveSync::Disable == $data['operate'] ? -1 : 1;
|
||||
if (!$product->save()) {
|
||||
throw new \Exception('产品更新失败');
|
||||
}
|
||||
}
|
||||
// 注释更新同步,防止tco同步修改官网手动调整数据
|
||||
// else if (strtotime($product['updated_at']) < strtotime($data['created_at'])) {
|
||||
// $product->spu = $data['spu'];
|
||||
// $product->name = $data['name'];
|
||||
// $product->category_id = $product_category['id'];
|
||||
// $product->status = Operate_Of_ReceiveSync::Disable == $data['operate'] ? -1 : 1;
|
||||
// if (!$product->save()) {
|
||||
// throw new \Exception('产品更新失败');
|
||||
// }
|
||||
// }
|
||||
} catch (\Throwable $th) {
|
||||
return error(sprintf('%s %s:%d', $th->getMessage(), $th->getFile(), $th->getLine()));
|
||||
}
|
||||
|
||||
@@ -1082,18 +1082,18 @@
|
||||
const allVideos = document.querySelectorAll('.fs-video');
|
||||
const fsBox = document.querySelector('.fs-box');
|
||||
let isVideoPlaying = false;
|
||||
let videoTip = null;
|
||||
// let videoTip = null;
|
||||
|
||||
// 初始化视频提示
|
||||
const initVideoTip = () =>
|
||||
{
|
||||
if (!fsBox || videoTip) return;
|
||||
videoTip = document.createElement('div');
|
||||
videoTip.className = 'video-tip';
|
||||
videoTip.innerText = '点击播放视频';
|
||||
fsBox.appendChild(videoTip);
|
||||
videoTip.style.display = 'none';
|
||||
};
|
||||
// const initVideoTip = () =>
|
||||
// {
|
||||
// if (!fsBox || videoTip) return;
|
||||
// videoTip = document.createElement('div');
|
||||
// videoTip.className = 'video-tip';
|
||||
// videoTip.innerText = '点击播放视频';
|
||||
// fsBox.appendChild(videoTip);
|
||||
// videoTip.style.display = 'none';
|
||||
// };
|
||||
|
||||
// 停止所有视频(仅暂停,无显隐)
|
||||
function stopAllVideos ()
|
||||
@@ -1103,7 +1103,7 @@
|
||||
video.pause(); // 仅暂停,删除display修改
|
||||
});
|
||||
isVideoPlaying = false;
|
||||
if (videoTip) videoTip.style.display = 'none';
|
||||
// if (videoTip) videoTip.style.display = 'none';
|
||||
}
|
||||
|
||||
// 播放指定视频(仅播放,无显隐)
|
||||
@@ -1117,17 +1117,17 @@
|
||||
video.play().then(() =>
|
||||
{
|
||||
isVideoPlaying = true;
|
||||
if (videoTip) videoTip.style.display = 'none';
|
||||
// if (videoTip) videoTip.style.display = 'none';
|
||||
}).catch((err) =>
|
||||
{
|
||||
console.log('视频自动播放失败:', err);
|
||||
if (videoTip) videoTip.style.display = 'block';
|
||||
// if (videoTip) videoTip.style.display = 'block';
|
||||
// 点击视频手动播放(仅执行一次)
|
||||
video.addEventListener('click', () =>
|
||||
{
|
||||
video.play();
|
||||
isVideoPlaying = true;
|
||||
if (videoTip) videoTip.style.display = 'none';
|
||||
// if (videoTip) videoTip.style.display = 'none';
|
||||
}, { once: true });
|
||||
});
|
||||
};
|
||||
@@ -1180,7 +1180,7 @@
|
||||
};
|
||||
|
||||
// 初始化执行
|
||||
initVideoTip();
|
||||
// initVideoTip();
|
||||
window.addEventListener('scroll', handleVideoScroll, { passive: true });
|
||||
window.addEventListener('resize', handleVideoResize);
|
||||
// 页面加载完成后尝试播放视频
|
||||
|
||||
@@ -1037,17 +1037,17 @@
|
||||
const allVideos = document.querySelectorAll('.fs-video');
|
||||
const fsBox = document.querySelector('.fs-box');
|
||||
let isVideoPlaying = false;
|
||||
let videoTip = null;
|
||||
// let videoTip = null;
|
||||
|
||||
// 初始化视频提示
|
||||
const initVideoTip = () => {
|
||||
if (!fsBox || videoTip) return;
|
||||
videoTip = document.createElement('div');
|
||||
videoTip.className = 'video-tip';
|
||||
videoTip.innerText = '点击播放视频';
|
||||
fsBox.appendChild(videoTip);
|
||||
videoTip.style.display = 'none';
|
||||
};
|
||||
// const initVideoTip = () => {
|
||||
// if (!fsBox || videoTip) return;
|
||||
// videoTip = document.createElement('div');
|
||||
// videoTip.className = 'video-tip';
|
||||
// videoTip.innerText = '点击播放视频';
|
||||
// fsBox.appendChild(videoTip);
|
||||
// videoTip.style.display = 'none';
|
||||
// };
|
||||
|
||||
// 停止所有视频
|
||||
function stopAllVideos ()
|
||||
@@ -1060,7 +1060,7 @@
|
||||
if (img) img.style.display = 'block';
|
||||
});
|
||||
isVideoPlaying = false;
|
||||
if (videoTip) videoTip.style.display = 'none';
|
||||
// if (videoTip) videoTip.style.display = 'none';
|
||||
}
|
||||
|
||||
// 播放指定视频
|
||||
@@ -1075,7 +1075,7 @@
|
||||
video.muted = true;
|
||||
video.play().then(() => {
|
||||
isVideoPlaying = true;
|
||||
if (videoTip) videoTip.style.display = 'none';
|
||||
// if (videoTip) videoTip.style.display = 'none';
|
||||
}).catch((err) => {
|
||||
console.log('视频自动播放失败:', err);
|
||||
video.style.display = 'block';
|
||||
@@ -1085,7 +1085,7 @@
|
||||
video.addEventListener('click', () => {
|
||||
video.play();
|
||||
isVideoPlaying = true;
|
||||
if (videoTip) videoTip.style.display = 'none';
|
||||
// if (videoTip) videoTip.style.display = 'none';
|
||||
}, { once: true });
|
||||
});
|
||||
};
|
||||
@@ -1140,7 +1140,7 @@
|
||||
};
|
||||
|
||||
// 初始化
|
||||
initVideoTip();
|
||||
// initVideoTip();
|
||||
window.addEventListener('scroll', handleVideoScroll, { passive: true });
|
||||
window.addEventListener('resize', handleVideoResize);
|
||||
// 页面加载完成后尝试播放
|
||||
|
||||
@@ -244,6 +244,25 @@ class ImageMigrator:
|
||||
if self.verbose:
|
||||
print("连接已关闭")
|
||||
|
||||
def chown_target(self, owner: str, target_path: str) -> bool:
|
||||
command = f"sudo chown {owner} {target_path}"
|
||||
stdin, stdout, stderr = self.target_client.exec_command(command)
|
||||
# 如果需要输入sudo密码
|
||||
if "sudo" in command and self.target_config.password:
|
||||
stdin.write(self.target_config.password + "\n")
|
||||
stdin.flush()
|
||||
|
||||
if self.verbose:
|
||||
# 获取输出和错误
|
||||
# output = stdout.read().decode()
|
||||
error = stderr.read().decode()
|
||||
exit_code = stdout.channel.recv_exit_status()
|
||||
if exit_code == 0:
|
||||
return True
|
||||
else:
|
||||
print(f"DEBUG chown_target: 修改 {target_path} 的所有者失败: {error}")
|
||||
return False
|
||||
|
||||
def ensure_target_directory(self, remote_dir: str) -> bool:
|
||||
"""确保目标目录存在(递归创建)"""
|
||||
try:
|
||||
@@ -298,11 +317,17 @@ class ImageMigrator:
|
||||
f"DEBUG ensure_target_directory: 创建目录: {current_path}"
|
||||
)
|
||||
try:
|
||||
# 创建目录
|
||||
self.target_sftp.mkdir(current_path)
|
||||
if self.verbose:
|
||||
print(
|
||||
f"DEBUG ensure_target_directory: 目录创建成功: {current_path}"
|
||||
)
|
||||
# 修改目录所有者
|
||||
if self.chown_target("www", current_path) and self.verbose:
|
||||
print(
|
||||
f"DEBUG ensure_target_directory: {current_path} 所有者修改为 www 成功"
|
||||
)
|
||||
except Exception as mkdir_e:
|
||||
# 如果创建失败,可能是权限问题或目录已存在
|
||||
if self.verbose:
|
||||
@@ -519,6 +544,8 @@ class ImageMigrator:
|
||||
print(f"DEBUG: 目录stat也失败: {stat_e}")
|
||||
|
||||
self.target_sftp.put(temp_path, target_path)
|
||||
if self.chown_target("www", target_path) and self.verbose:
|
||||
print(f"DEBUG transfer_file: {target_path} 所有者修改为 www 成功")
|
||||
|
||||
if self.verbose:
|
||||
print("DEBUG: 上传完成")
|
||||
@@ -672,13 +699,18 @@ def create_example_config(config_file: str):
|
||||
def read_image_paths(image_list_file: str) -> List[str]:
|
||||
"""从文件读取图片路径列表"""
|
||||
paths = []
|
||||
not_images = []
|
||||
try:
|
||||
with open(image_list_file, "r", encoding="utf-8") as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if line and not line.startswith("#"):
|
||||
if not line.endswith((".png", ".jpeg", ".jpg", ".gif", ".webp")):
|
||||
not_images.append(line)
|
||||
else:
|
||||
paths.append(line)
|
||||
print(f"从文件读取 {len(paths)} 个图片路径")
|
||||
print(f"从文件中读取到 {len(paths)} 个图片路径数据行")
|
||||
print(f"从文件中读取到 {len(not_images)} 个非图片路径数据行")
|
||||
except Exception as e:
|
||||
print(f"读取图片路径文件失败 {image_list_file}: {e}")
|
||||
return paths
|
||||
@@ -889,9 +921,14 @@ def main():
|
||||
print("请使用 --input 指定文件或直接在命令行提供路径")
|
||||
sys.exit(1)
|
||||
|
||||
origin_paths = image_paths
|
||||
# 去重
|
||||
image_paths = list(set(image_paths))
|
||||
|
||||
repeats = len(origin_paths) - len(image_paths)
|
||||
if repeats > 0:
|
||||
print(f"从文件中读取到 {repeats} 个重复图片路径数据行")
|
||||
|
||||
# 创建并运行迁移器
|
||||
migrator = ImageMigrator(
|
||||
source_config=source_config,
|
||||
|
||||
Reference in New Issue
Block a user