├── php-api/ # 改造后的PHP接口层 ├── java-ad-service/ # 若依框架微服务(广告+VIP+分账) ├── uniapp-reader/ # UniApp前端项目 │ ├── pages/ # 各端页面 │ └──
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

cleanMonitor.js 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { contentCleaner } from '@/utils/contentCleaner'
  2. import { request } from '@/utils/request'
  3. // 内容清洗质量监控
  4. export const cleanMonitor = {
  5. // 清洗并记录质量
  6. cleanAndMonitor(content, chapterId) {
  7. const startTime = Date.now()
  8. const originalLength = content.length
  9. // 执行清洗
  10. const cleanedContent = contentCleaner.clean(content)
  11. const cleanedLength = cleanedContent.length
  12. // 计算清洗指标
  13. const metrics = {
  14. chapterId,
  15. originalLength,
  16. cleanedLength,
  17. reductionRate: (originalLength - cleanedLength) / originalLength,
  18. timeCost: Date.now() - startTime,
  19. timestamp: new Date().toISOString()
  20. }
  21. // 记录到本地
  22. this.logLocal(metrics)
  23. // 异步上报到服务器
  24. this.reportMetrics(metrics)
  25. return cleanedContent
  26. },
  27. // 本地日志记录
  28. logLocal(metrics) {
  29. const logs = uni.getStorageSync('cleanLogs') || []
  30. logs.push(metrics)
  31. // 最多保留100条记录
  32. if (logs.length > 100) {
  33. logs.shift()
  34. }
  35. uni.setStorageSync('cleanLogs', logs)
  36. },
  37. // 上报到服务器
  38. async reportMetrics(metrics) {
  39. try {
  40. await request({
  41. url: '/monitor/clean',
  42. method: 'POST',
  43. data: metrics,
  44. headers: {
  45. 'Content-Type': 'application/json'
  46. }
  47. })
  48. } catch (e) {
  49. console.error('清洗指标上报失败', e)
  50. }
  51. },
  52. // 获取本地日志
  53. getLocalLogs() {
  54. return uni.getStorageSync('cleanLogs') || []
  55. }
  56. }