Files
opsxsql/frontend
opsx 71d5afff03 fix(query): 结尾分号导致 LIMIT 拼接成两条语句(MySQL 1064)+ SQL 编辑器光标异常与无法滚动
=== 一、点表生成的语句带分号 → 查询必报 1064 ===
用户报错:
  Error 1064 (42000): You have an error in your SQL syntax; ...
  near 'LIMIT 100 OFFSET 0' at line 2
复现语句(点表自动生成的原文,天然带分号):
  SELECT * FROM `cex_activity`.`concert_goods_language`;

根因在 instance_detail.go 的自动补 LIMIT:
  sqlStr = fmt.Sprintf("%s LIMIT %d OFFSET %d", sqlStr, limit, offset)
原语句已以 ';' 结尾 → 拼完变成
  SELECT * FROM ...; LIMIT 100 OFFSET 0
→ 两条语句,报错位置就是第 2 行的 LIMIT(与报错文案完全吻合)。

修复:新增 normalizeSQLForExec(),去掉首尾空白并反复剥掉结尾分号,
在两个「会拼 LIMIT」的入口统一调用:
  ① executeSQLQuery(查询)—— 归一化后再生效 COUNT(*) 统计与 LIMIT 注入
  ② exportSQLCSV(导出 CSV)—— 同样先归一化再拼 LIMIT

顺带收益:COUNT(*) 统计以前也会带上分号(虽然 MySQL 容忍),现在干净了。

安全边界未被放松:多语句仍被 isReadOnlySQL 拦住
  SELECT 1; SELECT 2      → 拒绝「不允许一次执行多条语句」✅
  SELECT 1; LIMIT 5       → 拒绝 ✅(这是一次性两条语句,不是尾分号)
  双分号 ;;               → 归一化后正常执行 ✅

=== 二、SQL / Redis / Mongo 编辑器:光标异常 + 只有 13 行且滚不动 ===
用户反馈:
  「默认还是有一个很长的竖线 一闪一闪,需要回车后第 2 行才正常」
  「输入框下面还有空白,最后只有 13 行可以输入,至少需要加一个滚动」

根因 1(滚不动,13 行):appTheme 的 '&' 没有 height:100%。
  .cm-editor 会随内容无限增高,而外层 div 固定 200px 且裁切,
  CodeMirror 内部的 .cm-scroller 永远拿不到受限高度 → 不产生滚动条。
  13 行 = 200px ÷ 15px 行高,正好对上。

根因 2(光标拉长):appTheme 在 extensions 里排在 oneDark 【之前】。
  CodeMirror theme 是后者覆盖前者,oneDark 的默认行高/内边距盖掉了我们的
  line-height,首次测量拿到的行高不对 → 空文档时光标高度算成好几行。

修复:
  ① appTheme '&' 增加 height:'100%';外层容器 style 改为
     height + minHeight:120px + resize:vertical + overflow:hidden
     (.cm-scroller 立刻有确定高度 → 内部滚动生效;右下角还能拖动拉高)
  ② appTheme 移到 oneDark 之后(顺序即优先级)
  ③ 行高统一写成 1.55em,并在 .cm-scroller / .cm-content / .cm-line /
     .cm-gutters 四处保持一致(CM 靠读 .cm-content 的 line-height 算光标高度)
  ④ 挂载后 requestMeasure() + 下一帧再测一次 + document.fonts.ready 后再测一次,
     修掉「首帧测量错乱」这一大类问题
  ⑤ SqlEditorSection 默认高度 200px → 240px(约 15 行可见)

注意:仍然不要给 .cm-cursor 写死 height / marginTop ——
CM 自己按行高算,写死会溢出到相邻行(历史上已经踩过一次)。

=== 三、实测 ===
  表本身为空:cex_activity.concert_goods_language COUNT(*)=0
             → SELECT * 返回 0 行是正确结果,不是故障
  分号归一化:带分号 / 不带分号 / 双分号 → rows=100 total=17447 完全一致,无 1064 ✅
  安全边界:两条语句、分号后接 LIMIT 均被拒 ✅
  编辑器产物:SqlEditor-*.js 内含 1.55em 与 resize:"vertical" ✅

镜像:lghost/opsxsql:latest + v0.1 = sha256:72a00dda2419
2026-10-27 09:22:11 +00:00
..
2026-07-08 08:53:48 +00:00

React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

React Compiler

The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see this documentation.

Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:

export default defineConfig([
  globalIgnores(['dist']),
  {
    files: ['**/*.{ts,tsx}'],
    extends: [
      // Other configs...

      // Remove tseslint.configs.recommended and replace with this
      tseslint.configs.recommendedTypeChecked,
      // Alternatively, use this for stricter rules
      tseslint.configs.strictTypeChecked,
      // Optionally, add this for stylistic rules
      tseslint.configs.stylisticTypeChecked,

      // Other configs...
    ],
    languageOptions: {
      parserOptions: {
        project: ['./tsconfig.node.json', './tsconfig.app.json'],
        tsconfigRootDir: import.meta.dirname,
      },
      // other options...
    },
  },
])

You can also install eslint-plugin-react-x and eslint-plugin-react-dom for React-specific lint rules:

// eslint.config.js
import reactX from 'eslint-plugin-react-x'
import reactDom from 'eslint-plugin-react-dom'

export default defineConfig([
  globalIgnores(['dist']),
  {
    files: ['**/*.{ts,tsx}'],
    extends: [
      // Other configs...
      // Enable lint rules for React
      reactX.configs['recommended-typescript'],
      // Enable lint rules for React DOM
      reactDom.configs.recommended,
    ],
    languageOptions: {
      parserOptions: {
        project: ['./tsconfig.node.json', './tsconfig.app.json'],
        tsconfigRootDir: import.meta.dirname,
      },
      // other options...
    },
  },
])