wip: refactor(client): migrate components to composition api
This commit is contained in:
		
							parent
							
								
									ed5c918d70
								
							
						
					
					
						commit
						133b5c6391
					
				
					 2 changed files with 39 additions and 96 deletions
				
			
		| 
						 | 
				
			
			@ -8,39 +8,28 @@
 | 
			
		|||
</div>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script lang="ts">
 | 
			
		||||
import { defineComponent } from 'vue';
 | 
			
		||||
import * as os from '@/os';
 | 
			
		||||
<script lang="ts" setup>
 | 
			
		||||
import { onUnmounted } from 'vue';
 | 
			
		||||
import { stream } from '@/stream';
 | 
			
		||||
 | 
			
		||||
export default defineComponent({
 | 
			
		||||
	data() {
 | 
			
		||||
		return {
 | 
			
		||||
			hasDisconnected: false,
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	computed: {
 | 
			
		||||
		stream() {
 | 
			
		||||
			return stream;
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
	created() {
 | 
			
		||||
		stream.on('_disconnected_', this.onDisconnected);
 | 
			
		||||
	},
 | 
			
		||||
	beforeUnmount() {
 | 
			
		||||
		stream.off('_disconnected_', this.onDisconnected);
 | 
			
		||||
	},
 | 
			
		||||
	methods: {
 | 
			
		||||
		onDisconnected() {
 | 
			
		||||
			this.hasDisconnected = true;
 | 
			
		||||
		},
 | 
			
		||||
		resetDisconnected() {
 | 
			
		||||
			this.hasDisconnected = false;
 | 
			
		||||
		},
 | 
			
		||||
		reload() {
 | 
			
		||||
			location.reload();
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
let hasDisconnected = $ref(false);
 | 
			
		||||
 | 
			
		||||
function onDisconnected() {
 | 
			
		||||
	hasDisconnected = true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function resetDisconnected() {
 | 
			
		||||
	hasDisconnected = false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function reload() {
 | 
			
		||||
	location.reload();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
stream.on('_disconnected_', onDisconnected);
 | 
			
		||||
 | 
			
		||||
onUnmounted(() => {
 | 
			
		||||
	stream.off('_disconnected_', onDisconnected);
 | 
			
		||||
});
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue