mirror of
				https://github.com/NotoChen/Jetbrains-Help.git
				synced 2025-10-31 08:58:31 +08:00 
			
		
		
		
	Merge remote-tracking branch 'origin/main'
# Conflicts: # src/main/java/com/jetbrains/help/util/FileTools.java
This commit is contained in:
		
						commit
						ff87be4161
					
				|  | @ -3,12 +3,10 @@ package com.jetbrains.help.util; | |||
| import cn.hutool.core.io.FileUtil; | ||||
| import cn.hutool.core.text.CharSequenceUtil; | ||||
| import cn.hutool.core.util.ObjectUtil; | ||||
| import cn.hutool.core.util.StrUtil; | ||||
| import org.springframework.boot.system.ApplicationHome; | ||||
| import org.springframework.core.io.ClassPathResource; | ||||
| 
 | ||||
| import java.io.File; | ||||
| import java.io.IOException; | ||||
| import java.io.*; | ||||
| 
 | ||||
| public interface FileTools { | ||||
| 
 | ||||
|  | @ -30,14 +28,14 @@ public interface FileTools { | |||
|         File file = getFile(path); | ||||
|         if (ObjectUtil.isNotNull(application.getSource())) { | ||||
|             ClassPathResource classPathResource = new ClassPathResource(path); | ||||
|             File classPathFile = FileUtil.file(classPathResource.getPath()); | ||||
|             if (classPathResource.exists() && !file.exists()) { | ||||
|                 try { | ||||
|                     FileUtil.writeFromStream(classPathResource.getInputStream(), classPathFile); | ||||
|                 try (InputStream inputStream = classPathResource.getInputStream()) { | ||||
|                     FileUtil.writeFromStream(inputStream, file); | ||||
|                 } catch (Exception e) { | ||||
|                     throw new IllegalArgumentException(CharSequenceUtil.format("{} 文件读取失败!", classPathFile.getPath()), e); | ||||
|                     throw new IllegalArgumentException( | ||||
|                             CharSequenceUtil.format("{} 文件读取失败!", path), e | ||||
|                     ); | ||||
|                 } | ||||
|                 FileUtil.copy(classPathFile, file, true); | ||||
|             } | ||||
|         } | ||||
|         return file; | ||||
|  |  | |||
|  | @ -74,16 +74,22 @@ $(document).ready(function() { | |||
|             return navigator.clipboard.writeText(val); | ||||
|         } else { | ||||
|             console.log(val); | ||||
|             const scrollX = window.scrollX; | ||||
|             const textArea = document.createElement('textarea') | ||||
|             textArea.value = val | ||||
|             // 使text area不在viewport,同时设置不可见
 | ||||
|             document.body.appendChild(textArea) | ||||
|             textArea.focus() | ||||
|             textArea.select() | ||||
|             return new Promise((res, rej) => { | ||||
|                 document.execCommand('copy') ? res() : rej() | ||||
|                 textArea.remove() | ||||
|             }) | ||||
|             try { | ||||
|                 const result = document.execCommand('copy'); | ||||
|                 return result ? Promise.resolve() : Promise.reject(); | ||||
|             } catch (e) { | ||||
|                 return Promise.reject(e); | ||||
|             } finally { | ||||
|                 textArea.remove(); | ||||
|                 window.scrollTo(scrollX, 0); | ||||
|             } | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 藏柏
						藏柏