Skip to content

Commit 5147b80

Browse files
author
PatrickSachs
committed
Support add to homescreen
1 parent efdf817 commit 5147b80

File tree

7 files changed

+31
-5
lines changed

7 files changed

+31
-5
lines changed

assets/images/icons/192.png

7.57 KB
Loading

assets/images/icons/512.png

38.7 KB
Loading

index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
<meta name="HandheldFriendly" content="True">
99
<meta name="MobileOptimized" content="320">
1010
<meta http-equiv="cleartype" content="on">
11-
<link rel="icon" type="image/x-icon" href="/assets/images/favicon.ico">
11+
<link rel="icon" type="image/x-icon" href="/assets/images/icons/favicon.ico">
1212
<link href='https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons' rel="stylesheet">
13+
<link rel="manifest" href="/manifest.json">
1314
</head>
1415

1516
<body>

manifest.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"short_name": "slow-tree",
3+
"name": "slow-tree by sahnee.de",
4+
"icons": [
5+
{
6+
"src": "/assets/images/icons/192.png",
7+
"type": "image/png",
8+
"sizes": "192x192"
9+
},
10+
{
11+
"src": "/assets/images/icons/512.png",
12+
"type": "image/png",
13+
"sizes": "512x512"
14+
}
15+
],
16+
"start_url": "/",
17+
"background_color": "#212121",
18+
"display": "standalone",
19+
"scope": "/",
20+
"theme_color": "#212121"
21+
}

src/components/App.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<v-list class="pa-0">
77
<v-list-tile avatar>
88
<v-list-tile-avatar>
9-
<img src="/assets/images/favicon.ico">
9+
<img src="/assets/images/icons/favicon.ico">
1010
</v-list-tile-avatar>
1111

1212
<v-list-tile-content>
@@ -299,20 +299,24 @@ export default class STApp extends Vue {
299299
this.onNewBackground(scene.background.backgroundImage);
300300
// Check cache
301301
const cache = localStorage.getItem("cache");
302+
let willCache = true;
302303
if (cache) {
303304
const json = JSON.parse(cache);
304305
try {
305306
scene.loadGame(json);
306-
this.cache();
307307
} catch (error) {
308308
this.oldSavegameVersion = true;
309309
localStorage.removeItem("cache");
310310
console.error("Failed to load savegame. Reason: " + error.message);
311311
this.errorMessage = error.message;
312+
willCache = false;
312313
}
313314
}
314315
//Fill the tree variable with the current tree id
315316
this.tree = scene.tree.treeType.id;
317+
if (willCache) {
318+
this.cache();
319+
}
316320
}
317321
318322
/**

webpack.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,13 @@ const watch = !isProduction;
1919
// PLUGINS
2020
// ===============================================
2121
const plugins = [];
22-
plugins.push(new CleanPlugin());
2322
plugins.push(new VueLoaderPlugin());
2423
plugins.push(new webpack.DefinePlugin({
2524
CANVAS_RENDERER: JSON.stringify(true),
2625
WEBGL_RENDERER: JSON.stringify(true),
2726
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
2827
}));
29-
plugins.push(new CopyPlugin(["index.html", { from: "assets", to: "assets" }]));
28+
plugins.push(new CopyPlugin(["index.html", "manifest.json", { from: "assets", to: "assets" }]));
3029
if (!isProduction) {
3130
plugins.push(new BrowserSyncPlugin({
3231
host: process.env.IP || 'localhost',
@@ -37,6 +36,7 @@ if (!isProduction) {
3736
}));
3837
}
3938
if (isProduction) {
39+
plugins.push(new CleanPlugin());
4040
plugins.push(new WorkboxPlugin.GenerateSW({
4141
swDest: "serviceworker.js",
4242
clientsClaim: true,

0 commit comments

Comments
 (0)