chore: 更新。

This commit is contained in:
Ivan Li 2023-03-16 20:13:08 +08:00
parent eeddff1dc1
commit 653729fcc2
6 changed files with 673 additions and 671 deletions

View File

@ -10,13 +10,13 @@
"tauri": "tauri" "tauri": "tauri"
}, },
"dependencies": { "dependencies": {
"@emotion/react": "^11.10.5", "@emotion/react": "^11.10.6",
"@emotion/styled": "^11.10.5", "@emotion/styled": "^11.10.6",
"@fortawesome/fontawesome-svg-core": "^6.3.0", "@fortawesome/fontawesome-svg-core": "^6.3.0",
"@fortawesome/free-regular-svg-icons": "^6.3.0", "@fortawesome/free-regular-svg-icons": "^6.3.0",
"@fortawesome/free-solid-svg-icons": "^6.3.0", "@fortawesome/free-solid-svg-icons": "^6.3.0",
"@fortawesome/react-fontawesome": "^0.2.0", "@fortawesome/react-fontawesome": "^0.2.0",
"@mui/material": "^5.11.8", "@mui/material": "^5.11.13",
"@tauri-apps/api": "^1.2.0", "@tauri-apps/api": "^1.2.0",
"clsx": "^1.2.1", "clsx": "^1.2.1",
"debug": "^4.3.4", "debug": "^4.3.4",
@ -27,26 +27,26 @@
"react-dom": "^18.2.0" "react-dom": "^18.2.0"
}, },
"devDependencies": { "devDependencies": {
"@babel/plugin-transform-react-jsx": "^7.20.13", "@babel/plugin-transform-react-jsx": "^7.21.0",
"@emotion/babel-plugin-jsx-pragmatic": "^0.2.0", "@emotion/babel-plugin-jsx-pragmatic": "^0.2.0",
"@emotion/serialize": "^1.1.1", "@emotion/serialize": "^1.1.1",
"@tauri-apps/cli": "^1.2.3", "@tauri-apps/cli": "^1.2.3",
"@types/debug": "^4.1.7", "@types/debug": "^4.1.7",
"@types/node": "^18.13.0", "@types/node": "^18.15.3",
"@types/ramda": "^0.28.23", "@types/ramda": "^0.28.23",
"@types/react": "^18.0.28", "@types/react": "^18.0.28",
"@types/react-dom": "^18.0.10", "@types/react-dom": "^18.0.11",
"@vitejs/plugin-react": "^2.2.0", "@vitejs/plugin-react": "^2.2.0",
"autoprefixer": "^10.4.13", "autoprefixer": "^10.4.14",
"babel-plugin-macros": "^3.1.0", "babel-plugin-macros": "^3.1.0",
"eslint-config-prettier": "^8.6.0", "eslint-config-prettier": "^8.7.0",
"eslint-plugin-import": "^2.27.5", "eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsx-a11y": "^6.7.1", "eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-prettier": "^4.2.1", "eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-simple-import-sort": "^8.0.0", "eslint-plugin-simple-import-sort": "^8.0.0",
"postcss": "^8.4.21", "postcss": "^8.4.21",
"prettier": "^2.8.4", "prettier": "^2.8.4",
"tailwindcss": "^3.2.6", "tailwindcss": "^3.2.7",
"twin.macro": "^3.1.0", "twin.macro": "^3.1.0",
"typescript": "^4.9.5", "typescript": "^4.9.5",
"vite": "^3.2.5" "vite": "^3.2.5"

File diff suppressed because it is too large Load Diff

870
src-tauri/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -158,16 +158,10 @@ impl Manager {
let rpc = rpc::Manager::global().await; let rpc = rpc::Manager::global().await;
rpc.publish_desktop_cmd(&models::CmdRespMqMessage::Brightness( rpc.publish_desktop_cmd(
models::ConfigDisplayCmd { format!("display{}/brightness", display_brightness.display_index).as_str(),
display_index: config.id, target.to_be_bytes().to_vec(),
value: models::CmdRespWithRange { )
value: config.brightness,
min: config.min_brightness,
max: config.max_brightness,
},
},
))
.await; .await;
} }
Err(err) => { Err(err) => {

View File

@ -52,11 +52,9 @@ impl Manager {
pub async fn publish_led_sub_pixels(&self, payload: Vec<u8>) -> anyhow::Result<()> { pub async fn publish_led_sub_pixels(&self, payload: Vec<u8>) -> anyhow::Result<()> {
self.client.publish_led_sub_pixels(payload).await self.client.publish_led_sub_pixels(payload).await
} }
pub async fn publish_desktop_cmd<T>(&self, msg: &T) -> anyhow::Result<()> pub async fn publish_desktop_cmd(&self, field: &str, payload: Vec<u8>) -> anyhow::Result<()>
where
T: ?Sized + serde::Serialize,
{ {
self.client.publish_desktop_cmd(msg).await self.client.publish_desktop_cmd(field, payload).await
} }
pub fn client(&self) -> &MqttRpc { pub fn client(&self) -> &MqttRpc {

View File

@ -12,7 +12,6 @@ const DISPLAY_TOPIC: &'static str = "display-ambient-light/display";
const DESKTOP_TOPIC: &'static str = "display-ambient-light/desktop"; const DESKTOP_TOPIC: &'static str = "display-ambient-light/desktop";
const DISPLAY_BRIGHTNESS_TOPIC: &'static str = "display-ambient-light/board/brightness"; const DISPLAY_BRIGHTNESS_TOPIC: &'static str = "display-ambient-light/board/brightness";
const BOARD_SEND_CMD: &'static str = "display-ambient-light/board/cmd"; const BOARD_SEND_CMD: &'static str = "display-ambient-light/board/cmd";
const DESKTOP_SEND_CMD: &'static str = "display-ambient-light/desktop/cmd";
pub struct MqttRpc { pub struct MqttRpc {
client: mqtt::AsyncClient, client: mqtt::AsyncClient,
@ -227,16 +226,12 @@ impl MqttRpc {
) -> broadcast::Receiver<display::DisplayBrightness> { ) -> broadcast::Receiver<display::DisplayBrightness> {
self.change_display_brightness_tx.subscribe() self.change_display_brightness_tx.subscribe()
} }
pub async fn publish_desktop_cmd<T>(&self, msg: &T) -> anyhow::Result<()> pub async fn publish_desktop_cmd(&self, field: &str, payload: Vec<u8>) -> anyhow::Result<()>
where
T: ?Sized + serde::Serialize,
{ {
let str = serde_json::to_string(msg)
.map_err(|err| anyhow::anyhow!("can not serialize. {:?}", err))?;
self.client self.client
.publish(mqtt::Message::new( .publish(mqtt::Message::new(
DESKTOP_SEND_CMD, format!("{}/{}", DESKTOP_TOPIC, field),
str.as_bytes(), payload,
mqtt::QOS_1, mqtt::QOS_1,
)) ))
.await .await