remove class vue dep (4)

vue3
Varun Patil 2022-12-10 02:04:07 -08:00
parent 2f482f4222
commit d2d0de0fd0
6 changed files with 291 additions and 254 deletions

View File

@ -66,9 +66,7 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { Component, Mixins, Watch } from "vue-property-decorator"; import { defineComponent } from "vue";
import GlobalMixin from "../../mixins/GlobalMixin";
import UserConfig from "../../mixins/UserConfig";
import NcActions from "@nextcloud/vue/dist/Components/NcActions"; import NcActions from "@nextcloud/vue/dist/Components/NcActions";
import NcActionButton from "@nextcloud/vue/dist/Components/NcActionButton"; import NcActionButton from "@nextcloud/vue/dist/Components/NcActionButton";
@ -90,7 +88,8 @@ import PlusIcon from "vue-material-design-icons/Plus.vue";
import ShareIcon from "vue-material-design-icons/ShareVariant.vue"; import ShareIcon from "vue-material-design-icons/ShareVariant.vue";
import { API } from "../../services/API"; import { API } from "../../services/API";
@Component({ export default defineComponent({
name: "AlbumTopMatter",
components: { components: {
NcActions, NcActions,
NcActionButton, NcActionButton,
@ -107,36 +106,43 @@ import { API } from "../../services/API";
PlusIcon, PlusIcon,
ShareIcon, ShareIcon,
}, },
})
export default class AlbumTopMatter extends Mixins(GlobalMixin, UserConfig) {
private name: string = "";
get isAlbumList() { data() {
return {
name: "",
};
},
computed: {
isAlbumList() {
return !Boolean(this.$route.params.name); return !Boolean(this.$route.params.name);
} },
get canEditAlbum() { canEditAlbum() {
return ( return (
!this.isAlbumList && this.$route.params.user === getCurrentUser()?.uid !this.isAlbumList && this.$route.params.user === getCurrentUser()?.uid
); );
} },
},
@Watch("$route") watch: {
async routeChange(from: any, to: any) { $route: async function (from: any, to: any) {
this.createMatter(); this.createMatter();
} },
},
mounted() { mounted() {
this.createMatter(); this.createMatter();
} },
methods: {
createMatter() { createMatter() {
this.name = this.$route.params.name || this.t("memories", "Albums"); this.name = this.$route.params.name || this.t("memories", "Albums");
} },
back() { back() {
this.$router.push({ name: "albums" }); this.$router.push({ name: "albums" });
} },
async downloadAlbum() { async downloadAlbum() {
const res = await axios.post( const res = await axios.post(
@ -145,8 +151,9 @@ export default class AlbumTopMatter extends Mixins(GlobalMixin, UserConfig) {
if (res.status === 200 && res.data.handle) { if (res.status === 200 && res.data.handle) {
downloadWithHandle(res.data.handle); downloadWithHandle(res.data.handle);
} }
} },
} },
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -52,9 +52,7 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { Component, Mixins, Watch } from "vue-property-decorator"; import { defineComponent } from "vue";
import GlobalMixin from "../../mixins/GlobalMixin";
import UserConfig from "../../mixins/UserConfig";
import NcActions from "@nextcloud/vue/dist/Components/NcActions"; import NcActions from "@nextcloud/vue/dist/Components/NcActions";
import NcActionButton from "@nextcloud/vue/dist/Components/NcActionButton"; import NcActionButton from "@nextcloud/vue/dist/Components/NcActionButton";
@ -68,7 +66,8 @@ import EditIcon from "vue-material-design-icons/Pencil.vue";
import DeleteIcon from "vue-material-design-icons/Close.vue"; import DeleteIcon from "vue-material-design-icons/Close.vue";
import MergeIcon from "vue-material-design-icons/Merge.vue"; import MergeIcon from "vue-material-design-icons/Merge.vue";
@Component({ export default defineComponent({
name: "FaceTopMatter",
components: { components: {
NcActions, NcActions,
NcActionButton, NcActionButton,
@ -81,26 +80,31 @@ import MergeIcon from "vue-material-design-icons/Merge.vue";
DeleteIcon, DeleteIcon,
MergeIcon, MergeIcon,
}, },
})
export default class FaceTopMatter extends Mixins(GlobalMixin, UserConfig) {
private name: string = "";
@Watch("$route") data() {
async routeChange(from: any, to: any) { return {
name: "",
};
},
watch: {
$route: function (from: any, to: any) {
this.createMatter(); this.createMatter();
} },
},
mounted() { mounted() {
this.createMatter(); this.createMatter();
} },
methods: {
createMatter() { createMatter() {
this.name = this.$route.params.name || ""; this.name = this.$route.params.name || "";
} },
back() { back() {
this.$router.push({ name: this.$route.name }); this.$router.push({ name: this.$route.name });
} },
changeShowFaceRect() { changeShowFaceRect() {
localStorage.setItem( localStorage.setItem(
@ -110,8 +114,9 @@ export default class FaceTopMatter extends Mixins(GlobalMixin, UserConfig) {
setTimeout(() => { setTimeout(() => {
this.$router.go(0); // refresh page this.$router.go(0); // refresh page
}, 500); }, 500);
} },
} },
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -32,7 +32,7 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { Component, Mixins, Watch } from "vue-property-decorator"; import { defineComponent } from "vue";
import { TopMatterFolder, TopMatterType } from "../../types"; import { TopMatterFolder, TopMatterType } from "../../types";
const NcBreadcrumbs = () => const NcBreadcrumbs = () =>
@ -42,14 +42,13 @@ const NcBreadcrumb = () =>
import NcActions from "@nextcloud/vue/dist/Components/NcActions"; import NcActions from "@nextcloud/vue/dist/Components/NcActions";
import NcActionButton from "@nextcloud/vue/dist/Components/NcActionButton"; import NcActionButton from "@nextcloud/vue/dist/Components/NcActionButton";
import GlobalMixin from "../../mixins/GlobalMixin";
import FolderShareModal from "../modal/FolderShareModal.vue"; import FolderShareModal from "../modal/FolderShareModal.vue";
import HomeIcon from "vue-material-design-icons/Home.vue"; import HomeIcon from "vue-material-design-icons/Home.vue";
import ShareIcon from "vue-material-design-icons/ShareVariant.vue"; import ShareIcon from "vue-material-design-icons/ShareVariant.vue";
@Component({ export default defineComponent({
name: "FolderTopMatter",
components: { components: {
NcBreadcrumbs, NcBreadcrumbs,
NcBreadcrumb, NcBreadcrumb,
@ -59,19 +58,24 @@ import ShareIcon from "vue-material-design-icons/ShareVariant.vue";
HomeIcon, HomeIcon,
ShareIcon, ShareIcon,
}, },
})
export default class FolderTopMatter extends Mixins(GlobalMixin) {
private topMatter?: TopMatterFolder = null;
@Watch("$route") data() {
async routeChange(from: any, to: any) { return {
topMatter: null as TopMatterFolder | null,
};
},
watch: {
$route: function (from: any, to: any) {
this.createMatter(); this.createMatter();
} },
},
mounted() { mounted() {
this.createMatter(); this.createMatter();
} },
methods: {
createMatter() { createMatter() {
if (this.$route.name === "folders") { if (this.$route.name === "folders") {
let path: any = this.$route.params.path || ""; let path: any = this.$route.params.path || "";
@ -93,8 +97,9 @@ export default class FolderTopMatter extends Mixins(GlobalMixin) {
} else { } else {
this.topMatter = null; this.topMatter = null;
} }
} },
} },
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -41,8 +41,7 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { Component, Emit, Mixins, Prop } from "vue-property-decorator"; import { defineComponent } from "vue";
import GlobalMixin from "../../mixins/GlobalMixin";
import NcActions from "@nextcloud/vue/dist/Components/NcActions"; import NcActions from "@nextcloud/vue/dist/Components/NcActions";
import NcActionButton from "@nextcloud/vue/dist/Components/NcActionButton"; import NcActionButton from "@nextcloud/vue/dist/Components/NcActionButton";
@ -63,7 +62,7 @@ interface IYear {
text: string; text: string;
} }
@Component({ export default defineComponent({
name: "OnThisDay", name: "OnThisDay",
components: { components: {
NcActions, NcActions,
@ -71,21 +70,23 @@ interface IYear {
LeftMoveIcon, LeftMoveIcon,
RightMoveIcon, RightMoveIcon,
}, },
})
export default class OnThisDay extends Mixins(GlobalMixin) {
private getPreviewUrl = getPreviewUrl;
@Prop() props: {
private viewer: any; viewer: {
type: Object,
required: false,
},
},
@Emit("load") data() {
onload() {} return {
getPreviewUrl,
private years: IYear[] = []; years: [] as IYear[],
hasRight: false,
private hasRight = false; hasLeft: false,
private hasLeft = false; scrollStack: [] as number[],
private scrollStack: number[] = []; };
},
mounted() { mounted() {
const inner = this.$refs.inner as HTMLElement; const inner = this.$refs.inner as HTMLElement;
@ -94,7 +95,12 @@ export default class OnThisDay extends Mixins(GlobalMixin) {
}); });
this.refresh(); this.refresh();
} },
methods: {
onload() {
this.$emit("load");
},
async refresh() { async refresh() {
// Look for cache // Look for cache
@ -114,7 +120,7 @@ export default class OnThisDay extends Mixins(GlobalMixin) {
) )
return; return;
this.process(photos); this.process(photos);
} },
async process(photos: IPhoto[]) { async process(photos: IPhoto[]) {
this.years = []; this.years = [];
@ -162,12 +168,12 @@ export default class OnThisDay extends Mixins(GlobalMixin) {
await this.$nextTick(); await this.$nextTick();
this.onScroll(); this.onScroll();
this.onload(); this.onload();
} },
moveLeft() { moveLeft() {
const inner = this.$refs.inner as HTMLElement; const inner = this.$refs.inner as HTMLElement;
inner.scrollBy(-(this.scrollStack.pop() || inner.clientWidth), 0); inner.scrollBy(-(this.scrollStack.pop() || inner.clientWidth), 0);
} },
moveRight() { moveRight() {
const inner = this.$refs.inner as HTMLElement; const inner = this.$refs.inner as HTMLElement;
@ -185,7 +191,7 @@ export default class OnThisDay extends Mixins(GlobalMixin) {
); );
this.scrollStack.push(scroll); this.scrollStack.push(scroll);
inner.scrollBy(scroll, 0); inner.scrollBy(scroll, 0);
} },
onScroll() { onScroll() {
const inner = this.$refs.inner as HTMLElement; const inner = this.$refs.inner as HTMLElement;
@ -193,13 +199,14 @@ export default class OnThisDay extends Mixins(GlobalMixin) {
this.hasLeft = inner.scrollLeft > 0; this.hasLeft = inner.scrollLeft > 0;
this.hasRight = this.hasRight =
inner.clientWidth + inner.scrollLeft < inner.scrollWidth - 20; inner.clientWidth + inner.scrollLeft < inner.scrollWidth - 20;
} },
click(year: IYear) { click(year: IYear) {
const allPhotos = this.years.flatMap((y) => y.photos); const allPhotos = this.years.flatMap((y) => y.photos);
this.viewer.openStatic(year.preview, allPhotos, 512); this.viewer.openStatic(year.preview, allPhotos, 512);
} },
} },
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -11,41 +11,47 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { Component, Mixins, Watch } from "vue-property-decorator"; import { defineComponent } from "vue";
import GlobalMixin from "../../mixins/GlobalMixin";
import NcActions from "@nextcloud/vue/dist/Components/NcActions"; import NcActions from "@nextcloud/vue/dist/Components/NcActions";
import NcActionButton from "@nextcloud/vue/dist/Components/NcActionButton"; import NcActionButton from "@nextcloud/vue/dist/Components/NcActionButton";
import BackIcon from "vue-material-design-icons/ArrowLeft.vue"; import BackIcon from "vue-material-design-icons/ArrowLeft.vue";
@Component({ export default defineComponent({
name: "TagTopMatter",
components: { components: {
NcActions, NcActions,
NcActionButton, NcActionButton,
BackIcon, BackIcon,
}, },
})
export default class TagTopMatter extends Mixins(GlobalMixin) {
private name: string = "";
@Watch("$route") data() {
async routeChange(from: any, to: any) { return {
name: "",
};
},
watch: {
$route: function (from: any, to: any) {
this.createMatter(); this.createMatter();
} },
},
mounted() { mounted() {
this.createMatter(); this.createMatter();
} },
methods: {
createMatter() { createMatter() {
this.name = this.$route.params.name || ""; this.name = this.$route.params.name || "";
} },
back() { back() {
this.$router.push({ name: "tags" }); this.$router.push({ name: "tags" });
} },
} },
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -8,35 +8,41 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { Component, Mixins, Watch } from "vue-property-decorator"; import { defineComponent } from "vue";
import FolderTopMatter from "./FolderTopMatter.vue"; import FolderTopMatter from "./FolderTopMatter.vue";
import TagTopMatter from "./TagTopMatter.vue"; import TagTopMatter from "./TagTopMatter.vue";
import FaceTopMatter from "./FaceTopMatter.vue"; import FaceTopMatter from "./FaceTopMatter.vue";
import AlbumTopMatter from "./AlbumTopMatter.vue"; import AlbumTopMatter from "./AlbumTopMatter.vue";
import GlobalMixin from "../../mixins/GlobalMixin";
import { TopMatterType } from "../../types"; import { TopMatterType } from "../../types";
@Component({ export default defineComponent({
name: "TopMatter",
components: { components: {
FolderTopMatter, FolderTopMatter,
TagTopMatter, TagTopMatter,
FaceTopMatter, FaceTopMatter,
AlbumTopMatter, AlbumTopMatter,
}, },
})
export default class TopMatter extends Mixins(GlobalMixin) {
public type: TopMatterType = TopMatterType.NONE;
@Watch("$route") data() {
async routeChange(from: any, to: any) { return {
type: TopMatterType.NONE,
};
},
watch: {
$route: function (from: any, to: any) {
this.setTopMatter(); this.setTopMatter();
} },
},
mounted() { mounted() {
this.setTopMatter(); this.setTopMatter();
} },
methods: {
/** Create top matter */ /** Create top matter */
setTopMatter() { setTopMatter() {
this.type = (() => { this.type = (() => {
@ -58,6 +64,7 @@ export default class TopMatter extends Mixins(GlobalMixin) {
return TopMatterType.NONE; return TopMatterType.NONE;
} }
})(); })();
} },
} },
});
</script> </script>