Code Monkey home page Code Monkey logo

vite-vue-sqlite-app's Introduction


Vite 4.0 Vue 3.2 SQLite App

vite-vue-sqlite-app

Vite 4.0 Vue 3.2 application demonstrating the use of the

@capacitor-community/sqlite-plugin


this app uses Capacitor 4


Maintainers

Maintainer GitHub Social
Quéau Jean Pierre jepiqueau

Installation

To start clone the project

git clone https://github.com/jepiqueau/vite-vue-sqlite-app.git 
cd vite-vue-sqlite-app
git remote rm origin
npm install

Capacitor Config File

In the main folder of your app, you MUST have a capacitor.config.ts file

import { CapacitorConfig } from '@capacitor/cli';

const appName: string = 'YOUR_APP_NAME';

const config: CapacitorConfig = {
  appId: 'YOUR_APP_ID', // ie com.jeep.app.vite.vue.sqlite
  appName: appName,
  webDir: 'dist',
  bundledWebRuntime: false,
  //  hideLogs: true,
  plugins: {
    CapacitorSQLite: {
      iosDatabaseLocation: 'Library/CapacitorDatabase',
      iosIsEncryption: false,
      iosKeychainPrefix: appName,
      iosBiometric: {
        biometricAuth: false,
        biometricTitle : "Biometric login for capacitor sqlite"
      },
      androidIsEncryption: false,
      androidBiometric: {
        biometricAuth : false,
        biometricTitle : "Biometric login for capacitor sqlite",
        biometricSubTitle : "Log in using your biometric"
      },
      electronWindowsLocation: "C:\\ProgramData\\CapacitorDatabases",
      electronMacLocation: "YOUR_VOLUME/CapacitorDatabases",
      electronLinuxLocation: "Databases"
    }
  }
};
export default config;

WEB Quirks

npx run dev

IOS Quirks

npm run ios:start

Once Xcode launches, you can build your app through the standard Xcode workflow.

ANDROID Quirks

npm run android:start

Once Android Studio launches, make sure that you are using

  • Gradle JDK version 11

  • Android Gradle Plugin Version 7.2.2

  • In variables.gradle

    minSdkVersion = 22
    compileSdkVersion = 33
    targetSdkVersion = 33
    
  • In AndroidManifest.xml

        <application
         android:allowBackup="false"
         android:fullBackupContent="false"
         android:dataExtractionRules="@xml/data_extraction_rules"
    
  • In res/xml create a file data_extraction_rules.xml containing:

    <?xml version="1.0" encoding="utf-8"?>
    <data-extraction-rules>
       <cloud-backup>
          <exclude domain="root" />
          <exclude domain="database" />
          <exclude domain="sharedpref" />
          <exclude domain="external" />
       </cloud-backup>
       <device-transfer>
          <exclude domain="root" />
          <exclude domain="database" />
          <exclude domain="sharedpref" />
          <exclude domain="external" />
       </device-transfer>
    </data-extraction-rules>
    

and build your app through the standard Android Studio workflow.

ELECTRON Quirks

Make sure that the package.json file is as followed

{
  "name": "vite-vue-sqlite-app",
  "version": "1.0.0",
  "description": "An Amazing Capacitor App",
  "author": {
    "name": "",
    "email": ""
  },
  "repository": {
    "type": "git",
    "url": ""
  },
  "license": "MIT",
  "main": "build/src/index.js",
  "scripts": {
    "build": "tsc && electron-rebuild",
    "electron:start-live": "node ./live-runner.js",
    "electron:start": "npm run build && electron --inspect=5858 ./",
    "electron:pack": "npm run build && electron-builder build --dir -c ./electron-builder.config.json",
    "electron:make": "npm run build && electron-builder build -c ./electron-builder.config.json -p always"
  },
  "dependencies": {
    "@capacitor-community/electron": "^4.1.2",
    "@capacitor-community/sqlite": "^4.6.2",
    "chokidar": "~3.5.3",
    "electron-is-dev": "~2.0.0",
    "electron-serve": "~1.1.0",
    "electron-unhandled": "~4.0.1",
    "electron-updater": "~5.0.1",
    "electron-window-state": "~5.0.3",
    "jszip": "^3.10.1",
    "node-fetch": "2.6.7",
    "sqlite3": "^5.1.4"
  },
  "devDependencies": {
    "@types/sqlite3": "^3.1.8",
    "electron": "^23.1.1",
    "electron-builder": "^22.10.3",
    "electron-rebuild": "^3.2.9",
    "typescript": "~4.3.5"
  },
  "keywords": [
    "capacitor",
    "electron"
  ]
}

In the main folder of your app

npm run electron:install
npm run electron:start

Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

vite-vue-sqlite-app's People

Contributors

jepiqueau avatar reslear avatar

Stargazers

nunhes avatar  avatar

Watchers

 avatar

Forkers

reslear

vite-vue-sqlite-app's Issues

Vite HMR / auto reload is broken.

How to Reproduce

Tested on M1 Pro (if relavant)

  1. git clone …
  2. npm run ci (to ensure versions are exactly the same)
  3. npm run dev
  4. Change any file to trigger auto reload.

image

At first, everything works like expected. After we change something we see an error like in the screenshot above.
I tried to use the SQLlite plugin myself and had the same issue. Manual reload of page and the error is gone. Any Idea whats causing this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.