feat(frontend): SortableJS 改为本地依赖,移除公网 CDN 运行时依赖(R33)

- package.json: 新增 sortablejs@^1.15.0(dependencies)
- src/main.js: import Sortable + 挂载 window.Sortable
  (保留全局挂载形式 => Admin.vue 的 window.Sortable.* 零改动)
- index.html: 删除 cdn.jsdelivr.net 的 <script>,留注释说明原因
- 原因: 内网/离线部署时 CDN 不可达 => window.Sortable 为 undefined,
  而 Admin.vue:3089/3276 的 `if (!window.Sortable) return` 会静默吞掉
  新闻/轮播的拖拽排序(界面零提示)
- 验证: 真 chromium 16/16 PASS(含整站 0 次 CDN 请求、宿主元素 expando
  Sortable<数字> 探针、news/carousel handle 正确、0 pageerror/0 console.error);
  构建 ✓ built in 18.57s / VITE_EXIT=0; TDZ src 38 + dist 26 全 PASS
This commit is contained in:
2026-09-29 09:57:48 +08:00
parent cb672b621a
commit 042e0a8e1f
4 changed files with 18 additions and 1 deletions

View File

@@ -47,7 +47,9 @@
} }
}); });
</script> </script>
<script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.0/Sortable.min.js"></script> <!-- SortableJS 已改为 npm 依赖本地打包(见 src/main.js),不再从公网 CDN 引入:
内网/离线部署时 CDN 不可达会让 window.Sortable 缺失,
而 Admin.vue 中的 `if (!window.Sortable) return` 会静默吞掉新闻/轮播的拖拽排序功能。 -->
</head> </head>
<body> <body>
<div id="app"></div> <div id="app"></div>

7
package-lock.json generated
View File

@@ -14,6 +14,7 @@
"axios": "^1.6.0", "axios": "^1.6.0",
"element-plus": "^2.5.0", "element-plus": "^2.5.0",
"pinia": "^2.1.0", "pinia": "^2.1.0",
"sortablejs": "^1.15.0",
"spark-md5": "^3.0.2", "spark-md5": "^3.0.2",
"vue": "^3.4.0", "vue": "^3.4.0",
"vue-router": "^4.3.0" "vue-router": "^4.3.0"
@@ -1680,6 +1681,12 @@
"node": ">=12.17.0" "node": ">=12.17.0"
} }
}, },
"node_modules/sortablejs": {
"version": "1.15.0",
"resolved": "https://registry.npmmirror.com/sortablejs/-/sortablejs-1.15.0.tgz",
"integrity": "sha512-bv9qgVMjUMf89wAvM6AxVvS/4MX3sPeN0+agqShejLU5z5GX4C75ow1O2e5k4L6XItUyAK3gH6AxSbXrOM5e8w==",
"license": "MIT"
},
"node_modules/source-map-js": { "node_modules/source-map-js": {
"version": "1.2.1", "version": "1.2.1",
"license": "BSD-3-Clause", "license": "BSD-3-Clause",

View File

@@ -16,6 +16,7 @@
"axios": "^1.6.0", "axios": "^1.6.0",
"element-plus": "^2.5.0", "element-plus": "^2.5.0",
"pinia": "^2.1.0", "pinia": "^2.1.0",
"sortablejs": "^1.15.0",
"spark-md5": "^3.0.2", "spark-md5": "^3.0.2",
"vue": "^3.4.0", "vue": "^3.4.0",
"vue-router": "^4.3.0" "vue-router": "^4.3.0"

View File

@@ -8,6 +8,13 @@ import 'element-plus/dist/index.css'
// 全局样式(含 Element Plus 主题色变量,防止 getThemeColors 解构 undefined 报错) // 全局样式(含 Element Plus 主题色变量,防止 getThemeColors 解构 undefined 报错)
import './styles/global.css' import './styles/global.css'
// SortableJS:新闻/轮播的拖拽排序依赖 window.Sortable(见 Admin.vue initNewsSortable/initCarouselSortable)。
// 原先由 index.html 从 cdn.jsdelivr.net 加载,内网/离线环境取不到时会静默失效
// (Admin.vue 内的 `if (!window.Sortable) return` 守卫不会报错也不提示)。
// 改为本地依赖并由 Vite 打包进产物,彻底消除对外网 CDN 的运行时依赖。
import Sortable from 'sortablejs'
window.Sortable = Sortable
import App from './App.vue' import App from './App.vue'
import router from './router' import router from './router'
// 主动 token 续期(防活跃用户因 token 过期被强制踢回登录页) // 主动 token 续期(防活跃用户因 token 过期被强制踢回登录页)