Skip to content

Commit

Permalink
Merge branch 'main' of github.com:lsk569937453/code-magic-public into…
Browse files Browse the repository at this point in the history
… release
  • Loading branch information
lsk569937453 committed Dec 23, 2023
2 parents 5577159 + dae7a76 commit b2a1430
Show file tree
Hide file tree
Showing 37 changed files with 1,106 additions and 315 deletions.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,16 @@
"ace-builds": "^1.32.0",
"cmdk": "^0.2.0",
"date-fns": "^2.30.0",
"i18next": "^23.7.11",
"lucide-react": "^0.263.1",
"next-themes": "^0.2.1",
"react": "^18.2.0",
"react-ace": "^10.1.0",
"react-color-palette": "^7.1.0",
"react-color": "^2.19.3",
"react-day-picker": "^8.8.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.45.2",
"react-i18next": "^13.5.0",
"recharts": "^2.7.2",
"tailwind-scrollbar": "^3.0.4",
"tailwindcss-animate": "^1.0.6",
Expand All @@ -65,13 +67,15 @@
"@tauri-apps/cli": "^1.4.0",
"@types/node": "^20.4.6",
"@types/react": "^18.2.18",
"@types/react-color": "^3.0.10",
"@types/react-dom": "^18.2.7",
"autoprefixer": "^10.4.14",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"postcss": "^8.4.27",
"prettier": "^3.0.1",
"prettier-plugin-tailwindcss": "^0.4.1",
"react-color": "^2.19.3",
"tailwind-merge": "^1.14.0",
"tailwindcss": "^3.3.3",
"taze": "^0.11.2",
Expand Down
119 changes: 112 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "code_magic"
version = "0.0.18"
version = "0.0.19"
description = "A development tools"
authors = ["lsk"]
license = "MIT"
Expand Down
20 changes: 20 additions & 0 deletions src-tauri/src/common_tools/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use crate::common_tools::qrcode::export_qrcode_with_error;
use crate::common_tools::qrcode::get_barcode_with_error;
use crate::common_tools::qrcode::get_qrcode_with_error;
use crate::common_tools::sql_lite::get_menu_config_with_error;
use crate::common_tools::sql_lite::reset_menu_index_with_error;
use crate::common_tools::sql_lite::set_menu_index_with_error;
use crate::common_tools::sql_lite::GetMenuConfigReq;
use crate::common_tools::timestamp::format_datetime_to_timestamp_with_error;
Expand Down Expand Up @@ -557,6 +558,25 @@ pub fn get_menu_config(
}
}
#[tauri::command]
pub fn reset_menu_index(state: State<SqlLiteState>) -> String {
match reset_menu_index_with_error(state) {
Ok(item) => {
let res = BaseResponse {
response_code: 0,
response_msg: item,
};
serde_json::to_string(&res).unwrap()
}
Err(e) => {
let res = BaseResponse {
response_code: 1,
response_msg: e.to_string(),
};
serde_json::to_string(&res).unwrap()
}
}
}
#[tauri::command]
pub fn set_menu_index(
state: State<SqlLiteState>,
source_index: i32,
Expand Down
10 changes: 8 additions & 2 deletions src-tauri/src/common_tools/sql_lite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,14 @@ pub fn set_menu_index_with_error(
params![menu_config.menu_index, menu_config.source_index],
)?;
}
// 1 2 3 4 5 6 7 8 2->7
// 1 2 3 4 5 6 7 8 7->2

Ok(())
}
pub fn reset_menu_index_with_error(state: State<SqlLiteState>) -> Result<(), anyhow::Error> {
let sql_lite = state.0.lock().map_err(|e| anyhow!("lock error"))?;

let connection = &sql_lite.connection;
let mut statement =
connection.execute("update menu_config set menu_index=source_index", params![])?;
Ok(())
}
3 changes: 2 additions & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ fn main() -> Result<(), anyhow::Error> {
format_pretty_xml,
get_about_version,
get_menu_config,
set_menu_index
set_menu_index,
reset_menu_index
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
Expand Down
1 change: 1 addition & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useState } from "react"
import { invoke } from "@tauri-apps/api/tauri"
import './i18n';

import { Menu } from "@/components/menu"

Expand Down
Loading

0 comments on commit b2a1430

Please sign in to comment.