@skillre/dsh-plugin-work-dashboard 0.15.1 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client/text.js +5 -0
- package/lib/client/zip.d.ts +38 -0
- package/lib/client/zip.js +165 -0
- package/lib/client.js +143 -12
- package/lib/index.js +8 -2
- package/lib/report-form.d.ts +11 -0
- package/lib/report-form.js +13 -0
- package/lib/report-page.js +42 -17
- package/lib/report-style.js +20 -0
- package/lib/types.d.ts +10 -0
- package/package.json +1 -1
- package/skills/poc-export/SKILL.md +1 -1
package/lib/client/text.js
CHANGED
|
@@ -173,6 +173,10 @@ export const zh = {
|
|
|
173
173
|
exportStageAll: '全部阶段',
|
|
174
174
|
exportStageEmpty: '这个阶段下没有项目。',
|
|
175
175
|
exportHint: '表单完全离线可用:没有 CDN、没有外部字体、没有服务器。每个项目一个文件;组员点「保存」把内容写回表单文件,再用企业微信发回。DSH 校验后准备待审变更,不直接写台账。',
|
|
176
|
+
// A batch of several projects arrives as one archive: the browser allows a
|
|
177
|
+
// single automatic download per click, so the remaining files would be blocked
|
|
178
|
+
// and the batch would look like it exported one project.
|
|
179
|
+
exportArchiveHint: '选了 {count} 个项目:会下载 1 个 zip,解压后每个项目一个表单,各自发回给对应组员。',
|
|
176
180
|
exportGenerate: '生成表单文件',
|
|
177
181
|
exportGenerating: '正在生成…',
|
|
178
182
|
exportDone: '已下载 {name}',
|
|
@@ -757,6 +761,7 @@ export const en = {
|
|
|
757
761
|
exportStageAll: 'All stages',
|
|
758
762
|
exportStageEmpty: 'No projects at this stage.',
|
|
759
763
|
exportHint: 'The form works fully offline: no CDN, no external fonts, no server. One file per project: the colleague saves answers back into the same form file and sends it back. DSH validates it and prepares a change for review.',
|
|
764
|
+
exportArchiveHint: '{count} projects selected: one zip is downloaded. Unzip it and every project has its own form to send to its owner.',
|
|
760
765
|
exportGenerate: 'Generate form files',
|
|
761
766
|
exportGenerating: 'Generating…',
|
|
762
767
|
exportDone: 'Downloaded {name}',
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A minimal ZIP writer — store only, no compression, no dependency.
|
|
3
|
+
*
|
|
4
|
+
* ## Why this exists
|
|
5
|
+
*
|
|
6
|
+
* Exporting several projects produces one form per project, and the browser will
|
|
7
|
+
* not let a single click start several downloads: the first `<a download>` is
|
|
8
|
+
* allowed, the rest are blocked until the user grants "automatic downloads" for
|
|
9
|
+
* the origin. That permission prompt is easy to miss and, once missed, the batch
|
|
10
|
+
* looks like it exported one file. Shipping the batch as one archive keeps the
|
|
11
|
+
* one-file-per-project rule *inside* the download while still being exactly one
|
|
12
|
+
* download.
|
|
13
|
+
*
|
|
14
|
+
* ## Why hand-rolled
|
|
15
|
+
*
|
|
16
|
+
* The client bundle is built with esbuild from this repository's own sources; a
|
|
17
|
+
* zip library would be a new runtime dependency for ~130 lines of struct
|
|
18
|
+
* packing. Store (method 0) is enough: the payload is UTF-8 HTML that is already
|
|
19
|
+
* mostly compressible-by-nobody's-standard, and the file is opened locally, not
|
|
20
|
+
* served.
|
|
21
|
+
*
|
|
22
|
+
* ## What it does not do
|
|
23
|
+
*
|
|
24
|
+
* No directory entries (the paths used here are flat), no ZIP64 (a batch is
|
|
25
|
+
* capped well below 4 GiB by `MAX_REPORT_PROJECTS`), no encryption, no comments.
|
|
26
|
+
*/
|
|
27
|
+
/** One member of the archive; `name` is the path inside it. */
|
|
28
|
+
export interface ZipEntry {
|
|
29
|
+
readonly name: string;
|
|
30
|
+
readonly content: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Pack the entries into one archive.
|
|
34
|
+
*
|
|
35
|
+
* Entry order is preserved, so the download lists the projects in the order the
|
|
36
|
+
* reader selected them.
|
|
37
|
+
*/
|
|
38
|
+
export declare function buildZip(entries: readonly ZipEntry[], at?: Date): Blob;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A minimal ZIP writer — store only, no compression, no dependency.
|
|
3
|
+
*
|
|
4
|
+
* ## Why this exists
|
|
5
|
+
*
|
|
6
|
+
* Exporting several projects produces one form per project, and the browser will
|
|
7
|
+
* not let a single click start several downloads: the first `<a download>` is
|
|
8
|
+
* allowed, the rest are blocked until the user grants "automatic downloads" for
|
|
9
|
+
* the origin. That permission prompt is easy to miss and, once missed, the batch
|
|
10
|
+
* looks like it exported one file. Shipping the batch as one archive keeps the
|
|
11
|
+
* one-file-per-project rule *inside* the download while still being exactly one
|
|
12
|
+
* download.
|
|
13
|
+
*
|
|
14
|
+
* ## Why hand-rolled
|
|
15
|
+
*
|
|
16
|
+
* The client bundle is built with esbuild from this repository's own sources; a
|
|
17
|
+
* zip library would be a new runtime dependency for ~130 lines of struct
|
|
18
|
+
* packing. Store (method 0) is enough: the payload is UTF-8 HTML that is already
|
|
19
|
+
* mostly compressible-by-nobody's-standard, and the file is opened locally, not
|
|
20
|
+
* served.
|
|
21
|
+
*
|
|
22
|
+
* ## What it does not do
|
|
23
|
+
*
|
|
24
|
+
* No directory entries (the paths used here are flat), no ZIP64 (a batch is
|
|
25
|
+
* capped well below 4 GiB by `MAX_REPORT_PROJECTS`), no encryption, no comments.
|
|
26
|
+
*/
|
|
27
|
+
/** CRC-32 lookup table, built once per page load (256 entries, trivial cost). */
|
|
28
|
+
const CRC_TABLE = (() => {
|
|
29
|
+
const table = new Uint32Array(256);
|
|
30
|
+
for (let index = 0; index < 256; index += 1) {
|
|
31
|
+
let value = index;
|
|
32
|
+
for (let bit = 0; bit < 8; bit += 1)
|
|
33
|
+
value = value & 1 ? 0xEDB88320 ^ (value >>> 1) : value >>> 1;
|
|
34
|
+
table[index] = value >>> 0;
|
|
35
|
+
}
|
|
36
|
+
return table;
|
|
37
|
+
})();
|
|
38
|
+
function crc32(bytes) {
|
|
39
|
+
let crc = 0xFFFFFFFF;
|
|
40
|
+
for (let index = 0; index < bytes.length; index += 1) {
|
|
41
|
+
crc = CRC_TABLE[(crc ^ bytes[index]) & 0xFF] ^ (crc >>> 8);
|
|
42
|
+
}
|
|
43
|
+
return (crc ^ 0xFFFFFFFF) >>> 0;
|
|
44
|
+
}
|
|
45
|
+
/** Growable byte buffer; the archive is assembled member by member. */
|
|
46
|
+
class ByteSink {
|
|
47
|
+
parts = [];
|
|
48
|
+
size = 0;
|
|
49
|
+
get length() {
|
|
50
|
+
return this.size;
|
|
51
|
+
}
|
|
52
|
+
push(bytes) {
|
|
53
|
+
this.parts.push(bytes);
|
|
54
|
+
this.size += bytes.length;
|
|
55
|
+
}
|
|
56
|
+
/** Little-endian integer of `width` bytes (1, 2 or 4). */
|
|
57
|
+
pushInt(value, width) {
|
|
58
|
+
const bytes = new Uint8Array(width);
|
|
59
|
+
for (let index = 0; index < width; index += 1)
|
|
60
|
+
bytes[index] = (value >>> (8 * index)) & 0xFF;
|
|
61
|
+
this.push(bytes);
|
|
62
|
+
}
|
|
63
|
+
concat() {
|
|
64
|
+
const out = new Uint8Array(this.size);
|
|
65
|
+
let offset = 0;
|
|
66
|
+
for (const part of this.parts) {
|
|
67
|
+
out.set(part, offset);
|
|
68
|
+
offset += part.length;
|
|
69
|
+
}
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* MS-DOS date and time, the only timestamp a ZIP stores.
|
|
75
|
+
*
|
|
76
|
+
* Years before 1980 cannot be represented, and the ZIP epoch starts there; a
|
|
77
|
+
* clock set that far back is a broken machine rather than a real export date, so
|
|
78
|
+
* it is clamped instead of throwing at the end of a successful export.
|
|
79
|
+
*/
|
|
80
|
+
function dosStamp(at) {
|
|
81
|
+
const year = Math.max(1980, at.getFullYear());
|
|
82
|
+
const time = (at.getHours() << 11) | (at.getMinutes() << 5) | Math.floor(at.getSeconds() / 2);
|
|
83
|
+
const date = ((year - 1980) << 9) | ((at.getMonth() + 1) << 5) | at.getDate();
|
|
84
|
+
return { time, date };
|
|
85
|
+
}
|
|
86
|
+
/** UTF-8 bytes of a member name; ZIP paths are always `/`-separated. */
|
|
87
|
+
function nameBytes(name) {
|
|
88
|
+
return new TextEncoder().encode(name.replace(/\\/g, '/').replace(/^\/+/, ''));
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Pack the entries into one archive.
|
|
92
|
+
*
|
|
93
|
+
* Entry order is preserved, so the download lists the projects in the order the
|
|
94
|
+
* reader selected them.
|
|
95
|
+
*/
|
|
96
|
+
export function buildZip(entries, at = new Date()) {
|
|
97
|
+
const encoder = new TextEncoder();
|
|
98
|
+
const { time, date } = dosStamp(at);
|
|
99
|
+
// General-purpose bit 11 marks the names as UTF-8. Without it a Chinese file
|
|
100
|
+
// name is decoded as CP437 by some tools and shows up as mojibake.
|
|
101
|
+
const flags = 0x0800;
|
|
102
|
+
const local = new ByteSink();
|
|
103
|
+
const central = new ByteSink();
|
|
104
|
+
const offsets = [];
|
|
105
|
+
for (const entry of entries) {
|
|
106
|
+
const name = nameBytes(entry.name);
|
|
107
|
+
const data = encoder.encode(entry.content);
|
|
108
|
+
const crc = crc32(data);
|
|
109
|
+
offsets.push(local.length);
|
|
110
|
+
local.pushInt(0x04034B50, 4); // local file header
|
|
111
|
+
local.pushInt(20, 2); // version needed to extract (2.0)
|
|
112
|
+
local.pushInt(flags, 2);
|
|
113
|
+
local.pushInt(0, 2); // method: store
|
|
114
|
+
local.pushInt(time, 2);
|
|
115
|
+
local.pushInt(date, 2);
|
|
116
|
+
local.pushInt(crc, 4);
|
|
117
|
+
local.pushInt(data.length, 4); // compressed size
|
|
118
|
+
local.pushInt(data.length, 4); // uncompressed size
|
|
119
|
+
local.pushInt(name.length, 2);
|
|
120
|
+
local.pushInt(0, 2); // extra field length
|
|
121
|
+
local.push(name);
|
|
122
|
+
local.push(data);
|
|
123
|
+
}
|
|
124
|
+
let centralSize = 0;
|
|
125
|
+
for (const [index, entry] of entries.entries()) {
|
|
126
|
+
const name = nameBytes(entry.name);
|
|
127
|
+
const data = encoder.encode(entry.content);
|
|
128
|
+
const before = central.length;
|
|
129
|
+
central.pushInt(0x02014B50, 4); // central directory header
|
|
130
|
+
central.pushInt(20, 2); // version made by
|
|
131
|
+
central.pushInt(20, 2); // version needed
|
|
132
|
+
central.pushInt(flags, 2);
|
|
133
|
+
central.pushInt(0, 2); // method: store
|
|
134
|
+
central.pushInt(time, 2);
|
|
135
|
+
central.pushInt(date, 2);
|
|
136
|
+
central.pushInt(crc32(data), 4);
|
|
137
|
+
central.pushInt(data.length, 4);
|
|
138
|
+
central.pushInt(data.length, 4);
|
|
139
|
+
central.pushInt(name.length, 2);
|
|
140
|
+
central.pushInt(0, 2); // extra field length
|
|
141
|
+
central.pushInt(0, 2); // comment length
|
|
142
|
+
central.pushInt(0, 2); // disk number start
|
|
143
|
+
central.pushInt(0, 2); // internal attributes
|
|
144
|
+
central.pushInt(0, 4); // external attributes
|
|
145
|
+
central.pushInt(offsets[index], 4);
|
|
146
|
+
central.push(name);
|
|
147
|
+
centralSize += central.length - before;
|
|
148
|
+
}
|
|
149
|
+
const directory = central.concat();
|
|
150
|
+
const out = local;
|
|
151
|
+
const directoryOffset = out.length;
|
|
152
|
+
out.push(directory);
|
|
153
|
+
out.pushInt(0x06054B50, 4); // end of central directory
|
|
154
|
+
out.pushInt(0, 2); // this disk
|
|
155
|
+
out.pushInt(0, 2); // disk with the central directory
|
|
156
|
+
out.pushInt(entries.length, 2);
|
|
157
|
+
out.pushInt(entries.length, 2);
|
|
158
|
+
out.pushInt(centralSize, 4);
|
|
159
|
+
out.pushInt(directoryOffset, 4);
|
|
160
|
+
out.pushInt(0, 2); // comment length
|
|
161
|
+
const bytes = out.concat();
|
|
162
|
+
// `Uint8Array<ArrayBufferLike>` is not a `BlobPart` under the DOM typings, even
|
|
163
|
+
// though every byte here is a fresh non-shared buffer.
|
|
164
|
+
return new Blob([bytes], { type: 'application/zip' });
|
|
165
|
+
}
|
package/lib/client.js
CHANGED
|
@@ -270,6 +270,10 @@ window.__ModuleLoader__.load({
|
|
|
270
270
|
exportStageAll: "\u5168\u90E8\u9636\u6BB5",
|
|
271
271
|
exportStageEmpty: "\u8FD9\u4E2A\u9636\u6BB5\u4E0B\u6CA1\u6709\u9879\u76EE\u3002",
|
|
272
272
|
exportHint: "\u8868\u5355\u5B8C\u5168\u79BB\u7EBF\u53EF\u7528\uFF1A\u6CA1\u6709 CDN\u3001\u6CA1\u6709\u5916\u90E8\u5B57\u4F53\u3001\u6CA1\u6709\u670D\u52A1\u5668\u3002\u6BCF\u4E2A\u9879\u76EE\u4E00\u4E2A\u6587\u4EF6\uFF1B\u7EC4\u5458\u70B9\u300C\u4FDD\u5B58\u300D\u628A\u5185\u5BB9\u5199\u56DE\u8868\u5355\u6587\u4EF6\uFF0C\u518D\u7528\u4F01\u4E1A\u5FAE\u4FE1\u53D1\u56DE\u3002DSH \u6821\u9A8C\u540E\u51C6\u5907\u5F85\u5BA1\u53D8\u66F4\uFF0C\u4E0D\u76F4\u63A5\u5199\u53F0\u8D26\u3002",
|
|
273
|
+
// A batch of several projects arrives as one archive: the browser allows a
|
|
274
|
+
// single automatic download per click, so the remaining files would be blocked
|
|
275
|
+
// and the batch would look like it exported one project.
|
|
276
|
+
exportArchiveHint: "\u9009\u4E86 {count} \u4E2A\u9879\u76EE\uFF1A\u4F1A\u4E0B\u8F7D 1 \u4E2A zip\uFF0C\u89E3\u538B\u540E\u6BCF\u4E2A\u9879\u76EE\u4E00\u4E2A\u8868\u5355\uFF0C\u5404\u81EA\u53D1\u56DE\u7ED9\u5BF9\u5E94\u7EC4\u5458\u3002",
|
|
273
277
|
exportGenerate: "\u751F\u6210\u8868\u5355\u6587\u4EF6",
|
|
274
278
|
exportGenerating: "\u6B63\u5728\u751F\u6210\u2026",
|
|
275
279
|
exportDone: "\u5DF2\u4E0B\u8F7D {name}",
|
|
@@ -853,6 +857,7 @@ window.__ModuleLoader__.load({
|
|
|
853
857
|
exportStageAll: "All stages",
|
|
854
858
|
exportStageEmpty: "No projects at this stage.",
|
|
855
859
|
exportHint: "The form works fully offline: no CDN, no external fonts, no server. One file per project: the colleague saves answers back into the same form file and sends it back. DSH validates it and prepares a change for review.",
|
|
860
|
+
exportArchiveHint: "{count} projects selected: one zip is downloaded. Unzip it and every project has its own form to send to its owner.",
|
|
856
861
|
exportGenerate: "Generate form files",
|
|
857
862
|
exportGenerating: "Generating\u2026",
|
|
858
863
|
exportDone: "Downloaded {name}",
|
|
@@ -4639,6 +4644,127 @@ window.__ModuleLoader__.load({
|
|
|
4639
4644
|
|
|
4640
4645
|
// src/client/export-form.tsx
|
|
4641
4646
|
var import_react3 = require("react");
|
|
4647
|
+
|
|
4648
|
+
// src/client/zip.ts
|
|
4649
|
+
var CRC_TABLE = (() => {
|
|
4650
|
+
const table = new Uint32Array(256);
|
|
4651
|
+
for (let index = 0; index < 256; index += 1) {
|
|
4652
|
+
let value = index;
|
|
4653
|
+
for (let bit = 0; bit < 8; bit += 1) value = value & 1 ? 3988292384 ^ value >>> 1 : value >>> 1;
|
|
4654
|
+
table[index] = value >>> 0;
|
|
4655
|
+
}
|
|
4656
|
+
return table;
|
|
4657
|
+
})();
|
|
4658
|
+
function crc32(bytes) {
|
|
4659
|
+
let crc = 4294967295;
|
|
4660
|
+
for (let index = 0; index < bytes.length; index += 1) {
|
|
4661
|
+
crc = CRC_TABLE[(crc ^ bytes[index]) & 255] ^ crc >>> 8;
|
|
4662
|
+
}
|
|
4663
|
+
return (crc ^ 4294967295) >>> 0;
|
|
4664
|
+
}
|
|
4665
|
+
var ByteSink = class {
|
|
4666
|
+
parts = [];
|
|
4667
|
+
size = 0;
|
|
4668
|
+
get length() {
|
|
4669
|
+
return this.size;
|
|
4670
|
+
}
|
|
4671
|
+
push(bytes) {
|
|
4672
|
+
this.parts.push(bytes);
|
|
4673
|
+
this.size += bytes.length;
|
|
4674
|
+
}
|
|
4675
|
+
/** Little-endian integer of `width` bytes (1, 2 or 4). */
|
|
4676
|
+
pushInt(value, width) {
|
|
4677
|
+
const bytes = new Uint8Array(width);
|
|
4678
|
+
for (let index = 0; index < width; index += 1) bytes[index] = value >>> 8 * index & 255;
|
|
4679
|
+
this.push(bytes);
|
|
4680
|
+
}
|
|
4681
|
+
concat() {
|
|
4682
|
+
const out = new Uint8Array(this.size);
|
|
4683
|
+
let offset = 0;
|
|
4684
|
+
for (const part of this.parts) {
|
|
4685
|
+
out.set(part, offset);
|
|
4686
|
+
offset += part.length;
|
|
4687
|
+
}
|
|
4688
|
+
return out;
|
|
4689
|
+
}
|
|
4690
|
+
};
|
|
4691
|
+
function dosStamp(at) {
|
|
4692
|
+
const year = Math.max(1980, at.getFullYear());
|
|
4693
|
+
const time = at.getHours() << 11 | at.getMinutes() << 5 | Math.floor(at.getSeconds() / 2);
|
|
4694
|
+
const date = year - 1980 << 9 | at.getMonth() + 1 << 5 | at.getDate();
|
|
4695
|
+
return { time, date };
|
|
4696
|
+
}
|
|
4697
|
+
function nameBytes(name) {
|
|
4698
|
+
return new TextEncoder().encode(name.replace(/\\/g, "/").replace(/^\/+/, ""));
|
|
4699
|
+
}
|
|
4700
|
+
function buildZip(entries, at = /* @__PURE__ */ new Date()) {
|
|
4701
|
+
const encoder = new TextEncoder();
|
|
4702
|
+
const { time, date } = dosStamp(at);
|
|
4703
|
+
const flags = 2048;
|
|
4704
|
+
const local = new ByteSink();
|
|
4705
|
+
const central = new ByteSink();
|
|
4706
|
+
const offsets = [];
|
|
4707
|
+
for (const entry of entries) {
|
|
4708
|
+
const name = nameBytes(entry.name);
|
|
4709
|
+
const data = encoder.encode(entry.content);
|
|
4710
|
+
const crc = crc32(data);
|
|
4711
|
+
offsets.push(local.length);
|
|
4712
|
+
local.pushInt(67324752, 4);
|
|
4713
|
+
local.pushInt(20, 2);
|
|
4714
|
+
local.pushInt(flags, 2);
|
|
4715
|
+
local.pushInt(0, 2);
|
|
4716
|
+
local.pushInt(time, 2);
|
|
4717
|
+
local.pushInt(date, 2);
|
|
4718
|
+
local.pushInt(crc, 4);
|
|
4719
|
+
local.pushInt(data.length, 4);
|
|
4720
|
+
local.pushInt(data.length, 4);
|
|
4721
|
+
local.pushInt(name.length, 2);
|
|
4722
|
+
local.pushInt(0, 2);
|
|
4723
|
+
local.push(name);
|
|
4724
|
+
local.push(data);
|
|
4725
|
+
}
|
|
4726
|
+
let centralSize = 0;
|
|
4727
|
+
for (const [index, entry] of entries.entries()) {
|
|
4728
|
+
const name = nameBytes(entry.name);
|
|
4729
|
+
const data = encoder.encode(entry.content);
|
|
4730
|
+
const before = central.length;
|
|
4731
|
+
central.pushInt(33639248, 4);
|
|
4732
|
+
central.pushInt(20, 2);
|
|
4733
|
+
central.pushInt(20, 2);
|
|
4734
|
+
central.pushInt(flags, 2);
|
|
4735
|
+
central.pushInt(0, 2);
|
|
4736
|
+
central.pushInt(time, 2);
|
|
4737
|
+
central.pushInt(date, 2);
|
|
4738
|
+
central.pushInt(crc32(data), 4);
|
|
4739
|
+
central.pushInt(data.length, 4);
|
|
4740
|
+
central.pushInt(data.length, 4);
|
|
4741
|
+
central.pushInt(name.length, 2);
|
|
4742
|
+
central.pushInt(0, 2);
|
|
4743
|
+
central.pushInt(0, 2);
|
|
4744
|
+
central.pushInt(0, 2);
|
|
4745
|
+
central.pushInt(0, 2);
|
|
4746
|
+
central.pushInt(0, 4);
|
|
4747
|
+
central.pushInt(offsets[index], 4);
|
|
4748
|
+
central.push(name);
|
|
4749
|
+
centralSize += central.length - before;
|
|
4750
|
+
}
|
|
4751
|
+
const directory = central.concat();
|
|
4752
|
+
const out = local;
|
|
4753
|
+
const directoryOffset = out.length;
|
|
4754
|
+
out.push(directory);
|
|
4755
|
+
out.pushInt(101010256, 4);
|
|
4756
|
+
out.pushInt(0, 2);
|
|
4757
|
+
out.pushInt(0, 2);
|
|
4758
|
+
out.pushInt(entries.length, 2);
|
|
4759
|
+
out.pushInt(entries.length, 2);
|
|
4760
|
+
out.pushInt(centralSize, 4);
|
|
4761
|
+
out.pushInt(directoryOffset, 4);
|
|
4762
|
+
out.pushInt(0, 2);
|
|
4763
|
+
const bytes = out.concat();
|
|
4764
|
+
return new Blob([bytes], { type: "application/zip" });
|
|
4765
|
+
}
|
|
4766
|
+
|
|
4767
|
+
// src/client/export-form.tsx
|
|
4642
4768
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
4643
4769
|
var STAGE_FILTERS = [
|
|
4644
4770
|
{ key: "G0", label: "G0" },
|
|
@@ -4677,6 +4803,16 @@ window.__ModuleLoader__.load({
|
|
|
4677
4803
|
};
|
|
4678
4804
|
const selectAll = () => setSelected(new Set(visibleRows.map((row) => row.pocId)));
|
|
4679
4805
|
const selectNone = () => setSelected(/* @__PURE__ */ new Set());
|
|
4806
|
+
const save = (fileName, payload) => {
|
|
4807
|
+
const url = URL.createObjectURL(payload);
|
|
4808
|
+
const anchor = document.createElement("a");
|
|
4809
|
+
anchor.href = url;
|
|
4810
|
+
anchor.download = fileName;
|
|
4811
|
+
document.body.appendChild(anchor);
|
|
4812
|
+
anchor.click();
|
|
4813
|
+
anchor.remove();
|
|
4814
|
+
setTimeout(() => URL.revokeObjectURL(url), 4e3);
|
|
4815
|
+
};
|
|
4680
4816
|
const generate = async () => {
|
|
4681
4817
|
if (intent === "progress" && selectedIds.length === 0) return;
|
|
4682
4818
|
setBusy(true);
|
|
@@ -4685,17 +4821,12 @@ window.__ModuleLoader__.load({
|
|
|
4685
4821
|
const result = await api.exportForm(mode, mode === "blank" ? [] : selectedIds);
|
|
4686
4822
|
const files = Array.isArray(result.files) ? result.files : [];
|
|
4687
4823
|
if (files.length === 0) throw new Error(t("exportFailed"));
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
const
|
|
4693
|
-
|
|
4694
|
-
anchor.download = file.fileName;
|
|
4695
|
-
document.body.appendChild(anchor);
|
|
4696
|
-
anchor.click();
|
|
4697
|
-
anchor.remove();
|
|
4698
|
-
setTimeout(() => URL.revokeObjectURL(url), 4e3);
|
|
4824
|
+
if (files.length === 1) {
|
|
4825
|
+
const only = files[0];
|
|
4826
|
+
save(only.fileName, new Blob([only.html], { type: "text/html;charset=utf-8" }));
|
|
4827
|
+
} else {
|
|
4828
|
+
const archive = buildZip(files.map((file) => ({ name: file.fileName, content: file.html })));
|
|
4829
|
+
save(result.archiveName ?? "\u8BB0\u5F55\u8FDB\u5C55.zip", archive);
|
|
4699
4830
|
}
|
|
4700
4831
|
onClose();
|
|
4701
4832
|
} catch (error) {
|
|
@@ -4803,7 +4934,7 @@ window.__ModuleLoader__.load({
|
|
|
4803
4934
|
] })
|
|
4804
4935
|
] })
|
|
4805
4936
|
] }) }, row.pocId)) })),
|
|
4806
|
-
intent === "new" ? null : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "helper-box", children: selectedIds.length === 0 ? t("exportBlankHint") : t("exportHint") })
|
|
4937
|
+
intent === "new" ? null : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "helper-box", children: selectedIds.length === 0 ? t("exportBlankHint") : selectedIds.length === 1 ? t("exportHint") : format(t("exportArchiveHint"), { count: selectedIds.length }) })
|
|
4807
4938
|
] }),
|
|
4808
4939
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "modal-footer", children: [
|
|
4809
4940
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "spacer" }),
|
package/lib/index.js
CHANGED
|
@@ -21,7 +21,7 @@ import { buildGlobalTimeline } from './timeline.js';
|
|
|
21
21
|
import { text } from './gap.js';
|
|
22
22
|
import { canReportProgress } from './progress.js';
|
|
23
23
|
import { buildDossier } from './report-contract.js';
|
|
24
|
-
import { buildReportHtml, reportFileName, reportFileNames } from './report-form.js';
|
|
24
|
+
import { buildReportHtml, reportArchiveName, reportFileName, reportFileNames } from './report-form.js';
|
|
25
25
|
import { registerBundledSkills } from './skill.js';
|
|
26
26
|
import { createExecuteRoute } from './transport.js';
|
|
27
27
|
export { resolveConfig };
|
|
@@ -147,6 +147,7 @@ export function createRuntime(config, options = {}) {
|
|
|
147
147
|
files: [{ html: buildReportHtml('new', [], stamp), fileName: reportFileName('new', null, stamp), projectCount: 0, pocId: null }],
|
|
148
148
|
fileCount: 1,
|
|
149
149
|
projectCount: 0,
|
|
150
|
+
archiveName: null,
|
|
150
151
|
};
|
|
151
152
|
}
|
|
152
153
|
const wanted = new Set(pocIds);
|
|
@@ -168,7 +169,12 @@ export function createRuntime(config, options = {}) {
|
|
|
168
169
|
projectCount: 1,
|
|
169
170
|
pocId: text(record.poc_id),
|
|
170
171
|
}));
|
|
171
|
-
return {
|
|
172
|
+
return {
|
|
173
|
+
files,
|
|
174
|
+
fileCount: files.length,
|
|
175
|
+
projectCount: records.length,
|
|
176
|
+
archiveName: files.length > 1 ? reportArchiveName(stamp) : null,
|
|
177
|
+
};
|
|
172
178
|
},
|
|
173
179
|
};
|
|
174
180
|
}
|
package/lib/report-form.d.ts
CHANGED
|
@@ -32,3 +32,14 @@ export declare function reportFileNames(intent: 'new' | 'progress', projects: re
|
|
|
32
32
|
owner?: string;
|
|
33
33
|
pocId?: string;
|
|
34
34
|
}[], now?: Date): string[];
|
|
35
|
+
/**
|
|
36
|
+
* The download name of a multi-project batch.
|
|
37
|
+
*
|
|
38
|
+
* A batch travels as ONE archive because browsers allow a single automatic
|
|
39
|
+
* download per click: the second `<a download>` in the same gesture is blocked
|
|
40
|
+
* (or silently dropped) unless the user grants "multiple downloads" for the
|
|
41
|
+
* origin, which is a permission prompt most people never notice. One archive is
|
|
42
|
+
* one download, so every selected project actually arrives. Inside it the files
|
|
43
|
+
* are still one form per project.
|
|
44
|
+
*/
|
|
45
|
+
export declare function reportArchiveName(now?: Date): string;
|
package/lib/report-form.js
CHANGED
|
@@ -112,3 +112,16 @@ export function reportFileNames(intent, projects, now = new Date()) {
|
|
|
112
112
|
return name;
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* The download name of a multi-project batch.
|
|
117
|
+
*
|
|
118
|
+
* A batch travels as ONE archive because browsers allow a single automatic
|
|
119
|
+
* download per click: the second `<a download>` in the same gesture is blocked
|
|
120
|
+
* (or silently dropped) unless the user grants "multiple downloads" for the
|
|
121
|
+
* origin, which is a permission prompt most people never notice. One archive is
|
|
122
|
+
* one download, so every selected project actually arrives. Inside it the files
|
|
123
|
+
* are still one form per project.
|
|
124
|
+
*/
|
|
125
|
+
export function reportArchiveName(now = new Date()) {
|
|
126
|
+
return `记录进展_${calendarDate(now)}.zip`;
|
|
127
|
+
}
|
package/lib/report-page.js
CHANGED
|
@@ -1838,6 +1838,34 @@ function reportPage() {
|
|
|
1838
1838
|
wrap.appendChild(body);
|
|
1839
1839
|
return wrap;
|
|
1840
1840
|
}
|
|
1841
|
+
/**
|
|
1842
|
+
* The "nothing happened this round" option.
|
|
1843
|
+
*
|
|
1844
|
+
* It is a statement about the whole round, not a chip belonging to one row, so
|
|
1845
|
+
* it takes the full width and carries its own type scale. The previous version
|
|
1846
|
+
* was an inline mini-button: in a project whose last round set no plans it
|
|
1847
|
+
* wrapped onto three lines inside a 174px bordered box, which made the one
|
|
1848
|
+
* control the reader most needs the least legible thing on the page.
|
|
1849
|
+
*/
|
|
1850
|
+
function renderNoProgressChoice(ws) {
|
|
1851
|
+
var label = el('label', 'rp-noop');
|
|
1852
|
+
if (ws.noProgress)
|
|
1853
|
+
label.setAttribute('data-n', '1');
|
|
1854
|
+
var checkbox = el('input', '');
|
|
1855
|
+
checkbox.type = 'checkbox';
|
|
1856
|
+
checkbox.setAttribute('data-role', 'no-progress');
|
|
1857
|
+
checkbox.checked = ws.noProgress;
|
|
1858
|
+
label.appendChild(checkbox);
|
|
1859
|
+
var body = el('span', '');
|
|
1860
|
+
var title = el('span', 'rp-noop-t');
|
|
1861
|
+
setText(title, '本轮无实质进展');
|
|
1862
|
+
body.appendChild(title);
|
|
1863
|
+
var sub = el('span', 'rp-noop-s');
|
|
1864
|
+
setText(sub, '勾选后本轮不用再填进展项,台账里会明确记成「无实质进展」。');
|
|
1865
|
+
body.appendChild(sub);
|
|
1866
|
+
label.appendChild(body);
|
|
1867
|
+
return label;
|
|
1868
|
+
}
|
|
1841
1869
|
function renderProgressSection(ws) {
|
|
1842
1870
|
var input = ws.input;
|
|
1843
1871
|
var sec = worksheetSection(false);
|
|
@@ -1853,24 +1881,11 @@ function reportPage() {
|
|
|
1853
1881
|
sec.appendChild(general);
|
|
1854
1882
|
registerRef('round:missing', general);
|
|
1855
1883
|
if (!planned) {
|
|
1856
|
-
var box = el('div', '');
|
|
1857
1884
|
var note = el('p', 'rp-hint');
|
|
1858
1885
|
setText(note, '上一轮没有约定计划,所以没有需要逐项对照的承诺。可以登记这轮实际做的事,或勾选下面的「本轮无实质进展」。');
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
var checkbox = el('input', '');
|
|
1863
|
-
checkbox.type = 'checkbox';
|
|
1864
|
-
checkbox.setAttribute('data-role', 'no-progress');
|
|
1865
|
-
checkbox.checked = ws.noProgress;
|
|
1866
|
-
label.appendChild(checkbox);
|
|
1867
|
-
var span = el('span', '');
|
|
1868
|
-
setText(span, '本轮无实质进展(明确记录)');
|
|
1869
|
-
label.appendChild(span);
|
|
1870
|
-
if (ws.noProgress)
|
|
1871
|
-
label.setAttribute('data-n', '1');
|
|
1872
|
-
box.appendChild(label);
|
|
1873
|
-
sec.appendChild(box);
|
|
1886
|
+
sec.appendChild(note);
|
|
1887
|
+
sec.appendChild(el('div', 'rp-noop-spacer'));
|
|
1888
|
+
sec.appendChild(renderNoProgressChoice(ws));
|
|
1874
1889
|
}
|
|
1875
1890
|
var list = el('div', '');
|
|
1876
1891
|
for (var i = 0; i < ws.lines.length; i += 1) {
|
|
@@ -1885,7 +1900,10 @@ function reportPage() {
|
|
|
1885
1900
|
var add = el('button', 'rp-addline');
|
|
1886
1901
|
add.type = 'button';
|
|
1887
1902
|
add.setAttribute('data-act', 'add-line');
|
|
1888
|
-
|
|
1903
|
+
// The no-plan row is a full-width block, so the link under it needs the same
|
|
1904
|
+
// breathing room the design gives it there; under a list of plan cards the
|
|
1905
|
+
// tighter spacing still reads as belonging to the last card.
|
|
1906
|
+
add.style.paddingTop = planned ? '10px' : '18px';
|
|
1889
1907
|
add.appendChild(svgIcon('plus', 12));
|
|
1890
1908
|
addText(add, planned ? '添加一条计划外的进展' : '添加一条进展');
|
|
1891
1909
|
sec.appendChild(add);
|
|
@@ -3697,6 +3715,13 @@ function reportPage() {
|
|
|
3697
3715
|
}
|
|
3698
3716
|
else if (role === 'no-progress') {
|
|
3699
3717
|
ws.noProgress = target.checked === true;
|
|
3718
|
+
var noop = target.parentNode;
|
|
3719
|
+
if (noop && noop.setAttribute) {
|
|
3720
|
+
if (ws.noProgress)
|
|
3721
|
+
noop.setAttribute('data-n', '1');
|
|
3722
|
+
else
|
|
3723
|
+
noop.removeAttribute('data-n');
|
|
3724
|
+
}
|
|
3700
3725
|
var change = app.querySelector('[data-role="round"][data-field="change"]');
|
|
3701
3726
|
if (change) {
|
|
3702
3727
|
change.disabled = ws.noProgress;
|
package/lib/report-style.js
CHANGED
|
@@ -144,6 +144,11 @@ html,body{
|
|
|
144
144
|
.rp-label{display:flex;align-items:center;gap:6px;font-family:var(--mono);font-size:10px;letter-spacing:.9px;color:var(--ink3);margin-bottom:7px;flex-wrap:wrap}
|
|
145
145
|
.rp-label .rp-req{color:var(--accent)}
|
|
146
146
|
.rp-label .rp-hint{font-family:var(--sans);letter-spacing:0;font-size:10.5px;color:var(--ink4)}
|
|
147
|
+
/* A standalone hint is prose, not a label suffix. Without its own rule it fell
|
|
148
|
+
back to the 13px body size in full ink and read as a paragraph of the form
|
|
149
|
+
itself — the words a colleague skims and ignores are exactly the ones that
|
|
150
|
+
explain what the section wants. */
|
|
151
|
+
p.rp-hint{font-size:12px;line-height:1.7;color:var(--ink3)}
|
|
147
152
|
.rp-box{background:var(--paper);border:1px solid var(--line);border-radius:2px;padding:11px 13px}
|
|
148
153
|
.rp-box.is-quiet{background:var(--quiet);border-color:var(--line2)}
|
|
149
154
|
.rp-box:focus-within{border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-soft)}
|
|
@@ -181,6 +186,21 @@ html,body{
|
|
|
181
186
|
.rp-mini[data-n="1"]{border-color:#BBD9C8;background:var(--accent-soft);color:var(--accent)}
|
|
182
187
|
.rp-mini[data-n="1"] svg{color:var(--accent)}
|
|
183
188
|
|
|
189
|
+
/* The "nothing happened this round" option.
|
|
190
|
+
It is a statement about the whole round, not a chip in a row, so it owns the
|
|
191
|
+
full width and keeps its own type scale. Rendered as a bordered inline chip it
|
|
192
|
+
wrapped onto three lines in a 174px box next to nothing — the one control a
|
|
193
|
+
colleague is most likely to reach for, and the least legible thing on screen. */
|
|
194
|
+
.rp-noop{display:flex;align-items:flex-start;gap:11px;width:100%;padding:13px 16px;border:1px solid var(--line);border-radius:2px;background:var(--paper);cursor:pointer;transition:border-color .15s,background .15s}
|
|
195
|
+
.rp-noop:hover{border-color:var(--ink4)}
|
|
196
|
+
.rp-noop:focus-within{border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-soft)}
|
|
197
|
+
.rp-noop input[type=checkbox]{width:14px;height:14px;margin-top:2px;flex:none;accent-color:var(--accent);cursor:pointer}
|
|
198
|
+
.rp-noop .rp-noop-t{display:block;font-size:13px;font-weight:500;color:var(--ink);transition:color .15s}
|
|
199
|
+
.rp-noop .rp-noop-s{display:block;font-size:11px;line-height:1.5;color:var(--ink3);padding-top:3px}
|
|
200
|
+
.rp-noop[data-n="1"]{border-color:#BBD9C8;background:var(--accent-soft)}
|
|
201
|
+
.rp-noop[data-n="1"] .rp-noop-t{color:var(--accent)}
|
|
202
|
+
.rp-noop-spacer{height:14px}
|
|
203
|
+
|
|
184
204
|
/* ---------- three-up ---------- */
|
|
185
205
|
.rp-three{display:flex;gap:14px;flex-wrap:wrap}
|
|
186
206
|
.rp-three>.rp-f{flex:1 1 28%;margin-bottom:0;min-width:170px}
|
package/lib/types.d.ts
CHANGED
|
@@ -741,6 +741,16 @@ export interface ExportFormResult {
|
|
|
741
741
|
fileCount: number;
|
|
742
742
|
/** How many projects the whole export covers; `0` for a blank form. */
|
|
743
743
|
projectCount: number;
|
|
744
|
+
/**
|
|
745
|
+
* Download name of the archive that carries a batch, or `null` for a batch of
|
|
746
|
+
* one (which downloads as a plain `.html`).
|
|
747
|
+
*
|
|
748
|
+
* The browser allows one automatic download per click, so a multi-project
|
|
749
|
+
* export arrives as a single `.zip` holding the same one-file-per-project set.
|
|
750
|
+
* The name is built on the Host, next to the file names, so the two cannot
|
|
751
|
+
* drift apart over the date format.
|
|
752
|
+
*/
|
|
753
|
+
archiveName: string | null;
|
|
744
754
|
}
|
|
745
755
|
/**
|
|
746
756
|
* Where a blocker comes from.
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@ node <skill-dir>/scripts/export-form.mjs --mode fill \
|
|
|
15
15
|
--poc "$HOME/.dsh/cache/work-dashboard/repo/projects/POC-006.yaml" --out /tmp/poc-progress.html
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
`--poc` 支持带 `*` 的路径,使用引号保留通配符。**一个项目一个文件**,文件名是「项目名称_负责人_记录进展_日期.html
|
|
18
|
+
`--poc` 支持带 `*` 的路径,使用引号保留通配符。**一个项目一个文件**,文件名是「项目名称_负责人_记录进展_日期.html」;多选时仍是一个项目一个文件,但下载的是一个 zip(浏览器一次点击只允许一次自动下载),解压后用,绝不合并成一份。只把同一接收者有权查看的项目一起导出。优先刷新看板或读取当前台账;旧项目可以预览,但必须在台账 3.2 迁移完成后重新导出再正式填报。不要用旧版 `poc_form.py`。
|
|
19
19
|
|
|
20
20
|
组员用浏览器打开,无需联网或登录。上轮各计划只读,可以反馈未开始、延期或取消。各项证据分别填写,不借用别项证据。下一步计划会原样带到下次表单;没有就明确选「暂无」。草稿只在本机且绑定此次导出,**不是已发送**。
|
|
21
21
|
|