screen-recorder-vue 0.0.8 → 0.0.9
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 +26 -17
package/package.json
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "screen-recorder-vue",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
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.8",
|
|
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,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { ScreenRecorder, IScreenRecorderOptions } from
|
|
3
|
-
import bindkey from
|
|
4
|
-
import { useDraggable } from
|
|
5
|
-
import { ref, reactive, useSlots } from
|
|
2
|
+
import { ScreenRecorder, IScreenRecorderOptions } from "screen-recorder-base";
|
|
3
|
+
import { bindkey } from "@w-xuefeng/bindkey";
|
|
4
|
+
import { useDraggable } from "@vueuse/core";
|
|
5
|
+
import { ref, reactive, useSlots } from "vue";
|
|
6
6
|
|
|
7
7
|
const props = defineProps<{
|
|
8
8
|
shortKey?: string;
|
|
@@ -15,10 +15,10 @@ const props = defineProps<{
|
|
|
15
15
|
}>();
|
|
16
16
|
|
|
17
17
|
const emit = defineEmits([
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
"recording-start",
|
|
19
|
+
"recording-end",
|
|
20
|
+
"recording-unsupport",
|
|
21
|
+
"recording-error",
|
|
22
22
|
]);
|
|
23
23
|
|
|
24
24
|
const notSlotStart = ref(!!!useSlots().start);
|
|
@@ -51,23 +51,23 @@ const options: IScreenRecorderOptions = {
|
|
|
51
51
|
state.unsupported = true;
|
|
52
52
|
state.recording = false;
|
|
53
53
|
state.error = false;
|
|
54
|
-
emit(
|
|
54
|
+
emit("recording-unsupport");
|
|
55
55
|
},
|
|
56
56
|
onRecordStart: (mediaStream: MediaStream) => {
|
|
57
57
|
state.recording = true;
|
|
58
58
|
state.error = false;
|
|
59
59
|
initPreview(mediaStream);
|
|
60
|
-
emit(
|
|
60
|
+
emit("recording-start", mediaStream);
|
|
61
61
|
},
|
|
62
62
|
onError: (err) => {
|
|
63
63
|
state.error = true;
|
|
64
64
|
state.recording = false;
|
|
65
|
-
emit(
|
|
65
|
+
emit("recording-error", err);
|
|
66
66
|
},
|
|
67
67
|
onRecordEnd: (blobUrl: string, fixedBlob: Blob) => {
|
|
68
68
|
state.recording = false;
|
|
69
69
|
state.error = false;
|
|
70
|
-
emit(
|
|
70
|
+
emit("recording-end", blobUrl, fixedBlob);
|
|
71
71
|
},
|
|
72
72
|
timeSlice: 1000,
|
|
73
73
|
videoOptions: props.videoOptions,
|
|
@@ -83,9 +83,9 @@ const end = () => {
|
|
|
83
83
|
state.screenRecorder?.stopRecording();
|
|
84
84
|
};
|
|
85
85
|
|
|
86
|
-
if (props.shortKey && props.shortKey.toUpperCase() !==
|
|
86
|
+
if (props.shortKey && props.shortKey.toUpperCase() !== "ESC") {
|
|
87
87
|
bindkey.add(props.shortKey, start);
|
|
88
|
-
bindkey.add(
|
|
88
|
+
bindkey.add("ESC", end);
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
const defaultBtnStyle = `
|
|
@@ -116,14 +116,23 @@ const defaultBtnStyle = `
|
|
|
116
116
|
v-if="notSlotStart && !state.recording"
|
|
117
117
|
@click="start"
|
|
118
118
|
:style="`${defaultBtnStyle}${startBtnStyle}`"
|
|
119
|
-
>
|
|
120
|
-
|
|
119
|
+
>
|
|
120
|
+
{{ startBtnText || "开始录屏" }}
|
|
121
|
+
</button>
|
|
122
|
+
<slot
|
|
123
|
+
name="start"
|
|
124
|
+
v-else-if="!state.recording"
|
|
125
|
+
:startEvent="start"
|
|
126
|
+
:endEvent="end"
|
|
127
|
+
></slot>
|
|
121
128
|
|
|
122
129
|
<button
|
|
123
130
|
v-if="notSlotEnd && state.recording"
|
|
124
131
|
@click="end"
|
|
125
132
|
:style="`${defaultBtnStyle}${endBtnStyle}`"
|
|
126
|
-
>
|
|
133
|
+
>
|
|
134
|
+
{{ endBtnText || "停止录屏" }}
|
|
135
|
+
</button>
|
|
127
136
|
<slot name="end" v-else-if="state.recording" :endEvent="end"></slot>
|
|
128
137
|
|
|
129
138
|
<video
|