Skip to content

Commit

Permalink
Improve app initialization and version updates
Browse files Browse the repository at this point in the history
- Bump application version to 0.2.2 for both Cargo and Tauri configuration.
- Enhance security by adding additional source URLs to the connect-src settings.
- Improve code clarity and initialization logic in the App.vue component.
  • Loading branch information
zhongweili committed Dec 15, 2024
1 parent 058d844 commit 44e5807
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "imagenie"
version = "0.2.0"
version = "0.2.2"
description = "A Tauri App"
authors = ["zhongwei"]
edition = "2021"
Expand Down
4 changes: 2 additions & 2 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "imagenie",
"version": "0.2.0",
"version": "0.2.2",
"identifier": "com.imagenie.app",
"build": {
"beforeDevCommand": "yarn dev",
Expand All @@ -27,7 +27,7 @@
"style-src": "'self' 'unsafe-inline'",
"img-src": "'self' asset: http://asset.localhost https://raw.githubusercontent.com blob: data:",
"default-src": "'self' asset:",
"connect-src": "'self' tauri: http://tauri.localhost ipc: http://ipc.localhost http://localhost:8023 ipc: https://api.github.com",
"connect-src": "'self' tauri: http://tauri.localhost ipc: http://ipc.localhost http://localhost:8023 ipc: https://api.github.com https://api.iconify.design https://api.unisvg.com https://api.simplesvg.com",
"script-src": "'self'"
},
"assetProtocol": {
Expand Down
30 changes: 26 additions & 4 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,20 +1,42 @@
<!-- App.vue -->
<template>
<main class="container">
<InitializationScreen v-if="isInitializing" @initialization-complete="onInitializationComplete" />
<InitializationScreen v-if="needsInitialization" @initialization-complete="onInitializationComplete" />
<MainLayout v-else />
</main>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { ref, onMounted } from 'vue';
import { invoke } from '@tauri-apps/api/core';
import MainLayout from '@/components/MainLayout.vue';
import InitializationScreen from '@/components/InitializationScreen.vue';
import { FACE_RESTORATION_MODEL, IMAGE_UPSCALING_MODEL, BACKGROUND_REMOVAL_MODEL } from './config/models';

const isInitializing = ref(true);
const needsInitialization = ref(true);
const MODELS = [BACKGROUND_REMOVAL_MODEL, FACE_RESTORATION_MODEL, IMAGE_UPSCALING_MODEL];

onMounted(async () => {
try {
let requiresDownload = false;
for (const model of MODELS) {
const needsDownload = await invoke('check_model_exists', { modelName: model });
if (needsDownload) {
requiresDownload = true;
break;
}
}

if (!requiresDownload) {
needsInitialization.value = false;
}
} catch (error) {
console.error('Error checking models:', error);
}
});

function onInitializationComplete() {
isInitializing.value = false;
needsInitialization.value = false;
}
</script>

Expand Down

0 comments on commit 44e5807

Please sign in to comment.