mirror of
				https://codeberg.org/yeentown/barkey.git
				synced 2025-11-04 07:24:13 +00:00 
			
		
		
		
	wip: refactor(client): migrate components to composition api
This commit is contained in:
		
							parent
							
								
									7f4fc20f98
								
							
						
					
					
						commit
						ffc07a08d7
					
				
					 3 changed files with 107 additions and 131 deletions
				
			
		| 
						 | 
					@ -4,25 +4,14 @@
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<script lang="ts">
 | 
					<script lang="ts" setup>
 | 
				
			||||||
import { defineComponent } from 'vue';
 | 
					import { } from 'vue';
 | 
				
			||||||
import MkButton from '@/components/ui/button.vue';
 | 
					 | 
				
			||||||
import XAntenna from './editor.vue';
 | 
					import XAntenna from './editor.vue';
 | 
				
			||||||
import * as symbols from '@/symbols';
 | 
					import * as symbols from '@/symbols';
 | 
				
			||||||
 | 
					import { i18n } from '@/i18n';
 | 
				
			||||||
 | 
					import { router } from '@/router';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default defineComponent({
 | 
					let draft = $ref({
 | 
				
			||||||
	components: {
 | 
					 | 
				
			||||||
		MkButton,
 | 
					 | 
				
			||||||
		XAntenna,
 | 
					 | 
				
			||||||
	},
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	data() {
 | 
					 | 
				
			||||||
		return {
 | 
					 | 
				
			||||||
			[symbols.PAGE_INFO]: {
 | 
					 | 
				
			||||||
				title: this.$ts.manageAntennas,
 | 
					 | 
				
			||||||
				icon: 'fas fa-satellite',
 | 
					 | 
				
			||||||
			},
 | 
					 | 
				
			||||||
			draft: {
 | 
					 | 
				
			||||||
	name: '',
 | 
						name: '',
 | 
				
			||||||
	src: 'all',
 | 
						src: 'all',
 | 
				
			||||||
	userListId: null,
 | 
						userListId: null,
 | 
				
			||||||
| 
						 | 
					@ -34,15 +23,18 @@ export default defineComponent({
 | 
				
			||||||
	caseSensitive: false,
 | 
						caseSensitive: false,
 | 
				
			||||||
	withFile: false,
 | 
						withFile: false,
 | 
				
			||||||
	notify: false
 | 
						notify: false
 | 
				
			||||||
			},
 | 
					});
 | 
				
			||||||
		};
 | 
					 | 
				
			||||||
	},
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	methods: {
 | 
					function onAntennaCreated() {
 | 
				
			||||||
		onAntennaCreated() {
 | 
						router.push('/my/antennas');
 | 
				
			||||||
			this.$router.push('/my/antennas');
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					defineExpose({
 | 
				
			||||||
 | 
						[symbols.PAGE_INFO]: {
 | 
				
			||||||
 | 
							title: i18n.locale.manageAntennas,
 | 
				
			||||||
 | 
							icon: 'fas fa-satellite',
 | 
				
			||||||
 | 
							bg: 'var(--bg)',
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,7 +3,7 @@
 | 
				
			||||||
	<div class="qtcaoidl">
 | 
						<div class="qtcaoidl">
 | 
				
			||||||
		<MkButton primary class="add" @click="create"><i class="fas fa-plus"></i> {{ $ts.add }}</MkButton>
 | 
							<MkButton primary class="add" @click="create"><i class="fas fa-plus"></i> {{ $ts.add }}</MkButton>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		<MkPagination v-slot="{items}" ref="list" :pagination="pagination" class="list">
 | 
							<MkPagination v-slot="{items}" ref="pagingComponent" :pagination="pagination" class="list">
 | 
				
			||||||
			<MkA v-for="item in items" :key="item.id" :to="`/clips/${item.id}`" class="item _panel _gap">
 | 
								<MkA v-for="item in items" :key="item.id" :to="`/clips/${item.id}`" class="item _panel _gap">
 | 
				
			||||||
				<b>{{ item.name }}</b>
 | 
									<b>{{ item.name }}</b>
 | 
				
			||||||
				<div v-if="item.description" class="description">{{ item.description }}</div>
 | 
									<div v-if="item.description" class="description">{{ item.description }}</div>
 | 
				
			||||||
| 
						 | 
					@ -13,71 +13,64 @@
 | 
				
			||||||
</MkSpacer>
 | 
					</MkSpacer>
 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<script lang="ts">
 | 
					<script lang="ts" setup>
 | 
				
			||||||
import { defineComponent } from 'vue';
 | 
					import { } from 'vue';
 | 
				
			||||||
import MkPagination from '@/components/ui/pagination.vue';
 | 
					import MkPagination from '@/components/ui/pagination.vue';
 | 
				
			||||||
import MkButton from '@/components/ui/button.vue';
 | 
					import MkButton from '@/components/ui/button.vue';
 | 
				
			||||||
import * as os from '@/os';
 | 
					import * as os from '@/os';
 | 
				
			||||||
import * as symbols from '@/symbols';
 | 
					import * as symbols from '@/symbols';
 | 
				
			||||||
 | 
					import i18n from '@/components/global/i18n';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default defineComponent({
 | 
					const pagination = {
 | 
				
			||||||
	components: {
 | 
					 | 
				
			||||||
		MkPagination,
 | 
					 | 
				
			||||||
		MkButton,
 | 
					 | 
				
			||||||
	},
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	data() {
 | 
					 | 
				
			||||||
		return {
 | 
					 | 
				
			||||||
			[symbols.PAGE_INFO]: {
 | 
					 | 
				
			||||||
				title: this.$ts.clip,
 | 
					 | 
				
			||||||
				icon: 'fas fa-paperclip',
 | 
					 | 
				
			||||||
				bg: 'var(--bg)',
 | 
					 | 
				
			||||||
				action: {
 | 
					 | 
				
			||||||
					icon: 'fas fa-plus',
 | 
					 | 
				
			||||||
					handler: this.create
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			},
 | 
					 | 
				
			||||||
			pagination: {
 | 
					 | 
				
			||||||
	endpoint: 'clips/list' as const,
 | 
						endpoint: 'clips/list' as const,
 | 
				
			||||||
	limit: 10,
 | 
						limit: 10,
 | 
				
			||||||
			},
 | 
					};
 | 
				
			||||||
			draft: null,
 | 
					 | 
				
			||||||
		};
 | 
					 | 
				
			||||||
	},
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	methods: {
 | 
					const pagingComponent = $ref<InstanceType<typeof MkPagination>>();
 | 
				
			||||||
		async create() {
 | 
					
 | 
				
			||||||
			const { canceled, result } = await os.form(this.$ts.createNewClip, {
 | 
					async function create() {
 | 
				
			||||||
 | 
						const { canceled, result } = await os.form(i18n.locale.createNewClip, {
 | 
				
			||||||
		name: {
 | 
							name: {
 | 
				
			||||||
			type: 'string',
 | 
								type: 'string',
 | 
				
			||||||
					label: this.$ts.name
 | 
								label: i18n.locale.name,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		description: {
 | 
							description: {
 | 
				
			||||||
			type: 'string',
 | 
								type: 'string',
 | 
				
			||||||
			required: false,
 | 
								required: false,
 | 
				
			||||||
			multiline: true,
 | 
								multiline: true,
 | 
				
			||||||
					label: this.$ts.description
 | 
								label: i18n.locale.description,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		isPublic: {
 | 
							isPublic: {
 | 
				
			||||||
			type: 'boolean',
 | 
								type: 'boolean',
 | 
				
			||||||
					label: this.$ts.public,
 | 
								label: i18n.locale.public,
 | 
				
			||||||
					default: false
 | 
								default: false,
 | 
				
			||||||
				}
 | 
							},
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
	if (canceled) return;
 | 
						if (canceled) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	os.apiWithDialog('clips/create', result);
 | 
						os.apiWithDialog('clips/create', result);
 | 
				
			||||||
		},
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		onClipCreated() {
 | 
						pagingComponent.reload();
 | 
				
			||||||
			this.$refs.list.reload();
 | 
					}
 | 
				
			||||||
			this.draft = null;
 | 
					 | 
				
			||||||
		},
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		onClipDeleted() {
 | 
					function onClipCreated() {
 | 
				
			||||||
			this.$refs.list.reload();
 | 
						pagingComponent.reload();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function onClipDeleted() {
 | 
				
			||||||
 | 
						pagingComponent.reload();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					defineExpose({
 | 
				
			||||||
 | 
						[symbols.PAGE_INFO]: {
 | 
				
			||||||
 | 
							title: i18n.locale.clip,
 | 
				
			||||||
 | 
							icon: 'fas fa-paperclip',
 | 
				
			||||||
 | 
							bg: 'var(--bg)',
 | 
				
			||||||
 | 
							action: {
 | 
				
			||||||
 | 
								icon: 'fas fa-plus',
 | 
				
			||||||
 | 
								handler: create
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,7 +3,7 @@
 | 
				
			||||||
	<div class="qkcjvfiv">
 | 
						<div class="qkcjvfiv">
 | 
				
			||||||
		<MkButton primary class="add" @click="create"><i class="fas fa-plus"></i> {{ $ts.createList }}</MkButton>
 | 
							<MkButton primary class="add" @click="create"><i class="fas fa-plus"></i> {{ $ts.createList }}</MkButton>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		<MkPagination v-slot="{items}" ref="list" :pagination="pagination" class="lists _content">
 | 
							<MkPagination v-slot="{items}" ref="pagingComponent" :pagination="pagination" class="lists _content">
 | 
				
			||||||
			<MkA v-for="list in items" :key="list.id" class="list _panel" :to="`/my/lists/${ list.id }`">
 | 
								<MkA v-for="list in items" :key="list.id" class="list _panel" :to="`/my/lists/${ list.id }`">
 | 
				
			||||||
				<div class="name">{{ list.name }}</div>
 | 
									<div class="name">{{ list.name }}</div>
 | 
				
			||||||
				<MkAvatars :user-ids="list.userIds"/>
 | 
									<MkAvatars :user-ids="list.userIds"/>
 | 
				
			||||||
| 
						 | 
					@ -13,50 +13,41 @@
 | 
				
			||||||
</MkSpacer>
 | 
					</MkSpacer>
 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<script lang="ts">
 | 
					<script lang="ts" setup>
 | 
				
			||||||
import { defineComponent } from 'vue';
 | 
					import { } from 'vue';
 | 
				
			||||||
import MkPagination from '@/components/ui/pagination.vue';
 | 
					import MkPagination from '@/components/ui/pagination.vue';
 | 
				
			||||||
import MkButton from '@/components/ui/button.vue';
 | 
					import MkButton from '@/components/ui/button.vue';
 | 
				
			||||||
import MkAvatars from '@/components/avatars.vue';
 | 
					import MkAvatars from '@/components/avatars.vue';
 | 
				
			||||||
import * as os from '@/os';
 | 
					import * as os from '@/os';
 | 
				
			||||||
import * as symbols from '@/symbols';
 | 
					import * as symbols from '@/symbols';
 | 
				
			||||||
 | 
					import { i18n } from '@/i18n';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default defineComponent({
 | 
					const pagingComponent = $ref<InstanceType<typeof MkPagination>>();
 | 
				
			||||||
	components: {
 | 
					 | 
				
			||||||
		MkPagination,
 | 
					 | 
				
			||||||
		MkButton,
 | 
					 | 
				
			||||||
		MkAvatars,
 | 
					 | 
				
			||||||
	},
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	data() {
 | 
					const pagination = {
 | 
				
			||||||
		return {
 | 
						endpoint: 'users/lists/list' as const,
 | 
				
			||||||
 | 
						limit: 10,
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					async function create() {
 | 
				
			||||||
 | 
						const { canceled, result: name } = await os.inputText({
 | 
				
			||||||
 | 
							title: i18n.locale.enterListName,
 | 
				
			||||||
 | 
						});
 | 
				
			||||||
 | 
						if (canceled) return;
 | 
				
			||||||
 | 
						await os.apiWithDialog('users/lists/create', { name: name });
 | 
				
			||||||
 | 
						pagingComponent.reload();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					defineExpose({
 | 
				
			||||||
	[symbols.PAGE_INFO]: {
 | 
						[symbols.PAGE_INFO]: {
 | 
				
			||||||
				title: this.$ts.manageLists,
 | 
							title: i18n.locale.manageLists,
 | 
				
			||||||
		icon: 'fas fa-list-ul',
 | 
							icon: 'fas fa-list-ul',
 | 
				
			||||||
		bg: 'var(--bg)',
 | 
							bg: 'var(--bg)',
 | 
				
			||||||
		action: {
 | 
							action: {
 | 
				
			||||||
			icon: 'fas fa-plus',
 | 
								icon: 'fas fa-plus',
 | 
				
			||||||
					handler: this.create
 | 
								handler: create,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
			pagination: {
 | 
					 | 
				
			||||||
				endpoint: 'users/lists/list' as const,
 | 
					 | 
				
			||||||
				limit: 10,
 | 
					 | 
				
			||||||
			},
 | 
					 | 
				
			||||||
		};
 | 
					 | 
				
			||||||
	},
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	methods: {
 | 
					 | 
				
			||||||
		async create() {
 | 
					 | 
				
			||||||
			const { canceled, result: name } = await os.inputText({
 | 
					 | 
				
			||||||
				title: this.$ts.enterListName,
 | 
					 | 
				
			||||||
			});
 | 
					 | 
				
			||||||
			if (canceled) return;
 | 
					 | 
				
			||||||
			await os.api('users/lists/create', { name: name });
 | 
					 | 
				
			||||||
			this.$refs.list.reload();
 | 
					 | 
				
			||||||
			os.success();
 | 
					 | 
				
			||||||
		},
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue