diff --git a/.pnpm-store/v11/projects/0e47ef389c0c12bdfaeb86af6e6a20bb/src/utils/categoryButtonAppearance.ts b/.pnpm-store/v11/projects/0e47ef389c0c12bdfaeb86af6e6a20bb/src/utils/categoryButtonAppearance.ts index 0379823..0bdf930 100644 --- a/.pnpm-store/v11/projects/0e47ef389c0c12bdfaeb86af6e6a20bb/src/utils/categoryButtonAppearance.ts +++ b/.pnpm-store/v11/projects/0e47ef389c0c12bdfaeb86af6e6a20bb/src/utils/categoryButtonAppearance.ts @@ -1,5 +1,7 @@ /** 与平台端 `categoryButtonAppearance.ts` 逻辑对齐,供 APP 列表与打标页渲染 */ +import { isAppLocalMediaPath } from './resolveMediaUrl' + export type AppearanceToken = 'TEXT' | 'COLOR' | 'IMAGE' const ORDER: AppearanceToken[] = ['TEXT', 'COLOR', 'IMAGE'] @@ -41,6 +43,7 @@ export function normalizeHexColor(v: unknown): string { function looksLikeImageUrl(s: string): boolean { if (!s) return false + if (isAppLocalMediaPath(s)) return true if (/^https?:\/\//i.test(s)) return true if (s.startsWith('/')) return true if (/\.(png|jpe?g|gif|webp|svg)(\?|$)/i.test(s)) return true diff --git a/.pnpm-store/v11/projects/0e47ef389c0c12bdfaeb86af6e6a20bb/src/utils/offlineLabelingSupport.ts b/.pnpm-store/v11/projects/0e47ef389c0c12bdfaeb86af6e6a20bb/src/utils/offlineLabelingSupport.ts index 58deb51..c2937f7 100644 --- a/.pnpm-store/v11/projects/0e47ef389c0c12bdfaeb86af6e6a20bb/src/utils/offlineLabelingSupport.ts +++ b/.pnpm-store/v11/projects/0e47ef389c0c12bdfaeb86af6e6a20bb/src/utils/offlineLabelingSupport.ts @@ -4,7 +4,7 @@ */ import type { PrintLogItemDto, UsAppLabelPrintInputVo } from '../types/usAppLabeling' import { fetchLabelMultipleOptionById } from '../services/labelMultipleOption' -import { resolveMediaUrlForApp } from './resolveMediaUrl' +import { isAppLocalMediaPath, resolveMediaUrlForApp } from './resolveMediaUrl' import { getOfflineCache, hasOfflineCache, setOfflineCache } from './sqliteSync' export type PrintLogPageCache = { @@ -181,8 +181,7 @@ function downloadAuthHeaders(): Record { function needsOfflineMediaDownload(raw: string): boolean { const s = String(raw || '').trim() if (!s) return false - if (s.startsWith('data:') || s.startsWith('file://')) return false - if (s.startsWith('_doc/') || s.startsWith('_www/')) return false + if (isAppLocalMediaPath(s)) return false if (/^https?:\/\//i.test(s)) return true if ( s.startsWith('/picture/') @@ -280,6 +279,44 @@ function cfgStr(cfg: Record, keys: string[]): string { return '' } +async function localizeMediaStringValue(raw: string): Promise<{ next: string; count: number }> { + const trimmed = String(raw || '').trim() + if (!trimmed) return { next: raw, count: 0 } + + // categoryPhotoUrl 常为 JSON 数组:["文案","#fff","/picture/xx.png"] + if (trimmed.startsWith('[')) { + try { + const arr = JSON.parse(trimmed) as unknown + if (Array.isArray(arr)) { + let count = 0 + const nextArr: unknown[] = [] + for (const item of arr) { + if (typeof item !== 'string') { + nextArr.push(item) + continue + } + const local = await localizeMediaPath(item) + if (local) { + nextArr.push(local) + count += 1 + } else { + nextArr.push(item) + } + } + return { + next: count > 0 ? JSON.stringify(nextArr) : trimmed, + count, + } + } + } catch { + /* 非 JSON,按普通 URL 处理 */ + } + } + + const local = await localizeMediaPath(trimmed) + return local ? { next: local, count: 1 } : { next: raw, count: 0 } +} + async function replaceUrlField( obj: Record, keys: string[], @@ -288,10 +325,10 @@ async function replaceUrlField( for (const k of keys) { const raw = obj[k] if (raw == null || typeof raw !== 'string') continue - const local = await localizeMediaPath(raw) - if (local) { - obj[k] = local - n += 1 + const { next, count } = await localizeMediaStringValue(raw) + if (count > 0) { + obj[k] = next + n += count } } return n diff --git a/.pnpm-store/v11/projects/0e47ef389c0c12bdfaeb86af6e6a20bb/src/utils/offlineSyncManager.ts b/.pnpm-store/v11/projects/0e47ef389c0c12bdfaeb86af6e6a20bb/src/utils/offlineSyncManager.ts index c5fb86d..19b5ab8 100644 --- a/.pnpm-store/v11/projects/0e47ef389c0c12bdfaeb86af6e6a20bb/src/utils/offlineSyncManager.ts +++ b/.pnpm-store/v11/projects/0e47ef389c0c12bdfaeb86af6e6a20bb/src/utils/offlineSyncManager.ts @@ -164,10 +164,9 @@ export async function performInitialOfflineSync(): Promise { ]) if (treeResult.status === 'fulfilled' && Array.isArray(treeResult.value)) { try { - const photos = await localizeTreeMediaUrls(treeResult.value) - if (photos > 0) { - await setOfflineCache('labeling', `labeling-tree:${locId}::`, treeResult.value) - } + // 无论本次新下载几张图,都写回本地化后的树,避免断网仍读到远端 URL + await localizeTreeMediaUrls(treeResult.value) + await setOfflineCache('labeling', `labeling-tree:${locId}::`, treeResult.value) } catch { /* 树图本地化失败不阻断 */ } diff --git a/.pnpm-store/v11/projects/0e47ef389c0c12bdfaeb86af6e6a20bb/src/utils/resolveMediaUrl.ts b/.pnpm-store/v11/projects/0e47ef389c0c12bdfaeb86af6e6a20bb/src/utils/resolveMediaUrl.ts index a9f124e..1c9872a 100644 --- a/.pnpm-store/v11/projects/0e47ef389c0c12bdfaeb86af6e6a20bb/src/utils/resolveMediaUrl.ts +++ b/.pnpm-store/v11/projects/0e47ef389c0c12bdfaeb86af6e6a20bb/src/utils/resolveMediaUrl.ts @@ -1,10 +1,39 @@ import { buildApiUrl, getStaticMediaOrigin } from './apiBase' -/** 相对路径拼后端根;绝对 URL / data URL 原样返回 */ +/** + * App 本地媒体路径(离线 downloadFile/saveFile、包内资源等)。 + * 这类路径禁止再拼 API 域名,否则断网后图片/Logo 全部挂掉。 + */ +export function isAppLocalMediaPath(stored: string | null | undefined): boolean { + const s = String(stored ?? '').trim() + if (!s) return false + if (s.startsWith('data:')) return true + if (s.startsWith('blob:')) return true + if (s.startsWith('file://')) return true + if (s.startsWith('wxfile://') || s.startsWith('weixin://')) return true + if (s.startsWith('content://')) return true + if (s.startsWith('_doc/') || s.startsWith('_www/') || s.startsWith('_downloads/')) { + return true + } + // uni.saveFile / plus.io 常见绝对路径 + if (/^[a-zA-Z]:[\\/]/.test(s)) return true + if ( + s.startsWith('/var/') + || s.startsWith('/data/') + || s.startsWith('/storage/') + || s.startsWith('/sdcard/') + ) { + return true + } + return false +} + +/** 相对路径拼后端根;绝对 URL / data URL / 本地路径原样返回 */ export function resolveMediaUrlForApp(stored: string | null | undefined): string { const s = (stored ?? '').trim() if (!s) return '' - if (s.startsWith('data:')) return s + // 离线已落地的本地文件必须原样返回,禁止再拼 API + if (isAppLocalMediaPath(s)) return s if (/^https?:\/\//i.test(s)) return s const path = s.startsWith('/') ? s : `/${s}` const mediaOrigin = getStaticMediaOrigin() @@ -21,6 +50,8 @@ export function storedValueLooksLikeImagePath(stored: string | null | undefined) if (!s) return false const lower = s.toLowerCase() if (lower.startsWith('data:image/')) return true + if (isAppLocalMediaPath(s) && /\.(png|jpe?g|gif|webp|bmp)(\?|#|$)/i.test(s)) return true + if (isAppLocalMediaPath(s)) return true if (lower.startsWith('/picture/') || lower.startsWith('/static/')) return true if (/\.(png|jpe?g|gif|webp|bmp)(\?|#|$)/i.test(s)) return true if (/^https?:\/\//i.test(s)) { diff --git a/泰额版/Food Labeling Management App UniApp/package.json b/泰额版/Food Labeling Management App UniApp/package.json index 7eb9527..d9a896a 100644 --- a/泰额版/Food Labeling Management App UniApp/package.json +++ b/泰额版/Food Labeling Management App UniApp/package.json @@ -2,7 +2,9 @@ "name": "food-labeling-management-app-uniapp", "version": "0.0.0", "scripts": { + "sync:static-fonts": "node scripts/sync-static-fonts.js", "sync:native-fast-printer": "powershell -ExecutionPolicy Bypass -File scripts/sync-native-fast-printer.ps1", + "prebuild:app": "node scripts/sync-static-fonts.js", "dev:custom": "uni -p", "dev:h5": "uni", "dev:h5:ssr": "uni --ssr", diff --git a/泰额版/Food Labeling Management App UniApp/scripts/sync-static-fonts.js b/泰额版/Food Labeling Management App UniApp/scripts/sync-static-fonts.js new file mode 100644 index 0000000..b3d5579 --- /dev/null +++ b/泰额版/Food Labeling Management App UniApp/scripts/sync-static-fonts.js @@ -0,0 +1,34 @@ +/** + * 将项目根 static/fonts 同步到 src/static/fonts,确保 HBuilderX / 自定义基座 APK 内存在 _www/static/fonts。 + * uni-app vite 工程内 src/static 会原样打进包;仅根目录 static/ 时部分打包链路会漏字体。 + */ +const fs = require('fs'); +const path = require('path'); + +const root = path.resolve(__dirname, '..'); +const srcDir = path.join(root, 'static', 'fonts'); +const destDir = path.join(root, 'src', 'static', 'fonts'); + +if (!fs.existsSync(srcDir)) { + console.warn('[sync-static-fonts] 未找到 static/fonts,跳过'); + process.exit(0); +} + +function copyRecursive(src, dest) { + if (!fs.existsSync(dest)) { + fs.mkdirSync(dest, { recursive: true }); + } + const entries = fs.readdirSync(src, { withFileTypes: true }); + for (const e of entries) { + const s = path.join(src, e.name); + const d = path.join(dest, e.name); + if (e.isDirectory()) { + copyRecursive(s, d); + } else { + fs.copyFileSync(s, d); + } + } +} + +copyRecursive(srcDir, destDir); +console.log('[sync-static-fonts] 已同步 static/fonts -> src/static/fonts'); diff --git a/泰额版/Food Labeling Management App UniApp/src/App.vue b/泰额版/Food Labeling Management App UniApp/src/App.vue index 21c0101..264a416 100644 --- a/泰额版/Food Labeling Management App UniApp/src/App.vue +++ b/泰额版/Food Labeling Management App UniApp/src/App.vue @@ -4,6 +4,11 @@ import { initOfflineSqlite } from "./utils/sqliteSync"; import { syncNowAndRefreshCaches } from "./utils/offlineSyncManager"; import { isLoggedIn } from "./utils/authSession"; import { preloadAllLabelEditorFonts } from "./utils/labelEditorFonts"; +import { + pauseGlobalAlertTimerMonitor, + startGlobalAlertTimerMonitor, + stopGlobalAlertTimerMonitor, +} from "./utils/globalAlertTimerMonitor"; let networkSyncInFlight = false; @@ -19,14 +24,21 @@ onLaunch(() => { networkSyncInFlight = false; }); }); + if (isLoggedIn()) { + startGlobalAlertTimerMonitor(); + } }); onShow(() => { - // App Show + if (isLoggedIn()) { + startGlobalAlertTimerMonitor(); + } else { + stopGlobalAlertTimerMonitor(); + } }); onHide(() => { - // App Hide + pauseGlobalAlertTimerMonitor(); }); diff --git a/泰额版/Food Labeling Management App UniApp/src/components/AppIcon.vue b/泰额版/Food Labeling Management App UniApp/src/components/AppIcon.vue index c7bcaa5..3ac68d3 100644 --- a/泰额版/Food Labeling Management App UniApp/src/components/AppIcon.vue +++ b/泰额版/Food Labeling Management App UniApp/src/components/AppIcon.vue @@ -41,6 +41,8 @@ const icons: Record = { utensils: '', plus: '', clock: '', + pin: '', + coffee: '', settings: '', globe: '', cloud: '', diff --git a/泰额版/Food Labeling Management App UniApp/src/components/LocationPicker.vue b/泰额版/Food Labeling Management App UniApp/src/components/LocationPicker.vue index 4ea8b31..e14e04d 100644 --- a/泰额版/Food Labeling Management App UniApp/src/components/LocationPicker.vue +++ b/泰额版/Food Labeling Management App UniApp/src/components/LocationPicker.vue @@ -8,7 +8,7 @@ - {{ t('location.switchLocation') }} + Switch Location @@ -50,6 +50,8 @@ import { getBoundLocations, getCurrentLocationCode, } from '../utils/stores' +import { usAppFetchMyProfile } from '../services/usAppAuth' +import { isAppAdminUser } from '../utils/appAdminRole' import type { UsAppBoundLocationDto } from '../types/usAppBound' const { t } = useI18n() @@ -57,6 +59,7 @@ const stores = ref([]) const currentId = ref(getCurrentStoreId()) const currentName = ref(getCurrentStoreName()) const showPicker = ref(false) +const checkingAdminScope = ref(false) function refreshList() { stores.value = getBoundLocations().filter((s) => s.state !== false) @@ -80,7 +83,20 @@ const displayLocationName = computed(() => { return code || '' }) -function openPicker() { +async function openPicker() { + if (checkingAdminScope.value) return + checkingAdminScope.value = true + try { + const profile = await usAppFetchMyProfile() + if (isAppAdminUser(profile)) { + uni.redirectTo({ url: '/pages/store-select/store-select' }) + return + } + } catch { + // If the role lookup fails, keep the existing local picker available. + } finally { + checkingAdminScope.value = false + } refreshList() currentId.value = getCurrentStoreId() showPicker.value = true diff --git a/泰额版/Food Labeling Management App UniApp/src/components/SideMenu.vue b/泰额版/Food Labeling Management App UniApp/src/components/SideMenu.vue index 50530ff..3c69c6a 100644 --- a/泰额版/Food Labeling Management App UniApp/src/components/SideMenu.vue +++ b/泰额版/Food Labeling Management App UniApp/src/components/SideMenu.vue @@ -67,7 +67,9 @@ - + + + @@ -79,6 +81,7 @@ import { useI18n } from 'vue-i18n' import AppIcon from './AppIcon.vue' import { getStatusBarHeight, getBottomSafeArea } from '../utils/statusBar' import { clearAuthSession } from '../utils/authSession' +import { stopGlobalAlertTimerMonitor } from '../utils/globalAlertTimerMonitor' import { STORE_CHANGED_EVENT, getCurrentStoreName } from '../utils/stores' const props = defineProps<{ @@ -122,6 +125,7 @@ const items = [ }, { key: 'profile', path: '/pages/more/profile', icon: 'user', labelKey: 'more.profile' }, { key: 'location', path: '/pages/more/location', icon: 'mapPin', labelKey: 'more.location' }, + { key: 'printerSetting', path: '/pages/labels/bluetooth', icon: 'printer', labelKey: 'more.printers' }, { key: 'training', path: '/pages/more/training', icon: 'fileText', labelKey: 'more.training' }, { key: 'alerts', path: '/pages/more/alerts', icon: 'alert', labelKey: 'more.alerts' }, { key: 'sync', path: '/pages/more/sync', icon: 'refresh', labelKey: 'more.sync' }, @@ -169,6 +173,7 @@ const currentPath = computed(() => { const isActive = (path: string) => !!path && path !== '__logout__' && currentPath.value === path const handleLogout = () => { + stopGlobalAlertTimerMonitor() clearAuthSession() uni.redirectTo({ url: '/pages/login/login' }) } @@ -352,12 +357,17 @@ const handleItemClick = (item: any) => { flex-shrink: 0; } -.footer-logo-img { - width: 260rpx; - height: 72rpx; - opacity: 0.85; - background: rgba(255,255,255,0.92); +.footer-logo-box { + width: 340rpx; + background: rgba(255, 255, 255, 0.96); border-radius: 10rpx; - padding: 8rpx 12rpx; + padding: 8rpx 10rpx; + box-sizing: border-box; + opacity: 0.95; +} + +.footer-logo-img { + width: 100%; + display: block; } diff --git a/泰额版/Food Labeling Management App UniApp/src/locales/en.ts b/泰额版/Food Labeling Management App UniApp/src/locales/en.ts index d6a9919..8d5adb1 100644 --- a/泰额版/Food Labeling Management App UniApp/src/locales/en.ts +++ b/泰额版/Food Labeling Management App UniApp/src/locales/en.ts @@ -218,6 +218,8 @@ export default { product: 'Product', expiresAt: 'Expires At', printedAt: 'Printed At', + location: 'Location', + printedBy: 'Printed By', loading: 'Loading...', loadingMore: 'Loading more...', endOfList: 'End of list', @@ -226,10 +228,31 @@ export default { loadFailed: 'Failed to load alerts', delete: 'Delete', deleting: 'Deleting...', - deleteTitle: 'Delete Alert', - deleteConfirm: 'Delete alert "{name}"?', + deleteTitle: 'Delete Timer Alert', + deleteConfirm: 'Delete the current timer alert?', deleteSuccess: 'Deleted', deleteFailed: 'Delete failed', + expiredTitle: 'Label Expired', + expiredConfirm: 'OK', + expiredUserFallback: 'colleague', + expiredAt: 'Label "{name}" expired at {time}. Please handle it promptly.', + addTimer: 'Add Timer', + addTimerTitle: 'Select Alert Template', + addTimerHint: 'Pick an enabled alert template to start a countdown', + addTimerConfirm: 'Confirm', + addTimerSuccess: 'Timer added', + addTimerFailed: 'Failed to add timer', + addTimerNoTemplate: 'Please select a template', + addTimerEmpty: 'No alert templates available', + addTimerLoading: 'Loading templates...', + durationLabel: 'Duration', + unitYear: 'Year', + unitMonth: 'Month', + unitDay: 'Day', + unitHour: 'Hour', + unitMinute: 'Minute', + unitSecond: 'Second', + unitCombined: 'Combined', }, location: { title: 'Location', diff --git a/泰额版/Food Labeling Management App UniApp/src/locales/zh.ts b/泰额版/Food Labeling Management App UniApp/src/locales/zh.ts index 1b38069..5eb0149 100644 --- a/泰额版/Food Labeling Management App UniApp/src/locales/zh.ts +++ b/泰额版/Food Labeling Management App UniApp/src/locales/zh.ts @@ -218,6 +218,8 @@ export default { product: '产品', expiresAt: '过期时间', printedAt: '打印时间', + location: '门店', + printedBy: '打印人', loading: '加载中...', loadingMore: '加载更多...', endOfList: '已到底', @@ -226,10 +228,31 @@ export default { loadFailed: '警告列表加载失败', delete: '删除', deleting: '删除中...', - deleteTitle: '删除警告', - deleteConfirm: '将删除警告 "{name}",是否确认?', + deleteTitle: '删除计时警告', + deleteConfirm: '是否删除当前计时警告?', deleteSuccess: '删除成功', deleteFailed: '删除失败', + expiredTitle: '标签已过期', + expiredConfirm: '知道了', + expiredUserFallback: '同事', + expiredAt: '标签「{name}」已于 {time} 过期,请及时处理', + addTimer: '新增计时', + addTimerTitle: '选择警告模板', + addTimerHint: '选择启用中的警告模板后确认,将加入倒计时列表', + addTimerConfirm: '确认添加', + addTimerSuccess: '已添加计时', + addTimerFailed: '添加计时失败', + addTimerNoTemplate: '请选择警告模板', + addTimerEmpty: '暂无可用警告模板', + addTimerLoading: '加载模板中...', + durationLabel: '时长', + unitYear: '年', + unitMonth: '月', + unitDay: '日', + unitHour: '时', + unitMinute: '分', + unitSecond: '秒', + unitCombined: '组合时间', }, location: { title: '工作地点', diff --git a/泰额版/Food Labeling Management App UniApp/src/manifest.json b/泰额版/Food Labeling Management App UniApp/src/manifest.json index c5535cf..b04b230 100644 --- a/泰额版/Food Labeling Management App UniApp/src/manifest.json +++ b/泰额版/Food Labeling Management App UniApp/src/manifest.json @@ -1,9 +1,9 @@ { - "name" : "food.labeling", + "name" : "3F", "appid" : "__UNI__5C033BE", - "description" : "", - "versionName" : "1.0.5", - "versionCode" : 105, + "description" : "3F", + "versionName" : "1.0.8", + "versionCode" : 108, "transformPx" : false, /* 5+App特有相关 */ "app-plus" : { @@ -52,7 +52,10 @@ "", "", "", - "" + "", + "", + "", + "" ], "abiFilters" : [ "armeabi-v7a", "arm64-v8a" ] }, @@ -93,6 +96,9 @@ "spotlight@3x" : "unpackage/res/icons/120x120.png" } } + }, + "splashscreen" : { + "iosStyle" : "common" } }, "nativePlugins" : { diff --git a/泰额版/Food Labeling Management App UniApp/src/pages.json b/泰额版/Food Labeling Management App UniApp/src/pages.json index eadab71..629ebb2 100644 --- a/泰额版/Food Labeling Management App UniApp/src/pages.json +++ b/泰额版/Food Labeling Management App UniApp/src/pages.json @@ -95,7 +95,8 @@ "path": "pages/more/alerts", "style": { "navigationBarTitleText": "Alerts", - "navigationStyle": "custom" + "navigationStyle": "custom", + "disableScroll": true } }, { diff --git a/泰额版/Food Labeling Management App UniApp/src/pages/index/index.vue b/泰额版/Food Labeling Management App UniApp/src/pages/index/index.vue index d8fd7d2..6ba904e 100644 --- a/泰额版/Food Labeling Management App UniApp/src/pages/index/index.vue +++ b/泰额版/Food Labeling Management App UniApp/src/pages/index/index.vue @@ -4,7 +4,9 @@ - + + + @@ -12,7 +14,6 @@ {{ storeName }} - @@ -44,7 +45,6 @@ import { useI18n } from 'vue-i18n' import { onShow } from '@dcloudio/uni-app' import AppIcon from '../../components/AppIcon.vue' import SideMenu from '../../components/SideMenu.vue' -import LocationPicker from '../../components/LocationPicker.vue' import { getStatusBarHeight } from '../../utils/statusBar' import { getAccessToken } from '../../utils/authSession' import { STORE_CHANGED_EVENT, getCurrentStoreName } from '../../utils/stores' @@ -101,7 +101,7 @@ const navTo = (path: string) => { } .header-hero { - min-height: 260rpx; + min-height: 300rpx; background: linear-gradient(135deg, var(--theme-primary), var(--theme-primary-dark)); padding-left: 32rpx; padding-right: 32rpx; @@ -109,15 +109,17 @@ const navTo = (path: string) => { } .top-bar { - height: 96rpx; + min-height: 96rpx; display: flex; align-items: center; justify-content: space-between; + gap: 12rpx; } .top-left-empty { width: 64rpx; height: 64rpx; + flex-shrink: 0; } .top-right { @@ -128,22 +130,32 @@ const navTo = (path: string) => { display: flex; align-items: center; justify-content: center; + flex-shrink: 0; } .top-center { flex: 1; + min-width: 0; display: flex; flex-direction: column; align-items: center; } -.header-logo { - width: 300rpx; - height: 80rpx; - background: rgba(255, 255, 255, 0.92); +.header-logo-box { + width: 440rpx; + background: rgba(255, 255, 255, 0.96); border-radius: 12rpx; padding: 8rpx 12rpx; margin-bottom: 8rpx; + box-sizing: border-box; + display: flex; + align-items: center; + justify-content: center; +} + +.header-logo { + width: 100%; + display: block; } .hero-info { diff --git a/泰额版/Food Labeling Management App UniApp/src/pages/labels/bluetooth.vue b/泰额版/Food Labeling Management App UniApp/src/pages/labels/bluetooth.vue index e708835..8d82e2b 100644 --- a/泰额版/Food Labeling Management App UniApp/src/pages/labels/bluetooth.vue +++ b/泰额版/Food Labeling Management App UniApp/src/pages/labels/bluetooth.vue @@ -7,7 +7,6 @@ Printer - @@ -299,9 +298,10 @@ 1. Ensure the printer is powered on and in pairing mode 2. On Android: enable Location (required for Bluetooth scan) 3. Place the printer within 10 m and tap Scan again - 4. Prefer GP-D320FX-spp_* (classic / Gainscha SDK2). Avoid GP-D320FX-ble_* (slow + layout wrap). - 5. Pair the printer in system Bluetooth first if it does not appear after Scan - 6. Restart the printer or app if not visible + 4. GP-D320FX has two names: spp_* (classic, fast) and ble_* (BLE, slower). App Scan may only show ble_* until spp is paired in Android Settings. + 5. To get spp_*: open Android Bluetooth → pair the printer → look for GP-D320FX-spp_* → then Scan again (paired devices are listed). + 6. If only ble_* appears: connect ble_* (BLE path works). Do not force classic/SDK2 on a ble_* name (that hangs at 20%). + 7. Restart the printer or app if not visible; keep Location ON for Android scan @@ -385,7 +385,6 @@ import { ref, computed, onMounted, onUnmounted, getCurrentInstance, nextTick } from 'vue' import { onLoad, onShow } from '@dcloudio/uni-app' import AppIcon from '../../components/AppIcon.vue' -import LocationPicker from '../../components/LocationPicker.vue' import SideMenu from '../../components/SideMenu.vue' import { getStatusBarHeight } from '../../utils/statusBar' import { getDeviceIdentity, isGpD740AioDevice, isGpD750AioDevice } from '../../utils/deviceInfo' @@ -843,9 +842,44 @@ const onDeviceFound = (res: any) => { devices.value.sort((a, b) => (b.RSSI || -100) - (a.RSSI || -100)) } +/** 把系统已配对经典设备并入列表(GP-D320FX-spp_* 常要先在系统蓝牙配对才看得见)。 */ +function loadPairedClassicDevices () { + // #ifdef APP-PLUS + try { + const classic = classicBluetooth + if (!classic || typeof classic.getPairedDevices !== 'function') { + debugInfo.value.pairedCount = 0 + return + } + const list = classic.getPairedDevices() || [] + debugInfo.value.pairedCount = list.length + let sppCount = 0 + list.forEach((item: any) => { + const name = String(item?.name || item?.localName || '').trim() + if (!name) return + if (/d320fx-spp|gp-d320fx-spp|\-spp_/i.test(name)) sppCount += 1 + upsertDevice({ + deviceId: item.deviceId, + name, + type: (item.type as BtDevice['type']) || 'classic', + RSSI: -40, + }) + }) + debugInfo.value.lastClassicEvent = sppCount > 0 + ? `paired loaded (spp=${sppCount})` + : (list.length > 0 ? 'paired loaded (no spp name)' : 'no paired devices') + } catch (e) { + console.error('loadPairedClassicDevices failed', e) + debugInfo.value.pairedCount = 0 + debugInfo.value.lastClassicEvent = 'load paired failed' + } + // #endif +} + function startClassicScan () { // #ifdef APP-PLUS const classic = classicBluetooth + loadPairedClassicDevices() if (classic && classic.startClassicDiscovery) { try { classic.startClassicDiscovery( diff --git a/泰额版/Food Labeling Management App UniApp/src/pages/labels/labels.vue b/泰额版/Food Labeling Management App UniApp/src/pages/labels/labels.vue index 87760f2..597d10e 100644 --- a/泰额版/Food Labeling Management App UniApp/src/pages/labels/labels.vue +++ b/泰额版/Food Labeling Management App UniApp/src/pages/labels/labels.vue @@ -7,7 +7,6 @@ Labeling - @@ -306,7 +305,6 @@ import { ref, computed, watch } from 'vue' import { onShow } from '@dcloudio/uni-app' import AppIcon from '../../components/AppIcon.vue' -import LocationPicker from '../../components/LocationPicker.vue' import SideMenu from '../../components/SideMenu.vue' import { getStatusBarHeight } from '../../utils/statusBar' import { getCurrentPrinterSummary } from '../../utils/print/manager/printerManager' diff --git a/泰额版/Food Labeling Management App UniApp/src/pages/labels/preview.vue b/泰额版/Food Labeling Management App UniApp/src/pages/labels/preview.vue index bcd901b..ceb05ce 100644 --- a/泰额版/Food Labeling Management App UniApp/src/pages/labels/preview.vue +++ b/泰额版/Food Labeling Management App UniApp/src/pages/labels/preview.vue @@ -7,7 +7,6 @@ Label Preview - @@ -201,6 +200,29 @@ + + + + + Printing {{ printProgressPercent }}% + {{ PRINT_BUILD_FINGERPRINT }} + + Copy Log + + + + + + + Log + + @@ -265,7 +287,6 @@ import { ref, computed, getCurrentInstance, nextTick, watch } from 'vue' import { onLoad, onShow, onUnload } from '@dcloudio/uni-app' import { useI18n } from 'vue-i18n' import AppIcon from '../../components/AppIcon.vue' -import LocationPicker from '../../components/LocationPicker.vue' import SideMenu from '../../components/SideMenu.vue' import NoPrinterModal from '../../components/NoPrinterModal.vue' import { getStatusBarHeight } from '../../utils/statusBar' @@ -284,6 +305,7 @@ import { import classicBluetooth from '../../utils/print/bluetoothTool.js' import { getNativeFastPrinterState, isNativeFastPrinterAvailable } from '../../utils/print/nativeFastPrinter' import { showNativeFastPrinterDebugModal } from '../../utils/print/showNativeFastPrinterDebugModal' +import { refreshGlobalAlertTimerMonitor } from '../../utils/globalAlertTimerMonitor' import { getCurrentPrinterMediaDebugInfo, getCurrentPrinterMediaGapMm, getCurrentPrinterMediaType, shouldDisableCutterForCurrentMedia } from '../../utils/print/printerMediaSettings' import type { SystemLabelTemplate, SystemTemplateElementBase } from '../../utils/print/types/printer' import { fetchLabelMultipleOptionById } from '../../services/labelMultipleOption' @@ -385,10 +407,13 @@ import { restoreD320faxVirtualBtBluetoothMode, isVirtualBtBluetoothConnection, } from '../../utils/print/printerConnection' +import { logLabelEditorFontPackDiagnostics } from '../../utils/labelEditorFonts' import { + getPrintRunDiagnosticsText, getPrintRunDiagnosticsTextForModal, persistPrintRunDiagnostics, printRunDiag, + PRINT_BUILD_FINGERPRINT, startPrintRunDiagnostics, } from '../../utils/print/printRunDiagnostics' import { isUsAppSessionExpiredError } from '../../utils/usAppApiRequest' @@ -520,7 +545,7 @@ function buildPrintPreflightDeviceInfoText (args: { lines.push(`- platform: ${String(sys.platform || '-')}`) lines.push(`- system: ${String(sys.system || '-')}`) lines.push(`- fingerprint: ${String(getDeviceFingerprint?.() || '-')}`) - lines.push(`- jsBuild: upos-no-silent-fallback@2026-04-22`) + lines.push(`- jsBuild: ${PRINT_BUILD_FINGERPRINT}`) lines.push('') lines.push('Printer / Connection') lines.push(`- selectedType: ${String(summary.type || '-')}`) @@ -895,8 +920,61 @@ function applyNativeTemplateStyleScale( } } -/** ????????0??00%?????????????? showLoading ?????? 0 ????????1%??*/ +/** 打印进度:页面内 overlay 显示,禁止 uni.showLoading(mask) 挡 Log */ let lastShownPrintPct = -999 +let printDiagPersistTimer: ReturnType | null = null +const printProgressPercent = ref(0) + +function startPrintDiagPersistLoop () { + stopPrintDiagPersistLoop() + try { + persistPrintRunDiagnostics() + } catch (_) {} + printDiagPersistTimer = setInterval(() => { + try { + persistPrintRunDiagnostics() + } catch (_) {} + }, 2000) +} + +function stopPrintDiagPersistLoop () { + if (printDiagPersistTimer) { + clearInterval(printDiagPersistTimer) + printDiagPersistTimer = null + } + try { + persistPrintRunDiagnostics() + } catch (_) {} +} + +function copyPrintRunDiagnosticsToClipboard () { + // 先落盘再读,避免卡在 SDK2 时剪贴板还是旧的 + try { + persistPrintRunDiagnostics() + } catch (_) {} + const text = getPrintRunDiagnosticsText() + if (!text.trim()) { + uni.showToast({ title: 'No print log yet', icon: 'none' }) + return + } + uni.setClipboardData({ + data: text, + success: () => { + uni.showToast({ + title: `Copied (${PRINT_BUILD_FINGERPRINT})`, + icon: 'none', + duration: 2800, + }) + }, + fail: () => { + uni.showModal({ + title: 'Print diagnostics', + content: getPrintRunDiagnosticsTextForModal(3600), + showCancel: false, + }) + }, + }) +} function showPrintProgress (percent: number) { const p = Math.max(0, Math.min(100, Math.round(percent))) @@ -910,8 +988,10 @@ function showPrintProgress (percent: number) { return } lastShownPrintPct = p + printProgressPercent.value = p + // 不用 uni.showLoading:原生遮罩会盖住 Log,导致无法点复制 try { - uni.showLoading({ title: `Printing ${p}%`, mask: true }) + uni.hideLoading() } catch (_) {} } @@ -1862,7 +1942,11 @@ const handlePrint = async () => { } isPrinting.value = true + printProgressPercent.value = 0 + lastShownPrintPct = -999 startPrintRunDiagnostics() + startPrintDiagPersistLoop() + void logLabelEditorFontPackDiagnostics() const printJobId = createPrintJobId() let watchdog: ReturnType | null = null let globalWatchdog: ReturnType | null = null @@ -1882,7 +1966,8 @@ const handlePrint = async () => { } try { lastShownPrintPct = -999 - uni.showLoading({ title: 'Rendering...', mask: true }) + printProgressPercent.value = 1 + showPrintProgress(1) /** Print base time: Prep / Use By share this click timestamp. */ const printBaseTime = new Date() const mergedForPrint = computeMergedPreviewTemplate(printBaseTime) @@ -2059,8 +2144,7 @@ const handlePrint = async () => { route: printRoute, stage: printStage, }) - /** ???? + native-plugin?JSON ??printTemplate??????????????*/ - uni.showLoading({ title: 'Printing...', mask: true }) + showPrintProgress(5) watchdog = setTimeout(() => { timeoutHandledByWatchdog = true try { uni.hideLoading() } catch (_) {} @@ -2594,6 +2678,7 @@ const handlePrint = async () => { icon: printLogSyncFailed ? 'none' : 'success', duration: printLogSyncFailed ? 2800 : 2000, }) + refreshGlobalAlertTimerMonitor() if (ENABLE_AUTO_NATIVE_DEBUG_MODAL && !printResultShown && shouldShowNativeFastDebugModal()) { setTimeout(() => { void showNativeFastPrinterDebugModal({ title: 'SDK print debug' }) @@ -2605,7 +2690,7 @@ const handlePrint = async () => { uni.hideLoading() const msg = e?.message ? String(e.message) : 'Print failed' /** withTimeout ??????????????watchdog ????????? */ - if (msg.includes('PRINT_TIMEOUT')) { + if (msg.includes('PRINT_TIMEOUT') || msg.includes('PRINT_STAGE_TIMEOUT')) { closeClassicBluetoothAfterInterruptedPrint('timeout') console.warn( '[preview] print job timeout (promise)', @@ -2622,9 +2707,11 @@ const handlePrint = async () => { await showPrintResultOnce() } else { uni.showToast({ - title: 'Printing is taking longer, please wait...', + title: msg.includes('PRINT_STAGE_TIMEOUT') + ? 'Print stuck — Logcat: [print-diag]' + : 'Printing is taking longer, please wait...', icon: 'none', - duration: 2500, + duration: 3200, }) } return @@ -2648,7 +2735,7 @@ const handlePrint = async () => { } else { uni.showModal({ title: 'Print Failed', - content: `${msg}\n\n${buildPrintDebugText({ + content: `${msg}\n\nLogcat / HBuilderX 搜 [print-diag],指纹 ${PRINT_BUILD_FINGERPRINT}\n\n${buildPrintDebugText({ stage: printStage, route: printRoute, jobId: printJobId, @@ -2664,6 +2751,7 @@ const handlePrint = async () => { }) } } finally { + stopPrintDiagPersistLoop() persistPrintRunDiagnostics() if (!isPrintJobActive(printJobId)) return try { @@ -3153,6 +3241,88 @@ const handlePrint = async () => { white-space: nowrap; } +.print-progress-overlay { + position: fixed; + inset: 0; + z-index: 1100; + display: flex; + align-items: center; + justify-content: center; + background: rgba(0, 0, 0, 0.28); + /* 遮罩不拦截;卡片与按钮自行接收点击 */ + pointer-events: none; +} + +.print-progress-card { + pointer-events: auto; + min-width: 320rpx; + padding: 36rpx 40rpx; + border-radius: 20rpx; + background: rgba(17, 24, 39, 0.92); + display: flex; + flex-direction: column; + align-items: center; + gap: 16rpx; +} + +.print-progress-log-btn { + margin-top: 8rpx; + padding: 14rpx 28rpx; + border-radius: 999rpx; + background: #2563eb; + pointer-events: auto; +} + +.print-progress-log-btn-text { + color: #fff; + font-size: 26rpx; + font-weight: 600; +} + +.print-progress-spinner { + width: 48rpx; + height: 48rpx; + border-radius: 50%; + border: 4rpx solid rgba(255, 255, 255, 0.25); + border-top-color: #fff; + animation: print-spin 0.8s linear infinite; +} + +@keyframes print-spin { + to { + transform: rotate(360deg); + } +} + +.print-progress-text { + color: #fff; + font-size: 28rpx; + font-weight: 600; +} + +.print-progress-hint { + color: rgba(255, 255, 255, 0.55); + font-size: 20rpx; +} + +.print-diag-log-btn { + position: fixed; + right: 32rpx; + bottom: calc(env(safe-area-inset-bottom, 0px) + 200rpx); + z-index: 12000; + padding: 16rpx 28rpx; + border-radius: 999rpx; + background: rgba(17, 24, 39, 0.92); + box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.22); + pointer-events: auto; +} + +.print-diag-log-text { + color: #fff; + font-size: 26rpx; + font-weight: 600; +} + .bottom-bar { position: fixed; bottom: 0; diff --git a/泰额版/Food Labeling Management App UniApp/src/pages/login/login.vue b/泰额版/Food Labeling Management App UniApp/src/pages/login/login.vue index aca382b..34009dd 100644 --- a/泰额版/Food Labeling Management App UniApp/src/pages/login/login.vue +++ b/泰额版/Food Labeling Management App UniApp/src/pages/login/login.vue @@ -2,7 +2,9 @@