Skip to content

Commit df651e1

Browse files
committed
fix:login issues
1 parent 4007924 commit df651e1

5 files changed

Lines changed: 43 additions & 40 deletions

File tree

chat2db-client/src/components/SearchResult/TableBox/index.less

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
.tableBox {
44
height: calc(100% - 26px);
5-
overflow: auto;
5+
overflow-y: auto;
6+
overflow-x: hidden;
67
display: flex;
78
flex-direction: column;
89
:global {
9-
.hGEOgo {
10+
.art-table {
1011
--header-bgcolor: #fafafa;
1112
--header-color: #000;
1213
table colgroup col {
@@ -15,6 +16,10 @@
1516
table colgroup col:nth-of-type(1) {
1617
min-width: 60px;
1718
}
19+
th,
20+
td {
21+
overflow: hidden;
22+
}
1823
.fnWppk {
1924
// word-break: break-all;
2025
// display: -webkit-box;

chat2db-client/src/components/SearchResult/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export default memo<IProps>((props) => {
4848
<div className={styles.statusBar}>
4949
<span>{`【${i18n('common.text.result')}${queryResultData.description}.`}</span>
5050
<span>{`【${i18n('common.text.timeConsuming')}${queryResultData.duration}ms.`}</span>
51-
{queryResultData?.dataList?.length && (
51+
{!!queryResultData?.dataList?.length && (
5252
<span>{`【${i18n('common.text.searchRow')}${queryResultData?.dataList?.length} ${i18n(
5353
'common.text.row',
5454
)}.`}</span>

chat2db-client/src/layouts/index.tsx

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -85,39 +85,43 @@ function AppContainer() {
8585
const [serviceFail, setServiceFail] = useState(false);
8686
const [isLogin, setIsLogin] = useState<boolean | null>(null);
8787

88+
useLayoutEffect(() => {
89+
collectInitApp();
90+
}, []);
91+
8892
useEffect(() => {
89-
const date = new Date('2030-12-30 12:30:00').toUTCString();
90-
document.cookie = `CHAT2DB.LOCALE=${getLang()};Expires=${date}`;
91-
indexedDB.createDB('chat2db', 1).then((db) => {
92-
window._indexedDB = {
93-
chat2db: db,
94-
};
95-
});
93+
injectThemeVar(token as any, appTheme.backgroundColor, appTheme.primaryColor);
94+
}, [token]);
95+
96+
function handelGetUserInfo() {
9697
getUser().then((res) => {
9798
if (!res) {
9899
navigate('/login');
99100
}
100101
// 向cookie中写入当前用户id
102+
const date = new Date('2030-12-30 12:30:00').toUTCString();
101103
document.cookie = `CHAT2DB.USER_ID=${res?.id};Expires=${date}`;
102104
setIsLogin(!!res);
103105
});
104-
}, []);
105-
106-
useEffect(() => {
107-
injectThemeVar(token as any, appTheme.backgroundColor, appTheme.primaryColor);
108-
}, [token]);
109-
110-
useLayoutEffect(() => {
111-
collectInitApp();
112-
}, []);
106+
}
113107

114108
// 初始化app
115109
function collectInitApp() {
116110
monitorOsTheme();
117111
initLang();
112+
initIndexedDB();
118113
setInitEnd(true);
119114
}
120115

116+
// 初始化indexedDB
117+
function initIndexedDB() {
118+
indexedDB.createDB('chat2db', 1).then((db) => {
119+
window._indexedDB = {
120+
chat2db: db,
121+
};
122+
});
123+
}
124+
121125
// 监听系统(OS)主题变化
122126
function monitorOsTheme() {
123127
function change(e: any) {
@@ -136,9 +140,12 @@ function AppContainer() {
136140

137141
// 初始化语言
138142
function initLang() {
139-
if (!getLang()) {
143+
const lang = getLang();
144+
if (!lang) {
140145
setLang(LangType.EN_US);
141146
document.documentElement.setAttribute('lang', LangType.EN_US);
147+
const date = new Date('2030-12-30 12:30:00').toUTCString();
148+
document.cookie = `CHAT2DB.LOCALE=${lang};Expires=${date}`;
142149
}
143150
}
144151

@@ -155,6 +162,7 @@ function AppContainer() {
155162
.then(() => {
156163
clearInterval(time);
157164
setStartSchedule(2);
165+
handelGetUserInfo();
158166
flag++;
159167
})
160168
.catch(() => {

chat2db-client/src/pages/main/workspace/components/SaveList/index.less

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@
4545
.saveBoxList {
4646
padding: 0px 10px;
4747
height: calc(26px * 3 + 6px);
48-
overflow-y: auto;
48+
overflow-y: hidden;
49+
&:hover {
50+
overflow-y: auto;
51+
}
4952
}
5053

5154
.leftModuleTitleShadow {

chat2db-client/src/pages/main/workspace/components/SaveList/index.tsx

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ const SaveList = dvaModel((props: any) => {
8585
}
8686

8787
function openConsole(data: IConsole) {
88-
let p: any = {
88+
const params: any = {
8989
id: data.id,
9090
tabOpened: ConsoleOpenedStatus.IS_OPEN,
9191
};
92-
historyServer.updateSavedConsole(p).then((res) => {
92+
historyServer.updateSavedConsole(params).then((res) => {
9393
dispatch({
9494
type: 'workspace/setCreateConsoleIntro',
9595
payload: {
@@ -103,24 +103,11 @@ const SaveList = dvaModel((props: any) => {
103103
}
104104

105105
function deleteSaved(data: IConsole) {
106-
let p: any = {
106+
const params: any = {
107107
id: data.id,
108+
status: ConsoleStatus.DRAFT,
108109
};
109-
historyServer.deleteSavedConsole(p).then((res) => {
110-
// dispatch({
111-
// type: 'workspace/fetchGetSavedConsole',
112-
// payload: {
113-
// orderByDesc: true,
114-
// tabOpened: ConsoleOpenedStatus.IS_OPEN,
115-
// ...curWorkspaceParams
116-
// },
117-
// callback: (res: any) => {
118-
// dispatch({
119-
// type: 'workspace/setOpenConsoleList',
120-
// payload: res.data,
121-
// })
122-
// }
123-
// })
110+
historyServer.updateSavedConsole(params).then((res) => {
124111
dispatch({
125112
type: 'workspace/fetchGetSavedConsole',
126113
payload: {
@@ -168,7 +155,7 @@ const SaveList = dvaModel((props: any) => {
168155
)}
169156
</div>
170157
<div ref={saveBoxListRef} className={styles.saveBoxList}>
171-
<LoadingContent data={consoleList} handleEmpty>
158+
<LoadingContent className={styles.loadingContent} data={consoleList} handleEmpty>
172159
{(searchedList || consoleList)?.map((t: IConsole) => {
173160
return (
174161
<div

0 commit comments

Comments
 (0)