修复: SFTP存储切换问题 & 添加开发者工具保护
- 修复SFTP按钮被错误禁用的问题 - 用户选择本地存储后可以正常切换回SFTP - 切换到SFTP时检查是否已配置,未配置则跳转到设置页面 - 添加右键菜单禁用 - 添加F12和开发者工具快捷键禁用 - 添加开发者工具打开检测 - 生产环境禁用console输出
This commit is contained in:
@@ -930,7 +930,7 @@
|
|||||||
class="btn"
|
class="btn"
|
||||||
:class="storageType === 'sftp' ? 'btn-primary' : 'btn-secondary'"
|
:class="storageType === 'sftp' ? 'btn-primary' : 'btn-secondary'"
|
||||||
@click="switchStorage('sftp')"
|
@click="switchStorage('sftp')"
|
||||||
:disabled="storageType === 'sftp' || !user.has_ftp_config">
|
:disabled="storageType === 'sftp'">
|
||||||
<i class="fas fa-server"></i> SFTP存储
|
<i class="fas fa-server"></i> SFTP存储
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -2007,5 +2007,76 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script src="app.js?v=20251110001"></script>
|
<script src="app.js?v=20251110001"></script>
|
||||||
|
|
||||||
|
<!-- 开发者工具保护 -->
|
||||||
|
<script>
|
||||||
|
// 禁用右键菜单
|
||||||
|
document.addEventListener('contextmenu', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 禁用F12和常见开发者工具快捷键
|
||||||
|
document.addEventListener('keydown', function(e) {
|
||||||
|
// F12
|
||||||
|
if (e.key === 'F12' || e.keyCode === 123) {
|
||||||
|
e.preventDefault();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Ctrl+Shift+I (开发者工具)
|
||||||
|
if (e.ctrlKey && e.shiftKey && (e.key === 'I' || e.keyCode === 73)) {
|
||||||
|
e.preventDefault();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Ctrl+Shift+J (控制台)
|
||||||
|
if (e.ctrlKey && e.shiftKey && (e.key === 'J' || e.keyCode === 74)) {
|
||||||
|
e.preventDefault();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Ctrl+U (查看源代码)
|
||||||
|
if (e.ctrlKey && (e.key === 'U' || e.keyCode === 85)) {
|
||||||
|
e.preventDefault();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Ctrl+Shift+C (元素选择器)
|
||||||
|
if (e.ctrlKey && e.shiftKey && (e.key === 'C' || e.keyCode === 67)) {
|
||||||
|
e.preventDefault();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 检测开发者工具是否打开
|
||||||
|
(function() {
|
||||||
|
const threshold = 160;
|
||||||
|
let isDevToolsOpen = false;
|
||||||
|
|
||||||
|
setInterval(function() {
|
||||||
|
const widthThreshold = window.outerWidth - window.innerWidth > threshold;
|
||||||
|
const heightThreshold = window.outerHeight - window.innerHeight > threshold;
|
||||||
|
const orientation = widthThreshold ? 'vertical' : 'horizontal';
|
||||||
|
|
||||||
|
if (!(heightThreshold && widthThreshold) &&
|
||||||
|
((window.Firebug && window.Firebug.chrome && window.Firebug.chrome.isInitialized) || widthThreshold || heightThreshold)) {
|
||||||
|
if (!isDevToolsOpen) {
|
||||||
|
isDevToolsOpen = true;
|
||||||
|
// 检测到开发者工具打开,可以选择清空页面或重定向
|
||||||
|
// document.body.innerHTML = '<h1 style="text-align:center;margin-top:20%;">请关闭开发者工具</h1>';
|
||||||
|
console.clear();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
isDevToolsOpen = false;
|
||||||
|
}
|
||||||
|
}, 500);
|
||||||
|
})();
|
||||||
|
|
||||||
|
// 禁用console输出(可选)
|
||||||
|
if (window.location.hostname !== 'localhost' && window.location.hostname !== '127.0.0.1') {
|
||||||
|
console.log = function() {};
|
||||||
|
console.info = function() {};
|
||||||
|
console.warn = function() {};
|
||||||
|
console.error = function() {};
|
||||||
|
console.debug = function() {};
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1483,6 +1483,13 @@ handleDragLeave(e) {
|
|||||||
|
|
||||||
// 用户切换存储方式
|
// 用户切换存储方式
|
||||||
async switchStorage(type) {
|
async switchStorage(type) {
|
||||||
|
// 检查是否尝试切换到SFTP但未配置
|
||||||
|
if (type === 'sftp' && !this.user.has_ftp_config) {
|
||||||
|
this.showToast('warning', '提示', '请先在设置页面配置SFTP信息');
|
||||||
|
this.currentView = 'settings';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!confirm(`确定要切换到${type === 'local' ? '本地存储' : 'SFTP存储'}吗?`)) {
|
if (!confirm(`确定要切换到${type === 'local' ? '本地存储' : 'SFTP存储'}吗?`)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user