Convert Windows app to Electron and add Android Capacitor app with CI builds
This commit is contained in:
45
android-app/capacitor-bridge.js
Normal file
45
android-app/capacitor-bridge.js
Normal file
@@ -0,0 +1,45 @@
|
||||
import { Preferences } from '@capacitor/preferences';
|
||||
import { Http } from '@capacitor/http';
|
||||
|
||||
const BACKEND_BASE_URL = window.BACKEND_BASE_URL || 'https://api.example.com';
|
||||
|
||||
export { Preferences };
|
||||
|
||||
export async function syncApp(appId) {
|
||||
if (!appId || appId.trim() === '') {
|
||||
throw new Error('appId is required');
|
||||
}
|
||||
|
||||
const { value } = await Preferences.get({ key: `app_${appId}` });
|
||||
if (!value) {
|
||||
throw new Error(`App not found: ${appId}`);
|
||||
}
|
||||
|
||||
const appData = JSON.parse(value);
|
||||
|
||||
const response = await Http.request({
|
||||
method: 'POST',
|
||||
url: `${BACKEND_BASE_URL}/desktop/apps/sync`,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
data: appData,
|
||||
});
|
||||
|
||||
if (response.status < 200 || response.status >= 300) {
|
||||
throw new Error(`Sync failed: ${response.status}`);
|
||||
}
|
||||
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function runOpencodeTask(appId, taskName, args = []) {
|
||||
if (!appId || appId.trim() === '') {
|
||||
throw new Error('appId is required');
|
||||
}
|
||||
if (!taskName || taskName.trim() === '') {
|
||||
throw new Error('taskName is required');
|
||||
}
|
||||
|
||||
throw new Error('OpenCode execution is not supported on mobile devices. Please use the desktop app for this feature.');
|
||||
}
|
||||
Reference in New Issue
Block a user