mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-26 09:03:54 +08:00
updata:智控台页面添加语言切换,支持中英繁。
This commit is contained in:
@@ -50,6 +50,7 @@ import CacheViewer from '@/components/CacheViewer.vue';
|
||||
import { logCacheStatus } from '@/utils/cacheViewer';
|
||||
|
||||
export default {
|
||||
name: 'App',
|
||||
components: {
|
||||
CacheViewer
|
||||
},
|
||||
@@ -78,7 +79,7 @@ export default {
|
||||
|
||||
// 在控制台输出提示信息
|
||||
console.info(
|
||||
'%c[小智服务] CDN缓存检查工具已加载',
|
||||
'%c[' + this.$t('system.name') + '] ' + this.$t('cache.cdnEnabled'),
|
||||
'color: #409EFF; font-weight: bold;'
|
||||
);
|
||||
console.info(
|
||||
@@ -89,7 +90,7 @@ export default {
|
||||
this.checkServiceWorkerStatus();
|
||||
} else {
|
||||
console.info(
|
||||
'%c[小智服务] CDN模式已禁用,使用本地打包资源',
|
||||
'%c[' + this.$t('system.name') + '] ' + this.$t('cache.cdnDisabled'),
|
||||
'color: #67C23A; font-weight: bold;'
|
||||
);
|
||||
}
|
||||
@@ -119,7 +120,7 @@ export default {
|
||||
const registrations = await navigator.serviceWorker.getRegistrations();
|
||||
if (registrations.length > 0) {
|
||||
console.info(
|
||||
'%c[小智服务] Service Worker已注册',
|
||||
'%c[' + this.$t('system.name') + '] ' + this.$t('cache.serviceWorkerRegistered'),
|
||||
'color: #67C23A; font-weight: bold;'
|
||||
);
|
||||
|
||||
@@ -128,46 +129,46 @@ export default {
|
||||
const hasCaches = await logCacheStatus();
|
||||
if (!hasCaches) {
|
||||
console.info(
|
||||
'%c[小智服务] 还未检测到缓存,请刷新页面或等待缓存建立',
|
||||
'%c[' + this.$t('system.name') + '] ' + this.$t('cache.noCacheDetected'),
|
||||
'color: #E6A23C; font-weight: bold;'
|
||||
);
|
||||
|
||||
// 开发环境下提供额外提示
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
console.info(
|
||||
'%c[' + this.$t('system.name') + '] ' + this.$t('cache.swDevEnvWarning'),
|
||||
'color: #E6A23C; font-weight: bold;'
|
||||
);
|
||||
|
||||
// 开发环境下提供额外提示
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
console.info(
|
||||
'%c[小智服务] 在开发环境中,Service Worker可能无法正常初始化缓存',
|
||||
'color: #E6A23C; font-weight: bold;'
|
||||
);
|
||||
console.info('请尝试以下方法检查Service Worker是否生效:');
|
||||
console.info('1. 在开发者工具的Application/Application标签页中查看Service Worker状态');
|
||||
console.info('2. 在开发者工具的Application/Cache/Cache Storage中查看缓存内容');
|
||||
console.info('3. 使用生产构建(npm run build)并通过HTTP服务器访问以测试完整功能');
|
||||
}
|
||||
console.info(this.$t('cache.swCheckMethods'));
|
||||
console.info('1. ' + this.$t('cache.swCheckMethod1'));
|
||||
console.info('2. ' + this.$t('cache.swCheckMethod2'));
|
||||
console.info('3. ' + this.$t('cache.swCheckMethod3'));
|
||||
}
|
||||
}
|
||||
}, 2000);
|
||||
} else {
|
||||
console.info(
|
||||
'%c[小智服务] Service Worker未注册,CDN资源可能无法缓存',
|
||||
'color: #F56C6C; font-weight: bold;'
|
||||
);
|
||||
'%c[' + this.$t('system.name') + '] ' + this.$t('cache.serviceWorkerNotRegistered'),
|
||||
'color: #F56C6C; font-weight: bold;'
|
||||
);
|
||||
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
console.info(
|
||||
'%c[小智服务] 在开发环境中,这是正常现象',
|
||||
'color: #E6A23C; font-weight: bold;'
|
||||
);
|
||||
console.info('Service Worker通常只在生产环境中生效');
|
||||
console.info('要测试Service Worker功能:');
|
||||
console.info('1. 运行npm run build构建生产版本');
|
||||
console.info('2. 通过HTTP服务器访问构建后的页面');
|
||||
}
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
console.info(
|
||||
'%c[' + this.$t('system.name') + '] ' + this.$t('cache.swDevEnvNormal'),
|
||||
'color: #E6A23C; font-weight: bold;'
|
||||
);
|
||||
console.info(this.$t('cache.swProdOnly'));
|
||||
console.info(this.$t('cache.swTestingTitle'));
|
||||
console.info('1. ' + this.$t('cache.swTestingStep1'));
|
||||
console.info('2. ' + this.$t('cache.swTestingStep2'));
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('检查Service Worker状态失败:', error);
|
||||
}
|
||||
} else {
|
||||
console.warn('当前浏览器不支持Service Worker,CDN资源缓存功能不可用');
|
||||
}
|
||||
console.warn(this.$t('cache.swNotSupported'));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user