Skip to content

Commit dc6f9a7

Browse files
committed
🤣 修复菜单按钮崩溃
实验性功能没有通过测试意外地和常规更新内容一起上传了....
1 parent 93098ab commit dc6f9a7

File tree

2 files changed

+37
-46
lines changed

2 files changed

+37
-46
lines changed

src-tauri/tauri.conf.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020
},
2121
"bundle": {
2222
"active": true,
23-
"icon": [
24-
"icons/icon.ico"
25-
],
23+
"icon": ["icons/icon.ico"],
2624
"identifier": "com.blueedgetechno.win11react",
2725
"targets": "all"
2826
},
@@ -41,4 +39,5 @@
4139
"height": 600
4240
}
4341
]
44-
}
42+
}
43+
}

src/components/start/start.jsx

+34-42
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,53 @@
11
import React, { useState, useEffect } from "react";
22
import { useSelector, useDispatch } from "react-redux";
33
import { Icon } from "../../utils/general";
4-
import pinyin from "tiny-pinyin";
5-
6-
7-
// 辅助函数:将中文字符串转换为拼音并提取首字母
8-
function getFirstLetter(str) {
9-
const pinyinName = pinyin.convertToPinyin(str, '', false);
10-
const firstLetter = pinyinName.charAt(0).toUpperCase();
11-
return firstLetter >= 'A' && firstLetter <= 'Z' ? firstLetter : '#';
12-
}
134

145
export const StartMenu = () => {
156
const { align } = useSelector((state) => state.taskbar);
167
const start = useSelector((state) => {
17-
const arr = state.startmenu;
18-
let ln = (6 - (arr.pnApps.length % 6)) % 6;
8+
var arr = state.startmenu,
9+
ln = (6 - (arr.pnApps.length % 6)) % 6;
1910

20-
for (let i = 0; i < ln; i++) {
11+
for (var i = 0; i < ln; i++) {
2112
arr.pnApps.push({
2213
empty: true,
2314
});
2415
}
2516

26-
arr.rcApps.forEach((app) => {
27-
if (app.lastUsed < 0) {
28-
app.lastUsed = "Recently Added";
29-
} else if (app.lastUsed < 10) {
30-
app.lastUsed = "Just Now";
31-
} else if (app.lastUsed < 60) {
32-
app.lastUsed += "m ago";
33-
} else if (app.lastUsed < 360) {
34-
app.lastUsed = Math.floor(app.lastUsed / 60) + "h ago";
17+
for (i = 0; i < arr.rcApps.length; i++) {
18+
if (arr.rcApps[i].lastUsed < 0) {
19+
arr.rcApps[i].lastUsed = "Recently Added";
20+
} else if (arr.rcApps[i].lastUsed < 10) {
21+
arr.rcApps[i].lastUsed = "Just Now";
22+
} else if (arr.rcApps[i].lastUsed < 60) {
23+
arr.rcApps[i].lastUsed += "m ago";
24+
} else if (arr.rcApps[i].lastUsed < 360) {
25+
arr.rcApps[i].lastUsed =
26+
Math.floor(arr.rcApps[i].lastUsed / 60) + "h ago";
3527
}
36-
});
28+
}
3729

38-
const allApps = {};
39-
const tmpApps = Object.keys(state.apps)
40-
.filter((x) => x !== "hz")
41-
.map((key) => {
42-
const app = state.apps[key];
43-
app.pinyinName = pinyin.convertToPinyin(app.name, '', false);
44-
return app;
45-
});
30+
var allApps = [],
31+
tmpApps = Object.keys(state.apps)
32+
.filter((x) => x != "hz")
33+
.map((key) => {
34+
return state.apps[key];
35+
});
4636

47-
tmpApps.sort((a, b) => a.pinyinName.localeCompare(b.pinyinName));
37+
tmpApps.sort((a, b) => (a.name > b.name ? 1 : b.name > a.name ? -1 : 0));
4838

49-
tmpApps.forEach((app) => {
50-
const firstLetter = getFirstLetter(app.name);
51-
if (!allApps[firstLetter]) {
52-
allApps[firstLetter] = [];
53-
}
54-
allApps[firstLetter].push(app);
55-
});
39+
for (i = 0; i < 27; i++) {
40+
allApps[i] = [];
41+
}
5642

57-
// 确保contApps被正确初始化为一个数组
58-
arr.contApps = Object.values(allApps);
43+
for (i = 0; i < tmpApps.length; i++) {
44+
var t1 = tmpApps[i].name.trim().toUpperCase().charCodeAt(0);
45+
if (t1 > 64 && t1 < 91) {
46+
allApps[t1 - 64].push(tmpApps[i]);
47+
} else {
48+
allApps[0].push(tmpApps[i]);
49+
}
50+
}
5951

6052
arr.contApps = allApps;
6153
arr.allApps = tmpApps;
@@ -270,12 +262,12 @@ export const StartMenu = () => {
270262
<div className="menuBar">
271263
<div className="profile handcr">
272264
<Icon
273-
src="prof"
265+
src="blueProf"
274266
ui
275267
rounded
276268
width={26}
277269
click="EXTERNAL"
278-
payload="https://blueedge.me/"
270+
payload="https://blueedge.me"
279271
/>
280272
<div className="usName">{userName}</div>
281273
</div>

0 commit comments

Comments
 (0)