Skip to content

Commit

Permalink
chore: Update lint config and fix lint error in web folder
Browse files Browse the repository at this point in the history
  • Loading branch information
谨欣 committed Aug 30, 2024
1 parent ac97dea commit b5fe9b3
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 41 deletions.
4 changes: 2 additions & 2 deletions web/lib/dto/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export async function connection() {
});
await sequelize.authenticate();
console.log('Connection has been established successfully.');
} catch (e) {
console.error('Unable to connect to the database:', e);
} catch {
// console.error('Unable to connect to the database:', e);
}
}

Expand Down
2 changes: 1 addition & 1 deletion web/lib/dto/models/feedback.dto.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DataTypes, Model } from 'sequelize';
import { DataTypes } from 'sequelize';
import { sequelize } from '../connect';

export interface FeedbackModal {
Expand Down
19 changes: 12 additions & 7 deletions web/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,30 @@ const nextConfig = {
patterns: [
{
from: path.join(__dirname, 'node_modules/@oceanbase-odc/monaco-plugin-ob/worker-dist/'),
to: 'static/ob-workers'
to: 'static/ob-workers',
},
],
})
)
}),
);
// 添加 monaco-editor-webpack-plugin 插件
config.plugins.push(
new MonacoWebpackPlugin({
// 你可以在这里配置插件的选项,例如:
languages: ['sql'],
filename: 'static/[name].worker.js'
})
filename: 'static/[name].worker.js',
}),
);
}
return config;
}
},
};

const withTM = require('next-transpile-modules')(['@berryv/g2-react','@antv/g2','react-syntax-highlighter', '@antv/gpt-vis']);
const withTM = require('next-transpile-modules')([
'@berryv/g2-react',
'@antv/g2',
'react-syntax-highlighter',
'@antv/gpt-vis',
]);

module.exports = withTM({
...nextConfig,
Expand Down
4 changes: 2 additions & 2 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"dev": "NODE_OPTIONS=--max_old_space_size=8192 next dev",
"build": "NODE_OPTIONS=--max_old_space_size=8192 next build",
"build:prod": "APP_ENV=prod NODE_OPTIONS=--max_old_space_size=8192 next build",
"lint": "eslint ../web/**/*.{ts,tsx}",
"format": "prettier --write ../web/**/*.{ts,tsx}",
"lint": "eslint ./**/*.{ts,tsx}",
"format": "prettier --write ./**/*.{ts,tsx}",
"export": "next export",
"compile": " NODE_OPTIONS=--max_old_space_size=8192 next build && next export"
},
Expand Down
57 changes: 28 additions & 29 deletions web/pages/construct/database.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { ChatContext } from '@/app/chat-context';
import { apiInterceptors, getDbList, getDbSupportType, newDialogue, postDbDelete } from '@/client/api';
import { apiInterceptors, getDbList, getDbSupportType, postDbDelete } from '@/client/api';
import GPTCard from '@/components/common/gpt-card';
import MuiLoading from '@/components/common/loading';
import FormDialog from '@/components/database/form-dialog';
import ConstructLayout from '@/new-components/layout/Construct';
import { DBOption, DBType, DbListResponse, DbSupportTypeResponse, IChatDbSchema } from '@/types/db';
import { DBOption, DBType, DbListResponse, DbSupportTypeResponse } from '@/types/db';
import { dbMapper } from '@/utils';
import { DeleteFilled, EditFilled, PlusOutlined } from '@ant-design/icons';
import { useAsyncEffect } from 'ahooks';
import { Badge, Button, Card, Drawer, Empty, Modal, message } from 'antd';
import { useRouter } from 'next/router';
import { useContext, useMemo, useState } from 'react';
import { useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';

type DBItem = DbListResponse[0];
Expand All @@ -20,9 +18,9 @@ export function isFileDb(dbTypeList: DBOption[], dbType: DBType) {
}

function Database() {
const { setCurrentDialogInfo } = useContext(ChatContext);
// const { setCurrentDialogInfo } = useContext(ChatContext); // unused
// const router = useRouter(); // unused
const { t } = useTranslation();
const router = useRouter();

const [dbList, setDbList] = useState<DbListResponse>([]);
const [dbSupportList, setDbSupportList] = useState<DbSupportTypeResponse>([]);
Expand Down Expand Up @@ -125,28 +123,29 @@ function Database() {
});
};

const handleChat = async (item: IChatDbSchema) => {
const [, data] = await apiInterceptors(
newDialogue({
chat_mode: 'chat_with_db_execute',
}),
);
// 知识库对话都默认私有知识库应用下
if (data?.conv_uid) {
setCurrentDialogInfo?.({
chat_scene: data.chat_mode,
app_code: data.chat_mode,
});
localStorage.setItem(
'cur_dialog_info',
JSON.stringify({
chat_scene: data.chat_mode,
app_code: data.chat_mode,
}),
);
router.push(`/chat?scene=chat_with_db_execute&id=${data?.conv_uid}&db_name=${item.db_name}`);
}
};
// TODO: unused function call
// const handleChat = async (item: IChatDbSchema) => {
// const [, data] = await apiInterceptors(
// newDialogue({
// chat_mode: 'chat_with_db_execute',
// }),
// );
// // 知识库对话都默认私有知识库应用下
// if (data?.conv_uid) {
// setCurrentDialogInfo?.({
// chat_scene: data.chat_mode,
// app_code: data.chat_mode,
// });
// localStorage.setItem(
// 'cur_dialog_info',
// JSON.stringify({
// chat_scene: data.chat_mode,
// app_code: data.chat_mode,
// }),
// );
// router.push(`/chat?scene=chat_with_db_execute&id=${data?.conv_uid}&db_name=${item.db_name}`);
// }
// };

return (
<ConstructLayout>
Expand Down

0 comments on commit b5fe9b3

Please sign in to comment.