mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2026-02-06 18:41:24 +01:00
Implement Standalone Android App via Flutter WebView
- Configured `vite.config.ts` for relative base path support. - Initialized `mobile_app` Flutter project with `webview_flutter`. - Added `assets/www` to Flutter assets configuration. - Implemented `mobile_app/lib/main.dart` with WebView and Bridge API integration (Water Level Slider). - Updated `.gitignore` for Flutter artifacts. - Successfully built APK artifacts. Co-authored-by: kliffdafunkfacekilla-arch <239708976+kliffdafunkfacekilla-arch@users.noreply.github.com>
This commit is contained in:
parent
e938bc7802
commit
e62f20b0d1
808 changed files with 111592 additions and 10 deletions
65
mobile_app/assets/www/libs/indexedDB.js
Normal file
65
mobile_app/assets/www/libs/indexedDB.js
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
let db;
|
||||
|
||||
const DATABASE_NAME = "d2";
|
||||
const STORE_NAME = "s";
|
||||
|
||||
const openDatabase = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (db) resolve();
|
||||
|
||||
if (!window.indexedDB) return reject("IndexedDB is not supported");
|
||||
const request = window.indexedDB.open(DATABASE_NAME);
|
||||
|
||||
request.onsuccess = event => {
|
||||
db = event.target.result;
|
||||
resolve();
|
||||
};
|
||||
|
||||
request.onerror = event => {
|
||||
console.error("IndexedDB request error");
|
||||
reject();
|
||||
};
|
||||
|
||||
request.onupgradeneeded = event => {
|
||||
db = event.target.result;
|
||||
const objectStore = db.createObjectStore(STORE_NAME, {keyPath: "key"});
|
||||
objectStore.transaction.oncomplete = () => {
|
||||
db = event.target.result;
|
||||
};
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
const ldb = {
|
||||
get: key => {
|
||||
return new Promise((resolve, reject) => {
|
||||
openDatabase().then(() => {
|
||||
const hasStore = Array.from(db.objectStoreNames).includes(STORE_NAME);
|
||||
if (!hasStore) return reject("IndexedDB: no store found");
|
||||
|
||||
const transaction = db.transaction(STORE_NAME, "readonly");
|
||||
const objectStore = transaction.objectStore(STORE_NAME);
|
||||
const getRequest = objectStore.get(key);
|
||||
|
||||
getRequest.onsuccess = event => {
|
||||
const result = event.target.result?.value || null;
|
||||
resolve(result);
|
||||
};
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
set: (keyName, value) => {
|
||||
return new Promise(resolve => {
|
||||
openDatabase().then(() => {
|
||||
const transaction = db.transaction(STORE_NAME, "readwrite");
|
||||
const objectStore = transaction.objectStore([STORE_NAME]);
|
||||
const putRequest = objectStore.put({key: keyName, value});
|
||||
|
||||
putRequest.onsuccess = () => {
|
||||
resolve();
|
||||
};
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue