@@ -6,7 +6,7 @@ import Hls from 'hls.js';
|
||||
export const useVideosStore = defineStore('videos', () => {
|
||||
// --- State (状态) ---
|
||||
// 相当于 Vuex 中的 state,用 ref 或 reactive 定义
|
||||
const hisUrl = ref();
|
||||
const hisUrl = ref('');
|
||||
|
||||
// --- Getters (计算属性) ---
|
||||
// 相当于 Vuex 中的 getters,直接用 computed 定义
|
||||
@@ -14,12 +14,14 @@ export const useVideosStore = defineStore('videos', () => {
|
||||
// --- Actions (动作) ---
|
||||
// 相当于 Vuex 中的 actions/mutations,直接写同步或异步函数
|
||||
async function getVideos(deviceId?: string | number) {
|
||||
hisUrl.value = '';
|
||||
try {
|
||||
const response = await listDemo(deviceId);
|
||||
console.log('获取视频:', response);
|
||||
hisUrl.value = response.data;
|
||||
hisUrl.value = response?.data || '';
|
||||
} catch (error) {
|
||||
console.error('获取视频失败', error);
|
||||
hisUrl.value = '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user