Skip to content

Commit 1611d85

Browse files
committed
feat: eslint
1 parent dbc205d commit 1611d85

File tree

13 files changed

+79
-133
lines changed

13 files changed

+79
-133
lines changed

frontend/.eslintignore

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"globals": {
3+
"ElMessage": true,
4+
"ElMessageBox": true
5+
}
6+
}

frontend/.eslintrc.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

frontend/eslint.config.cjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ const eslintPluginPrettierRecommended = require('eslint-plugin-prettier/recommen
55
const eslintPluginVue = require('eslint-plugin-vue')
66
const globals = require('globals')
77
const typescriptEslint = require('typescript-eslint')
8+
const eslintrcImport = require('./.eslintrc-auto-import.json')
9+
810

911
module.exports = typescriptEslint.config(
1012
{
1113
languageOptions: {
12-
globals: globals.browser,
14+
globals: { ...globals.browser, ...globals.node, ...eslintrcImport.globals },
1315
ecmaVersion: 'latest',
1416
parserOptions: {
1517
parser: typescriptEslint.parser,
@@ -47,13 +49,12 @@ module.exports = typescriptEslint.config(
4749
'dist/',
4850
'public/',
4951
'eslint.config.cjs',
50-
'.eslintrc.js',
5152
'**/*.md',
5253
'**/*.woff',
5354
'**/*.ttf',
5455
'**/.vscode/',
5556
'**/.DS_Store',
5657
]),
5758
eslintConfigPrettier,
58-
eslintPluginPrettierRecommended
59+
eslintPluginPrettierRecommended,
5960
)

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"snowflake-id": "^1.1.0",
3030
"tinymce": "^5.8.2",
3131
"vue": "^3.5.13",
32+
"vue-dompurify-html": "^5.3.0",
3233
"vue-i18n": "^9.14.4",
3334
"vue-router": "^4.5.0",
3435
"web-storage-cache": "^1.1.1"

frontend/src/components/icon-custom/src/Icon.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ const svgClass = computed(() => {
2929
<template>
3030
<div
3131
v-if="staticContent"
32+
v-dompurify-html="staticContent"
3233
class="svg-container"
3334
:class="svgClass"
3435
aria-hidden="true"
35-
v-html="staticContent"
3636
></div>
3737
<slot v-else />
3838
</template>

frontend/src/main.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ import './style.less'
44
import App from './App.vue'
55
import router from './router'
66
import { i18n } from './i18n'
7+
import VueDOMPurifyHTML from 'vue-dompurify-html'
8+
79
// import 'element-plus/dist/index.css'
810
const app = createApp(App)
911
const pinia = createPinia()
1012

1113
app.use(pinia)
1214
app.use(router)
1315
app.use(i18n)
16+
app.use(VueDOMPurifyHTML)
1417
app.mount('#app')

frontend/src/views/chat/ChatAnswer.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,12 @@ function onTypeChange() {
215215
<div>
216216
<template v-if="message.record.sql_answer">
217217
<div>SQL Generation:</div>
218-
<div v-if="message.record.sql_answer" v-html="renderSqlThinking"></div>
218+
<div v-if="message.record.sql_answer" v-dompurify-html="renderSqlThinking"></div>
219219
</template>
220220
<template v-if="message.record.chart_answer">
221221
<el-divider></el-divider>
222222
<div>Chart Generation:</div>
223-
<div v-html="renderChartThinking"></div>
223+
<div v-dompurify-html="renderChartThinking"></div>
224224
</template>
225225
</div>
226226
</el-collapse-item>

frontend/src/views/chat/ChatBlock.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ defineProps<{
1111
<div class="chat-block">
1212
<slot>
1313
<div class="chat-block-content">
14-
<div v-html="msg?.content"></div>
14+
<div v-dompurify-html="msg?.content"></div>
1515
</div>
1616
</slot>
1717
</div>

frontend/src/views/chat/index.vue

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -341,17 +341,6 @@ const sendMessage = async () => {
341341
}
342342
}
343343
344-
//@ts-ignore
345-
const formatMessage = (content: string) => {
346-
if (!content) return ''
347-
return content
348-
.replace(/&/g, '&amp;')
349-
.replace(/</g, '&lt;')
350-
.replace(/>/g, '&gt;')
351-
.replace(/\n/g, '<br>')
352-
.replace(/ {2}/g, '&nbsp;&nbsp;')
353-
}
354-
355344
const handleCtrlEnter = (e: KeyboardEvent) => {
356345
const textarea = e.target as HTMLTextAreaElement
357346
const start = textarea.selectionStart

0 commit comments

Comments
 (0)