Skip to content

Commit f99d166

Browse files
committed
Add initial HTML, CSS, and JavaScript files for Tauri app interface; update MainActivity to load local index.html
1 parent 749b8d5 commit f99d166

File tree

6 files changed

+221
-2
lines changed

6 files changed

+221
-2
lines changed
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 6 additions & 0 deletions
Loading

app/src/main/assets/index.html

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="stylesheet" href="./styles.css" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Tauri App</title>
8+
<!-- <script type="module" src="./main.js" defer></script> -->
9+
<script>
10+
window.addEventListener('DOMContentLoaded', () => {
11+
console.log('DOMContentLoaded-----')
12+
const getdata = document.querySelector('#getdata')
13+
getdata.addEventListener('click', (e) => {
14+
e.preventDefault()
15+
console.log('getdata')
16+
fetch('https://api.github.com/users/octocat')
17+
.then((response) => response.json())
18+
.then((data) => {
19+
console.log('data', data)
20+
const greetMsgEl =
21+
document.querySelector('#greet-msg')
22+
greetMsgEl.textContent = data.login
23+
})
24+
.catch((error) => {
25+
console.error('error', error)
26+
})
27+
})
28+
})
29+
</script>
30+
</head>
31+
32+
<body>
33+
<main class="container">
34+
<h1>Welcome to TauriMan</h1>
35+
36+
<div class="row">
37+
<a
38+
href="https://tauri.app"
39+
target="_blank"
40+
rel="noopener noreferrer"
41+
>
42+
<img
43+
src="./assets/tauri.svg"
44+
class="logo tauri"
45+
alt="Tauri logo"
46+
/>
47+
</a>
48+
<a
49+
href="https://pakeplus.com/"
50+
target="_blank"
51+
rel="noopener noreferrer"
52+
>
53+
<img
54+
src="https://files.pakeplus.com/pakeplus.png"
55+
class="logo vanilla"
56+
alt="JavaScript logo"
57+
/>
58+
</a>
59+
</div>
60+
<p>Click to get data</p>
61+
<form class="row" id="greet-form">
62+
<input id="greet-input" placeholder="Enter a name..." />
63+
<button type="submit" id="getdata">GET DATA</button>
64+
</form>
65+
<p id="greet-msg"></p>
66+
<video
67+
src="https://files.pakeplus.com/test.mp4"
68+
autoplay
69+
controls
70+
style="width: 100%; height: 100%"
71+
></video>
72+
</main>
73+
</body>
74+
</html>

app/src/main/assets/main.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
let greetInputEl
2+
let greetMsgEl
3+
4+
async function get_data() {
5+
fetch('https://api.github.com/users/octocat')
6+
.then((response) => response.json())
7+
.then((data) => {
8+
console.log('data', data)
9+
greetMsgEl = document.querySelector('#greet-msg')
10+
greetMsgEl.textContent = data.login
11+
greetInputEl.value = data.login
12+
})
13+
.catch((error) => {
14+
console.error('error', error)
15+
})
16+
}
17+
18+
window.addEventListener('DOMContentLoaded', () => {
19+
greetInputEl = document.querySelector('#greet-input')
20+
document.querySelector('#getdata').addEventListener('click', (e) => {
21+
e.preventDefault()
22+
console.log('getdata')
23+
get_data()
24+
})
25+
})

app/src/main/assets/styles.css

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
.logo.vanilla:hover {
2+
filter: drop-shadow(0 0 2em #ffe21c);
3+
}
4+
:root {
5+
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
6+
font-size: 16px;
7+
line-height: 24px;
8+
font-weight: 400;
9+
10+
color: #0f0f0f;
11+
background-color: #f6f6f6;
12+
13+
font-synthesis: none;
14+
text-rendering: optimizeLegibility;
15+
-webkit-font-smoothing: antialiased;
16+
-moz-osx-font-smoothing: grayscale;
17+
-webkit-text-size-adjust: 100%;
18+
}
19+
20+
.container {
21+
margin: 0;
22+
padding-top: 10vh;
23+
display: flex;
24+
flex-direction: column;
25+
justify-content: center;
26+
text-align: center;
27+
}
28+
29+
.logo {
30+
height: 6em;
31+
padding: 1.5em;
32+
will-change: filter;
33+
transition: 0.75s;
34+
}
35+
36+
.logo.tauri:hover {
37+
filter: drop-shadow(0 0 2em #24c8db);
38+
}
39+
40+
.row {
41+
display: flex;
42+
justify-content: center;
43+
}
44+
45+
a {
46+
font-weight: 500;
47+
color: #646cff;
48+
text-decoration: inherit;
49+
}
50+
51+
a:hover {
52+
color: #535bf2;
53+
}
54+
55+
h1 {
56+
text-align: center;
57+
}
58+
59+
input,
60+
button {
61+
border-radius: 8px;
62+
border: 1px solid transparent;
63+
padding: 0.6em 1.2em;
64+
font-size: 1em;
65+
font-weight: 500;
66+
font-family: inherit;
67+
color: #0f0f0f;
68+
background-color: #ffffff;
69+
transition: border-color 0.25s;
70+
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
71+
}
72+
73+
button {
74+
cursor: pointer;
75+
}
76+
77+
button:hover {
78+
border-color: #396cd8;
79+
}
80+
button:active {
81+
border-color: #396cd8;
82+
background-color: #e8e8e8;
83+
}
84+
85+
input,
86+
button {
87+
outline: none;
88+
}
89+
90+
#greet-input {
91+
margin-right: 5px;
92+
}
93+
94+
@media (prefers-color-scheme: dark) {
95+
:root {
96+
color: #f6f6f6;
97+
background-color: #2f2f2f;
98+
}
99+
100+
a:hover {
101+
color: #24c8db;
102+
}
103+
104+
input,
105+
button {
106+
color: #ffffff;
107+
background-color: #0f0f0f98;
108+
}
109+
button:active {
110+
background-color: #0f0f0f69;
111+
}
112+
}

app/src/main/java/com/app/pakeplus/MainActivity.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ class MainActivity : AppCompatActivity() {
116116
false
117117
}
118118

119-
webView.loadUrl("https://juejin.cn/")
119+
// webView.loadUrl("https://juejin.cn/")
120+
webView.loadUrl("file:///android_asset/index.html")
120121

121122
// binding = ActivityMainBinding.inflate(layoutInflater)
122123
// setContentView(R.layout.single_main)
@@ -168,7 +169,7 @@ class MainActivity : AppCompatActivity() {
168169
inner class MyWebViewClient : WebViewClient() {
169170

170171
// vConsole debug
171-
private var debug = false
172+
private var debug = true
172173

173174
@Deprecated("Deprecated in Java", ReplaceWith("false"))
174175
override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {

0 commit comments

Comments
 (0)