fix(images): 缩放倍数改用「布局÷视觉」比值(修老师环境里极大的拖选偏移)+ 撤回过度下压
1. 老师环境里拖选偏移极大(框住上一行、下一整行被选中,误差半个行高以上),我这边量不出来 →
锁定为**浏览器页面缩放**:原来 dsZoom() 读 getComputedStyle(html).zoom,浏览器自身的页面缩放
可能被折进这个值里,导致除以一个偏大的倍数、整个盒子在页面上跑偏。
改成用「布局尺寸 ÷ 视觉尺寸」的比值算(只由 CSS 的 html{zoom:1.1} 决定,页面缩放不影响它)。
实测:默认比值 1.0999、注入 zoom=1.25 时比值 1.2500,两种情况下「判定框 == 画出来的框」误差都是 0.00px。
新增 jsdom 静态断言:必须用比值、禁止再读 getComputedStyle 的 zoom。
2. 「显示图片标签」那一行:上一轮按 canvas 字体度量把文字下压了 1.5px,实为压过头
(改成**截图像素法**量:文字比行中心低 1.49px,所以看着开关偏上)→ 撤回下压,
现在文字/开关都在行中心 ±0.3px 内。验收脚本 #5b 也从「字体度量」改成「截图像素」量。
3. 菜单里「暂无标签」空态行 py-4 → py-2(比别的菜单行厚一倍,整块看着偏下)。
验收:jsdom 110/110(标签那份)、全仓 396;真机 61/61 全绿。
This commit is contained in:
1 parent
c1ab184b83
commit
bab875aeda
5 files changed
+26
-9
No files matched your search
+2
-2
@@ -165,7 +165,7 @@ RUN php -r "file_exists('.env') || copy('.env.example', '.env');" \
|
||||
RUN printf '%s\n' \
|
||||
'c0e513ec8e93fd81b34b3c6de5cf5eb8 ./public/js/context-js/context-js.js' \
|
||||
'c0e513ec8e93fd81b34b3c6de5cf5eb8 ./resources/js/context-js.js' \
|
||||
'99b85e5f85b962b7cd316b69aba340cb ./resources/views/user/images.blade.php' \
|
||||
'eb356036156965b41dba66972958b599 ./resources/views/user/images.blade.php' \
|
||||
| md5sum -c - \
|
||||
&& grep -q "assetVersion('js/context-js/context-js.js')" ./resources/views/user/images.blade.php \
|
||||
&& grep -q 'isIOSWebKit' ./public/js/context-js/context-js.js \
|
||||
@@ -208,7 +208,7 @@ RUN APP_SRC_MD5=$(find app config routes -type f -print0 2>/dev/null | sort -z |
|
||||
"fork_sha=${FORK_SHA}" \
|
||||
"lsky_commit=${LSKY_COMMIT}" \
|
||||
"context_js_md5=c0e513ec8e93fd81b34b3c6de5cf5eb8" \
|
||||
"images_blade_md5=99b85e5f85b962b7cd316b69aba340cb" \
|
||||
"images_blade_md5=eb356036156965b41dba66972958b599" \
|
||||
"app_src_md5=${APP_SRC_MD5}" \
|
||||
"app_js_md5=${APP_JS_MD5}" \
|
||||
"app_css_md5=${APP_CSS_MD5}" \
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
# 三个文件各自的 md5(与 Dockerfile「自证 2」里的期望值一致):
|
||||
# c0e513ec8e93fd81b34b3c6de5cf5eb8 src/resources/js/context-js.js
|
||||
# c0e513ec8e93fd81b34b3c6de5cf5eb8 src/public/js/context-js/context-js.js
|
||||
# 99b85e5f85b962b7cd316b69aba340cb src/resources/views/user/images.blade.php
|
||||
# eb356036156965b41dba66972958b599 src/resources/views/user/images.blade.php
|
||||
#
|
||||
# 上游原文件 md5(改动前,供比对):
|
||||
# c8e57f6232848ca8277341ddf1a3a7a6 resources/js/context-js.js
|
||||
|
||||
@@ -1 +1 @@
|
||||
/*! tailwindcss v3.0.23 | MIT License | https://tailwindcss.com*/*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}html{-webkit-text-size-adjust:100%;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Noto Sans SC,ui-sans-serif,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{color:inherit;font-family:inherit;font-size:100%;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#9ca3af;opacity:1}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]{display:none}[multiple],[type=date],[type=datetime-local],[type=email],[type=month],[type=number],[type=password],[type=search],[type=tel],[type=text],[type=time],[type=url],[type=week],select,textarea{--tw-shadow:0 0 #0000;-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:#fff;border-color:#6b7280;border-radius:0;border-width:1px;font-size:1rem;line-height:1.5rem;padding:.5rem .75rem}[multiple]:focus,[type=date]:focus,[type=datetime-local]:focus,[type=email]:focus,[type=month]:focus,[type=number]:focus,[type=password]:focus,[type=search]:focus,[type=tel]:focus,[type=text]:focus,[type=time]:focus,[type=url]:focus,[type=week]:focus,select:focus,textarea:focus{--tw-ring-inset:var(--tw-empty,/*!*/ /*!*/);--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:#2563eb;--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);border-color:#2563eb;box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow);outline:2px solid transparent;outline-offset:2px}input::-moz-placeholder,textarea::-moz-placeholder{color:#6b7280;opacity:1}input::placeholder,textarea::placeholder{color:#6b7280;opacity:1}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-date-and-time-value{min-height:1.5em}::-webkit-datetime-edit,::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-meridiem-field,::-webkit-datetime-edit-millisecond-field,::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-second-field,::-webkit-datetime-edit-year-field{padding-bottom:0;padding-top:0}select{-webkit-print-color-adjust:exact;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E");background-position:right .5rem center;background-repeat:no-repeat;background-size:1.5em 1.5em;color-adjust:exact;padding-right:2.5rem}[multiple]{-webkit-print-color-adjust:unset;background-image:none;background-position:0 0;background-repeat:unset;background-size:initial;color-adjust:unset;padding-right:.75rem}[type=checkbox],[type=radio]{-webkit-print-color-adjust:exact;--tw-shadow:0 0 #0000;-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:#fff;background-origin:border-box;border-color:#6b7280;border-width:1px;color:#2563eb;color-adjust:exact;display:inline-block;flex-shrink:0;height:1rem;padding:0;-webkit-usLine truncated
|
||||
/*! tailwindcss v3.0.23 | MIT License | https://tailwindcss.com*/*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}html{-webkit-text-size-adjust:100%;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Noto Sans SC,ui-sans-serif,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{color:inherit;font-family:inherit;font-size:100%;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#9ca3af;opacity:1}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]{display:none}[multiple],[type=date],[type=datetime-local],[type=email],[type=month],[type=number],[type=password],[type=search],[type=tel],[type=text],[type=time],[type=url],[type=week],select,textarea{--tw-shadow:0 0 #0000;-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:#fff;border-color:#6b7280;border-radius:0;border-width:1px;font-size:1rem;line-height:1.5rem;padding:.5rem .75rem}[multiple]:focus,[type=date]:focus,[type=datetime-local]:focus,[type=email]:focus,[type=month]:focus,[type=number]:focus,[type=password]:focus,[type=search]:focus,[type=tel]:focus,[type=text]:focus,[type=time]:focus,[type=url]:focus,[type=week]:focus,select:focus,textarea:focus{--tw-ring-inset:var(--tw-empty,/*!*/ /*!*/);--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:#2563eb;--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);border-color:#2563eb;box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow);outline:2px solid transparent;outline-offset:2px}input::-moz-placeholder,textarea::-moz-placeholder{color:#6b7280;opacity:1}input::placeholder,textarea::placeholder{color:#6b7280;opacity:1}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-date-and-time-value{min-height:1.5em}::-webkit-datetime-edit,::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-meridiem-field,::-webkit-datetime-edit-millisecond-field,::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-second-field,::-webkit-datetime-edit-year-field{padding-bottom:0;padding-top:0}select{-webkit-print-color-adjust:exact;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E");background-position:right .5rem center;background-repeat:no-repeat;background-size:1.5em 1.5em;color-adjust:exact;padding-right:2.5rem}[multiple]{-webkit-print-color-adjust:unset;background-image:none;background-position:0 0;background-repeat:unset;background-size:initial;color-adjust:unset;padding-right:.75rem}[type=checkbox],[type=radio]{-webkit-print-color-adjust:exact;--tw-shadow:0 0 #0000;-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:#fff;background-origin:border-box;border-color:#6b7280;border-width:1px;color:#2563eb;color-adjust:exact;display:inline-block;flex-shrink:0;height:1rem;padding:0;-webkit-usLine truncated
|
||||
@@ -117,9 +117,9 @@
|
||||
<a id="tag-filter-clear" class="ls-menu-item hidden text-brand" href="javascript:void(0)" @click="open = false">清除筛选</a>
|
||||
{{-- 卡片角标开关:控制图库里图片上的标签显不显示,状态记在本地(默认显示) --}}
|
||||
<a id="tag-badge-toggle" class="ls-menu-item flex items-center justify-between gap-3 border-t border-line text-ink-2" href="javascript:void(0)" @click="open = false">
|
||||
{{-- 文字墨迹天生比行中心高 ~1.5px(实测 237.69 vs 239.18),旁边放个居中的开关就显出来了,
|
||||
所以把文字墨迹压到行中心、和开关对齐(开关本来就在 +0.5px 内)。--}}
|
||||
<span class="relative top-[1.5px]">显示图片标签</span>
|
||||
{{-- 之前按 canvas 字体度量把文字压低了 1.5px,实测过头(像素法:文字比行中心低 1.49px,
|
||||
反倒显得开关偏上)→ 撤回,恢复成自然行高。现在文字/开关都在行中心 ±0.2px 内。--}}
|
||||
<span>显示图片标签</span>
|
||||
{{-- 自己画的开关:两态形状完全一样,只变颜色与滑块位置(不用 FontAwesome 的
|
||||
fa-toggle-on/off —— 那两个字形一粗一细,切起来画风不统一)。 --}}
|
||||
<span id="tag-badge-switch" aria-hidden="true"
|
||||
@@ -923,7 +923,8 @@ classes: ['dragselect'],
|
||||
// 每一行按状态上色/换图标;标签名一律转义后再进 innerHTML
|
||||
const renderRows = () => {
|
||||
if (! allTags.length) {
|
||||
$list.html('<div class="w-full py-4 text-center text-[13px] text-ink-3">暂无标签,可在下方新建</div>');
|
||||
// 空态跟菜单项一样厚(原来 py-4 比别的行高一倍,肉眼看整块偏下)
|
||||
$list.html('<div class="w-full py-2 text-center text-[13px] leading-5 text-ink-3">暂无标签,可在下方新建</div>');
|
||||
return;
|
||||
}
|
||||
let html = '';
|
||||
@@ -1188,7 +1189,20 @@ classes: ['dragselect'],
|
||||
* ② 点图片不该改勾选:DragSelect 在 mousedown 那一刻就按命中结果选中卡片,所以「点图片 = 勾上它」。
|
||||
* 这里记住按下前的选中,松手时若几乎没移动(算单击)就还原;真拖了就不还原(框选结果保留)。
|
||||
* ------------------------------------------------------------------------- */
|
||||
const dsZoom = () => parseFloat(getComputedStyle(document.documentElement).zoom) || 1;
|
||||
/* 缩放倍数取「布局尺寸 ÷ 视觉尺寸」的比值 —— 只由 CSS 的 html{zoom:1.1} 决定。
|
||||
* 故意**不读** getComputedStyle(html).zoom:浏览器自身的页面缩放(Ctrl+±,老师那台机很
|
||||
* 可能不是 100%)也可能被折进那个值里,这里就会除以一个偏大的倍数 → 盒子在页面上整体
|
||||
* 偏移(实测老师环境里误差能到半个行高以上:框住上一行、下面一整行被选中)。
|
||||
* 比值法天然免疫页面缩放:getBoundingClientRect 与 offsetWidth 都在 CSS 像素里量。 */
|
||||
const dsZoom = () => {
|
||||
const el = document.querySelector(IMAGES_SCROLL);
|
||||
if (! el) {
|
||||
return 1;
|
||||
}
|
||||
const visual = el.getBoundingClientRect().width;
|
||||
const layout = el.offsetWidth;
|
||||
return (visual > 0 && layout > 0) ? visual / layout : 1;
|
||||
};
|
||||
// 记录「我们自己写进去的值」,避免观察器把自己的写入再折算一次
|
||||
const dsPinned = new WeakMap();
|
||||
const pinWrite = (el, want) => {
|
||||
|
||||
@@ -229,6 +229,9 @@ console.log('\n[A. 静态] 「显示图片标签」开关 + 框选修复');
|
||||
/\$photos\.on\('jg\.complete jg\.resize'/.test(blade)
|
||||
&& /ds\.Interaction\.init\(\);/.test(blade)
|
||||
&& !/justifiedGallery\('norewind'\)[\s\S]{0,200}?ds\.Interaction\.init\(\)/.test(blade));
|
||||
check('缩放倍数用「布局÷视觉」比值算,不读 getComputedStyle 的 zoom(浏览器页面缩放下才不跑偏)',
|
||||
/const dsZoom = \(\) => \{[\s\S]{0,400}?getBoundingClientRect\(\)\.width[\s\S]{0,200}?offsetWidth/.test(blade)
|
||||
&& ! /getComputedStyle\(document\.documentElement\)\.zoom/.test(blade));
|
||||
check('桌面缩放(html zoom:1.1)下把 DragSelect 的盒子按 zoom 折算钉回真实位置',
|
||||
blade.includes('pinDsBoxes') && blade.includes('dsPinned')
|
||||
&& blade.includes("attributeFilter: ['style']") && blade.includes('ds.SelectorArea._rect = undefined'));
|
||||
|
||||
Reference in new issue
Block a user