create-tauri-vue-app 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-tauri-vue-app",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Scaffold a new Tauri + Vue desktop application",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,3 +1,11 @@
1
+ # 设计
2
+
3
+ 在做系统设计的时候,包括这几个方面
4
+
5
+ 1. 前后端交互的流程 (用 mermaid 写)
6
+ 2. Command 交互的数据结构(用 JSON 的格式)
7
+ 3. 表结构
8
+
1
9
  # 前端编码规范
2
10
 
3
11
  1. 尽量复用 element plus 组件进行 UI 开发
@@ -12,7 +12,6 @@
12
12
  "dependencies": {
13
13
  "@tauri-apps/api": "^2.11.0",
14
14
  "@tauri-apps/plugin-log": "^2.8.0",
15
- "@tauri-apps/plugin-shell": "^2.3.5",
16
15
  "@tauri-apps/plugin-sql": "^2.4.0",
17
16
  "element-plus": "^2.13.7",
18
17
  "vue": "^3.5.32",
@@ -7,7 +7,7 @@ export async function getDb() {
7
7
  if (!db) {
8
8
  const home = await path.homeDir();
9
9
  // 分层拼接,自动适配 / 和 \
10
- const dbDir = await path.join(home, '.{{PROJECT_NAME}}');
10
+ const dbDir = await path.join(home, '.{{PROJECT_NAME}}/app');
11
11
  const dbFilePath = await path.join(dbDir, 'app.db');
12
12
  // sqlite 连接串格式:sqlite:完整本地路径
13
13
  const dbUrl = `sqlite:${dbFilePath}`;
@@ -24,5 +24,4 @@ dirs = "5"
24
24
  log = "0.4"
25
25
  tauri = { version = "2.10.3", features = ["devtools"] }
26
26
  tauri-plugin-log = "2"
27
- tauri-plugin-shell = "2"
28
- tauri-plugin-sql = { version = "2", features = ["sqlite"] }
27
+ tauri-plugin-sql = { git = "https://github.com/tuyu79/plugins-workspace.git", branch = "v2-sql-default", package = "tauri-plugin-sql", features = ["sqlite"] }
@@ -6,49 +6,10 @@
6
6
  "permissions": [
7
7
  "core:default",
8
8
  "log:default",
9
- "shell:allow-open",
10
9
  "sql:default",
11
10
  "sql:allow-load",
12
11
  "sql:allow-execute",
13
12
  "sql:allow-select",
14
- "sql:allow-close",
15
- "shell:allow-execute",
16
- "shell:allow-spawn",
17
- "shell:allow-stdin-write",
18
- {
19
- "identifier": "shell:allow-execute",
20
- "allow": [
21
- {
22
- "name": "xcode-select",
23
- "cmd": "xcode-select",
24
- "args": true
25
- },
26
- {
27
- "name": "sh",
28
- "cmd": "sh",
29
- "args": true
30
- },
31
- {
32
- "name": "node",
33
- "cmd": "node",
34
- "args": true
35
- },
36
- {
37
- "name": "curl",
38
- "cmd": "curl",
39
- "args": true
40
- },
41
- {
42
- "name": "open",
43
- "cmd": "open",
44
- "args": true
45
- },
46
- {
47
- "name": "osascript",
48
- "cmd": "osascript",
49
- "args": true
50
- }
51
- ]
52
- }
13
+ "sql:allow-close"
53
14
  ]
54
15
  }
@@ -0,0 +1,8 @@
1
+ CREATE TABLE IF NOT EXISTS tasks (
2
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
3
+ title TEXT NOT NULL,
4
+ description TEXT,
5
+ completed INTEGER DEFAULT 0,
6
+ created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
7
+ updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
8
+ );
@@ -4,6 +4,15 @@ use tauri_plugin_log::{Target, TargetKind};
4
4
 
5
5
  pub fn run() {
6
6
 
7
+ let migrations = vec![
8
+ Migration {
9
+ version: 1,
10
+ description: "create_initial_tables",
11
+ sql: include_str!("../migrations/0000_initial.sql"),
12
+ kind: MigrationKind::Up,
13
+ },
14
+ ];
15
+
7
16
  let app_dir = {
8
17
  let home = dirs::home_dir().expect("failed to get home directory");
9
18
  let dir = home.join(".{{PROJECT_NAME}}").join("app");
@@ -24,50 +33,21 @@ pub fn run() {
24
33
  ])
25
34
  .build(),
26
35
  )
27
- .plugin(tauri_plugin_shell::init())
28
36
  .plugin(
29
37
  tauri_plugin_sql::Builder::default()
30
38
  .add_migrations(
31
39
  &db_path,
32
- vec![
33
- Migration {
34
- version: 1,
35
- description: "create_tasks_table",
36
- sql: r#"
37
- CREATE TABLE IF NOT EXISTS tasks (
38
- id INTEGER PRIMARY KEY AUTOINCREMENT,
39
- title TEXT NOT NULL,
40
- description TEXT,
41
- completed INTEGER DEFAULT 0,
42
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
43
- updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
44
- )
45
- "#,
46
- kind: MigrationKind::Up,
47
- },
48
- Migration {
49
- version: 2,
50
- description: "create_downloads_table",
51
- sql: r#"
52
- CREATE TABLE IF NOT EXISTS downloads (
53
- id INTEGER PRIMARY KEY AUTOINCREMENT,
54
- filename TEXT NOT NULL,
55
- url TEXT,
56
- save_path TEXT,
57
- file_size TEXT,
58
- status TEXT DEFAULT 'downloading',
59
- progress INTEGER DEFAULT 0,
60
- gid TEXT,
61
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
62
- updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
63
- )
64
- "#,
65
- kind: MigrationKind::Up,
66
- },
67
- ],
40
+ migrations,
68
41
  )
69
42
  .build(),
70
43
  )
44
+ .invoke_handler(tauri::generate_handler![
45
+
46
+ ])
47
+ .setup(|_app| {
48
+ log::info!("{{PROJECT_NAME}} app initialised");
49
+ Ok(())
50
+ })
71
51
  .run(tauri::generate_context!())
72
52
  .expect("error while running tauri application");
73
53
  }
@@ -34,5 +34,12 @@
34
34
  "icons/icon.icns",
35
35
  "icons/icon.ico"
36
36
  ]
37
+ },
38
+ "plugins": {
39
+ "sql": {
40
+ "preload": [
41
+ "sqlite:~/.{{PROJECT_NAME}}/app/app.db"
42
+ ]
43
+ }
37
44
  }
38
45
  }