mirror of
https://github.com/fzxx/XiangYue.git
synced 2025-11-25 03:15:16 +08:00
v1.1.2.0
This commit is contained in:
16
License.txt
16
License.txt
@@ -1,26 +1,26 @@
|
|||||||
私下研究专用许可证
|
私下研究专用许可证
|
||||||
|
|
||||||
版本 1.0,2025年7月10日
|
版本 1.0,2025年7月10日
|
||||||
|
|
||||||
|
版权所有 © 风之暇想
|
||||||
|
|
||||||
1. 许可范围限制
|
1. 许可范围限制
|
||||||
仅限个人或内部研究使用:可在个人或组织内部私下研究、学习和分析源代码。
|
仅限个人或内部研究使用:可在个人或组织内部私下研究、学习和分析源代码。
|
||||||
禁止行为:商业用途、公开传播对软件的研究成果、衍生作品或逆向工程结果(原始文件传播除外);公开学术使用。
|
禁止行为:商业用途、公开传播对软件的研究成果、衍生作品或逆向工程结果(原始文件传播除外);公开学术使用。
|
||||||
|
|
||||||
2. 传播条款
|
2. 传播条款
|
||||||
允许以原始未修改形式公开传播,需附带完整许可声明,保留所有版权标识,并提供源代码或源码链接。
|
允许以原始未修改形式公开传播,需附带完整许可声明,保留所有版权标识,并提供源代码或源码链接。
|
||||||
|
|
||||||
3. 知识产权保护
|
3. 知识产权保护
|
||||||
任何修改、衍生作品均受本许可约束,且不得公开传播。
|
任何修改、衍生作品均受本许可约束,且不得公开传播。
|
||||||
|
|
||||||
4. 责任与担保
|
4. 责任与担保
|
||||||
软件按“原样”提供,无任何保证;版权持有者不对使用导致的任何损害负责。
|
软件按“原样”提供,无任何保证;版权持有者不对使用导致的任何损害负责。
|
||||||
|
|
||||||
5. 附加限制
|
5. 附加限制
|
||||||
禁止用于非法、不道德或损害他人权益的活动。
|
禁止用于非法、不道德或损害他人权益的活动。
|
||||||
|
|
||||||
6. 开源组件兼容性
|
6. 开源组件兼容性
|
||||||
第三方开源组件受其自身许可证约束。
|
第三方开源组件受其自身许可证约束。
|
||||||
|
|
||||||
|
|
||||||
使用本软件即表示同意上述条款。若不同意,请勿使用。
|
使用本软件即表示同意上述条款。若不同意,请勿使用。
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
const DEFAULT_PASSWORD='a184f7b849ffffed24d266a30298c72ef2f5ad040db73bf37151fac767630728';async function handleStream(stream,writerData){const writer=stream.writable.getWriter();writer.write(writerData);writer.close();const reader=stream.readable.getReader();const chunks=[];while(true){const{done,value}=await reader.read();if(done)break;chunks.push(value);}
|
const DEFAULT_PASSWORD='a184f7b849ffffed24d266a30298c72ef2f5ad040db73bf37151fac767630728';const STORAGE_KEYS={THEME_MODE:'theme_mode',OUTPUT_MODE:'output_mode'};async function handleStream(stream,writerData){const writer=stream.writable.getWriter();writer.write(writerData);writer.close();const reader=stream.readable.getReader();const chunks=[];while(true){const{done,value}=await reader.read();if(done)break;chunks.push(value);}
|
||||||
return new Blob(chunks).arrayBuffer();}
|
return new Blob(chunks).arrayBuffer();}
|
||||||
const utils={arrayBufferToBase64(buffer){let binary='';const bytes=new Uint8Array(buffer);for(let i=0;i<bytes.byteLength;i++){binary+=String.fromCharCode(bytes[i]);}
|
const utils={arrayBufferToBase64(buffer){let binary='';const bytes=new Uint8Array(buffer);for(let i=0;i<bytes.byteLength;i++){binary+=String.fromCharCode(bytes[i]);}
|
||||||
return btoa(binary);},base64ToArrayBuffer(base64){const binaryString=atob(base64);const bytes=new Uint8Array(binaryString.length);for(let i=0;i<binaryString.length;i++){bytes[i]=binaryString.charCodeAt(i);}
|
return btoa(binary);},base64ToArrayBuffer(base64){const binaryString=atob(base64);const bytes=new Uint8Array(binaryString.length);for(let i=0;i<binaryString.length;i++){bytes[i]=binaryString.charCodeAt(i);}
|
||||||
return bytes.buffer;},stringToArrayBuffer(str){return new TextEncoder().encode(str).buffer;},arrayBufferToString(buffer){return new TextDecoder().decode(buffer);},generateRandomBytes(length){return crypto.getRandomValues(new Uint8Array(length));},async compressData(data,method='deflate'){if(!window.CompressionStream)throw new Error('当前浏览器不支持CompressionStream API');const cs=new CompressionStream(method);return handleStream(cs,data);},async decompressData(data,method='deflate'){if(!window.DecompressionStream)throw new Error('当前浏览器不支持DecompressionStream API');const ds=new DecompressionStream(method);return handleStream(ds,data);},generatePassword(length){const charset='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+~`|}{[]:;?><,./-=';let password='';for(let i=0;i<length;i++){const randomIndex=Math.floor(Math.random()*charset.length);password+=charset.charAt(randomIndex);}
|
return bytes.buffer;},stringToArrayBuffer(str){return new TextEncoder().encode(str).buffer;},arrayBufferToString(buffer){return new TextDecoder().decode(buffer);},generateRandomBytes(length){return crypto.getRandomValues(new Uint8Array(length));},async compressData(data,method='deflate'){if(!window.CompressionStream)throw new Error('当前浏览器不支持CompressionStream API');const cs=new CompressionStream(method);return handleStream(cs,data);},async decompressData(data,method='deflate'){if(!window.DecompressionStream)throw new Error('当前浏览器不支持DecompressionStream API');const ds=new DecompressionStream(method);return handleStream(ds,data);},generatePassword(length){const charset='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+~`|}{[]:;?><,./-=';let password='';for(let i=0;i<length;i++){const randomIndex=Math.floor(Math.random()*charset.length);password+=charset.charAt(randomIndex);}
|
||||||
return password;},copyToClipboard(text){navigator.clipboard.writeText(text).catch(err=>{console.error('复制失败:',err);showNotification('复制到剪贴板失败,请手动复制',false);});},detectCiphertextType(ciphertext){if(/^[A-Za-z0-9+/=]+$/.test(ciphertext)){return'base64';}
|
return password;},copyToClipboard(text){navigator.clipboard.writeText(text).catch(err=>{console.error('复制失败:',err);showNotification('复制到剪贴板失败,请手动复制',false);});},detectCiphertextType(ciphertext){if(/^[A-Za-z0-9+/=]+$/.test(ciphertext)){return'base64';}
|
||||||
const emojiRegex=/[\u{1F600}-\u{1F64F}\u{1F300}-\u{1F5FF}\u{1F680}-\u{1F6FF}\u{1F1E0}-\u{1F1FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}]/u;if(emojiRegex.test(ciphertext)){return'emoji';}
|
const emojiRegex=/[\u{1F600}-\u{1F64F}\u{1F300}-\u{1F5FF}\u{1F680}-\u{1F6FF}\u{1F1E0}-\u{1F1FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}]/u;if(emojiRegex.test(ciphertext)){return'emoji';}
|
||||||
return'chinese';}};
|
return'chinese';},saveThemeMode(mode){if(['light','dark'].includes(mode)){localStorage.setItem(STORAGE_KEYS.THEME_MODE,mode);}},getSavedThemeMode(){return localStorage.getItem(STORAGE_KEYS.THEME_MODE)||null;},saveOutputMode(mode){if(['chinese','base64','emoji'].includes(mode)){localStorage.setItem(STORAGE_KEYS.OUTPUT_MODE,mode);}},getSavedOutputMode(){return localStorage.getItem(STORAGE_KEYS.OUTPUT_MODE)||'chinese';}};
|
||||||
41
js/web.js
41
js/web.js
@@ -1,25 +1,20 @@
|
|||||||
function showNotification(message,isSuccess=true){const notificationContainer=document.createElement('div');notificationContainer.className='fixed right-4 transition-all duration-300 ease-in-out translate-x-full z-50';const navHeight=document.querySelector('nav')?.offsetHeight||0;notificationContainer.style.top=`${navHeight + 10}px`;const setNotificationWidth=()=>{notificationContainer.style.width=window.innerWidth<640?'90%':'280px';};setNotificationWidth();const isDarkMode=document.documentElement.classList.contains('dark');const baseClass=`bg-white rounded-lg shadow-lg p-3 flex items-start ${isSuccess ? 'border-l-4 border-green-500' : 'border-l-4 border-red-500'}`;const darkClass=`bg-gray-800 border-gray-700 text-white`;const finalClass=isDarkMode?`${baseClass} ${darkClass}`:baseClass;notificationContainer.innerHTML=`
|
(function applyThemeEarly(){const STORAGE_KEYS={THEME_MODE:'theme_mode'};const savedThemeMode=localStorage.getItem(STORAGE_KEYS.THEME_MODE);const systemDarkMode=window.matchMedia('(prefers-color-scheme: dark)').matches;const isDarkMode=savedThemeMode?savedThemeMode==='dark':systemDarkMode;if(isDarkMode){document.documentElement.classList.add('dark');}})();function showNotification(message,isSuccess=true){const notificationContainer=document.createElement('div');notificationContainer.className='fixed right-4 transition-all duration-300 ease-in-out translate-x-full z-50';const navHeight=document.querySelector('nav')?.offsetHeight||0;notificationContainer.style.top=`${navHeight + 10}px`;const setNotificationWidth=()=>{notificationContainer.style.width=window.innerWidth<640?'90%':'280px';};setNotificationWidth();const isDarkMode=document.documentElement.classList.contains('dark');const baseClass=`bg-white rounded-lg shadow-lg p-3 flex items-start ${isSuccess ? 'border-l-4 border-green-500' : 'border-l-4 border-red-500'}`;const darkClass=`bg-gray-800 border-gray-700 text-white`;const finalClass=isDarkMode?`${baseClass} ${darkClass}`:baseClass;notificationContainer.innerHTML=`
|
||||||
<div class="${finalClass}">
|
<div class="${finalClass}">
|
||||||
<div class="flex-shrink-0 mt-0.5 mr-2 ${isSuccess ? 'text-green-500' : 'text-red-500'}">
|
<div class="flex-shrink-0 mt-0.5 mr-2 ${isSuccess ? 'text-green-500' : 'text-red-500'}">
|
||||||
<i class="fa-solid fa-${isSuccess ? 'check' : 'exclamation'}-circle"></i>
|
<i class="fa-solid fa-${isSuccess ? 'check' : 'exclamation'}-circle"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="max-w-[90%]">
|
<div class="max-w-[90%]">
|
||||||
<p class="text-sm font-medium text-gray-800 dark:text-white">${message}</p>
|
<p class="text-sm font-medium text-gray-800 dark:text-white">${message}</p>
|
||||||
</div>
|
</div>
|
||||||
<button class="ml-auto flex-shrink-0 inline-flex text-gray-400 hover:text-gray-600 focus:outline-none" onclick="this.parentElement.parentElement.remove()">
|
<button class="ml-auto flex-shrink-0 inline-flex text-gray-400 hover:text-gray-600 focus:outline-none" onclick="this.parentElement.parentElement.remove()">
|
||||||
<i class="fa-solid fa-times"></i>
|
<i class="fa-solid fa-times"></i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
`;document.body.appendChild(notificationContainer);setTimeout(()=>{notificationContainer.classList.remove('translate-x-full');},10);const removeNotification=()=>{notificationContainer.classList.add('translate-x-full');setTimeout(()=>{notificationContainer.remove();},300);};const timeoutId=setTimeout(removeNotification,5000);notificationContainer.querySelector('button').addEventListener('click',()=>{clearTimeout(timeoutId);removeNotification();});window.addEventListener('resize',setNotificationWidth);return notificationContainer;}
|
`;document.body.appendChild(notificationContainer);setTimeout(()=>{notificationContainer.classList.remove('translate-x-full');},10);const removeNotification=()=>{notificationContainer.classList.add('translate-x-full');setTimeout(()=>{notificationContainer.remove();},300);};const timeoutId=setTimeout(removeNotification,5000);notificationContainer.querySelector('button').addEventListener('click',()=>{clearTimeout(timeoutId);removeNotification();});window.addEventListener('resize',setNotificationWidth);return notificationContainer;}
|
||||||
function updateNotificationStyle(notificationContainer){const isDarkMode=document.documentElement.classList.contains('dark');const baseClass=`bg-white rounded-lg shadow-lg p-3 flex items-start ${notificationContainer.querySelector('div').classList.contains('border-l-4.border-green-500') ? 'border-l-4 border-green-500' : 'border-l-4 border-red-500'}`;const darkClass=`bg-gray-800 border-gray-700 text-white`;const finalClass=isDarkMode?`${baseClass} ${darkClass}`:baseClass;notificationContainer.querySelector('div').className=finalClass;}
|
function updateNotificationStyle(notificationContainer){const isDarkMode=document.documentElement.classList.contains('dark');const baseClass=`bg-white rounded-lg shadow-lg p-3 flex items-start ${notificationContainer.querySelector('div').classList.contains('border-l-4.border-green-500') ? 'border-l-4 border-green-500' : 'border-l-4 border-red-500'}`;const darkClass=`bg-gray-800 border-gray-700 text-white`;const finalClass=isDarkMode?`${baseClass} ${darkClass}`:baseClass;notificationContainer.querySelector('div').className=finalClass;}
|
||||||
document.addEventListener('DOMContentLoaded',()=>{const elements={textInput:document.getElementById('text-input'),resultOutput:document.getElementById('result-output'),encryptionKey:document.getElementById('encryption-key'),encryptBtn:document.getElementById('encrypt-btn'),decryptBtn:document.getElementById('decrypt-btn'),copyBtn:document.getElementById('copy-btn'),clearBtn:document.getElementById('clear-btn'),toggleKeyVisibility:document.getElementById('toggle-key-visibility'),generatePassword:document.getElementById('generate-password'),resultStatus:document.getElementById('result-status'),themeToggle:document.getElementById('theme-toggle'),base64Toggle:document.getElementById('base64-toggle'),pasteBtn:document.getElementById('paste-btn')};const isDarkMode=localStorage.theme==='dark'||(!('theme'in localStorage)&&window.matchMedia('(prefers-color-scheme: dark)').matches);if(isDarkMode){document.documentElement.classList.add('dark');elements.themeToggle.innerHTML='<i class="fa-solid fa-moon text-white"></i>';}
|
document.addEventListener('DOMContentLoaded',()=>{const elements={textInput:document.getElementById('text-input'),resultOutput:document.getElementById('result-output'),encryptionKey:document.getElementById('encryption-key'),encryptBtn:document.getElementById('encrypt-btn'),decryptBtn:document.getElementById('decrypt-btn'),copyBtn:document.getElementById('copy-btn'),clearBtn:document.getElementById('clear-btn'),toggleKeyVisibility:document.getElementById('toggle-key-visibility'),generatePassword:document.getElementById('generate-password'),resultStatus:document.getElementById('result-status'),themeToggle:document.getElementById('theme-toggle'),base64Toggle:document.getElementById('base64-toggle'),pasteBtn:document.getElementById('paste-btn')};let savedThemeMode=utils.getSavedThemeMode();const systemDarkMode=window.matchMedia('(prefers-color-scheme: dark)').matches;const isDarkMode=savedThemeMode?savedThemeMode==='dark':systemDarkMode;if(isDarkMode){elements.themeToggle.innerHTML='<i class="fa-solid fa-moon text-white"></i>';}else{elements.themeToggle.innerHTML='<i class="fa-solid fa-sun text-dark"></i>';}
|
||||||
const checkBrowserSupport=()=>{const requiredAPIs=[{api:window.crypto.subtle,message:'当前浏览器不支持Web Crypto API,无法使用加密功能'},{api:window.CompressionStream&&window.DecompressionStream,message:'当前浏览器不支持压缩/解压缩API,无法使用加密功能'}];for(const{api,message}
|
let outputMode=utils.getSavedOutputMode();const icons={chinese:'language',base64:'code',emoji:'smile'};elements.base64Toggle.innerHTML=`<i class="fa-solid fa-${icons[outputMode]} theme-toggle-icon"></i>`;const checkBrowserSupport=()=>{const requiredAPIs=[{api:window.crypto.subtle,message:'当前浏览器不支持Web Crypto API,无法使用加密功能'},{api:window.CompressionStream&&window.DecompressionStream,message:'当前浏览器不支持压缩/解压缩API,无法使用加密功能'}];for(const{api,message}of requiredAPIs){if(!api){showNotification(message,false);elements.encryptBtn.disabled=true;elements.decryptBtn.disabled=true;return false;}}
|
||||||
of requiredAPIs){if(!api){showNotification(message,false);elements.encryptBtn.disabled=true;elements.decryptBtn.disabled=true;return false;}}
|
try{new CompressionStream('deflate');new DecompressionStream('deflate');return true;}catch(e){showNotification('当前浏览器不支持Deflate压缩算法,无法使用加密功能',false);elements.encryptBtn.disabled=true;elements.decryptBtn.disabled=true;return false;}};checkBrowserSupport();elements.generatePassword.addEventListener('click',()=>{const password=utils.generatePassword(25);elements.encryptionKey.value=password;utils.copyToClipboard(password);showNotification('已生成并复制25位随机密码');});elements.toggleKeyVisibility.addEventListener('click',()=>{const type=elements.encryptionKey.getAttribute('type')==='password'?'text':'password';elements.encryptionKey.setAttribute('type',type);elements.toggleKeyVisibility.innerHTML=`<i class="fa-regular fa-${type === 'password' ? 'eye-slash' : 'eye'}"></i>`;});elements.base64Toggle.addEventListener('click',()=>{switch(outputMode){case'chinese':outputMode='base64';break;case'base64':outputMode='emoji';break;case'emoji':outputMode='chinese';break;}
|
||||||
try{new CompressionStream('deflate');new DecompressionStream('deflate');return true;}
|
utils.saveOutputMode(outputMode);elements.base64Toggle.innerHTML=`<i class="fa-solid fa-${icons[outputMode]} theme-toggle-icon"></i>`;showNotification(`已切换到 ${outputMode === 'chinese' ? '中文' : outputMode === 'base64' ? 'Base64' : 'Emoji'} 模式`);});elements.pasteBtn.addEventListener('click',async()=>{try{const clipboardText=await navigator.clipboard.readText();elements.textInput.value=clipboardText;showNotification('已从剪贴板粘贴文本');}catch(error){showNotification('无法从剪贴板粘贴文本',false);}});const handleEncryptionDecryption=async(action,inputText,password,isDefaultPassword)=>{try{elements.resultStatus.textContent=`${action}中......`;elements.resultStatus.className='absolute top-3 right-3 px-2 py-1 rounded-full text-xs font-medium bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200';elements.resultStatus.classList.remove('hidden');const result=action==='加密'?await encryptionMethod1.encrypt(inputText,password,outputMode):await encryptionMethod1.decrypt(inputText,password);elements.resultOutput.value=result;elements.resultStatus.textContent=`${action}成功`;elements.resultStatus.className='absolute top-3 right-3 px-2 py-1 rounded-full text-xs font-medium bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200';if(isDefaultPassword){showNotification(`未检测到密码,使用默认密码${action},建议更换为安全的密码。`,true);}else{showNotification(`文本已成功${action}`);}}catch(error){elements.resultOutput.value='';elements.resultStatus.textContent=`${action}失败`;elements.resultStatus.className='absolute top-3 right-3 px-2 py-1 rounded-full text-xs font-medium bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200';elements.resultStatus.classList.remove('hidden');showNotification(error.message,false);}};elements.encryptBtn.addEventListener('click',async()=>{const plaintext=elements.textInput.value;let password=elements.encryptionKey.value.trim();let isDefaultPassword=false;if(!plaintext)return showNotification('请输入要加密的文本',false);if(!password){password=DEFAULT_PASSWORD;isDefaultPassword=true;}
|
||||||
catch(e){showNotification('当前浏览器不支持Deflate压缩算法,无法使用加密功能',false);elements.encryptBtn.disabled=true;elements.decryptBtn.disabled=true;return false;}};checkBrowserSupport();elements.generatePassword.addEventListener('click',()=>{const password=utils.generatePassword(25);elements.encryptionKey.value=password;utils.copyToClipboard(password);showNotification('已生成并复制25位随机密码');});elements.toggleKeyVisibility.addEventListener('click',()=>{const type=elements.encryptionKey.getAttribute('type')==='password'?'text':'password';elements.encryptionKey.setAttribute('type',type);elements.toggleKeyVisibility.innerHTML=`<i class="fa-regular fa-${type === 'password' ? 'eye-slash' : 'eye'}"></i>`;});let outputMode='chinese';elements.base64Toggle.addEventListener('click',()=>{switch(outputMode){case'chinese':outputMode='base64';break;case'base64':outputMode='emoji';break;case'emoji':outputMode='chinese';break;}
|
|
||||||
const icons={chinese:'language',base64:'code',emoji:'smile'};elements.base64Toggle.innerHTML=`<i class="fa-solid fa-${icons[outputMode]} theme-toggle-icon"></i>`;showNotification(`已切换到 ${outputMode === 'chinese' ? '中文' : outputMode === 'base64' ? 'Base64' : 'Emoji'} 模式`);});elements.pasteBtn.addEventListener('click',async()=>{try{const clipboardText=await navigator.clipboard.readText();elements.textInput.value=clipboardText;showNotification('已从剪贴板粘贴文本');}
|
|
||||||
catch(error){showNotification('无法从剪贴板粘贴文本',false);}});const handleEncryptionDecryption=async(action,inputText,password,isDefaultPassword)=>{try{elements.resultStatus.textContent=`${action}中......`;elements.resultStatus.className='absolute top-3 right-3 px-2 py-1 rounded-full text-xs font-medium bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200';elements.resultStatus.classList.remove('hidden');const result=action==='加密'?await encryptionMethod1.encrypt(inputText,password,outputMode):await encryptionMethod1.decrypt(inputText,password);elements.resultOutput.value=result;elements.resultStatus.textContent=`${action}成功`;elements.resultStatus.className='absolute top-3 right-3 px-2 py-1 rounded-full text-xs font-medium bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200';if(isDefaultPassword){showNotification(`未检测到密码,使用默认密码${action},建议更换为安全的密码。`,true);}
|
|
||||||
else{showNotification(`文本已成功${action}`);}}
|
|
||||||
catch(error){elements.resultOutput.value='';elements.resultStatus.textContent=`${action}失败`;elements.resultStatus.className='absolute top-3 right-3 px-2 py-1 rounded-full text-xs font-medium bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200';elements.resultStatus.classList.remove('hidden');showNotification(error.message,false);}};elements.encryptBtn.addEventListener('click',async()=>{const plaintext=elements.textInput.value;let password=elements.encryptionKey.value.trim();let isDefaultPassword=false;if(!plaintext)return showNotification('请输入要加密的文本',false);if(!password){password=DEFAULT_PASSWORD;isDefaultPassword=true;}
|
|
||||||
await handleEncryptionDecryption('加密',plaintext,password,isDefaultPassword);});elements.decryptBtn.addEventListener('click',async()=>{const ciphertext=elements.textInput.value.trim();let password=elements.encryptionKey.value.trim();let isDefaultPassword=false;if(!ciphertext)return showNotification('请输入要解密的文本',false);if(!password){password=DEFAULT_PASSWORD;isDefaultPassword=true;}
|
await handleEncryptionDecryption('加密',plaintext,password,isDefaultPassword);});elements.decryptBtn.addEventListener('click',async()=>{const ciphertext=elements.textInput.value.trim();let password=elements.encryptionKey.value.trim();let isDefaultPassword=false;if(!ciphertext)return showNotification('请输入要解密的文本',false);if(!password){password=DEFAULT_PASSWORD;isDefaultPassword=true;}
|
||||||
const detectedMode=utils.detectCiphertextType(ciphertext);showNotification(`已识别密文类型: ${detectedMode === 'chinese' ? '中文' : detectedMode === 'base64' ? 'Base64' : 'Emoji'}`);await handleEncryptionDecryption('解密',ciphertext,password,isDefaultPassword);});elements.copyBtn.addEventListener('click',()=>{const result=elements.resultOutput.value;if(!result)return showNotification('没有可复制的结果',false);utils.copyToClipboard(result);showNotification('结果已复制到剪贴板');});elements.clearBtn.addEventListener('click',()=>{elements.textInput.value='';elements.resultOutput.value='';elements.encryptionKey.value='';elements.resultStatus.classList.add('hidden');showNotification('已清空所有内容');});elements.themeToggle.addEventListener('click',()=>{const isDark=document.documentElement.classList.toggle('dark');localStorage.theme=isDark?'dark':'light';elements.themeToggle.innerHTML=`<i class="fa-solid fa-${isDark ? 'moon' : 'sun'} text-${isDark ? 'white' : 'dark'}"></i>`;const notifications=document.querySelectorAll('.fixed.right-4.transition-all.duration-300.ease-in-out.z-50');notifications.forEach(notification=>{updateNotificationStyle(notification);});});});
|
const detectedMode=utils.detectCiphertextType(ciphertext);showNotification(`已识别密文类型: ${detectedMode === 'chinese' ? '中文' : detectedMode === 'base64' ? 'Base64' : 'Emoji'}`);await handleEncryptionDecryption('解密',ciphertext,password,isDefaultPassword);});elements.copyBtn.addEventListener('click',()=>{const result=elements.resultOutput.value;if(!result)return showNotification('没有可复制的结果',false);utils.copyToClipboard(result);showNotification('结果已复制到剪贴板');});elements.clearBtn.addEventListener('click',()=>{elements.textInput.value='';elements.resultOutput.value='';elements.encryptionKey.value='';elements.resultStatus.classList.add('hidden');showNotification('已清空所有内容');});elements.themeToggle.addEventListener('click',()=>{const isDark=document.documentElement.classList.toggle('dark');const newMode=isDark?'dark':'light';utils.saveThemeMode(newMode);elements.themeToggle.innerHTML=`<i class="fa-solid fa-${isDark ? 'moon' : 'sun'} text-${isDark ? 'white' : 'dark'}"></i>`;const notifications=document.querySelectorAll('.fixed.right-4.transition-all.duration-300.ease-in-out.z-50');notifications.forEach(notification=>{updateNotificationStyle(notification);});});});
|
||||||
Reference in New Issue
Block a user