iT邦幫忙

2022 iThome 鐵人賽

DAY 11
0
Modern Web

30天學習Tauri系列 第 11

11.實作Tauri Todo - Backend (一) 加入Todo功能

  • 分享至 

  • xImage
  •  

接下來幾天要實現我們Tauri後端的功能,這裡我們使用sqlite來當作我們的database

首先,簡單介紹下SQLite。SQLite是關聯式資料庫管理系統,被包含在一個相對小的C lib裡。SQLite常常被整合在使用者程式中。

接著我們開始安裝,我們到todo\src-tauri\Cargo.toml並將rusqlite加入。

在dependecy加入
rusqlite = { version = "0.28.0", features = ["bundled"] }

[package]
name = "todo"
version = "0.0.0"
description = "A Tauri App"
authors = ["you"]
license = ""
repository = ""
edition = "2021"
rust-version = "1.57"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[build-dependencies]
tauri-build = { version = "1.1", features = [] }

[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.1", features = ["api-all"] }
rusqlite = { version = "0.28.0", features = ["bundled"] }

[features]
# by default Tauri runs in production mode
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
default = [ "custom-protocol" ]
# this feature is used used for production builds where `devPath` points to the filesystem
# DO NOT remove this
custom-protocol = [ "tauri/custom-protocol" ]

接著,我們在終端進入src-tauri目錄下執行cargo build
https://ithelp.ithome.com.tw/upload/images/20220926/2010893197Fu7isu4j.png

此時我們已經安裝好rusqlite,明天接著實做Tauri後端的Todo功能


上一篇
10.Tauri Window Menu (二)
下一篇
12.實作Tauri Todo -Backend (二) 編寫Tauri Core
系列文
30天學習Tauri30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言