@veltra/desktop 1.10.0 → 1.12.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/dist/components/ai-button/ai-button.js +117 -0
- package/dist/components/ai-button/ai-button.js.map +1 -0
- package/dist/components/ai-button/style.d.ts +1 -0
- package/dist/components/ai-button/style.js +3 -0
- package/dist/components/ai-button/style2.css +29 -0
- package/dist/components/code-editor/basic-setup.js +5 -5
- package/dist/components/code-editor/code-editor.js +2 -2
- package/dist/components/code-editor/langs/bash/index.js +2 -2
- package/dist/components/code-editor/langs/powershell/index.js +2 -2
- package/dist/components/code-editor/langs/spel/index.js +1 -1
- package/dist/components/code-editor/langs/spel/language.js +1 -1
- package/dist/components/code-editor/shell-extension.js +2 -2
- package/dist/components/file-viewer/previewers/image-previewer.js +28 -124
- package/dist/components/file-viewer/previewers/image-previewer.js.map +1 -1
- package/dist/components/file-viewer/previewers/pdf-worker-wrapper.js.map +1 -1
- package/dist/components/file-viewer/previewers/sheet-previewer.js +5 -5
- package/dist/components/file-viewer/previewers/sheet-previewer.js.map +1 -1
- package/dist/components/file-viewer/style2.css +42 -203
- package/dist/components/image-previewer/image-previewer.js +286 -0
- package/dist/components/image-previewer/image-previewer.js.map +1 -0
- package/dist/components/image-previewer/style.d.ts +1 -0
- package/dist/components/image-previewer/style.js +2 -0
- package/dist/components/image-previewer/style2.css +174 -0
- package/dist/components/index.d.ts +21 -19
- package/dist/components/index.js +41 -37
- package/dist/components/index.js.map +1 -1
- package/dist/index.d.ts +110 -106
- package/dist/index.js +108 -106
- package/dist/node_modules/.bun/@codemirror_autocomplete@6.20.3/node_modules/@codemirror/autocomplete/dist/index.js +3 -3
- package/dist/node_modules/.bun/@codemirror_autocomplete@6.20.3/node_modules/@codemirror/autocomplete/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/{@codemirror_commands@6.11.0 → @codemirror_commands@6.11.1}/node_modules/@codemirror/commands/dist/index.js +6 -6
- package/dist/node_modules/.bun/@codemirror_commands@6.11.1/node_modules/@codemirror/commands/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@codemirror_lang-css@6.3.1/node_modules/@codemirror/lang-css/dist/index.js +1 -1
- package/dist/node_modules/.bun/@codemirror_lang-css@6.3.1/node_modules/@codemirror/lang-css/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@codemirror_lang-html@6.4.12/node_modules/@codemirror/lang-html/dist/index.js +3 -3
- package/dist/node_modules/.bun/@codemirror_lang-html@6.4.12/node_modules/@codemirror/lang-html/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@codemirror_lang-java@6.0.2/node_modules/@codemirror/lang-java/dist/index.js +1 -1
- package/dist/node_modules/.bun/@codemirror_lang-java@6.0.2/node_modules/@codemirror/lang-java/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@codemirror_lang-javascript@6.2.5/node_modules/@codemirror/lang-javascript/dist/index.js +3 -3
- package/dist/node_modules/.bun/@codemirror_lang-javascript@6.2.5/node_modules/@codemirror/lang-javascript/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@codemirror_lang-json@6.0.2/node_modules/@codemirror/lang-json/dist/index.js +1 -1
- package/dist/node_modules/.bun/@codemirror_lang-json@6.0.2/node_modules/@codemirror/lang-json/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@codemirror_lang-markdown@6.5.2/node_modules/@codemirror/lang-markdown/dist/index.js +3 -3
- package/dist/node_modules/.bun/@codemirror_lang-markdown@6.5.2/node_modules/@codemirror/lang-markdown/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@codemirror_lang-sql@6.10.0/node_modules/@codemirror/lang-sql/dist/index.js +1 -1
- package/dist/node_modules/.bun/@codemirror_lang-sql@6.10.0/node_modules/@codemirror/lang-sql/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/{@codemirror_language@6.12.4 → @codemirror_language@6.13.1}/node_modules/@codemirror/language/dist/index.js +5 -168
- package/dist/node_modules/.bun/@codemirror_language@6.13.1/node_modules/@codemirror/language/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/{@codemirror_legacy-modes@6.5.4 → @codemirror_legacy-modes@6.5.5}/node_modules/@codemirror/legacy-modes/mode/powershell.js +1 -1
- package/dist/node_modules/.bun/{@codemirror_legacy-modes@6.5.4 → @codemirror_legacy-modes@6.5.5}/node_modules/@codemirror/legacy-modes/mode/powershell.js.map +1 -1
- package/dist/node_modules/.bun/{@codemirror_legacy-modes@6.5.4 → @codemirror_legacy-modes@6.5.5}/node_modules/@codemirror/legacy-modes/mode/shell.js +1 -1
- package/dist/node_modules/.bun/{@codemirror_legacy-modes@6.5.4 → @codemirror_legacy-modes@6.5.5}/node_modules/@codemirror/legacy-modes/mode/shell.js.map +1 -1
- package/dist/node_modules/.bun/@codemirror_lint@6.9.7/node_modules/@codemirror/lint/dist/index.js +2 -2
- package/dist/node_modules/.bun/@codemirror_lint@6.9.7/node_modules/@codemirror/lint/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/{@codemirror_search@6.7.1 → @codemirror_search@6.7.2}/node_modules/@codemirror/search/dist/index.js +10 -3
- package/dist/node_modules/.bun/@codemirror_search@6.7.2/node_modules/@codemirror/search/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/{@codemirror_state@6.7.1 → @codemirror_state@6.7.6}/node_modules/@codemirror/state/dist/index.js +50 -16
- package/dist/node_modules/.bun/@codemirror_state@6.7.6/node_modules/@codemirror/state/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@codemirror_streamparser@6.0.0/node_modules/@codemirror/streamparser/dist/index.js +169 -0
- package/dist/node_modules/.bun/@codemirror_streamparser@6.0.0/node_modules/@codemirror/streamparser/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@codemirror_theme-one-dark@6.1.3/node_modules/@codemirror/theme-one-dark/dist/index.js +2 -2
- package/dist/node_modules/.bun/@codemirror_theme-one-dark@6.1.3/node_modules/@codemirror/theme-one-dark/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/{@codemirror_view@6.43.9 → @codemirror_view@6.43.14}/node_modules/@codemirror/view/dist/index.js +159 -93
- package/dist/node_modules/.bun/@codemirror_view@6.43.14/node_modules/@codemirror/view/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@lezer_common@1.5.3/node_modules/@lezer/common/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@lezer_css@1.3.9/node_modules/@lezer/css/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@lezer_highlight@1.2.5/node_modules/@lezer/highlight/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@lezer_html@1.3.13/node_modules/@lezer/html/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@lezer_java@1.1.5/node_modules/@lezer/java/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@lezer_javascript@1.5.6/node_modules/@lezer/javascript/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@lezer_json@1.0.3/node_modules/@lezer/json/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@lezer_lr@1.4.11/node_modules/@lezer/lr/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@lezer_markdown@1.8.0/node_modules/@lezer/markdown/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@marijn_find-cluster-break@1.0.4/node_modules/@marijn/find-cluster-break/src/index.js.map +1 -1
- package/dist/node_modules/.bun/crelt@1.0.7/node_modules/crelt/index.js.map +1 -1
- package/dist/node_modules/.bun/style-mod@4.1.4/node_modules/style-mod/src/style-mod.js.map +1 -1
- package/dist/node_modules/.bun/w3c-keyname@2.2.8/node_modules/w3c-keyname/index.js.map +1 -1
- package/dist/types/ai-button.d.ts +42 -0
- package/dist/types/image-previewer.d.ts +48 -0
- package/dist/types/index.d.ts +3 -1
- package/package.json +16 -16
- package/src/components/ai-button/__test__/ai-button.test.ts +375 -0
- package/src/components/ai-button/ai-button.vue +87 -0
- package/src/components/ai-button/index.ts +1 -0
- package/src/components/ai-button/style.scss +19 -0
- package/src/components/ai-button/style.ts +3 -0
- package/src/components/file-viewer/__test__/file-viewer.test.ts +58 -0
- package/src/components/file-viewer/previewers/image-previewer.vue +25 -138
- package/src/components/file-viewer/previewers/sheet-previewer.vue +1 -1
- package/src/components/file-viewer/style.scss +54 -266
- package/src/components/image-previewer/__test__/image-previewer.test.ts +292 -0
- package/src/components/image-previewer/image-previewer.vue +314 -0
- package/src/components/image-previewer/index.ts +1 -0
- package/src/components/image-previewer/style.scss +188 -0
- package/src/components/image-previewer/style.ts +2 -0
- package/src/components/index.ts +4 -0
- package/src/types/ai-button.ts +44 -0
- package/src/types/image-previewer.ts +50 -0
- package/src/types/index.ts +3 -0
- package/dist/node_modules/.bun/@codemirror_commands@6.11.0/node_modules/@codemirror/commands/dist/index.js.map +0 -1
- package/dist/node_modules/.bun/@codemirror_language@6.12.4/node_modules/@codemirror/language/dist/index.js.map +0 -1
- package/dist/node_modules/.bun/@codemirror_search@6.7.1/node_modules/@codemirror/search/dist/index.js.map +0 -1
- package/dist/node_modules/.bun/@codemirror_state@6.7.1/node_modules/@codemirror/state/dist/index.js.map +0 -1
- package/dist/node_modules/.bun/@codemirror_view@6.43.9/node_modules/@codemirror/view/dist/index.js.map +0 -1
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import _sfc_main$1 from "../tip/tip.js";
|
|
2
|
+
import _sfc_main$2 from "../button/button.js";
|
|
3
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, normalizeClass, openBlock, ref, renderSlot, unref, withCtx } from "vue";
|
|
4
|
+
import { useConfig } from "@veltra/compositions";
|
|
5
|
+
import { bem, requestAiText } from "@veltra/utils";
|
|
6
|
+
import { Sparkles } from "@veltra/icons";
|
|
7
|
+
//#region src/components/ai-button/ai-button.vue
|
|
8
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
9
|
+
name: "UAiButton",
|
|
10
|
+
__name: "ai-button",
|
|
11
|
+
props: {
|
|
12
|
+
provider: {},
|
|
13
|
+
systemPrompt: {},
|
|
14
|
+
prompt: {},
|
|
15
|
+
variant: { default: "default" },
|
|
16
|
+
size: {}
|
|
17
|
+
},
|
|
18
|
+
emits: [
|
|
19
|
+
"success",
|
|
20
|
+
"error",
|
|
21
|
+
"delta",
|
|
22
|
+
"confirm",
|
|
23
|
+
"cancel"
|
|
24
|
+
],
|
|
25
|
+
setup(__props, { emit: __emit }) {
|
|
26
|
+
const emit = __emit;
|
|
27
|
+
const cls = bem("ai-button");
|
|
28
|
+
const { config } = useConfig();
|
|
29
|
+
/** 配置优先级:实例 provider 字段 > 全局 ai 字段 > 默认值(stream 缺省 false) */
|
|
30
|
+
const requestConfig = computed(() => ({
|
|
31
|
+
stream: false,
|
|
32
|
+
...config.ai,
|
|
33
|
+
...__props.provider
|
|
34
|
+
}));
|
|
35
|
+
/** 生成中:按钮 loading 转圈并禁用 */
|
|
36
|
+
const loading = ref(false);
|
|
37
|
+
/** 发起请求;生成中忽略重复触发 */
|
|
38
|
+
function send() {
|
|
39
|
+
if (loading.value) return;
|
|
40
|
+
loading.value = true;
|
|
41
|
+
requestAiText({
|
|
42
|
+
config: requestConfig.value,
|
|
43
|
+
prompt: __props.prompt ?? "",
|
|
44
|
+
systemPrompt: __props.systemPrompt,
|
|
45
|
+
onDelta: (chunk) => emit("delta", chunk),
|
|
46
|
+
onSuccess: (text) => emit("success", text),
|
|
47
|
+
onError: (error) => emit("error", error)
|
|
48
|
+
}).finally(() => {
|
|
49
|
+
loading.value = false;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/** pre-input 气泡可见性 */
|
|
53
|
+
const visible = ref(false);
|
|
54
|
+
function confirm() {
|
|
55
|
+
emit("confirm");
|
|
56
|
+
visible.value = false;
|
|
57
|
+
send();
|
|
58
|
+
}
|
|
59
|
+
function cancel() {
|
|
60
|
+
emit("cancel");
|
|
61
|
+
visible.value = false;
|
|
62
|
+
}
|
|
63
|
+
return (_ctx, _cache) => {
|
|
64
|
+
return openBlock(), createElementBlock(Fragment, null, [createCommentVNode(" pre-input 变体:先经气泡收集补充输入,确认后再发请求 "), __props.variant === "pre-input" ? (openBlock(), createBlock(unref(_sfc_main$1), {
|
|
65
|
+
key: 0,
|
|
66
|
+
trigger: "click",
|
|
67
|
+
direction: "bottom",
|
|
68
|
+
visible: visible.value,
|
|
69
|
+
"onUpdate:visible": _cache[0] || (_cache[0] = ($event) => visible.value = $event)
|
|
70
|
+
}, {
|
|
71
|
+
content: withCtx(() => [createElementVNode("div", { class: normalizeClass(unref(cls).e("main")) }, [renderSlot(_ctx.$slots, "pre-input")], 2), createElementVNode("div", { class: normalizeClass(unref(cls).e("action")) }, [createVNode(unref(_sfc_main$2), {
|
|
72
|
+
size: "small",
|
|
73
|
+
type: "primary",
|
|
74
|
+
text: "",
|
|
75
|
+
onClick: cancel
|
|
76
|
+
}, {
|
|
77
|
+
default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode(" 取消 ", -1)])]),
|
|
78
|
+
_: 1
|
|
79
|
+
}), createVNode(unref(_sfc_main$2), {
|
|
80
|
+
size: "small",
|
|
81
|
+
type: "primary",
|
|
82
|
+
onClick: confirm
|
|
83
|
+
}, {
|
|
84
|
+
default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode(" 确认 ", -1)])]),
|
|
85
|
+
_: 1
|
|
86
|
+
})], 2)]),
|
|
87
|
+
default: withCtx(() => [createVNode(unref(_sfc_main$2), {
|
|
88
|
+
class: normalizeClass(unref(cls).b),
|
|
89
|
+
size: __props.size,
|
|
90
|
+
icon: unref(Sparkles),
|
|
91
|
+
loading: loading.value
|
|
92
|
+
}, null, 8, [
|
|
93
|
+
"class",
|
|
94
|
+
"size",
|
|
95
|
+
"icon",
|
|
96
|
+
"loading"
|
|
97
|
+
])]),
|
|
98
|
+
_: 3
|
|
99
|
+
}, 8, ["visible"])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createCommentVNode(" 普通变体:点击即发 "), createVNode(unref(_sfc_main$2), {
|
|
100
|
+
class: normalizeClass(unref(cls).b),
|
|
101
|
+
size: __props.size,
|
|
102
|
+
icon: unref(Sparkles),
|
|
103
|
+
loading: loading.value,
|
|
104
|
+
onClick: send
|
|
105
|
+
}, null, 8, [
|
|
106
|
+
"class",
|
|
107
|
+
"size",
|
|
108
|
+
"icon",
|
|
109
|
+
"loading"
|
|
110
|
+
])], 2112))], 2112);
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
//#endregion
|
|
115
|
+
export { _sfc_main as default };
|
|
116
|
+
|
|
117
|
+
//# sourceMappingURL=ai-button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-button.js","names":["_openBlock","_createElementBlock","_Fragment","_createCommentVNode","_createBlock","_unref","UTip","_withCtx","_createElementVNode","_normalizeClass","_renderSlot","_createVNode","UButton","_createTextVNode"],"sources":["../../../src/components/ai-button/ai-button.vue"],"sourcesContent":["<template>\n <!-- pre-input 变体:先经气泡收集补充输入,确认后再发请求 -->\n <u-tip\n v-if=\"variant === 'pre-input'\"\n trigger=\"click\"\n direction=\"bottom\"\n v-model:visible=\"visible\"\n >\n <u-button :class=\"cls.b\" :size=\"size\" :icon=\"Sparkles\" :loading=\"loading\" />\n\n <template #content>\n <div :class=\"cls.e('main')\">\n <slot name=\"pre-input\" />\n </div>\n <div :class=\"cls.e('action')\">\n <u-button size=\"small\" type=\"primary\" text @click=\"cancel\"> 取消 </u-button>\n <u-button size=\"small\" type=\"primary\" @click=\"confirm\"> 确认 </u-button>\n </div>\n </template>\n </u-tip>\n\n <!-- 普通变体:点击即发 -->\n <u-button v-else :class=\"cls.b\" :size=\"size\" :icon=\"Sparkles\" :loading=\"loading\" @click=\"send\" />\n</template>\n\n<script lang=\"ts\" setup>\nimport { useConfig } from '@veltra/compositions'\nimport { Sparkles } from '@veltra/icons'\nimport { bem, requestAiText } from '@veltra/utils'\nimport type { AiProviderConfig } from '@veltra/utils'\nimport { computed, ref } from 'vue'\n\nimport type { AiButtonEmits, AiButtonProps } from '../../types'\nimport { UButton } from '../button'\nimport { UTip } from '../tip'\n\ndefineOptions({ name: 'UAiButton' })\n\nconst { provider, systemPrompt, prompt, variant = 'default', size } = defineProps<AiButtonProps>()\n\nconst emit = defineEmits<AiButtonEmits>()\n\nconst cls = bem('ai-button')\n\nconst { config } = useConfig()\n\n/** 配置优先级:实例 provider 字段 > 全局 ai 字段 > 默认值(stream 缺省 false) */\nconst requestConfig = computed<AiProviderConfig>(() => ({\n stream: false,\n ...config.ai,\n ...provider\n}))\n\n/** 生成中:按钮 loading 转圈并禁用 */\nconst loading = ref(false)\n\n/** 发起请求;生成中忽略重复触发 */\nfunction send() {\n if (loading.value) return\n loading.value = true\n\n requestAiText({\n config: requestConfig.value,\n prompt: prompt ?? '',\n systemPrompt,\n onDelta: (chunk) => emit('delta', chunk),\n onSuccess: (text) => emit('success', text),\n onError: (error) => emit('error', error)\n }).finally(() => {\n loading.value = false\n })\n}\n\n/** pre-input 气泡可见性 */\nconst visible = ref(false)\n\nfunction confirm() {\n emit('confirm')\n visible.value = false\n send()\n}\n\nfunction cancel() {\n emit('cancel')\n visible.value = false\n}\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;EAwCA,MAAM,OAAO;EAEb,MAAM,MAAM,IAAI,WAAW;EAE3B,MAAM,EAAE,WAAW,UAAU;;EAG7B,MAAM,gBAAgB,gBAAkC;GACtD,QAAQ;GACR,GAAG,OAAO;GACV,GAAG,QAAA;EACL,EAAE;;EAGF,MAAM,UAAU,IAAI,KAAK;;EAGzB,SAAS,OAAO;GACd,IAAI,QAAQ,OAAO;GACnB,QAAQ,QAAQ;GAEhB,cAAc;IACZ,QAAQ,cAAc;IACtB,QAAQ,QAAA,UAAU;IAClB,cAAW,QAAA;IACX,UAAU,UAAU,KAAK,SAAS,KAAK;IACvC,YAAY,SAAS,KAAK,WAAW,IAAI;IACzC,UAAU,UAAU,KAAK,SAAS,KAAK;GACzC,CAAC,CAAC,CAAC,cAAc;IACf,QAAQ,QAAQ;GAClB,CAAC;EACH;;EAGA,MAAM,UAAU,IAAI,KAAK;EAEzB,SAAS,UAAU;GACjB,KAAK,SAAS;GACd,QAAQ,QAAQ;GAChB,KAAK;EACP;EAEA,SAAS,SAAS;GAChB,KAAK,QAAQ;GACb,QAAQ,QAAQ;EAClB;;GApFE,OAAA,UAAA,GAAA,mBAAA,UAAA,MAAA,CAAAG,mBAAA,mCAAA,GAEQ,QAAA,YAAO,eADfH,UAAA,GAAAI,YAiBQC,MAAAC,WAAA,GAAA;;IAfN,SAAQ;IACR,WAAU;IACF,SAAS,QAAA;IAAA,oBAAA,OAAA,OAAA,OAAA,MAAA,WAAA,QAAO,QAAA;;IAIb,SAAOC,cAGV,CAFNC,mBAEM,OAAA,EAFA,OAAKC,eAAEJ,MAAA,GAAA,CAAG,CAAC,EAAC,MAAA,CAAA,EAAA,GAChB,CAAAK,WAAyB,KAAA,QAAA,WAAA,CAAA,GAAA,CAE3B,GAAAF,mBAGM,OAAA,EAHA,OAAKC,eAAEJ,MAAA,GAAA,CAAG,CAAC,EAAC,QAAA,CAAA,EAAA,GAChB,CAAAM,YAA0EN,MAAAO,WAAA,GAAA;KAAhE,MAAK;KAAQ,MAAK;KAAU,MAAA;KAAM,SAAO;;KAAQ,SAAAL,cAAI,CAAA,GAAA,OAAA,OAAA,OAAA,KAAA,CAAJM,gBAAA,QAAI,EAAA,CAAA,EAAA,CAAA;;IAC/D,CAAA,GAAAF,YAAsEN,MAAAO,WAAA,GAAA;KAA5D,MAAK;KAAQ,MAAK;KAAW,SAAO;;KAAS,SAAAL,cAAI,CAAA,GAAA,OAAA,OAAA,OAAA,KAAA,CAAJM,gBAAA,QAAI,EAAA,CAAA,EAAA,CAAA;;;IAR/D,SAAAN,cAA4E,CAA5EI,YAA4EN,MAAAO,WAAA,GAAA;KAAjE,OAAKH,eAAEJ,MAAA,GAAA,CAAG,CAAC,CAAC;KAAG,MAAM,QAAA;KAAO,MAAMA,MAAA,QAAA;KAAW,SAAS,QAAA;;;;;;;;GAcnE,GAAA,GAAA,CAAA,SAAA,CAAA,MAAAL,UAAA,GAAAC,mBAAiGC,UAAA,EAAA,KAAA,EAAA,GAAA,CADjGC,mBAAA,aAAA,GACAQ,YAAiGN,MAAAO,WAAA,GAAA;IAA/E,OAAKH,eAAEJ,MAAA,GAAA,CAAG,CAAC,CAAC;IAAG,MAAM,QAAA;IAAO,MAAMA,MAAA,QAAA;IAAW,SAAS,QAAA;IAAU,SAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../button/style.js";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
@charset "UTF-8";
|
|
2
|
+
/** flex布局 */
|
|
3
|
+
/**
|
|
4
|
+
* 设置css变量
|
|
5
|
+
* 参数1:变量前缀
|
|
6
|
+
* 参数2: 一个由值组成的列表或者由key, value组成的map
|
|
7
|
+
* css-var(height, (
|
|
8
|
+
* large: 40px
|
|
9
|
+
* default: 32px
|
|
10
|
+
* small: 24px
|
|
11
|
+
* ))
|
|
12
|
+
* 生成的css变量:
|
|
13
|
+
* --u-height-large: 40px;
|
|
14
|
+
* --u-height-default: 32px;
|
|
15
|
+
* --u-height-small: 24px;
|
|
16
|
+
*/
|
|
17
|
+
/** 暗色:`UITheme.render()` 按主题系列写入 html[data-theme] */
|
|
18
|
+
.u-ai-button__main {
|
|
19
|
+
max-width: 280px;
|
|
20
|
+
width: max-content;
|
|
21
|
+
}
|
|
22
|
+
.u-ai-button__action {
|
|
23
|
+
margin-top: var(--u-gap-default);
|
|
24
|
+
display: flex;
|
|
25
|
+
justify-content: flex-end;
|
|
26
|
+
align-items: center;
|
|
27
|
+
flex-wrap: nowrap;
|
|
28
|
+
gap: var(--u-gap-small);
|
|
29
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { EditorState } from "../../node_modules/.bun/@codemirror_state@6.7.
|
|
2
|
-
import { crosshairCursor, drawSelection, dropCursor, highlightActiveLine, highlightActiveLineGutter, highlightSpecialChars, keymap, lineNumbers, rectangularSelection } from "../../node_modules/.bun/@codemirror_view@6.43.
|
|
3
|
-
import { bracketMatching, defaultHighlightStyle, foldGutter, foldKeymap, indentOnInput, syntaxHighlighting } from "../../node_modules/.bun/@codemirror_language@6.
|
|
1
|
+
import { EditorState } from "../../node_modules/.bun/@codemirror_state@6.7.6/node_modules/@codemirror/state/dist/index.js";
|
|
2
|
+
import { crosshairCursor, drawSelection, dropCursor, highlightActiveLine, highlightActiveLineGutter, highlightSpecialChars, keymap, lineNumbers, rectangularSelection } from "../../node_modules/.bun/@codemirror_view@6.43.14/node_modules/@codemirror/view/dist/index.js";
|
|
3
|
+
import { bracketMatching, defaultHighlightStyle, foldGutter, foldKeymap, indentOnInput, syntaxHighlighting } from "../../node_modules/.bun/@codemirror_language@6.13.1/node_modules/@codemirror/language/dist/index.js";
|
|
4
4
|
import { autocompletion, closeBrackets, closeBracketsKeymap, completionKeymap } from "../../node_modules/.bun/@codemirror_autocomplete@6.20.3/node_modules/@codemirror/autocomplete/dist/index.js";
|
|
5
|
-
import { defaultKeymap, history, historyKeymap, indentWithTab } from "../../node_modules/.bun/@codemirror_commands@6.11.
|
|
5
|
+
import { defaultKeymap, history, historyKeymap, indentWithTab } from "../../node_modules/.bun/@codemirror_commands@6.11.1/node_modules/@codemirror/commands/dist/index.js";
|
|
6
6
|
import { lintKeymap } from "../../node_modules/.bun/@codemirror_lint@6.9.7/node_modules/@codemirror/lint/dist/index.js";
|
|
7
|
-
import { highlightSelectionMatches, searchKeymap } from "../../node_modules/.bun/@codemirror_search@6.7.
|
|
7
|
+
import { highlightSelectionMatches, searchKeymap } from "../../node_modules/.bun/@codemirror_search@6.7.2/node_modules/@codemirror/search/dist/index.js";
|
|
8
8
|
//#region src/components/code-editor/basic-setup.ts
|
|
9
9
|
/**
|
|
10
10
|
* 等价于 codemirror 包的 basicSetup,按官方建议内联以便统一依赖来源。
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _sfc_main$1 from "../icon/icon.js";
|
|
2
2
|
import _sfc_main$2 from "../scroll/scroll.js";
|
|
3
3
|
import _sfc_main$3 from "../select/select.js";
|
|
4
|
-
import { Compartment, EditorState } from "../../node_modules/.bun/@codemirror_state@6.7.
|
|
5
|
-
import { EditorView, tooltips } from "../../node_modules/.bun/@codemirror_view@6.43.
|
|
4
|
+
import { Compartment, EditorState } from "../../node_modules/.bun/@codemirror_state@6.7.6/node_modules/@codemirror/state/dist/index.js";
|
|
5
|
+
import { EditorView, tooltips } from "../../node_modules/.bun/@codemirror_view@6.43.14/node_modules/@codemirror/view/dist/index.js";
|
|
6
6
|
import { oneDark } from "../../node_modules/.bun/@codemirror_theme-one-dark@6.1.3/node_modules/@codemirror/theme-one-dark/dist/index.js";
|
|
7
7
|
import { basicSetup } from "./basic-setup.js";
|
|
8
8
|
import { loadLanguage } from "./lang-loaders.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LanguageSupport, StreamLanguage } from "../../../../node_modules/.bun/@codemirror_language@6.
|
|
2
|
-
import { shell } from "../../../../node_modules/.bun/@codemirror_legacy-modes@6.5.
|
|
1
|
+
import { LanguageSupport, StreamLanguage } from "../../../../node_modules/.bun/@codemirror_language@6.13.1/node_modules/@codemirror/language/dist/index.js";
|
|
2
|
+
import { shell } from "../../../../node_modules/.bun/@codemirror_legacy-modes@6.5.5/node_modules/@codemirror/legacy-modes/mode/shell.js";
|
|
3
3
|
//#region src/components/code-editor/langs/bash/index.ts
|
|
4
4
|
/** Bash / shell 脚本语言支持(基于 CodeMirror legacy shell mode) */
|
|
5
5
|
function bash() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LanguageSupport, StreamLanguage } from "../../../../node_modules/.bun/@codemirror_language@6.
|
|
2
|
-
import { powerShell } from "../../../../node_modules/.bun/@codemirror_legacy-modes@6.5.
|
|
1
|
+
import { LanguageSupport, StreamLanguage } from "../../../../node_modules/.bun/@codemirror_language@6.13.1/node_modules/@codemirror/language/dist/index.js";
|
|
2
|
+
import { powerShell } from "../../../../node_modules/.bun/@codemirror_legacy-modes@6.5.5/node_modules/@codemirror/legacy-modes/mode/powershell.js";
|
|
3
3
|
//#region src/components/code-editor/langs/powershell/index.ts
|
|
4
4
|
/** PowerShell 语言支持(基于 CodeMirror legacy powershell mode) */
|
|
5
5
|
function powershell() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LanguageSupport } from "../../../../node_modules/.bun/@codemirror_language@6.
|
|
1
|
+
import { LanguageSupport } from "../../../../node_modules/.bun/@codemirror_language@6.13.1/node_modules/@codemirror/language/dist/index.js";
|
|
2
2
|
import { spelCompletion } from "./completion.js";
|
|
3
3
|
import { spelLanguage } from "./language.js";
|
|
4
4
|
//#region src/components/code-editor/langs/spel/index.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StreamLanguage } from "../../../../node_modules/.bun/@codemirror_language@6.
|
|
1
|
+
import { StreamLanguage } from "../../../../node_modules/.bun/@codemirror_language@6.13.1/node_modules/@codemirror/language/dist/index.js";
|
|
2
2
|
//#region src/components/code-editor/langs/spel/language.ts
|
|
3
3
|
const KEYWORDS = /* @__PURE__ */ new Set([
|
|
4
4
|
"new",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EditorSelection, EditorState, RangeSetBuilder, StateField } from "../../node_modules/.bun/@codemirror_state@6.7.
|
|
2
|
-
import { Decoration, EditorView } from "../../node_modules/.bun/@codemirror_view@6.43.
|
|
1
|
+
import { EditorSelection, EditorState, RangeSetBuilder, StateField } from "../../node_modules/.bun/@codemirror_state@6.7.6/node_modules/@codemirror/state/dist/index.js";
|
|
2
|
+
import { Decoration, EditorView } from "../../node_modules/.bun/@codemirror_view@6.43.14/node_modules/@codemirror/view/dist/index.js";
|
|
3
3
|
//#region src/components/code-editor/shell-extension.ts
|
|
4
4
|
/**
|
|
5
5
|
* 判断 Text 文档是否与外壳对齐。
|
|
@@ -1,149 +1,53 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import _sfc_main$1 from "../../image-previewer/image-previewer.js";
|
|
2
|
+
import { createBlock, defineComponent, normalizeClass, openBlock, unref, useTemplateRef } from "vue";
|
|
3
3
|
import { bem } from "@veltra/utils";
|
|
4
4
|
//#region src/components/file-viewer/previewers/image-previewer.vue
|
|
5
|
-
const _hoisted_1 = ["src", "alt"];
|
|
6
5
|
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
7
6
|
name: "UFileViewerImagePreviewer",
|
|
8
|
-
inheritAttrs: false,
|
|
9
7
|
__name: "image-previewer",
|
|
10
8
|
props: { file: {} },
|
|
11
9
|
emits: ["error", "zoom-change"],
|
|
12
10
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
13
|
-
const props = __props;
|
|
14
11
|
const emit = __emit;
|
|
15
12
|
const cls = bem("file-viewer");
|
|
16
|
-
const
|
|
17
|
-
const root = useTemplateRef("root");
|
|
18
|
-
const url = shallowRef("");
|
|
19
|
-
const loading = ref(true);
|
|
20
|
-
const failed = ref(false);
|
|
21
|
-
/** 缩放级别;缩放入口统一经 setScale 收敛到 [ZOOM_MIN, ZOOM_MAX] */
|
|
22
|
-
const scale = ref(1);
|
|
23
|
-
/** 拖拽起止各写一次,仅驱动 grabbing 光标 */
|
|
24
|
-
const isDragging = ref(false);
|
|
25
|
-
let panState;
|
|
26
|
-
let offsetX = 0;
|
|
27
|
-
let offsetY = 0;
|
|
28
|
-
/** transform 唯一写入口:直接写根元素 style,绕开响应式 */
|
|
29
|
-
function applyTransform() {
|
|
30
|
-
const el = root.value;
|
|
31
|
-
if (!el) return;
|
|
32
|
-
el.style.transform = `translate3d(${offsetX}px, ${offsetY}px, 0) scale(${scale.value})`;
|
|
33
|
-
}
|
|
34
|
-
function setScale(value) {
|
|
35
|
-
scale.value = clampZoom(value);
|
|
36
|
-
if (scale.value <= 1) {
|
|
37
|
-
offsetX = 0;
|
|
38
|
-
offsetY = 0;
|
|
39
|
-
}
|
|
40
|
-
applyTransform();
|
|
41
|
-
emit("zoom-change", scale.value);
|
|
42
|
-
}
|
|
13
|
+
const previewer = useTemplateRef("previewer");
|
|
43
14
|
function zoomIn() {
|
|
44
|
-
|
|
15
|
+
previewer.value?.zoomIn();
|
|
45
16
|
}
|
|
46
17
|
function zoomOut() {
|
|
47
|
-
|
|
18
|
+
previewer.value?.zoomOut();
|
|
48
19
|
}
|
|
49
20
|
function resetZoom() {
|
|
50
|
-
|
|
21
|
+
previewer.value?.resetZoom();
|
|
22
|
+
}
|
|
23
|
+
function onZoomChange(level) {
|
|
24
|
+
emit("zoom-change", level);
|
|
25
|
+
}
|
|
26
|
+
function onError(err) {
|
|
27
|
+
emit("error", err);
|
|
51
28
|
}
|
|
52
29
|
__expose({
|
|
53
30
|
zoomIn,
|
|
54
31
|
zoomOut,
|
|
55
32
|
resetZoom
|
|
56
33
|
});
|
|
57
|
-
function onPointerDown(e) {
|
|
58
|
-
if (scale.value <= 1 || e.button !== 0) return;
|
|
59
|
-
panState = {
|
|
60
|
-
pointerId: e.pointerId,
|
|
61
|
-
startX: e.clientX,
|
|
62
|
-
startY: e.clientY,
|
|
63
|
-
originX: offsetX,
|
|
64
|
-
originY: offsetY
|
|
65
|
-
};
|
|
66
|
-
isDragging.value = true;
|
|
67
|
-
root.value?.setPointerCapture(e.pointerId);
|
|
68
|
-
e.preventDefault();
|
|
69
|
-
}
|
|
70
|
-
function onPointerMove(e) {
|
|
71
|
-
if (!panState || panState.pointerId !== e.pointerId) return;
|
|
72
|
-
offsetX = panState.originX + e.clientX - panState.startX;
|
|
73
|
-
offsetY = panState.originY + e.clientY - panState.startY;
|
|
74
|
-
applyTransform();
|
|
75
|
-
}
|
|
76
|
-
function onPointerEnd(e) {
|
|
77
|
-
if (!panState || panState.pointerId !== e.pointerId) return;
|
|
78
|
-
const el = root.value;
|
|
79
|
-
if (el?.hasPointerCapture(e.pointerId)) el.releasePointerCapture(e.pointerId);
|
|
80
|
-
panState = void 0;
|
|
81
|
-
isDragging.value = false;
|
|
82
|
-
}
|
|
83
|
-
function onWheel(e) {
|
|
84
|
-
if (!(e.ctrlKey || e.metaKey)) return;
|
|
85
|
-
e.preventDefault();
|
|
86
|
-
setScale(scale.value + (e.deltaY > 0 ? -ZOOM_STEP : ZOOM_STEP));
|
|
87
|
-
}
|
|
88
|
-
function onDblclick() {
|
|
89
|
-
if (scale.value === 1) setScale(2);
|
|
90
|
-
else resetZoom();
|
|
91
|
-
}
|
|
92
|
-
let revoke;
|
|
93
|
-
function load() {
|
|
94
|
-
loading.value = true;
|
|
95
|
-
failed.value = false;
|
|
96
|
-
revoke?.();
|
|
97
|
-
const r = toBlobUrl(props.file.src, props.file.mime);
|
|
98
|
-
url.value = r.url;
|
|
99
|
-
revoke = r.revoke;
|
|
100
|
-
setScale(1);
|
|
101
|
-
}
|
|
102
|
-
function onImgError(e) {
|
|
103
|
-
loading.value = false;
|
|
104
|
-
failed.value = true;
|
|
105
|
-
emit("error", e);
|
|
106
|
-
}
|
|
107
|
-
watch(() => props.file.src, () => load(), { immediate: true });
|
|
108
|
-
onBeforeUnmount(() => {
|
|
109
|
-
revoke?.();
|
|
110
|
-
url.value = "";
|
|
111
|
-
});
|
|
112
34
|
return (_ctx, _cache) => {
|
|
113
|
-
return openBlock(),
|
|
114
|
-
ref_key: "
|
|
115
|
-
ref:
|
|
116
|
-
class:
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
url.value ? (openBlock(), createElementBlock("img", {
|
|
130
|
-
key: 0,
|
|
131
|
-
src: url.value,
|
|
132
|
-
alt: __props.file.name,
|
|
133
|
-
draggable: "false",
|
|
134
|
-
onDragstart: _cache[0] || (_cache[0] = withModifiers(() => {}, ["prevent"])),
|
|
135
|
-
onLoad: _cache[1] || (_cache[1] = ($event) => loading.value = false),
|
|
136
|
-
onError: onImgError
|
|
137
|
-
}, null, 40, _hoisted_1)) : createCommentVNode("v-if", true),
|
|
138
|
-
loading.value ? (openBlock(), createElementBlock("div", {
|
|
139
|
-
key: 1,
|
|
140
|
-
class: normalizeClass(unref(cls).e("loading"))
|
|
141
|
-
}, "加载中…", 2)) : createCommentVNode("v-if", true),
|
|
142
|
-
failed.value ? (openBlock(), createElementBlock("div", {
|
|
143
|
-
key: 2,
|
|
144
|
-
class: normalizeClass(unref(cls).e("loading"))
|
|
145
|
-
}, "图片加载失败", 2)) : createCommentVNode("v-if", true)
|
|
146
|
-
], 16);
|
|
35
|
+
return openBlock(), createBlock(_sfc_main$1, {
|
|
36
|
+
ref_key: "previewer",
|
|
37
|
+
ref: previewer,
|
|
38
|
+
class: normalizeClass(unref(cls).e("image")),
|
|
39
|
+
src: __props.file.src,
|
|
40
|
+
alt: __props.file.name,
|
|
41
|
+
mime: __props.file.mime,
|
|
42
|
+
modal: false,
|
|
43
|
+
onZoomChange,
|
|
44
|
+
onError
|
|
45
|
+
}, null, 8, [
|
|
46
|
+
"class",
|
|
47
|
+
"src",
|
|
48
|
+
"alt",
|
|
49
|
+
"mime"
|
|
50
|
+
]);
|
|
147
51
|
};
|
|
148
52
|
}
|
|
149
53
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-previewer.js","names":["_openBlock","
|
|
1
|
+
{"version":3,"file":"image-previewer.js","names":["_openBlock","_createBlock","UImagePreviewer","_normalizeClass","_unref"],"sources":["../../../../src/components/file-viewer/previewers/image-previewer.vue"],"sourcesContent":["<template>\n <UImagePreviewer\n ref=\"previewer\"\n :class=\"cls.e('image')\"\n :src=\"file.src\"\n :alt=\"file.name\"\n :mime=\"file.mime\"\n :modal=\"false\"\n @zoom-change=\"onZoomChange\"\n @error=\"onError\"\n />\n</template>\n\n<script lang=\"ts\" setup>\nimport { bem } from '@veltra/utils'\nimport { useTemplateRef } from 'vue'\n\nimport type { FileViewerItem } from '../../../types/file-viewer'\nimport type { ImagePreviewerExposed } from '../../../types/image-previewer'\nimport UImagePreviewer from '../../image-previewer/image-previewer.vue'\n\ndefineOptions({ name: 'UFileViewerImagePreviewer' })\n\ndefineProps<{ file: FileViewerItem }>()\n\nconst emit = defineEmits<{\n (e: 'error', err: unknown): void\n (e: 'zoom-change', level: number): void\n}>()\n\nconst cls = bem('file-viewer')\n\n// 缩放命令转发给内嵌预览面,file-viewer 工具栏经本 expose 驱动\nconst previewer = useTemplateRef<ImagePreviewerExposed>('previewer')\n\nfunction zoomIn() {\n previewer.value?.zoomIn()\n}\n\nfunction zoomOut() {\n previewer.value?.zoomOut()\n}\n\nfunction resetZoom() {\n previewer.value?.resetZoom()\n}\n\nfunction onZoomChange(level: number) {\n emit('zoom-change', level)\n}\n\nfunction onError(err: unknown) {\n emit('error', err)\n}\n\ndefineExpose({ zoomIn, zoomOut, resetZoom })\n</script>\n"],"mappings":";;;;;;;;;;EAyBA,MAAM,OAAO;EAKb,MAAM,MAAM,IAAI,aAAa;EAG7B,MAAM,YAAY,eAAsC,WAAW;EAEnE,SAAS,SAAS;GAChB,UAAU,OAAO,OAAO;EAC1B;EAEA,SAAS,UAAU;GACjB,UAAU,OAAO,QAAQ;EAC3B;EAEA,SAAS,YAAY;GACnB,UAAU,OAAO,UAAU;EAC7B;EAEA,SAAS,aAAa,OAAe;GACnC,KAAK,eAAe,KAAK;EAC3B;EAEA,SAAS,QAAQ,KAAc;GAC7B,KAAK,SAAS,GAAG;EACnB;EAEA,SAAa;GAAE;GAAQ;GAAS;EAAU,CAAC;;GAtDzC,OAAAA,UAAA,GAAAC,YASEC,aAAA;IARI,SAAA;IAAJ,KAAI;IACH,OAAKC,eAAEC,MAAA,GAAA,CAAG,CAAC,EAAC,OAAA,CAAA;IACZ,KAAK,QAAA,KAAK;IACV,KAAK,QAAA,KAAK;IACV,MAAM,QAAA,KAAK;IACX,OAAO;IACM;IACN"}
|