diff --git a/main/manager-web/src/components/CacheViewer.vue b/main/manager-web/src/components/CacheViewer.vue
new file mode 100644
index 000000000..66d4da7dc
--- /dev/null
+++ b/main/manager-web/src/components/CacheViewer.vue
@@ -0,0 +1,207 @@
+
+
+
+
+
+
+
+
您的浏览器不支持Cache API或Service Worker未安装
+
刷新页面
+
+
+
+
+ Service Worker可能尚未完成初始化或缓存尚未建立。请刷新页面或等待一会后再试。
+
+
+
+
+ 共发现 {{ cacheData.totalCached }} 个缓存资源
+
+
+
JavaScript 资源 ({{ cacheData.js.length }})
+
+
+
+
+ 已缓存
+ 未缓存
+
+
+
+
+ CSS 资源 ({{ cacheData.css.length }})
+
+
+
+
+ 已缓存
+ 未缓存
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/main/manager-web/src/components/DeviceItem.vue b/main/manager-web/src/components/DeviceItem.vue
index 13bf608d1..80f64f2cb 100644
--- a/main/manager-web/src/components/DeviceItem.vue
+++ b/main/manager-web/src/components/DeviceItem.vue
@@ -83,7 +83,8 @@ export default {
font-size: 10px;
color: #5778ff;
background: #e6ebff;
- width: 57px;
+ width: auto;
+ padding: 0 12px;
height: 21px;
line-height: 21px;
cursor: pointer;
diff --git a/main/manager-web/src/components/ModelEditDialog.vue b/main/manager-web/src/components/ModelEditDialog.vue
index 57d9b6ad2..9a5341161 100644
--- a/main/manager-web/src/components/ModelEditDialog.vue
+++ b/main/manager-web/src/components/ModelEditDialog.vue
@@ -17,7 +17,7 @@
是否启用
-
+
设为默认
@@ -64,18 +64,10 @@
-
-
+
@@ -165,57 +157,57 @@ export default {
},
methods: {
resetForm() {
- this.form = {
- id: "",
- modelType: "",
- modelCode: "",
- modelName: "",
- isDefault: false,
- isEnabled: false,
- docLink: "",
- remark: "",
- sort: 0,
- configJson: {}
- };
- this.dynamicCallInfoFields.forEach(field => {
- this.$set(this.form.configJson, field.prop, '');
- });
+ this.form = {
+ id: "",
+ modelType: "",
+ modelCode: "",
+ modelName: "",
+ isDefault: false,
+ isEnabled: false,
+ docLink: "",
+ remark: "",
+ sort: 0,
+ configJson: {}
+ };
+ this.dynamicCallInfoFields.forEach(field => {
+ this.$set(this.form.configJson, field.prop, '');
+ });
},
resetProviders() {
this.providers = [];
this.providersLoaded = false;
},
loadModelData() {
- if (this.modelData.id) {
- Api.model.getModelConfig(this.modelData.id, ({ data }) => {
- if (data.code === 0 && data.data) {
- const model = data.data;
- this.pendingProviderType = model.configJson.type;
- this.pendingModelData = model;
+ if (this.modelData.id) {
+ Api.model.getModelConfig(this.modelData.id, ({ data }) => {
+ if (data.code === 0 && data.data) {
+ const model = data.data;
+ this.pendingProviderType = model.configJson.type;
+ this.pendingModelData = model;
- if (this.providersLoaded) {
- this.loadProviderFields(model.configJson.type);
- } else {
- this.loadProviders();
- }
- }
- });
- }
+ if (this.providersLoaded) {
+ this.loadProviderFields(model.configJson.type);
+ } else {
+ this.loadProviders();
+ }
+ }
+ });
+ }
},
handleSave() {
- const provideCode = this.form.configJson.type;
- const formData = {
- id: this.modelData.id,
- modelCode: this.form.modelCode,
- modelName: this.form.modelName,
- isDefault: this.form.isDefault ? 1 : 0,
- isEnabled: this.form.isEnabled ? 1 : 0,
- docLink: this.form.docLink,
- remark: this.form.remark,
- sort: this.form.sort || 0,
- configJson: {
- ...this.form.configJson,
- }
+ const provideCode = this.form.configJson.type;
+ const formData = {
+ id: this.modelData.id,
+ modelCode: this.form.modelCode,
+ modelName: this.form.modelName,
+ isDefault: this.form.isDefault ? 1 : 0,
+ isEnabled: this.form.isEnabled ? 1 : 0,
+ docLink: this.form.docLink,
+ remark: this.form.remark,
+ sort: this.form.sort || 0,
+ configJson: {
+ ...this.form.configJson,
+ }
};
this.$emit("save", { provideCode, formData });
this.dialogVisible = false;
diff --git a/main/manager-web/src/components/TtsModel.vue b/main/manager-web/src/components/TtsModel.vue
index 06984b6d0..437f1c73d 100644
--- a/main/manager-web/src/components/TtsModel.vue
+++ b/main/manager-web/src/components/TtsModel.vue
@@ -551,28 +551,26 @@ export default {
/* 备注文本 */
::v-deep .remark-input .el-textarea__inner {
- background-color: #f5f5f5;
border-radius: 4px;
border: 1px solid #e6e6e6;
padding: 8px 12px;
resize: none;
max-height: 40px !important;
line-height: 1.5;
-}
-
-::v-deep .remark-input .el-textarea__inner::placeholder {
- color: black !important;
- opacity: 0.7;
-}
-
-::v-deep .remark-input .el-textarea__inner {
- background-color: #f4f6fa;
+ background-color: transparent !important;
}
::v-deep .remark-input .el-textarea__inner:focus {
- background-color: #edeffb;
+ border-color: #409EFF !important;
+ outline: none;
}
+::v-deep .remark-input .el-textarea__inner::placeholder {
+ color: #c0c4cc !important;
+ opacity: 1;
+}
+
+
/* 滚动容器 */
.scroll-wrapper {
display: flex;
@@ -582,7 +580,7 @@ export default {
.table-container {
flex: 1;
- overflow-y: scroll;
+ overflow: auto;
scrollbar-width: none;
padding-right: 15px;
width: calc(100% - 16px);
@@ -641,8 +639,8 @@ export default {
/* 音频播放器容器样式 */
.custom-audio-container {
- width: 280px;
- margin: auto;
+ width: 90%;
+ margin: 0 auto;
}
/* 新增按钮组样式 */
@@ -650,6 +648,12 @@ export default {
bottom: 20px;
padding-top: 10px;
}
+
+.action-buttons .el-button {
+ padding: 8px 15px;
+ font-size: 11px;
+}
+
.edit-btn,
.delete-btn,
.save-btn {
@@ -668,4 +672,40 @@ export default {
.save-btn {
color: #5cca8e !important;
}
+
+/* 表格单元格自适应 */
+::v-deep .el-table__body-wrapper {
+ overflow-x: hidden !important;
+}
+
+::v-deep .el-table td {
+ white-space: pre-wrap !important;
+ word-break: break-all !important;
+}
+/* 按钮组定位调整 */
+.action-buttons {
+ position: static;
+ padding: 15px 0;
+ background: white;
+ box-shadow: 0 -2px 12px rgba(0,0,0,0.05);
+}
+
+/* 输入框自适应 */
+::v-deep .el-input__inner,
+::v-deep .el-textarea__inner {
+ width: 100% !important;
+ min-width: 120px;
+}
+
+/* 音频输入框特殊处理 */
+.audio-input ::v-deep .el-input__inner {
+ min-width: 200px;
+}
+
+/* 操作按钮弹性布局 */
+::v-deep .el-table__row .el-button {
+ flex-shrink: 0;
+ margin: 2px !important;
+}
+
\ No newline at end of file
diff --git a/main/manager-web/src/components/VersionFooter.vue b/main/manager-web/src/components/VersionFooter.vue
new file mode 100644
index 000000000..6226bcc0d
--- /dev/null
+++ b/main/manager-web/src/components/VersionFooter.vue
@@ -0,0 +1,23 @@
+
+
+ ©2025 xiaozhi-esp32-server v{{ version }}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/main/manager-web/src/main.js b/main/manager-web/src/main.js
index e082f682f..58e04f0d0 100644
--- a/main/manager-web/src/main.js
+++ b/main/manager-web/src/main.js
@@ -6,11 +6,16 @@ import App from './App.vue';
import router from './router';
import store from './store';
import './styles/global.scss';
+import { register as registerServiceWorker } from './registerServiceWorker';
Vue.use(ElementUI);
Vue.config.productionTip = false
+// 注册Service Worker
+registerServiceWorker();
+
+// 创建Vue实例
new Vue({
router,
store,
diff --git a/main/manager-web/src/registerServiceWorker.js b/main/manager-web/src/registerServiceWorker.js
new file mode 100644
index 000000000..64d6c43a0
--- /dev/null
+++ b/main/manager-web/src/registerServiceWorker.js
@@ -0,0 +1,113 @@
+/* eslint-disable no-console */
+
+export const register = () => {
+ if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
+ window.addEventListener('load', () => {
+ const swUrl = `${process.env.BASE_URL}service-worker.js`;
+
+ console.info(`[小智服务] 正在尝试注册Service Worker,URL: ${swUrl}`);
+
+ // 先检查Service Worker是否已注册
+ navigator.serviceWorker.getRegistrations().then(registrations => {
+ if (registrations.length > 0) {
+ console.info('[小智服务] 发现已有Service Worker注册,正在检查更新');
+ }
+
+ // 继续注册Service Worker
+ navigator.serviceWorker
+ .register(swUrl)
+ .then(registration => {
+ console.info('[小智服务] Service Worker注册成功');
+
+ // 更新处理
+ registration.onupdatefound = () => {
+ const installingWorker = registration.installing;
+ if (installingWorker == null) {
+ return;
+ }
+ installingWorker.onstatechange = () => {
+ if (installingWorker.state === 'installed') {
+ if (navigator.serviceWorker.controller) {
+ // 内容已缓存更新,通知用户刷新
+ console.log('[小智服务] 新内容可用,请刷新页面');
+ // 可以在这里展示更新提示
+ const updateNotification = document.createElement('div');
+ updateNotification.style.cssText = `
+ position: fixed;
+ bottom: 20px;
+ right: 20px;
+ background: #409EFF;
+ color: white;
+ padding: 12px 20px;
+ border-radius: 4px;
+ box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
+ z-index: 9999;
+ `;
+ updateNotification.innerHTML = `
+
+ 发现新版本,点击刷新应用
+
+
+ `;
+ document.body.appendChild(updateNotification);
+ updateNotification.querySelector('button').addEventListener('click', () => {
+ window.location.reload();
+ });
+ } else {
+ // 一切正常,Service Worker已成功安装
+ console.log('[小智服务] 内容已缓存供离线使用');
+
+ // 可以在这里初始化缓存
+ setTimeout(() => {
+ // 预热CDN缓存
+ const cdnUrls = [
+ 'https://unpkg.com/element-ui@2.15.14/lib/theme-chalk/index.css',
+ 'https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css',
+ 'https://unpkg.com/vue@2.6.14/dist/vue.min.js',
+ 'https://unpkg.com/vue-router@3.6.5/dist/vue-router.min.js',
+ 'https://unpkg.com/vuex@3.6.2/dist/vuex.min.js',
+ 'https://unpkg.com/element-ui@2.15.14/lib/index.js',
+ 'https://unpkg.com/axios@0.27.2/dist/axios.min.js',
+ 'https://unpkg.com/opus-decoder@0.7.7/dist/opus-decoder.min.js'
+ ];
+
+ // 预热缓存
+ cdnUrls.forEach(url => {
+ fetch(url, { mode: 'no-cors' }).catch(err => {
+ console.log(`预热缓存 ${url} 失败`, err);
+ });
+ });
+ }, 2000);
+ }
+ }
+ };
+ };
+ })
+ .catch(error => {
+ console.error('Service Worker 注册失败:', error);
+
+ if (error.name === 'TypeError' && error.message.includes('Failed to register a ServiceWorker')) {
+ console.warn('[小智服务] 注册Service Worker时出现网络错误,CDN资源可能无法缓存');
+ if (process.env.NODE_ENV === 'production') {
+ console.info(
+ '可能原因:1. 服务器未配置正确的MIME类型 2. 服务器SSL证书问题 3. 服务器未返回service-worker.js文件'
+ );
+ }
+ }
+ });
+ });
+ });
+ }
+};
+
+export const unregister = () => {
+ if ('serviceWorker' in navigator) {
+ navigator.serviceWorker.ready
+ .then(registration => {
+ registration.unregister();
+ })
+ .catch(error => {
+ console.error(error.message);
+ });
+ }
+};
\ No newline at end of file
diff --git a/main/manager-web/src/service-worker.js b/main/manager-web/src/service-worker.js
new file mode 100644
index 000000000..ab9551fa6
--- /dev/null
+++ b/main/manager-web/src/service-worker.js
@@ -0,0 +1,174 @@
+/* global self, workbox */
+
+// 自定义Service Worker安装和激活的处理逻辑
+self.addEventListener('message', (event) => {
+ if (event.data && event.data.type === 'SKIP_WAITING') {
+ self.skipWaiting();
+ }
+});
+
+// CDN资源列表
+const CDN_CSS = [
+ 'https://unpkg.com/element-ui@2.15.14/lib/theme-chalk/index.css',
+ 'https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css'
+];
+
+const CDN_JS = [
+ 'https://unpkg.com/vue@2.6.14/dist/vue.min.js',
+ 'https://unpkg.com/vue-router@3.6.5/dist/vue-router.min.js',
+ 'https://unpkg.com/vuex@3.6.2/dist/vuex.min.js',
+ 'https://unpkg.com/element-ui@2.15.14/lib/index.js',
+ 'https://unpkg.com/axios@0.27.2/dist/axios.min.js',
+ 'https://unpkg.com/opus-decoder@0.7.7/dist/opus-decoder.min.js'
+];
+
+// 当Service Worker被注入manifest后会自动执行
+const manifest = self.__WB_MANIFEST || [];
+
+// 检查是否启用CDN模式
+const isCDNEnabled = manifest.some(entry =>
+ entry.url === 'cdn-mode' && entry.revision === 'enabled'
+);
+
+console.log(`Service Worker 已初始化, CDN模式: ${isCDNEnabled ? '启用' : '禁用'}`);
+
+// 注入workbox相关代码
+importScripts('https://storage.googleapis.com/workbox-cdn/releases/7.0.0/workbox-sw.js');
+workbox.setConfig({ debug: false });
+
+// 开启workbox
+workbox.core.skipWaiting();
+workbox.core.clientsClaim();
+
+// 预缓存离线页面
+const OFFLINE_URL = '/offline.html';
+workbox.precaching.precacheAndRoute([
+ { url: OFFLINE_URL, revision: null }
+]);
+
+// 添加安装完成事件处理器,在控制台显示安装消息
+self.addEventListener('install', event => {
+ if (isCDNEnabled) {
+ console.log('Service Worker 已安装,开始缓存CDN资源');
+ } else {
+ console.log('Service Worker 已安装,CDN模式禁用,仅缓存本地资源');
+ }
+
+ // 确保离线页面被缓存
+ event.waitUntil(
+ caches.open('offline-cache').then((cache) => {
+ return cache.add(OFFLINE_URL);
+ })
+ );
+});
+
+// 添加激活事件处理器
+self.addEventListener('activate', event => {
+ console.log('Service Worker 已激活,现在控制着页面');
+
+ // 清理旧版本缓存
+ event.waitUntil(
+ caches.keys().then(cacheNames => {
+ return Promise.all(
+ cacheNames.filter(cacheName => {
+ // 清理除当前版本外的缓存
+ return cacheName.startsWith('workbox-') && !workbox.core.cacheNames.runtime.includes(cacheName);
+ }).map(cacheName => {
+ return caches.delete(cacheName);
+ })
+ );
+ })
+ );
+});
+
+// 添加fetch事件拦截器,用于查看CDN资源是否命中缓存
+self.addEventListener('fetch', event => {
+ // 只有启用CDN模式时才进行CDN资源缓存监控
+ if (isCDNEnabled) {
+ const url = new URL(event.request.url);
+
+ // 针对CDN资源,输出是否命中缓存的信息
+ if ([...CDN_CSS, ...CDN_JS].includes(url.href)) {
+ // 不干扰正常的fetch流程,只添加日志
+ console.log(`请求CDN资源: ${url.href}`);
+ }
+ }
+});
+
+// 仅在CDN模式下缓存CDN资源
+if (isCDNEnabled) {
+ // 缓存CDN的CSS资源
+ workbox.routing.registerRoute(
+ ({ url }) => CDN_CSS.includes(url.href),
+ new workbox.strategies.CacheFirst({
+ cacheName: 'cdn-stylesheets',
+ plugins: [
+ new workbox.expiration.ExpirationPlugin({
+ maxAgeSeconds: 365 * 24 * 60 * 60, // 增加到1年缓存
+ maxEntries: 10, // 最多缓存10个CSS文件
+ }),
+ new workbox.cacheableResponse.CacheableResponsePlugin({
+ statuses: [0, 200], // 缓存成功响应
+ }),
+ ],
+ })
+ );
+
+ // 缓存CDN的JS资源
+ workbox.routing.registerRoute(
+ ({ url }) => CDN_JS.includes(url.href),
+ new workbox.strategies.CacheFirst({
+ cacheName: 'cdn-scripts',
+ plugins: [
+ new workbox.expiration.ExpirationPlugin({
+ maxAgeSeconds: 365 * 24 * 60 * 60, // 增加到1年缓存
+ maxEntries: 20, // 最多缓存20个JS文件
+ }),
+ new workbox.cacheableResponse.CacheableResponsePlugin({
+ statuses: [0, 200], // 缓存成功响应
+ }),
+ ],
+ })
+ );
+}
+
+// 无论是否启用CDN模式,都缓存本地静态资源
+workbox.routing.registerRoute(
+ /\.(?:js|css|png|jpg|jpeg|svg|gif|ico|woff|woff2|eot|ttf|otf)$/,
+ new workbox.strategies.StaleWhileRevalidate({
+ cacheName: 'static-resources',
+ plugins: [
+ new workbox.expiration.ExpirationPlugin({
+ maxAgeSeconds: 7 * 24 * 60 * 60, // 7天缓存
+ maxEntries: 50, // 最多缓存50个文件
+ }),
+ ],
+ })
+);
+
+// 缓存HTML页面
+workbox.routing.registerRoute(
+ /\.html$/,
+ new workbox.strategies.NetworkFirst({
+ cacheName: 'html-cache',
+ plugins: [
+ new workbox.expiration.ExpirationPlugin({
+ maxAgeSeconds: 1 * 24 * 60 * 60, // 1天缓存
+ maxEntries: 10, // 最多缓存10个HTML文件
+ }),
+ ],
+ })
+);
+
+// 离线页面 - 使用更可靠的处理方式
+workbox.routing.setCatchHandler(async ({ event }) => {
+ // 根据请求类型返回适当的默认页面
+ switch (event.request.destination) {
+ case 'document':
+ // 如果是网页请求,返回离线页面
+ return caches.match(OFFLINE_URL);
+ default:
+ // 所有其他请求返回错误
+ return Response.error();
+ }
+});
\ No newline at end of file
diff --git a/main/manager-web/src/store/index.js b/main/manager-web/src/store/index.js
index e359c479f..7a33ed61e 100644
--- a/main/manager-web/src/store/index.js
+++ b/main/manager-web/src/store/index.js
@@ -1,6 +1,7 @@
import { goToPage } from "@/utils";
import Vue from 'vue';
import Vuex from 'vuex';
+import Api from '../apis/api';
import Constant from '../utils/constant';
Vue.use(Vuex)
@@ -9,7 +10,11 @@ export default new Vuex.Store({
state: {
token: '',
userInfo: {}, // 添加用户信息存储
- isSuperAdmin: false // 添加superAdmin状态
+ isSuperAdmin: false, // 添加superAdmin状态
+ pubConfig: { // 添加公共配置存储
+ version: '',
+ allowUserRegister: false
+ }
},
getters: {
getToken(state) {
@@ -26,6 +31,9 @@ export default new Vuex.Store({
return state.isSuperAdmin
}
return localStorage.getItem('isSuperAdmin') === 'true'
+ },
+ getPubConfig(state) {
+ return state.pubConfig
}
},
mutations: {
@@ -39,6 +47,9 @@ export default new Vuex.Store({
state.isSuperAdmin = isSuperAdmin
localStorage.setItem('isSuperAdmin', isSuperAdmin)
},
+ setPubConfig(state, config) {
+ state.pubConfig = config
+ },
clearAuth(state) {
state.token = ''
state.userInfo = {}
@@ -55,6 +66,17 @@ export default new Vuex.Store({
goToPage(Constant.PAGE.LOGIN, true);
window.location.reload(); // 彻底重置状态
})
+ },
+ // 添加获取公共配置的 action
+ fetchPubConfig({ commit }) {
+ return new Promise((resolve) => {
+ Api.user.getPubConfig(({ data }) => {
+ if (data.code === 0) {
+ commit('setPubConfig', data.data);
+ }
+ resolve();
+ });
+ });
}
},
modules: {
diff --git a/main/manager-web/src/utils/cacheViewer.js b/main/manager-web/src/utils/cacheViewer.js
new file mode 100644
index 000000000..2f8a547ca
--- /dev/null
+++ b/main/manager-web/src/utils/cacheViewer.js
@@ -0,0 +1,142 @@
+/**
+ * 缓存查看工具 - 用于检查CDN资源是否已被Service Worker缓存
+ */
+
+/**
+ * 获取所有Service Worker缓存的名称
+ * @returns {Promise} 缓存名称列表
+ */
+export const getCacheNames = async () => {
+ if (!('caches' in window)) {
+ return [];
+ }
+
+ try {
+ return await caches.keys();
+ } catch (error) {
+ console.error('获取缓存名称失败:', error);
+ return [];
+ }
+};
+
+/**
+ * 获取指定缓存中的所有URL
+ * @param {string} cacheName 缓存名称
+ * @returns {Promise} 缓存的URL列表
+ */
+export const getCacheUrls = async (cacheName) => {
+ if (!('caches' in window)) {
+ return [];
+ }
+
+ try {
+ const cache = await caches.open(cacheName);
+ const requests = await cache.keys();
+ return requests.map(request => request.url);
+ } catch (error) {
+ console.error(`获取缓存 ${cacheName} 的URL失败:`, error);
+ return [];
+ }
+};
+
+/**
+ * 检查特定URL是否已被缓存
+ * @param {string} url 要检查的URL
+ * @returns {Promise} 是否已缓存
+ */
+export const isUrlCached = async (url) => {
+ if (!('caches' in window)) {
+ return false;
+ }
+
+ try {
+ const cacheNames = await getCacheNames();
+ for (const cacheName of cacheNames) {
+ const cache = await caches.open(cacheName);
+ const match = await cache.match(url);
+ if (match) {
+ return true;
+ }
+ }
+ return false;
+ } catch (error) {
+ console.error(`检查URL ${url} 是否缓存失败:`, error);
+ return false;
+ }
+};
+
+/**
+ * 获取当前页面所有CDN资源的缓存状态
+ * @returns {Promise
@@ -81,7 +92,8 @@ export default {
searchCode: "",
paramsList: [],
currentPage: 1,
- pageSize: 5,
+ pageSize: 10,
+ pageSizeOptions: [10, 20, 50, 100],
total: 0,
dialogVisible: false,
dialogTitle: "新增参数",
@@ -96,7 +108,9 @@ export default {
},
created() {
this.fetchParams();
+
},
+
computed: {
pageCount() {
return Math.ceil(this.total / this.pageSize);
@@ -118,6 +132,11 @@ export default {
},
},
methods: {
+ handlePageSizeChange(val) {
+ this.pageSize = val;
+ this.currentPage = 1;
+ this.fetchParams();
+ },
fetchParams() {
Api.admin.getParamsList(
{
@@ -127,10 +146,16 @@ export default {
},
({ data }) => {
if (data.code === 0) {
- this.paramsList = data.data.list;
+ this.paramsList = data.data.list.map(item => ({
+ ...item,
+ selected: false
+ }));
this.total = data.data.total;
} else {
- this.$message.error(data.msg || '获取参数列表失败');
+ this.$message.error({
+ message: data.msg || '获取参数列表失败',
+ showClose: true
+ });
}
}
);
@@ -140,12 +165,10 @@ export default {
this.fetchParams();
},
handleSelectAll() {
- if (this.isAllSelected) {
- this.$refs.paramsTable.clearSelection();
- } else {
- this.$refs.paramsTable.toggleAllSelection();
- }
this.isAllSelected = !this.isAllSelected;
+ this.paramsList.forEach(row => {
+ row.selected = this.isAllSelected;
+ });
},
showAddDialog() {
this.dialogTitle = "新增参数";
@@ -167,7 +190,10 @@ export default {
// 编辑
Api.admin.updateParam(form, ({ data }) => {
if (data.code === 0) {
- this.$message.success("修改成功");
+ this.$message.success({
+ message:"修改成功",
+ showClose:true
+ });
this.dialogVisible = false;
this.fetchParams();
}
@@ -176,23 +202,40 @@ export default {
// 新增
Api.admin.addParam(form, ({ data }) => {
if (data.code === 0) {
- this.$message.success("新增成功");
+ this.$message.success({
+ message:"新增成功",
+ showClose:true
+ });
this.dialogVisible = false;
this.fetchParams();
}
});
}
},
+
+ deleteSelectedParams() {
+ const selectedRows = this.paramsList.filter(row => row.selected);
+ if (selectedRows.length === 0) {
+ this.$message.warning({
+ message: "请先选择需要删除的参数",
+ showClose: true
+ });
+ return;
+ }
+ this.deleteParam(selectedRows);
+ },
deleteParam(row) {
// 处理单个参数或参数数组
const params = Array.isArray(row) ? row : [row];
if (Array.isArray(row) && row.length === 0) {
- this.$message.warning("请先选择需要删除的参数");
+ this.$message.warning({
+ message:"请先选择需要删除的参数",
+ showClose:true
+ });
return;
}
-
const paramCount = params.length;
this.$confirm(`确定要删除选中的${paramCount}个参数吗?`, '警告', {
confirmButtonText: '确定',
@@ -202,7 +245,10 @@ export default {
}).then(() => {
const ids = params.map(param => param.id);
if (ids.some(id => isNaN(id))) {
- this.$message.error('存在无效的参数ID');
+ this.$message.error({
+ message:'存在无效的参数ID',
+ showClose: true
+ });
return;
}
@@ -212,7 +258,7 @@ export default {
message: `成功删除${paramCount}个参数`,
showClose: true
});
- this.fetchParams(); // 刷新参数列表
+ this.fetchParams();
} else {
this.$message.error({
message: data.msg || '删除失败,请重试',
@@ -278,15 +324,20 @@ export default {
background: linear-gradient(to bottom right, #dce8ff, #e4eeff, #e6cbfd) center;
-webkit-background-size: cover;
-o-background-size: cover;
+ overflow: hidden;
}
.main-wrapper {
- margin: 5px 22px;
- border-radius: 15px;
- min-height: 600px;
- box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
- position: relative;
- background: rgba(237, 242, 255, 0.5);
+ margin: 5px 22px;
+ border-radius: 15px;
+ min-height: calc(100vh - 24vh);
+ height: auto;
+ max-height: 80vh;
+ box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
+ position: relative;
+ background: rgba(237, 242, 255, 0.5);
+ display: flex;
+ flex-direction: column;
}
.operation-bar {
@@ -331,14 +382,20 @@ export default {
flex: 1;
height: 100%;
min-width: 600px;
- overflow-x: auto;
+ overflow: auto;
background-color: white;
+ display: flex;
+ flex-direction: column;
}
.params-card {
background: white;
border: none;
box-shadow: none;
+ display: flex;
+ flex-direction: column;
+ flex: 1;
+ overflow: hidden;
}
.table_bottom {
@@ -346,6 +403,7 @@ export default {
justify-content: space-between;
align-items: center;
margin-top: 10px;
+ padding-bottom: 10px;
}
.ctrl_btn {
@@ -382,29 +440,19 @@ export default {
}
}
-.copyright {
- text-align: center;
- color: #979db1;
- font-size: 12px;
- font-weight: 400;
- margin-top: auto;
- padding: 30px 0 20px;
- position: absolute;
- bottom: 0;
- left: 50%;
- transform: translateX(-50%);
- width: 100%;
-}
-
.custom-pagination {
display: flex;
align-items: center;
- gap: 8px;
- margin-top: 15px;
+ gap: 10px;
+
+ .el-select {
+ margin-right: 8px;
+ }
.pagination-btn:first-child,
.pagination-btn:nth-child(2),
- .pagination-btn:nth-last-child(2) {
+ .pagination-btn:nth-last-child(2),
+ .pagination-btn:nth-child(3) {
min-width: 60px;
height: 32px;
padding: 0 12px;
@@ -426,7 +474,7 @@ export default {
}
}
- .pagination-btn:not(:first-child):not(:nth-child(2)):not(:nth-last-child(2)) {
+ .pagination-btn:not(:first-child):not(:nth-child(3)):not(:nth-child(2)):not(:nth-last-child(2)) {
min-width: 28px;
height: 32px;
padding: 0;
@@ -462,7 +510,19 @@ export default {
:deep(.transparent-table) {
background: white;
+ flex: 1;
+ width: 100%;
+ display: flex;
+ flex-direction: column;
+ .el-table__body-wrapper {
+ flex: 1;
+ overflow-y: auto;
+ max-height: none !important;
+ }
+ .el-table__header-wrapper {
+ flex-shrink: 0;
+ }
.el-table__header th {
background: white !important;
color: black;
@@ -482,19 +542,6 @@ export default {
}
}
-:deep(.custom-selection-header) {
- .el-checkbox {
- display: none !important;
- }
-
- &::after {
- content: "选择";
- display: inline-block;
- color: black;
- font-weight: bold;
- padding-bottom: 18px;
- }
-}
:deep(.el-checkbox__inner) {
background-color: #eeeeee !important;
@@ -550,4 +597,63 @@ export default {
overflow: hidden;
text-overflow: ellipsis;
}
+
+.page-size-select {
+ width: 100px;
+ margin-right: 10px;
+
+ :deep(.el-input__inner) {
+ height: 32px;
+ line-height: 32px;
+ border-radius: 4px;
+ border: 1px solid #e4e7ed;
+ background: #dee7ff;
+ color: #606266;
+ font-size: 14px;
+ }
+
+ :deep(.el-input__suffix) {
+ right: 6px;
+ width: 15px;
+ height: 20px;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ top: 6px;
+ border-radius: 4px;
+ }
+
+ :deep(.el-input__suffix-inner) {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 100%;
+ }
+
+ :deep(.el-icon-arrow-up:before) {
+ content: "";
+ display: inline-block;
+ border-left: 6px solid transparent;
+ border-right: 6px solid transparent;
+ border-top: 9px solid #606266;
+ position: relative;
+ transform: rotate(0deg);
+ transition: transform 0.3s;
+ }
+}
+
+:deep(.el-table) {
+ .el-table__body-wrapper {
+ transition: height 0.3s ease;
+ }
+}
+
+.el-table {
+ --table-max-height: calc(100vh - 40vh);
+ max-height: var(--table-max-height);
+
+ .el-table__body-wrapper {
+ max-height: calc(var(--table-max-height) - 40px);
+ }
+}
diff --git a/main/manager-web/src/views/UserManagement.vue b/main/manager-web/src/views/UserManagement.vue
index 45015d97d..988d42a68 100644
--- a/main/manager-web/src/views/UserManagement.vue
+++ b/main/manager-web/src/views/UserManagement.vue
@@ -15,9 +15,12 @@
-
-
+
+
+
+
+
+
@@ -42,7 +45,7 @@
- {{ isAllSelected ? '取消全选' : '全选' }}
+ {{ isAllSelected ? '取消全选' : '全选' }}
启用
删除
- ©2025 xiaozhi-esp32-server
@@ -88,8 +99,9 @@ export default {
currentPassword: "",
searchPhone: "",
userList: [],
+ pageSizeOptions: [10, 20, 50, 100],
currentPage: 1,
- pageSize: 5,
+ pageSize: 10,
total: 0,
isAllSelected: false
};
@@ -118,35 +130,42 @@ export default {
},
},
methods: {
+ handlePageSizeChange(val) {
+ this.pageSize = val;
+ this.currentPage = 1;
+ this.fetchUsers();
+ },
+
fetchUsers() {
- Api.admin.getUserList(
- {
- page: this.currentPage,
- limit: this.pageSize,
- mobile: this.searchPhone,
- },
- ({ data }) => {
- if (data.code === 0) {
- this.userList = data.data.list
- this.total = data.data.total;
- }
- }
- );
+ Api.admin.getUserList(
+ {
+ page: this.currentPage,
+ limit: this.pageSize,
+ mobile: this.searchPhone,
+ },
+ ({ data }) => {
+ if (data.code === 0) {
+ this.userList = data.data.list.map(item => ({
+ ...item,
+ selected: false
+ }));
+ this.total = data.data.total;
+ }
+ }
+ );
},
handleSearch() {
this.currentPage = 1;
this.fetchUsers();
},
handleSelectAll() {
- if (this.isAllSelected) {
- this.$refs.userTable.clearSelection();
- } else {
- this.$refs.userTable.toggleAllSelection();
- }
- this.isAllSelected = !this.isAllSelected;
+ this.isAllSelected = !this.isAllSelected;
+ this.userList.forEach(row => {
+ row.selected = this.isAllSelected;
+ });
},
batchDelete() {
- const selectedUsers = this.$refs.userTable.selection;
+ const selectedUsers = this.userList.filter(user => user.selected);
if (selectedUsers.length === 0) {
this.$message.warning("请先选择需要删除的用户");
return;
@@ -211,20 +230,12 @@ export default {
});
},
batchEnable() {
- const selectedUsers = this.$refs.userTable.selection;
- if (selectedUsers.length === 0) {
- this.$message.warning("请先选择需要启用的用户");
- return;
- }
- this.handleChangeStatus(selectedUsers, 1);
+ const selectedUsers = this.userList.filter(user => user.selected);
+ this.handleChangeStatus(selectedUsers, 1);
},
batchDisable() {
- const selectedUsers = this.$refs.userTable.selection;
- if (selectedUsers.length === 0) {
- this.$message.warning("请先选择需要禁用的用户");
- return;
- }
- this.handleChangeStatus(selectedUsers, 0);
+ const selectedUsers = this.userList.filter(user => user.selected);
+ this.handleChangeStatus(selectedUsers, 0);
},
resetPassword(row) {
this.$confirm("重置后将会生成新密码,是否继续?", "提示", {
@@ -267,12 +278,6 @@ export default {
})
.catch(() => { });
},
- headerCellClassName({ columnIndex }) {
- if (columnIndex === 0) {
- return "custom-selection-header";
- }
- return "";
- },
goFirst() {
this.currentPage = 1;
this.fetchUsers();
@@ -344,15 +349,20 @@ export default {
background: linear-gradient(to bottom right, #dce8ff, #e4eeff, #e6cbfd) center;
-webkit-background-size: cover;
-o-background-size: cover;
+ overflow: hidden;
}
.main-wrapper {
margin: 5px 22px;
border-radius: 15px;
- min-height: 600px;
+ min-height: calc(100vh - 24vh);
+ height: auto;
+ max-height: 80vh;
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
position: relative;
background: rgba(237, 242, 255, 0.5);
+ display: flex;
+ flex-direction: column;
}
.operation-bar {
@@ -399,12 +409,18 @@ export default {
min-width: 600px;
overflow-x: auto;
background-color: white;
+ display: flex;
+ flex-direction: column;
}
.user-card {
background: white;
border: none;
box-shadow: none;
+ display: flex;
+ flex-direction: column;
+ flex: 1;
+ overflow: hidden;
}
.table_bottom {
@@ -465,28 +481,18 @@ export default {
color: black;
}
-.copyright {
- text-align: center;
- color: #979db1;
- font-size: 12px;
- font-weight: 400;
- margin-top: auto;
- padding: 30px 0 20px;
- position: absolute;
- bottom: 0;
- left: 50%;
- transform: translateX(-50%);
- width: 100%;
-}
-
.custom-pagination {
display: flex;
align-items: center;
gap: 8px;
- margin-top: 15px;
+
+ .el-select {
+ margin-right: 8px;
+ }
.pagination-btn:first-child,
.pagination-btn:nth-child(2),
+ .pagination-btn:nth-child(3),
.pagination-btn:nth-last-child(2) {
min-width: 60px;
height: 32px;
@@ -509,7 +515,7 @@ export default {
}
}
- .pagination-btn:not(:first-child):not(:nth-child(2)):not(:nth-last-child(2)) {
+ .pagination-btn:not(:first-child):not(:nth-child(2)):not(:nth-child(3)):not(:nth-last-child(2)) {
min-width: 28px;
height: 32px;
padding: 0;
@@ -545,6 +551,19 @@ export default {
:deep(.transparent-table) {
background: white;
+ flex: 1;
+ width: 100%;
+ display: flex;
+ flex-direction: column;
+ .el-table__body-wrapper {
+ flex: 1;
+ overflow-y: auto;
+ max-height: none !important;
+ }
+
+ .el-table__header-wrapper {
+ flex-shrink: 0;
+ }
.el-table__header th {
background: white !important;
@@ -573,19 +592,6 @@ export default {
color: #5a64b5 !important;
}
-:deep(.custom-selection-header) {
- .el-checkbox {
- display: none !important;
- }
-
- &::after {
- content: "选择";
- display: inline-block;
- color: black;
- font-weight: bold;
- padding-bottom: 18px;
- }
-}
:deep(.el-checkbox__inner) {
background-color: #eeeeee !important;
@@ -622,4 +628,59 @@ export default {
}
}
}
+
+.page-size-select {
+ width: 100px;
+ margin-right: 10px;
+
+ :deep(.el-input__inner) {
+ height: 32px;
+ line-height: 32px;
+ border-radius: 4px;
+ border: 1px solid #e4e7ed;
+ background: #dee7ff;
+ color: #606266;
+ font-size: 14px;
+ }
+
+ :deep(.el-input__suffix) {
+ right: 6px;
+ width: 15px;
+ height: 20px;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ top: 6px;
+ border-radius: 4px;
+ }
+
+ :deep(.el-input__suffix-inner) {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 100%;
+ }
+
+ :deep(.el-icon-arrow-up:before) {
+ content: "";
+ display: inline-block;
+ border-left: 6px solid transparent;
+ border-right: 6px solid transparent;
+ border-top: 9px solid #606266;
+ position: relative;
+ transform: rotate(0deg);
+ transition: transform 0.3s;
+ }
+}
+
+.el-table {
+ --table-max-height: calc(100vh - 40vh);
+ max-height: var(--table-max-height);
+
+ .el-table__body-wrapper {
+ max-height: calc(var(--table-max-height) - 40px);
+ }
+}
+
+
diff --git a/main/manager-web/src/views/home.vue b/main/manager-web/src/views/home.vue
index 0e9fd32a9..b09d032e7 100644
--- a/main/manager-web/src/views/home.vue
+++ b/main/manager-web/src/views/home.vue
@@ -19,13 +19,13 @@
Hello, Let's have a wonderful day!
-
-
@@ -35,11 +35,11 @@
@deviceManage="handleDeviceManage" @delete="handleDeleteAgent" />
-
- ©2025 xiaozhi-esp32-server
-
+
+
+