mirror of
				https://github.com/NotoChen/Jetbrains-Help.git
				synced 2025-11-01 01:38:31 +08:00 
			
		
		
		
	
						commit
						9e91cef62d
					
				|  | @ -8,7 +8,7 @@ import org.springframework.boot.system.ApplicationHome; | ||||||
| import org.springframework.core.io.ClassPathResource; | import org.springframework.core.io.ClassPathResource; | ||||||
| 
 | 
 | ||||||
| import java.io.File; | import java.io.File; | ||||||
| import java.io.IOException; | import java.io.InputStream; | ||||||
| 
 | 
 | ||||||
| public interface FileTools { | public interface FileTools { | ||||||
| 
 | 
 | ||||||
|  | @ -30,14 +30,14 @@ public interface FileTools { | ||||||
|         File file = getFile(path); |         File file = getFile(path); | ||||||
|         if (ObjectUtil.isNotNull(application.getSource())) { |         if (ObjectUtil.isNotNull(application.getSource())) { | ||||||
|             ClassPathResource classPathResource = new ClassPathResource(path); |             ClassPathResource classPathResource = new ClassPathResource(path); | ||||||
|             File classPathFile = FileUtil.file(classPathResource.getPath()); |  | ||||||
|             if (classPathResource.exists() && !file.exists()) { |             if (classPathResource.exists() && !file.exists()) { | ||||||
|                 try { |                 try (InputStream inputStream = classPathResource.getInputStream()) { | ||||||
|                     FileUtil.writeFromStream(classPathResource.getInputStream(), classPathFile); |                     FileUtil.writeFromStream(inputStream, file); | ||||||
|                 } catch (Exception e) { |                 } catch (Exception e) { | ||||||
|                     throw new IllegalArgumentException(CharSequenceUtil.format("{} File read failed", classPathFile.getPath()), e); |                     throw new IllegalArgumentException( | ||||||
|  |                             CharSequenceUtil.format("{} File read or write failed", path), e | ||||||
|  |                     ); | ||||||
|                 } |                 } | ||||||
|                 FileUtil.copy(classPathFile, file, true); |  | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         return file; |         return file; | ||||||
|  |  | ||||||
|  | @ -74,16 +74,22 @@ $(document).ready(function() { | ||||||
|             return navigator.clipboard.writeText(val); |             return navigator.clipboard.writeText(val); | ||||||
|         } else { |         } else { | ||||||
|             console.log(val); |             console.log(val); | ||||||
|  |             const scrollX = window.scrollX; | ||||||
|             const textArea = document.createElement('textarea') |             const textArea = document.createElement('textarea') | ||||||
|             textArea.value = val |             textArea.value = val | ||||||
|             // 使text area不在viewport,同时设置不可见
 |             // 使text area不在viewport,同时设置不可见
 | ||||||
|             document.body.appendChild(textArea) |             document.body.appendChild(textArea) | ||||||
|             textArea.focus() |             textArea.focus() | ||||||
|             textArea.select() |             textArea.select() | ||||||
|             return new Promise((res, rej) => { |             try { | ||||||
|                 document.execCommand('copy') ? res() : rej() |                 const result = document.execCommand('copy'); | ||||||
|                 textArea.remove() |                 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
	 NotoChen
						NotoChen