screen-recorder-vue 0.0.8 → 0.0.11
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/package.json +15 -15
- package/src/App.vue +1 -1
- package/src/components/ScreenRecorder.vue +29 -17
- package/tsconfig.json +2 -1
package/package.json
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "screen-recorder-vue",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"main": "src/index.ts",
|
|
5
5
|
"module": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
|
+
"types": "./src/index.ts",
|
|
9
10
|
"import": "./src/index.ts",
|
|
10
|
-
"require": "./src/index.ts"
|
|
11
|
-
"types": "./src/index.ts"
|
|
11
|
+
"require": "./src/index.ts"
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
|
-
"predev": "
|
|
16
|
-
"prebuild": "
|
|
17
|
-
"dev": "vite",
|
|
15
|
+
"predev": "pnpm --filter screen-recorder-base build",
|
|
16
|
+
"prebuild": "pnpm --filter screen-recorder-base build",
|
|
17
|
+
"dev": "vite --host",
|
|
18
18
|
"build": "vite build",
|
|
19
19
|
"serve": "vite preview"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@vueuse/core": "^
|
|
23
|
-
"@w-xuefeng/bindkey": "^1.0.
|
|
24
|
-
"screen-recorder-base": "^0.0.
|
|
22
|
+
"@vueuse/core": "^14.1.0",
|
|
23
|
+
"@w-xuefeng/bindkey": "^1.0.3",
|
|
24
|
+
"screen-recorder-base": "^0.0.10",
|
|
25
25
|
"vue": "^3.2.16"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@types/node": "^
|
|
29
|
-
"@vitejs/plugin-vue": "^
|
|
30
|
-
"typescript": "^
|
|
31
|
-
"vite": "^
|
|
32
|
-
"vue-tsc": "^
|
|
28
|
+
"@types/node": "^25.0.10",
|
|
29
|
+
"@vitejs/plugin-vue": "^6.0.3",
|
|
30
|
+
"typescript": "^5.9.3",
|
|
31
|
+
"vite": "^7.3.1",
|
|
32
|
+
"vue-tsc": "^3.2.3"
|
|
33
33
|
}
|
|
34
|
-
}
|
|
34
|
+
}
|
package/src/App.vue
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import {
|
|
3
|
+
ScreenRecorder,
|
|
4
|
+
type IScreenRecorderOptions,
|
|
5
|
+
} from "screen-recorder-base";
|
|
6
|
+
import { bindkey } from "@w-xuefeng/bindkey";
|
|
7
|
+
import { useDraggable } from "@vueuse/core";
|
|
8
|
+
import { ref, reactive, useSlots } from "vue";
|
|
6
9
|
|
|
7
10
|
const props = defineProps<{
|
|
8
11
|
shortKey?: string;
|
|
@@ -15,10 +18,10 @@ const props = defineProps<{
|
|
|
15
18
|
}>();
|
|
16
19
|
|
|
17
20
|
const emit = defineEmits([
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
"recording-start",
|
|
22
|
+
"recording-end",
|
|
23
|
+
"recording-unsupport",
|
|
24
|
+
"recording-error",
|
|
22
25
|
]);
|
|
23
26
|
|
|
24
27
|
const notSlotStart = ref(!!!useSlots().start);
|
|
@@ -51,23 +54,23 @@ const options: IScreenRecorderOptions = {
|
|
|
51
54
|
state.unsupported = true;
|
|
52
55
|
state.recording = false;
|
|
53
56
|
state.error = false;
|
|
54
|
-
emit(
|
|
57
|
+
emit("recording-unsupport");
|
|
55
58
|
},
|
|
56
59
|
onRecordStart: (mediaStream: MediaStream) => {
|
|
57
60
|
state.recording = true;
|
|
58
61
|
state.error = false;
|
|
59
62
|
initPreview(mediaStream);
|
|
60
|
-
emit(
|
|
63
|
+
emit("recording-start", mediaStream);
|
|
61
64
|
},
|
|
62
65
|
onError: (err) => {
|
|
63
66
|
state.error = true;
|
|
64
67
|
state.recording = false;
|
|
65
|
-
emit(
|
|
68
|
+
emit("recording-error", err);
|
|
66
69
|
},
|
|
67
70
|
onRecordEnd: (blobUrl: string, fixedBlob: Blob) => {
|
|
68
71
|
state.recording = false;
|
|
69
72
|
state.error = false;
|
|
70
|
-
emit(
|
|
73
|
+
emit("recording-end", blobUrl, fixedBlob);
|
|
71
74
|
},
|
|
72
75
|
timeSlice: 1000,
|
|
73
76
|
videoOptions: props.videoOptions,
|
|
@@ -83,9 +86,9 @@ const end = () => {
|
|
|
83
86
|
state.screenRecorder?.stopRecording();
|
|
84
87
|
};
|
|
85
88
|
|
|
86
|
-
if (props.shortKey && props.shortKey.toUpperCase() !==
|
|
89
|
+
if (props.shortKey && props.shortKey.toUpperCase() !== "ESC") {
|
|
87
90
|
bindkey.add(props.shortKey, start);
|
|
88
|
-
bindkey.add(
|
|
91
|
+
bindkey.add("ESC", end);
|
|
89
92
|
}
|
|
90
93
|
|
|
91
94
|
const defaultBtnStyle = `
|
|
@@ -116,14 +119,23 @@ const defaultBtnStyle = `
|
|
|
116
119
|
v-if="notSlotStart && !state.recording"
|
|
117
120
|
@click="start"
|
|
118
121
|
:style="`${defaultBtnStyle}${startBtnStyle}`"
|
|
119
|
-
>
|
|
120
|
-
|
|
122
|
+
>
|
|
123
|
+
{{ startBtnText || "开始录屏" }}
|
|
124
|
+
</button>
|
|
125
|
+
<slot
|
|
126
|
+
name="start"
|
|
127
|
+
v-else-if="!state.recording"
|
|
128
|
+
:startEvent="start"
|
|
129
|
+
:endEvent="end"
|
|
130
|
+
></slot>
|
|
121
131
|
|
|
122
132
|
<button
|
|
123
133
|
v-if="notSlotEnd && state.recording"
|
|
124
134
|
@click="end"
|
|
125
135
|
:style="`${defaultBtnStyle}${endBtnStyle}`"
|
|
126
|
-
>
|
|
136
|
+
>
|
|
137
|
+
{{ endBtnText || "停止录屏" }}
|
|
138
|
+
</button>
|
|
127
139
|
<slot name="end" v-else-if="state.recording" :endEvent="end"></slot>
|
|
128
140
|
|
|
129
141
|
<video
|