@wanlianyida/portal-kit 0.0.0-stage → 0.1.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/README.md CHANGED
@@ -1,3 +1,68 @@
1
- # Temporary Holding Version
1
+ # @wanlianyida/portal-kit
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 开放平台官网、文档中心、控制台共用的界面。当前包含右下角问题反馈,以及正文划线评论。
4
+
5
+ 页面、语言、应用和企业由各项目传入。飞书 webhook 留在各项目的环境变量里,不写进这个包。
6
+
7
+ ## 本地预览
8
+
9
+ 在组件库目录执行:
10
+
11
+ ```bash
12
+ pnpm dev
13
+ ```
14
+
15
+ 浏览器打开 http://localhost:5174 。左侧是组件菜单,点一项进入对应预览。新组件在 `playground/menu.ts` 登记,并在 `playground/demos` 放一个预览页。改 `src` 里的组件会热更新,不用先构建。
16
+
17
+ ## 安装
18
+
19
+ ```bash
20
+ pnpm add @wanlianyida/portal-kit
21
+ ```
22
+
23
+ 宿主项目需要自行安装 `vue@^3.5` 和 `element-plus@^2.14`。
24
+
25
+ ## 用法
26
+
27
+ ```vue
28
+ <script setup lang="ts">
29
+ import { FeedbackWidget } from '@wanlianyida/portal-kit';
30
+ import { useRoute } from 'vue-router';
31
+
32
+ const route = useRoute();
33
+ const webhookUrl = import.meta.env.VITE_FEEDBACK_WEBHOOK_URL?.trim() ?? '';
34
+ </script>
35
+
36
+ <template>
37
+ <FeedbackWidget
38
+ :webhook-url="webhookUrl"
39
+ :dev="import.meta.env.DEV"
40
+ :page="route.path"
41
+ locale="zh-CN"
42
+ source="文档中心"
43
+ />
44
+ </template>
45
+ ```
46
+
47
+ 控制台再补上 `app-name`、`app-key`、`merchant`。文档中心没有应用时留空即可。
48
+
49
+ 划线评论包住可划选的正文。选中文字后出现评论按钮,弹窗提交到同一张飞书表,类型为「划线评论」,并带上划线原文。页面上不展示已提交的评论。
50
+
51
+ ```vue
52
+ <script setup lang="ts">
53
+ import { SelectionComment } from '@wanlianyida/portal-kit';
54
+ </script>
55
+
56
+ <template>
57
+ <SelectionComment
58
+ :webhook-url="webhookUrl"
59
+ :dev="import.meta.env.DEV"
60
+ :page="route.path"
61
+ source="文档中心"
62
+ >
63
+ <article>文档正文</article>
64
+ </SelectionComment>
65
+ </template>
66
+ ```
67
+
68
+ `dev` 为 true 时,即使还没配 webhook 也会显示入口。生产环境传 false,地址不是飞书 https 域名时入口不出现。
@@ -0,0 +1,162 @@
1
+ import { ComponentOptionsMixin } from 'vue';
2
+ import { ComponentProvideOptions } from 'vue';
3
+ import { DefineComponent } from 'vue';
4
+ import { PublicProps } from 'vue';
5
+
6
+ declare const __VLS_component: DefineComponent<SelectionCommentProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<SelectionCommentProps> & Readonly<{}>, {
7
+ webhookUrl: string;
8
+ dev: boolean;
9
+ page: string;
10
+ locale: string;
11
+ source: string;
12
+ appName: string;
13
+ appKey: string;
14
+ merchant: string;
15
+ }, {}, {}, {}, string, ComponentProvideOptions, false, {
16
+ root: HTMLDivElement;
17
+ }, HTMLDivElement>;
18
+
19
+ declare function __VLS_template(): {
20
+ attrs: Partial<{}>;
21
+ slots: {
22
+ default?(_: {}): any;
23
+ };
24
+ refs: {
25
+ root: HTMLDivElement;
26
+ };
27
+ rootEl: HTMLDivElement;
28
+ };
29
+
30
+ declare type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
31
+
32
+ declare type __VLS_WithTemplateSlots<T, S> = T & {
33
+ new (): {
34
+ $slots: S;
35
+ };
36
+ };
37
+
38
+ export declare function buildFeedbackPayload(input: FeedbackInput, now?: Date): FeedbackPayload;
39
+
40
+ /** 未传入地址时写入的飞书多维表格。各项目仍可用 webhookUrl 覆盖。 */
41
+ export declare const DEFAULT_FEEDBACK_WEBHOOK = "https://bytedance.larkoffice.com/base/workflow/webhook/event/D9h2a3gAkwESDohg6xKcqhq7nZe";
42
+
43
+ /**
44
+ * 问题反馈直达飞书多维表格,不经过业务后端。
45
+ *
46
+ * 表格里建一条「接收到 webhook 时」的自动化:下一步「新增记录」,把下面 JSON 字段映射到列。
47
+ * 不要开 IP 白名单,也不要开 Bearer 校验——浏览器跨域预检过不了,带这些校验请求发不出去。
48
+ * 地址由各项目通过 webhookUrl 传入,会出现在该项目的前端产物里,只能用来新增一行。
49
+ *
50
+ * 示例请求体(自动化「输出设置 → 手动设置」可直接粘贴):
51
+ * {"score":5,"scoreLabel":"很好","category":"experience","categoryLabel":"体验问题","content":"示例","contact":"","source":"控制台","kind":"反馈","quote":"","page":"/apps/profile","appName":"示例应用","appKey":"ak_example","merchant":"示例企业","locale":"zh-CN","submittedAt":"2026-10-27 14:29:00","userAgent":"Mozilla/5.0"}
52
+ */
53
+ export declare type FeedbackCategory = 'experience' | 'suggestion' | 'other';
54
+
55
+ export declare class FeedbackChannelError extends Error {
56
+ constructor();
57
+ }
58
+
59
+ export declare interface FeedbackInput {
60
+ score: number;
61
+ category: FeedbackCategory;
62
+ content: string;
63
+ contact: string;
64
+ /** 提交来自哪个站点,固定中文,例如「控制台」「文档中心」 */
65
+ source: string;
66
+ page: string;
67
+ appName: string;
68
+ appKey: string;
69
+ merchant: string;
70
+ locale: string;
71
+ /** 记录类型。右下角反馈为「反馈」,划线评论为「划线评论」。 */
72
+ kind?: string;
73
+ /** 划线选中的原文。普通反馈为空。 */
74
+ quote?: string;
75
+ }
76
+
77
+ export declare interface FeedbackPayload {
78
+ score: number;
79
+ /** 固定中文,方便表格里直接分组,不随界面语言变化 */
80
+ scoreLabel: string;
81
+ category: FeedbackCategory;
82
+ categoryLabel: string;
83
+ content: string;
84
+ contact: string;
85
+ /** 固定中文,方便表格里直接筛选站点 */
86
+ source: string;
87
+ page: string;
88
+ appName: string;
89
+ appKey: string;
90
+ merchant: string;
91
+ locale: string;
92
+ kind: string;
93
+ quote: string;
94
+ /** 北京时间,文本列可直接读 */
95
+ submittedAt: string;
96
+ userAgent: string;
97
+ }
98
+
99
+ export declare const FeedbackWidget: DefineComponent<FeedbackWidgetProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<FeedbackWidgetProps> & Readonly<{}>, {
100
+ webhookUrl: string;
101
+ dev: boolean;
102
+ page: string;
103
+ locale: string;
104
+ source: string;
105
+ appName: string;
106
+ appKey: string;
107
+ merchant: string;
108
+ }, {}, {}, {}, string, ComponentProvideOptions, false, {
109
+ root: HTMLDivElement;
110
+ entryRef: HTMLButtonElement;
111
+ }, any>;
112
+
113
+ export declare interface FeedbackWidgetProps {
114
+ /** 飞书多维表格 webhook。只接受 https 的飞书 / Lark 域名。 */
115
+ webhookUrl?: string;
116
+ /** 为 true 时,即使还没配 webhook 也展示入口,方便本地看样式。 */
117
+ dev?: boolean;
118
+ /** 当前页面路径。不传则提交时使用浏览器地址。 */
119
+ page?: string;
120
+ /** `zh-CN` 或 `en` / `en-US`。其它值按中文显示。 */
121
+ locale?: string;
122
+ /** 站点来源,写入飞书。控制台传「控制台」,文档中心传「文档中心」。 */
123
+ source?: string;
124
+ appName?: string;
125
+ appKey?: string;
126
+ merchant?: string;
127
+ }
128
+
129
+ export declare function formatFeedbackTime(date: Date): string;
130
+
131
+ /** 只接受飞书 / Lark 的 https 地址,避免把企业名和页面路径发到任意域名。 */
132
+ export declare function isFeishuWebhook(url: string): boolean;
133
+
134
+ /**
135
+ * text/plain 属于浏览器的简单请求,不会先发 OPTIONS。
136
+ * 飞书不回 Access-Control-Allow-Origin,带 application/json 会被预检拦住。
137
+ * no-cors 读不到响应体,请求发出即视为已提交。
138
+ */
139
+ export declare function postFeedback(input: FeedbackInput, webhookUrl: string, now?: Date): Promise<void>;
140
+
141
+ export declare const SelectionComment: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
142
+
143
+ export declare interface SelectionCommentProps {
144
+ /** 飞书多维表格 webhook。只接受 https 的飞书 / Lark 域名。 */
145
+ webhookUrl?: string;
146
+ /** 为 true 时,即使还没配 webhook 也响应划线,方便本地看样式。 */
147
+ dev?: boolean;
148
+ /** 当前页面路径。不传则提交时使用浏览器地址。 */
149
+ page?: string;
150
+ /** `zh-CN` 或 `en` / `en-US`。其它值按中文显示。 */
151
+ locale?: string;
152
+ /** 站点来源,写入飞书。文档中心传「文档中心」。 */
153
+ source?: string;
154
+ appName?: string;
155
+ appKey?: string;
156
+ merchant?: string;
157
+ }
158
+
159
+ /** 本地始终展示入口,方便看样式;生产环境没配好地址就不出现,避免点了提交失败。 */
160
+ export declare function showFeedbackEntry(isDev: boolean, webhookUrl: string): boolean;
161
+
162
+ export { }
package/dist/index.js ADDED
@@ -0,0 +1,789 @@
1
+ import './style.css';
2
+ import { defineComponent as ke, computed as M, ref as y, reactive as j, watch as U, onUnmounted as We, openBlock as C, createBlock as xe, Teleport as _e, createElementBlock as P, normalizeStyle as Ee, normalizeClass as Z, createElementVNode as s, toDisplayString as v, createVNode as f, unref as p, withModifiers as Ge, withCtx as h, Fragment as He, renderList as Ke, createTextVNode as I, createCommentVNode as ee, onMounted as Ye, onBeforeUnmount as Xe, renderSlot as Ze, withDirectives as Je, vModelText as Qe } from "vue";
3
+ import { ElForm as je, ElFormItem as J, ElRadioGroup as et, ElRadio as ie, ElInput as be, ElButton as te, ElTooltip as tt, ElMessage as ce, ElDialog as ot } from "element-plus";
4
+ import "element-plus/es/components/button/style/css";
5
+ import "element-plus/es/components/form/style/css";
6
+ import "element-plus/es/components/form-item/style/css";
7
+ import "element-plus/es/components/input/style/css";
8
+ import "element-plus/es/components/message/style/css";
9
+ import "element-plus/es/components/radio/style/css";
10
+ import "element-plus/es/components/radio-group/style/css";
11
+ import "element-plus/es/components/tooltip/style/css";
12
+ import "element-plus/es/components/dialog/style/css";
13
+ const nt = ["", "很差", "较差", "一般", "较好", "很好"], at = {
14
+ experience: "体验问题",
15
+ suggestion: "功能建议",
16
+ other: "其他"
17
+ }, rt = ["feishu.cn", "larksuite.com", "larkoffice.com"], Ce = "https://bytedance.larkoffice.com/base/workflow/webhook/event/D9h2a3gAkwESDohg6xKcqhq7nZe";
18
+ class se extends Error {
19
+ constructor() {
20
+ super("Feishu feedback webhook is missing or not an https Feishu host"), this.name = "FeedbackChannelError";
21
+ }
22
+ }
23
+ function Se(a) {
24
+ try {
25
+ const o = new URL(a);
26
+ if (o.protocol !== "https:") return !1;
27
+ const t = o.hostname.toLowerCase();
28
+ return rt.some((m) => t === m || t.endsWith(`.${m}`));
29
+ } catch {
30
+ return !1;
31
+ }
32
+ }
33
+ function Me(a, o) {
34
+ return a || Se(o);
35
+ }
36
+ function lt(a) {
37
+ return new Intl.DateTimeFormat("sv-SE", {
38
+ timeZone: "Asia/Shanghai",
39
+ year: "numeric",
40
+ month: "2-digit",
41
+ day: "2-digit",
42
+ hour: "2-digit",
43
+ minute: "2-digit",
44
+ second: "2-digit",
45
+ hourCycle: "h23"
46
+ }).format(a).replace("T", " ");
47
+ }
48
+ function it(a, o = /* @__PURE__ */ new Date()) {
49
+ var m;
50
+ const t = a.score;
51
+ return {
52
+ score: t,
53
+ scoreLabel: nt[t] ?? "",
54
+ category: a.category,
55
+ categoryLabel: at[a.category],
56
+ content: a.content.trim().slice(0, 500),
57
+ contact: a.contact.trim().slice(0, 80),
58
+ source: a.source.trim().slice(0, 40),
59
+ page: a.page.slice(0, 200),
60
+ appName: a.appName.slice(0, 80),
61
+ appKey: a.appKey.slice(0, 80),
62
+ merchant: a.merchant.slice(0, 80),
63
+ locale: a.locale.slice(0, 16),
64
+ kind: (((m = a.kind) == null ? void 0 : m.trim()) || "反馈").slice(0, 20),
65
+ quote: (a.quote ?? "").trim().slice(0, 500),
66
+ submittedAt: lt(o),
67
+ userAgent: (typeof navigator > "u" ? "" : navigator.userAgent).slice(0, 300)
68
+ };
69
+ }
70
+ async function Fe(a, o, t = /* @__PURE__ */ new Date()) {
71
+ const m = o.trim();
72
+ if (!Se(m)) throw new se();
73
+ await fetch(m, {
74
+ method: "POST",
75
+ mode: "no-cors",
76
+ headers: { "Content-Type": "text/plain;charset=UTF-8" },
77
+ body: JSON.stringify(it(a, t))
78
+ });
79
+ }
80
+ const ct = {
81
+ entry: "问题反馈",
82
+ title: "问题反馈",
83
+ hint: "说说这次使用的感受,我们会记下来跟进。",
84
+ score: "使用体验",
85
+ scoreRequired: "请选择使用体验",
86
+ scorePoor: "很差",
87
+ scoreFair: "较差",
88
+ scoreOk: "一般",
89
+ scoreGood: "较好",
90
+ scoreGreat: "很好",
91
+ category: "反馈类型",
92
+ categoryExperience: "体验问题",
93
+ categorySuggestion: "功能建议",
94
+ categoryOther: "其他",
95
+ content: "具体描述",
96
+ contentRequired: "请填写具体描述",
97
+ contentPlaceholder: "遇到了什么,或希望怎么改进",
98
+ contact: "联系方式",
99
+ contactPlaceholder: "选填,方便我们回复",
100
+ context: "会一并记录当前页面、应用和企业,方便定位。",
101
+ submit: "提交",
102
+ submitted: "已提交,感谢反馈",
103
+ submitFailed: "提交失败,请稍后再试",
104
+ channelMissing: "反馈通道还没配置,暂时无法提交",
105
+ close: "关闭反馈",
106
+ cancel: "取消"
107
+ }, st = {
108
+ entry: "Feedback",
109
+ title: "Feedback",
110
+ hint: "Tell us how this visit felt. We will record it and follow up.",
111
+ score: "Experience",
112
+ scoreRequired: "Choose an experience score",
113
+ scorePoor: "Poor",
114
+ scoreFair: "Fair",
115
+ scoreOk: "Okay",
116
+ scoreGood: "Good",
117
+ scoreGreat: "Great",
118
+ category: "Type",
119
+ categoryExperience: "Experience issue",
120
+ categorySuggestion: "Suggestion",
121
+ categoryOther: "Other",
122
+ content: "Details",
123
+ contentRequired: "Describe the feedback",
124
+ contentPlaceholder: "What happened, or what should change",
125
+ contact: "Contact",
126
+ contactPlaceholder: "Optional, so we can reply",
127
+ context: "The current page, app, and enterprise are included to help us locate the issue.",
128
+ submit: "Submit",
129
+ submitted: "Submitted. Thank you.",
130
+ submitFailed: "Submission failed. Please try again.",
131
+ channelMissing: "The feedback channel is not configured yet",
132
+ close: "Close feedback",
133
+ cancel: "Cancel"
134
+ };
135
+ function ut(a, o) {
136
+ return (a.toLowerCase().startsWith("en") ? st : ct)[o];
137
+ }
138
+ const dt = { class: "feedback-head" }, mt = { id: "feedback-title" }, ft = ["aria-label"], pt = { class: "feedback-hint" }, ht = ["aria-label"], gt = ["aria-pressed", "aria-label", "onClick"], vt = { class: "feedback-context" }, yt = { class: "feedback-actions" }, bt = ["aria-label", "aria-expanded"], wt = {
139
+ class: "feedback-mark",
140
+ viewBox: "0 0 24 24",
141
+ width: "28",
142
+ height: "28",
143
+ "aria-hidden": "true"
144
+ }, kt = ["transform"], xt = ["transform"], _t = ["transform"], Q = 56, N = 12, we = "wop-feedback-anchor", Et = 700, Ct = 5, St = 2.05, Mt = 1.55, Ft = /* @__PURE__ */ ke({
145
+ __name: "FeedbackWidget",
146
+ props: {
147
+ webhookUrl: { default: Ce },
148
+ dev: { type: Boolean, default: !1 },
149
+ page: { default: "" },
150
+ locale: { default: "zh-CN" },
151
+ source: { default: "" },
152
+ appName: { default: "" },
153
+ appKey: { default: "" },
154
+ merchant: { default: "" }
155
+ },
156
+ setup(a) {
157
+ const o = a;
158
+ function t(e) {
159
+ return ut(o.locale, e);
160
+ }
161
+ const m = M(() => Me(o.dev, o.webhookUrl)), d = y(!1), F = y(), u = y(R()), x = y(!S()), _ = y(!1), g = j({ x: 0, y: 0, angle: 0 }), z = M(() => `translate(${g.x.toFixed(2)} ${g.y.toFixed(2)})`), b = M(() => `rotate(${g.angle.toFixed(1)} 9.7 12.2)`), oe = M(() => `rotate(${g.angle.toFixed(1)} 14.7 12.2)`);
162
+ let w = 0, q = 0, B = !1, $ = !1, L = 0, r = null, c = !1, k = 0;
163
+ function S() {
164
+ return typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
165
+ }
166
+ function T(e, n) {
167
+ const l = Math.max(N, window.innerWidth - Q - N), D = Math.max(N, window.innerHeight - Q - N);
168
+ return {
169
+ x: Math.min(Math.max(N, e), l),
170
+ y: Math.min(Math.max(N, n), D)
171
+ };
172
+ }
173
+ function R() {
174
+ try {
175
+ const e = localStorage.getItem(we);
176
+ if (!e) return null;
177
+ const n = JSON.parse(e);
178
+ return typeof n.x != "number" || typeof n.y != "number" ? null : T(n.x, n.y);
179
+ } catch {
180
+ return null;
181
+ }
182
+ }
183
+ function V(e) {
184
+ try {
185
+ localStorage.setItem(we, JSON.stringify(e));
186
+ } catch {
187
+ }
188
+ }
189
+ const W = M(
190
+ () => u.value ? { left: `${u.value.x}px`, top: `${u.value.y}px` } : void 0
191
+ );
192
+ function A() {
193
+ return u.value ? u.value : {
194
+ x: window.innerWidth - Q - 24,
195
+ y: window.innerHeight - Q - 24
196
+ };
197
+ }
198
+ const O = M(() => A().x < window.innerWidth * 0.45), Pe = M(() => A().y < 280);
199
+ function ue() {
200
+ if (window.clearTimeout(k), S()) {
201
+ x.value = !1;
202
+ return;
203
+ }
204
+ x.value = !1, k = window.setTimeout(() => {
205
+ r || (x.value = !0);
206
+ }, Et);
207
+ }
208
+ function Te(e) {
209
+ w = e.clientX, q = e.clientY, B = !0;
210
+ }
211
+ function Re(e) {
212
+ const n = Math.sin(e / 900) * 0.12, l = Math.cos(e / 1100) * 0.08, D = Math.sin(e / 800) * 4, ve = F.value;
213
+ if (!ve || !B)
214
+ return {
215
+ x: Math.sin(e / 1400) * 0.35,
216
+ y: Math.cos(e / 1600) * 0.2,
217
+ angle: Math.sin(e / 1300) * 12
218
+ };
219
+ const Y = ve.getBoundingClientRect(), re = w - (Y.left + Y.width / 2), le = q - (Y.top + Y.height / 2), X = Math.hypot(re, le);
220
+ if (X < 8) return { x: n, y: l, angle: D };
221
+ const ye = Math.min(X / 240, 1), Ve = Math.atan2(le, re) * 180 / Math.PI;
222
+ return {
223
+ x: re / X * St * ye + n,
224
+ y: le / X * Mt * ye + l,
225
+ angle: Ve + D
226
+ };
227
+ }
228
+ function de(e) {
229
+ if (L = 0, !!$) {
230
+ if (!document.hidden) {
231
+ const n = Re(e);
232
+ g.x += (n.x - g.x) * 0.14, g.y += (n.y - g.y) * 0.14;
233
+ let l = n.angle - g.angle;
234
+ l = ((l + 180) % 360 + 360) % 360 - 180, g.angle += l * 0.14;
235
+ }
236
+ L = requestAnimationFrame(de);
237
+ }
238
+ }
239
+ function Ae() {
240
+ $ || S() || ($ = !0, L = requestAnimationFrame(de));
241
+ }
242
+ function Oe() {
243
+ $ = !1, L && cancelAnimationFrame(L), L = 0;
244
+ }
245
+ function me(e) {
246
+ Te(e), !r && ue();
247
+ }
248
+ function fe() {
249
+ u.value && (u.value = T(u.value.x, u.value.y));
250
+ }
251
+ function pe() {
252
+ window.removeEventListener("pointermove", he), window.removeEventListener("pointerup", G), window.removeEventListener("pointercancel", G);
253
+ }
254
+ function Ie(e) {
255
+ var l;
256
+ if (e.button !== 0 || !K.value) return;
257
+ const n = K.value.getBoundingClientRect();
258
+ r = {
259
+ pointerId: e.pointerId,
260
+ x: e.clientX,
261
+ y: e.clientY,
262
+ left: n.left,
263
+ top: n.top,
264
+ moved: !1
265
+ }, x.value = !1, window.addEventListener("pointermove", he), window.addEventListener("pointerup", G), window.addEventListener("pointercancel", G);
266
+ try {
267
+ (l = F.value) == null || l.setPointerCapture(e.pointerId);
268
+ } catch {
269
+ }
270
+ }
271
+ function he(e) {
272
+ if (!r || e.pointerId !== r.pointerId) return;
273
+ const n = e.clientX - r.x, l = e.clientY - r.y;
274
+ !r.moved && Math.hypot(n, l) < Ct || (r.moved = !0, _.value = !0, u.value = T(r.left + n, r.top + l));
275
+ }
276
+ function G(e) {
277
+ if (!r || e.pointerId !== r.pointerId) return;
278
+ const n = r.moved;
279
+ r = null, _.value = !1, pe(), n && u.value && (c = !0, V(u.value)), ue();
280
+ }
281
+ function $e() {
282
+ if (c) {
283
+ c = !1;
284
+ return;
285
+ }
286
+ d.value = !d.value;
287
+ }
288
+ function Ne() {
289
+ window.addEventListener("pointermove", me, { passive: !0 }), window.addEventListener("resize", fe), Ae();
290
+ }
291
+ function ge() {
292
+ window.removeEventListener("pointermove", me), window.removeEventListener("resize", fe), pe(), window.clearTimeout(k), Oe();
293
+ }
294
+ U(m, (e) => e ? Ne() : ge(), { immediate: !0 });
295
+ const H = y(!1), K = y(), i = j({
296
+ score: 0,
297
+ category: "experience",
298
+ content: "",
299
+ contact: ""
300
+ }), E = j({ score: "", content: "" }), qe = M(() => [
301
+ { value: 1, label: t("scorePoor") },
302
+ { value: 2, label: t("scoreFair") },
303
+ { value: 3, label: t("scoreOk") },
304
+ { value: 4, label: t("scoreGood") },
305
+ { value: 5, label: t("scoreGreat") }
306
+ ]);
307
+ function Be() {
308
+ i.score = 0, i.category = "experience", i.content = "", i.contact = "", E.score = "", E.content = "";
309
+ }
310
+ function ne(e) {
311
+ var l;
312
+ const n = e.target;
313
+ !(n instanceof Node) || (l = K.value) != null && l.contains(n) || (d.value = !1);
314
+ }
315
+ function ae(e) {
316
+ e.key === "Escape" && (d.value = !1);
317
+ }
318
+ U(d, (e) => {
319
+ if (e) {
320
+ document.addEventListener("pointerdown", ne), document.addEventListener("keydown", ae);
321
+ return;
322
+ }
323
+ document.removeEventListener("pointerdown", ne), document.removeEventListener("keydown", ae);
324
+ }), U(
325
+ () => i.score,
326
+ (e) => {
327
+ e >= 1 && (E.score = "");
328
+ }
329
+ ), U(
330
+ () => i.content,
331
+ (e) => {
332
+ e.trim() && (E.content = "");
333
+ }
334
+ ), We(() => {
335
+ ge(), document.removeEventListener("pointerdown", ne), document.removeEventListener("keydown", ae);
336
+ });
337
+ function De() {
338
+ return o.page ? o.page : typeof window > "u" ? "" : window.location.pathname;
339
+ }
340
+ function Ue() {
341
+ return E.score = i.score >= 1 && i.score <= 5 ? "" : t("scoreRequired"), E.content = i.content.trim() ? "" : t("contentRequired"), !E.score && !E.content;
342
+ }
343
+ async function ze() {
344
+ if (!(H.value || !Ue())) {
345
+ H.value = !0;
346
+ try {
347
+ await Fe(
348
+ {
349
+ score: i.score,
350
+ category: i.category,
351
+ content: i.content,
352
+ contact: i.contact,
353
+ page: De(),
354
+ source: o.source,
355
+ appName: o.appName,
356
+ appKey: o.appKey,
357
+ merchant: o.merchant,
358
+ locale: o.locale,
359
+ kind: "反馈"
360
+ },
361
+ o.webhookUrl
362
+ ), ce.success(t("submitted")), d.value = !1, Be();
363
+ } catch (e) {
364
+ const n = e instanceof se ? t("channelMissing") : t("submitFailed");
365
+ ce.error(n);
366
+ } finally {
367
+ H.value = !1;
368
+ }
369
+ }
370
+ }
371
+ return (e, n) => (C(), xe(_e, { to: "body" }, [
372
+ m.value ? (C(), P("div", {
373
+ key: 0,
374
+ ref_key: "root",
375
+ ref: K,
376
+ class: Z(["feedback", { "is-placed": u.value, "is-dragging": _.value }]),
377
+ style: Ee(W.value)
378
+ }, [
379
+ d.value ? (C(), P("section", {
380
+ key: 0,
381
+ class: Z(["feedback-panel", { "is-on-right": O.value, "is-below": Pe.value }]),
382
+ role: "dialog",
383
+ "aria-labelledby": "feedback-title"
384
+ }, [
385
+ s("header", dt, [
386
+ s("h2", mt, v(t("title")), 1),
387
+ s("button", {
388
+ type: "button",
389
+ class: "feedback-close",
390
+ "aria-label": t("close"),
391
+ onClick: n[0] || (n[0] = (l) => d.value = !1)
392
+ }, " × ", 8, ft)
393
+ ]),
394
+ s("p", pt, v(t("hint")), 1),
395
+ f(p(je), {
396
+ "label-position": "top",
397
+ "require-asterisk-position": "right",
398
+ onSubmit: Ge(ze, ["prevent"])
399
+ }, {
400
+ default: h(() => [
401
+ f(p(J), {
402
+ label: t("score"),
403
+ error: E.score,
404
+ required: ""
405
+ }, {
406
+ default: h(() => [
407
+ s("div", {
408
+ class: "feedback-scores",
409
+ role: "group",
410
+ "aria-label": t("score")
411
+ }, [
412
+ (C(!0), P(He, null, Ke(qe.value, (l) => (C(), P("button", {
413
+ key: l.value,
414
+ type: "button",
415
+ class: Z(["feedback-score", { "is-active": i.score === l.value }]),
416
+ "aria-pressed": i.score === l.value,
417
+ "aria-label": l.label,
418
+ onClick: (D) => i.score = l.value
419
+ }, v(l.label), 11, gt))), 128))
420
+ ], 8, ht)
421
+ ]),
422
+ _: 1
423
+ }, 8, ["label", "error"]),
424
+ f(p(J), {
425
+ label: t("category")
426
+ }, {
427
+ default: h(() => [
428
+ f(p(et), {
429
+ modelValue: i.category,
430
+ "onUpdate:modelValue": n[1] || (n[1] = (l) => i.category = l)
431
+ }, {
432
+ default: h(() => [
433
+ f(p(ie), { value: "experience" }, {
434
+ default: h(() => [
435
+ I(v(t("categoryExperience")), 1)
436
+ ]),
437
+ _: 1
438
+ }),
439
+ f(p(ie), { value: "suggestion" }, {
440
+ default: h(() => [
441
+ I(v(t("categorySuggestion")), 1)
442
+ ]),
443
+ _: 1
444
+ }),
445
+ f(p(ie), { value: "other" }, {
446
+ default: h(() => [
447
+ I(v(t("categoryOther")), 1)
448
+ ]),
449
+ _: 1
450
+ })
451
+ ]),
452
+ _: 1
453
+ }, 8, ["modelValue"])
454
+ ]),
455
+ _: 1
456
+ }, 8, ["label"]),
457
+ f(p(J), {
458
+ label: t("content"),
459
+ error: E.content,
460
+ required: ""
461
+ }, {
462
+ default: h(() => [
463
+ f(p(be), {
464
+ modelValue: i.content,
465
+ "onUpdate:modelValue": n[2] || (n[2] = (l) => i.content = l),
466
+ type: "textarea",
467
+ rows: 4,
468
+ maxlength: "500",
469
+ "show-word-limit": "",
470
+ placeholder: t("contentPlaceholder")
471
+ }, null, 8, ["modelValue", "placeholder"])
472
+ ]),
473
+ _: 1
474
+ }, 8, ["label", "error"]),
475
+ f(p(J), {
476
+ label: t("contact")
477
+ }, {
478
+ default: h(() => [
479
+ f(p(be), {
480
+ modelValue: i.contact,
481
+ "onUpdate:modelValue": n[3] || (n[3] = (l) => i.contact = l),
482
+ maxlength: "80",
483
+ placeholder: t("contactPlaceholder")
484
+ }, null, 8, ["modelValue", "placeholder"])
485
+ ]),
486
+ _: 1
487
+ }, 8, ["label"]),
488
+ s("p", vt, v(t("context")), 1),
489
+ s("div", yt, [
490
+ f(p(te), {
491
+ onClick: n[4] || (n[4] = (l) => d.value = !1)
492
+ }, {
493
+ default: h(() => [
494
+ I(v(t("cancel")), 1)
495
+ ]),
496
+ _: 1
497
+ }),
498
+ f(p(te), {
499
+ type: "primary",
500
+ "native-type": "submit",
501
+ loading: H.value
502
+ }, {
503
+ default: h(() => [
504
+ I(v(t("submit")), 1)
505
+ ]),
506
+ _: 1
507
+ }, 8, ["loading"])
508
+ ])
509
+ ]),
510
+ _: 1
511
+ })
512
+ ], 2)) : ee("", !0),
513
+ f(p(tt), {
514
+ content: t("entry"),
515
+ placement: O.value ? "right" : "left",
516
+ disabled: d.value || _.value
517
+ }, {
518
+ default: h(() => [
519
+ s("button", {
520
+ ref_key: "entryRef",
521
+ ref: F,
522
+ type: "button",
523
+ class: "feedback-entry",
524
+ "aria-label": t("entry"),
525
+ "aria-expanded": d.value,
526
+ onPointerdown: Ie,
527
+ onClick: $e
528
+ }, [
529
+ (C(), P("svg", wt, [
530
+ s("g", {
531
+ class: Z(["feedback-frame", { "is-hopping": x.value }])
532
+ }, [
533
+ n[5] || (n[5] = s("rect", {
534
+ x: "2.5",
535
+ y: "5",
536
+ width: "19",
537
+ height: "14",
538
+ rx: "2.2",
539
+ fill: "none",
540
+ stroke: "currentColor",
541
+ "stroke-width": "1.7"
542
+ }, null, -1)),
543
+ s("g", { transform: z.value }, [
544
+ s("path", {
545
+ fill: "currentColor",
546
+ transform: b.value,
547
+ d: "M8.1 12.2 9.7 10.6 11.3 12.2 9.7 13.8Z"
548
+ }, null, 8, xt),
549
+ s("path", {
550
+ fill: "currentColor",
551
+ transform: oe.value,
552
+ d: "M13.1 12.2 14.7 10.6 16.3 12.2 14.7 13.8Z"
553
+ }, null, 8, _t)
554
+ ], 8, kt)
555
+ ], 2)
556
+ ]))
557
+ ], 40, bt)
558
+ ]),
559
+ _: 1
560
+ }, 8, ["content", "placement", "disabled"])
561
+ ], 6)) : ee("", !0)
562
+ ]));
563
+ }
564
+ }), Le = (a, o) => {
565
+ const t = a.__vccOpts || a;
566
+ for (const [m, d] of o)
567
+ t[m] = d;
568
+ return t;
569
+ }, Jt = /* @__PURE__ */ Le(Ft, [["__scopeId", "data-v-a47df69b"]]), Lt = {
570
+ commentButton: "评论",
571
+ commentTitle: "划线评论",
572
+ commentQuote: "划线内容",
573
+ commentContent: "评论",
574
+ commentPlaceholder: "写下对这段内容的评论",
575
+ commentRequired: "请填写评论",
576
+ submit: "提交",
577
+ submitted: "已提交,感谢反馈",
578
+ submitFailed: "提交失败,请稍后再试",
579
+ channelMissing: "反馈通道还没配置,暂时无法提交",
580
+ cancel: "取消"
581
+ }, Pt = {
582
+ commentButton: "Comment",
583
+ commentTitle: "Inline comment",
584
+ commentQuote: "Selected text",
585
+ commentContent: "Comment",
586
+ commentPlaceholder: "Write a comment on this passage",
587
+ commentRequired: "Enter a comment",
588
+ submit: "Submit",
589
+ submitted: "Submitted. Thank you.",
590
+ submitFailed: "Submission failed. Please try again.",
591
+ channelMissing: "The feedback channel is not configured yet",
592
+ cancel: "Cancel"
593
+ };
594
+ function Tt(a, o) {
595
+ return (a.toLowerCase().startsWith("en") ? Pt : Lt)[o];
596
+ }
597
+ const Rt = ["aria-label"], At = { class: "selection-comment-label" }, Ot = { class: "selection-comment-quote" }, It = { class: "selection-comment-field" }, $t = { class: "selection-comment-label" }, Nt = ["placeholder"], qt = {
598
+ key: 0,
599
+ class: "selection-comment-error"
600
+ }, Bt = /* @__PURE__ */ ke({
601
+ __name: "SelectionComment",
602
+ props: {
603
+ webhookUrl: { default: Ce },
604
+ dev: { type: Boolean, default: !1 },
605
+ page: { default: "" },
606
+ locale: { default: "zh-CN" },
607
+ source: { default: "" },
608
+ appName: { default: "" },
609
+ appKey: { default: "" },
610
+ merchant: { default: "" }
611
+ },
612
+ setup(a) {
613
+ const o = a, t = y(), m = y(!1), d = j({ top: 8, left: 8 }), F = y(""), u = y(!1), x = y(""), _ = y(""), g = y(!1), z = M(() => Me(o.dev, o.webhookUrl));
614
+ function b(r) {
615
+ return Tt(o.locale, r);
616
+ }
617
+ function oe() {
618
+ return o.page ? o.page : typeof window > "u" ? "" : window.location.pathname;
619
+ }
620
+ function w() {
621
+ m.value = !1;
622
+ }
623
+ function q() {
624
+ if (!z.value || u.value) {
625
+ w();
626
+ return;
627
+ }
628
+ const r = t.value, c = window.getSelection();
629
+ if (!r || !c || c.rangeCount === 0 || c.isCollapsed) {
630
+ w();
631
+ return;
632
+ }
633
+ const k = c.toString().replace(/\s+/g, " ").trim(), S = c.anchorNode, T = S instanceof Element ? S : S == null ? void 0 : S.parentElement;
634
+ if (!k || !T || !r.contains(T)) {
635
+ w();
636
+ return;
637
+ }
638
+ if (T.closest("input, textarea, .selection-comment-trigger, .selection-comment-dialog")) {
639
+ w();
640
+ return;
641
+ }
642
+ const R = c.getRangeAt(0).getBoundingClientRect(), V = 36, W = window.innerWidth || 0;
643
+ let A = R.top - 44, O = R.right - V;
644
+ !R.width && !R.height ? (A = 8, O = 8) : A < 8 && (A = R.bottom + 8), W > 0 && (O = Math.min(Math.max(8, O), W - V - 8)), d.top = A, d.left = O, F.value = k.slice(0, 500), m.value = !0;
645
+ }
646
+ function B(r) {
647
+ r.preventDefault();
648
+ }
649
+ function $() {
650
+ var r;
651
+ F.value && (x.value = "", _.value = "", u.value = !0, w(), (r = window.getSelection()) == null || r.removeAllRanges());
652
+ }
653
+ async function L() {
654
+ const r = x.value.trim();
655
+ if (!r) {
656
+ _.value = b("commentRequired");
657
+ return;
658
+ }
659
+ if (!g.value) {
660
+ g.value = !0;
661
+ try {
662
+ await Fe(
663
+ {
664
+ score: 0,
665
+ category: "other",
666
+ content: r,
667
+ contact: "",
668
+ source: o.source,
669
+ page: oe(),
670
+ appName: o.appName,
671
+ appKey: o.appKey,
672
+ merchant: o.merchant,
673
+ locale: o.locale,
674
+ kind: "划线评论",
675
+ quote: F.value
676
+ },
677
+ o.webhookUrl
678
+ ), u.value = !1, ce.success(b("submitted"));
679
+ } catch (c) {
680
+ _.value = c instanceof se ? b("channelMissing") : b("submitFailed");
681
+ } finally {
682
+ g.value = !1;
683
+ }
684
+ }
685
+ }
686
+ return U(z, (r) => {
687
+ r || w();
688
+ }), Ye(() => {
689
+ document.addEventListener("selectionchange", q), window.addEventListener("scroll", w, !0), window.addEventListener("resize", w);
690
+ }), Xe(() => {
691
+ document.removeEventListener("selectionchange", q), window.removeEventListener("scroll", w, !0), window.removeEventListener("resize", w);
692
+ }), (r, c) => (C(), P("div", {
693
+ ref_key: "root",
694
+ ref: t,
695
+ class: "selection-comment"
696
+ }, [
697
+ Ze(r.$slots, "default", {}, void 0, !0),
698
+ (C(), xe(_e, { to: "body" }, [
699
+ m.value ? (C(), P("button", {
700
+ key: 0,
701
+ type: "button",
702
+ class: "selection-comment-trigger",
703
+ style: Ee({ top: `${d.top}px`, left: `${d.left}px` }),
704
+ "aria-label": b("commentButton"),
705
+ onPointerdown: B,
706
+ onMousedown: B,
707
+ onClick: $
708
+ }, [...c[3] || (c[3] = [
709
+ s("svg", {
710
+ viewBox: "0 0 24 24",
711
+ "aria-hidden": "true"
712
+ }, [
713
+ s("path", {
714
+ d: "M5 5.5h14a1.5 1.5 0 0 1 1.5 1.5v8A1.5 1.5 0 0 1 19 16.5H9.2L5 20v-3.5A1.5 1.5 0 0 1 3.5 15V7A1.5 1.5 0 0 1 5 5.5Z",
715
+ fill: "none",
716
+ stroke: "currentColor",
717
+ "stroke-width": "1.6",
718
+ "stroke-linejoin": "round"
719
+ }),
720
+ s("path", {
721
+ d: "M8 9.5h8M8 12.5h5",
722
+ fill: "none",
723
+ stroke: "currentColor",
724
+ "stroke-width": "1.6",
725
+ "stroke-linecap": "round"
726
+ })
727
+ ], -1)
728
+ ])], 44, Rt)) : ee("", !0)
729
+ ])),
730
+ f(p(ot), {
731
+ modelValue: u.value,
732
+ "onUpdate:modelValue": c[2] || (c[2] = (k) => u.value = k),
733
+ class: "selection-comment-dialog",
734
+ title: b("commentTitle"),
735
+ width: "480px",
736
+ "append-to-body": ""
737
+ }, {
738
+ footer: h(() => [
739
+ f(p(te), {
740
+ onClick: c[1] || (c[1] = (k) => u.value = !1)
741
+ }, {
742
+ default: h(() => [
743
+ I(v(b("cancel")), 1)
744
+ ]),
745
+ _: 1
746
+ }),
747
+ f(p(te), {
748
+ type: "primary",
749
+ loading: g.value,
750
+ onClick: L
751
+ }, {
752
+ default: h(() => [
753
+ I(v(b("submit")), 1)
754
+ ]),
755
+ _: 1
756
+ }, 8, ["loading"])
757
+ ]),
758
+ default: h(() => [
759
+ s("p", At, v(b("commentQuote")), 1),
760
+ s("blockquote", Ot, v(F.value), 1),
761
+ s("label", It, [
762
+ s("span", $t, v(b("commentContent")), 1),
763
+ Je(s("textarea", {
764
+ "onUpdate:modelValue": c[0] || (c[0] = (k) => x.value = k),
765
+ maxlength: "500",
766
+ rows: "4",
767
+ placeholder: b("commentPlaceholder")
768
+ }, null, 8, Nt), [
769
+ [Qe, x.value]
770
+ ])
771
+ ]),
772
+ _.value ? (C(), P("p", qt, v(_.value), 1)) : ee("", !0)
773
+ ]),
774
+ _: 1
775
+ }, 8, ["modelValue", "title"])
776
+ ], 512));
777
+ }
778
+ }), Qt = /* @__PURE__ */ Le(Bt, [["__scopeId", "data-v-1bf1af9c"]]);
779
+ export {
780
+ Ce as DEFAULT_FEEDBACK_WEBHOOK,
781
+ se as FeedbackChannelError,
782
+ Jt as FeedbackWidget,
783
+ Qt as SelectionComment,
784
+ it as buildFeedbackPayload,
785
+ lt as formatFeedbackTime,
786
+ Se as isFeishuWebhook,
787
+ Fe as postFeedback,
788
+ Me as showFeedbackEntry
789
+ };
package/dist/style.css ADDED
@@ -0,0 +1 @@
1
+ .feedback[data-v-a47df69b]{--el-color-primary: #165dff;--el-color-primary-dark-2: #0e42d2;--el-color-primary-light-3: #4080ff;--el-color-primary-light-5: #94bfff;--el-color-primary-light-7: #c9ddff;--el-color-primary-light-8: #d9e5ff;--el-color-primary-light-9: #e8f3ff;position:fixed;right:24px;bottom:24px;z-index:30;width:56px}.feedback.is-placed[data-v-a47df69b]{right:auto;bottom:auto}.feedback-panel[data-v-a47df69b]{position:absolute;right:0;bottom:72px;display:flex;flex-direction:column;box-sizing:border-box;width:min(360px,calc(100vw - 32px));max-height:min(640px,calc(100vh - 112px));padding:20px;overflow:auto;background:#fff;border:1px solid #e5e6eb;border-radius:12px;box-shadow:0 4px 12px #0d253d1a}.feedback-panel.is-on-right[data-v-a47df69b]{right:auto;left:0}.feedback-panel.is-below[data-v-a47df69b]{top:72px;bottom:auto}.feedback-head[data-v-a47df69b]{display:flex;align-items:center;justify-content:space-between}.feedback-head h2[data-v-a47df69b]{margin:0;color:#1d2129;font-weight:600;font-size:16px;line-height:24px}.feedback-close[data-v-a47df69b]{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;color:#86909c;font-size:20px;line-height:1;background:transparent;border:0;border-radius:4px;cursor:pointer}.feedback-close[data-v-a47df69b]:hover{color:#1d2129;background:#1d21290f}.feedback-hint[data-v-a47df69b],.feedback-context[data-v-a47df69b]{margin:0;color:#86909c;font-size:12px;line-height:20px}.feedback-hint[data-v-a47df69b]{margin:4px 0 16px}.feedback-scores[data-v-a47df69b]{display:flex;gap:8px;width:100%}.feedback-score[data-v-a47df69b]{flex:1;height:36px;padding:0 4px;color:var(--el-text-color-regular, #606266);font-size:13px;background:var(--el-fill-color-blank, #fff);border:1px solid var(--el-border-color, #dcdfe6);border-radius:6px;cursor:pointer}.feedback-score[data-v-a47df69b]:hover{color:var(--el-text-color-regular, #606266);background:var(--el-fill-color-light, #f5f7fa);border-color:var(--el-border-color-darker, #cdd0d6)}.feedback-score.is-active[data-v-a47df69b],.feedback-score.is-active[data-v-a47df69b]:hover{color:var(--el-color-primary, #165dff);font-weight:600;background:var(--el-fill-color-blank, #fff);border-color:var(--el-color-primary, #165dff)}.feedback-panel[data-v-a47df69b] .el-form-item{margin-bottom:16px}.feedback-panel[data-v-a47df69b] .el-radio{margin-right:16px}.feedback-context[data-v-a47df69b]{margin-bottom:16px}.feedback-actions[data-v-a47df69b]{display:flex;gap:8px;justify-content:flex-end}.feedback-mark[data-v-a47df69b]{display:block;overflow:visible}.feedback-frame[data-v-a47df69b]{transform-box:fill-box;transform-origin:center}.feedback-frame.is-hopping[data-v-a47df69b]{animation:feedback-frame-hop-a47df69b 2.8s cubic-bezier(.37,.08,.2,1) infinite}@keyframes feedback-frame-hop-a47df69b{0%,42%,to{transform:translateY(0)}14%{transform:translateY(-3.2px)}26%{transform:translateY(0)}34%{transform:translateY(-1.2px)}}.feedback-entry[data-v-a47df69b]{display:flex;align-items:center;justify-content:center;width:50px;height:50px;padding:0;color:#fff;background:#3c4043;border:0;border-radius:50%;box-shadow:0 2px 8px #1f23291f;cursor:grab;-webkit-user-select:none;user-select:none;touch-action:none}.feedback.is-dragging .feedback-entry[data-v-a47df69b]{cursor:grabbing}.feedback-entry[data-v-a47df69b]:hover,.feedback-entry[aria-expanded=true][data-v-a47df69b]{background:#2a2d31}.feedback-entry[data-v-a47df69b]:focus-visible,.feedback-close[data-v-a47df69b]:focus-visible,.feedback-score[data-v-a47df69b]:focus-visible{outline:2px solid var(--el-color-primary, #165dff);outline-offset:3px}.selection-comment-trigger[data-v-1bf1af9c]{position:fixed;z-index:3000;display:grid;width:36px;height:36px;padding:0;color:#1f2329;background:#fff;border:1px solid #e5e6eb;border-radius:8px;box-shadow:0 4px 16px #1f23291f;place-items:center;cursor:pointer}.selection-comment-trigger svg[data-v-1bf1af9c]{width:18px;height:18px}.selection-comment-trigger[data-v-1bf1af9c]:hover{color:#165dff;border-color:#165dff}.selection-comment-dialog{--el-color-primary: #165dff;--el-color-primary-dark-2: #0e42d2;--el-color-primary-light-3: #4080ff;--el-color-primary-light-5: #94bfff;--el-color-primary-light-7: #c9ddff;--el-color-primary-light-8: #d9e5ff;--el-color-primary-light-9: #e8f3ff}.selection-comment-label{margin:0 0 8px;color:var(--el-text-color-regular, #606266);font-size:14px}.selection-comment-quote{margin:0 0 16px;padding:8px 12px;color:#1f2329;font-size:14px;line-height:1.6;background:#f7f8fa;border-left:3px solid #165dff}.selection-comment-field{display:block}.selection-comment-field textarea{box-sizing:border-box;width:100%;padding:8px 12px;color:#1f2329;font:inherit;border:1px solid #dcdfe6;border-radius:4px;resize:vertical}.selection-comment-field textarea:focus{border-color:#165dff;outline:none}.selection-comment-error{margin:8px 0 0;color:var(--el-color-danger, #f53f3f);font-size:13px}
package/package.json CHANGED
@@ -1,6 +1,53 @@
1
1
  {
2
2
  "name": "@wanlianyida/portal-kit",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "开放平台共享组件,包含问题反馈和划线评论。",
5
+ "type": "module",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "main": "./dist/index.js",
10
+ "module": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js"
16
+ },
17
+ "./style.css": "./dist/style.css"
18
+ },
19
+ "sideEffects": [
20
+ "dist/index.js",
21
+ "dist/style.css"
22
+ ],
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "scripts": {
27
+ "dev": "vite",
28
+ "build": "vue-tsc --noEmit && vite build",
29
+ "test": "vitest run",
30
+ "prepublishOnly": "npm run test && npm run build"
31
+ },
32
+ "peerDependencies": {
33
+ "element-plus": "^2.14.0",
34
+ "vue": "^3.5.0"
35
+ },
36
+ "devDependencies": {
37
+ "@vitejs/plugin-vue": "^5.2.3",
38
+ "@vue/test-utils": "^2.5.1",
39
+ "element-plus": "^2.14.1",
40
+ "happy-dom": "^21.0.4",
41
+ "typescript": "5.6.3",
42
+ "vite": "^6.2.3",
43
+ "vite-plugin-dts": "^4.5.4",
44
+ "vitest": "^5.0.0",
45
+ "vue": "^3.5.13",
46
+ "vue-tsc": "^2.2.8"
47
+ },
48
+ "packageManager": "pnpm@10.28.1",
49
+ "engines": {
50
+ "node": ">=22.12.0",
51
+ "pnpm": ">=9"
52
+ }
53
+ }