Skip to content

Commit

Permalink
copy
Browse files Browse the repository at this point in the history
  • Loading branch information
mukeshtestgit committed Nov 28, 2024
1 parent e709408 commit ac6df20
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
53 changes: 53 additions & 0 deletions copy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PWA TEST</title>
<script>

</script>
</head>

<body>
<h1>Welcome to the PWA World!</h1>

<form>
<!-- 图片选择器 -->
<input type="file" id="imageInput" accept="image/*">
</form>

<!-- 图片预览容器 -->
<div id="previewContainer">
<h3>图片预览:</h3>
<img id="preview" src="" alt="Preview" style="max-width: 300px; display: none;">
</div>

<script>
// 获取 input 和 img 元素
const imageInput = document.getElementById('imageInput');
const preview = document.getElementById('preview');

// 当用户选择图片时触发事件
imageInput.addEventListener('change', function (event) {
const file = event.target.files[0]; // 获取用户选择的文件
if (file) {
const reader = new FileReader(); // 创建 FileReader 对象

// 文件加载完成后,将内容设置为图片的 src
reader.onload = function (e) {
preview.src = e.target.result;
preview.style.display = 'block'; // 显示图片
};

reader.readAsDataURL(file); // 读取文件内容为 DataURL
} else {
preview.style.display = 'none'; // 如果没有文件,隐藏图片预览
}
});
</script>

</body>

</html>
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"display_Override": [
"window-controls-overlay"
],
"start_url": "https://spm-all-ap.s3.ap-southeast-1.amazonaws.com/app/SPM.html",
"start_url": "https://esectoma.github.io/copypwa/copy.html",
"scope": "./",
"theme_color": "#000",
"background_color": "#fff",
Expand Down

0 comments on commit ac6df20

Please sign in to comment.