chore(deps): Add Capacitor camera and filesystem plugins
- Add @capacitor/camera@6.0.0 for cross-platform photo capture - Add @capacitor/filesystem@6.0.0 for file system operations - Maintain compatibility with existing Capacitor core v6.2.1 These plugins enable native camera access and file system operations for the Capacitor platform implementation.
This commit is contained in:
@@ -92,10 +92,10 @@
|
||||
<script lang="ts">
|
||||
/**
|
||||
* PhotoDialog.vue - Cross-platform photo capture and selection component
|
||||
*
|
||||
*
|
||||
* This component provides a unified interface for taking photos and selecting images
|
||||
* across different platforms using the PlatformService.
|
||||
*
|
||||
*
|
||||
* @author Matthew Raymer
|
||||
* @file PhotoDialog.vue
|
||||
*/
|
||||
@@ -186,12 +186,15 @@ export default class PhotoDialog extends Vue {
|
||||
this.fileName = result.fileName;
|
||||
} catch (error) {
|
||||
logger.error("Error taking picture:", error);
|
||||
this.$notify({
|
||||
group: "alert",
|
||||
type: "danger",
|
||||
title: "Error",
|
||||
text: "Failed to take picture. Please try again.",
|
||||
}, 5000);
|
||||
this.$notify(
|
||||
{
|
||||
group: "alert",
|
||||
type: "danger",
|
||||
title: "Error",
|
||||
text: "Failed to take picture. Please try again.",
|
||||
},
|
||||
5000,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,12 +205,15 @@ export default class PhotoDialog extends Vue {
|
||||
this.fileName = result.fileName;
|
||||
} catch (error) {
|
||||
logger.error("Error picking image:", error);
|
||||
this.$notify({
|
||||
group: "alert",
|
||||
type: "danger",
|
||||
title: "Error",
|
||||
text: "Failed to pick image. Please try again.",
|
||||
}, 5000);
|
||||
this.$notify(
|
||||
{
|
||||
group: "alert",
|
||||
type: "danger",
|
||||
title: "Error",
|
||||
text: "Failed to pick image. Please try again.",
|
||||
},
|
||||
5000,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ export class CapacitorPlatformService implements PlatformService {
|
||||
const blob = await this.processImageData(image.base64String);
|
||||
return {
|
||||
blob,
|
||||
fileName: `photo_${Date.now()}.${image.format || 'jpg'}`
|
||||
fileName: `photo_${Date.now()}.${image.format || "jpg"}`,
|
||||
};
|
||||
} catch (error) {
|
||||
logger.error("Error taking picture with Capacitor:", error);
|
||||
@@ -69,7 +69,7 @@ export class CapacitorPlatformService implements PlatformService {
|
||||
const blob = await this.processImageData(image.base64String);
|
||||
return {
|
||||
blob,
|
||||
fileName: `photo_${Date.now()}.${image.format || 'jpg'}`
|
||||
fileName: `photo_${Date.now()}.${image.format || "jpg"}`,
|
||||
};
|
||||
} catch (error) {
|
||||
logger.error("Error picking image with Capacitor:", error);
|
||||
@@ -94,7 +94,7 @@ export class CapacitorPlatformService implements PlatformService {
|
||||
const byteArray = new Uint8Array(byteNumbers);
|
||||
byteArrays.push(byteArray);
|
||||
}
|
||||
return new Blob(byteArrays, { type: 'image/jpeg' });
|
||||
return new Blob(byteArrays, { type: "image/jpeg" });
|
||||
}
|
||||
|
||||
isCapacitor(): boolean {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { PlatformService } from "../PlatformService";
|
||||
import { ImageResult, PlatformService } from "../PlatformService";
|
||||
import { logger } from "../../utils/logger";
|
||||
|
||||
export class ElectronPlatformService implements PlatformService {
|
||||
async readFile(path: string): Promise<string> {
|
||||
@@ -17,11 +18,13 @@ export class ElectronPlatformService implements PlatformService {
|
||||
throw new Error("Not implemented");
|
||||
}
|
||||
|
||||
async takePicture(): Promise<string> {
|
||||
async takePicture(): Promise<ImageResult> {
|
||||
logger.error("takePicture not implemented in Electron platform");
|
||||
throw new Error("Not implemented");
|
||||
}
|
||||
|
||||
async pickImage(): Promise<string> {
|
||||
async pickImage(): Promise<ImageResult> {
|
||||
logger.error("pickImage not implemented in Electron platform");
|
||||
throw new Error("Not implemented");
|
||||
}
|
||||
|
||||
@@ -42,6 +45,7 @@ export class ElectronPlatformService implements PlatformService {
|
||||
}
|
||||
|
||||
async handleDeepLink(url: string): Promise<void> {
|
||||
logger.error("handleDeepLink not implemented in Electron platform");
|
||||
throw new Error("Not implemented");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { PlatformService } from "../PlatformService";
|
||||
import { ImageResult, PlatformService } from "../PlatformService";
|
||||
import { logger } from "../../utils/logger";
|
||||
|
||||
export class PyWebViewPlatformService implements PlatformService {
|
||||
async readFile(path: string): Promise<string> {
|
||||
@@ -17,11 +18,13 @@ export class PyWebViewPlatformService implements PlatformService {
|
||||
throw new Error("Not implemented");
|
||||
}
|
||||
|
||||
async takePicture(): Promise<string> {
|
||||
async takePicture(): Promise<ImageResult> {
|
||||
logger.error("takePicture not implemented in PyWebView platform");
|
||||
throw new Error("Not implemented");
|
||||
}
|
||||
|
||||
async pickImage(): Promise<string> {
|
||||
async pickImage(): Promise<ImageResult> {
|
||||
logger.error("pickImage not implemented in PyWebView platform");
|
||||
throw new Error("Not implemented");
|
||||
}
|
||||
|
||||
@@ -42,6 +45,7 @@ export class PyWebViewPlatformService implements PlatformService {
|
||||
}
|
||||
|
||||
async handleDeepLink(url: string): Promise<void> {
|
||||
logger.error("handleDeepLink not implemented in PyWebView platform");
|
||||
throw new Error("Not implemented");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ export class WebPlatformService implements PlatformService {
|
||||
const blob = await this.processImageFile(file);
|
||||
resolve({
|
||||
blob,
|
||||
fileName: file.name || "photo.jpg"
|
||||
fileName: file.name || "photo.jpg",
|
||||
});
|
||||
} catch (error) {
|
||||
logger.error("Error processing camera image:", error);
|
||||
@@ -60,7 +60,7 @@ export class WebPlatformService implements PlatformService {
|
||||
const blob = await this.processImageFile(file);
|
||||
resolve({
|
||||
blob,
|
||||
fileName: file.name || "photo.jpg"
|
||||
fileName: file.name || "photo.jpg",
|
||||
});
|
||||
} catch (error) {
|
||||
logger.error("Error processing picked image:", error);
|
||||
@@ -82,9 +82,9 @@ export class WebPlatformService implements PlatformService {
|
||||
const dataUrl = event.target?.result as string;
|
||||
// Convert to blob to ensure consistent format
|
||||
fetch(dataUrl)
|
||||
.then(res => res.blob())
|
||||
.then(blob => resolve(blob))
|
||||
.catch(error => {
|
||||
.then((res) => res.blob())
|
||||
.then((blob) => resolve(blob))
|
||||
.catch((error) => {
|
||||
logger.error("Error converting data URL to blob:", error);
|
||||
reject(error);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user