Migration to vue3 continued

Remove garbage from vscode renaming
Fix reading route in pinia store
This commit is contained in:
Kloon ImKloon 2023-08-28 19:31:12 +02:00
parent 7c91ba03b7
commit 85fe716031
No known key found for this signature in database
GPG Key ID: CCF1C86A995C5B6A
37 changed files with 65 additions and 51 deletions

View File

@ -203,4 +203,3 @@ export default {
},
};
</script>
@/stores/file@/stores/layout

View File

@ -129,4 +129,3 @@ export default {
},
};
</script>
@/stores/file@/stores/layout

View File

@ -134,6 +134,7 @@ export default {
components: {
ProgressBar,
},
inject: ["$showError"],
computed: {
...mapState(useAuthStore, ["user", "isLoggedIn"]),
...mapState(useLayoutStore, ["show"]),
@ -177,7 +178,7 @@ export default {
methods: {
...mapActions(useLayoutStore, ["closeHovers", "showHover"]),
toRoot() {
this.$router.push({ path: "/files/" });
this.$router.push({ path: "/files" });
this.closeHovers();
},
toSettings() {
@ -191,4 +192,3 @@ export default {
},
};
</script>
@/stores/auth@/stores/layout

View File

@ -257,4 +257,3 @@ export default {
},
};
</script>
@/stores/auth@/stores/file@/stores/layout

View File

@ -27,4 +27,3 @@ export default {
</script>
<style></style>
@/stores/layout

View File

@ -56,4 +56,3 @@ export default {
</script>
<style></style>
@/stores/layout

View File

@ -123,4 +123,3 @@ export default {
},
};
</script>
@/stores/file@/stores/layout

View File

@ -38,6 +38,7 @@ import { useLayoutStore } from "@/stores/layout";
export default {
name: "delete",
inject: ["$showError"],
computed: {
...mapState(useFileStore, [
"isListing",
@ -86,4 +87,3 @@ export default {
},
};
</script>
@/stores/file@/stores/layout

View File

@ -42,4 +42,3 @@ export default {
computed: mapState(useLayoutStore, ["showConfirm"]),
};
</script>
@/stores/layout

View File

@ -140,4 +140,3 @@ export default {
},
};
</script>
@/stores/auth@/stores/file

View File

@ -43,4 +43,3 @@ export default {
},
};
</script>
@/stores/layout

View File

@ -157,4 +157,3 @@ export default {
},
};
</script>
@/stores/file@/stores/layout

View File

@ -105,4 +105,3 @@ export default {
},
};
</script>
@/stores/file@/stores/layout

View File

@ -51,6 +51,7 @@ export default {
name: "",
};
},
inject: ["$showError"],
computed: {
...mapState(useFileStore, ["isFiles", "isListing"]),
},
@ -72,7 +73,7 @@ export default {
try {
await api.post(uri);
this.$router.push({ path: uri });
this.$router.push({ path: `${uri}` });
} catch (e) {
this.$showError(e);
}
@ -82,4 +83,3 @@ export default {
},
};
</script>
@/stores/file@/stores/layout

View File

@ -51,6 +51,7 @@ export default {
name: "",
};
},
inject: ["$showError"],
computed: {
...mapState(useFileStore, ["isFiles", "isListing"]),
},
@ -82,4 +83,3 @@ export default {
},
};
</script>
@/stores/file@/stores/layout

View File

@ -115,4 +115,3 @@ export default {
},
};
</script>
@/stores/layout

View File

@ -113,4 +113,3 @@ export default {
},
};
</script>
@/stores/file@/stores/layout

View File

@ -51,4 +51,3 @@ export default {
},
};
</script>
@/stores/layout

View File

@ -51,4 +51,3 @@ export default {
},
};
</script>
@/stores/layout

View File

@ -257,4 +257,3 @@ export default {
},
};
</script>
@/stores/file@/stores/layout

View File

@ -41,4 +41,3 @@ export default {
},
};
</script>
@/stores/layout

View File

@ -62,4 +62,3 @@ export default {
},
};
</script>
@/stores/upload

View File

@ -1,5 +1,7 @@
import "whatwg-fetch";
import cssVars from "css-vars-ponyfill";
import Noty from "noty";
import { disableExternal } from "@/utils/constants";
import { createApp } from "vue";
import VueLazyload from "vue-lazyload";
import createPinia from "@/stores";
@ -33,4 +35,53 @@ app.directive("focus", {
},
});
const notyDefault = {
type: "info",
layout: "bottomRight",
timeout: 1000,
progressBar: true,
};
app.provide("$noty", (opts) => {
new Noty(Object.assign({}, notyDefault, opts)).show();
});
app.provide("$showSuccess", (message) => {
new Noty(
Object.assign({}, notyDefault, {
text: message,
type: "success",
})
).show();
});
app.provide("$showError", (error, displayReport = true) => {
let btns = [
Noty.button(i18n.global.t("buttons.close"), "", function () {
n.close();
}),
];
if (!disableExternal && displayReport) {
btns.unshift(
Noty.button(i18n.global.t("buttons.reportIssue"), "", function () {
window.open(
"https://github.com/filebrowser/filebrowser/issues/new/choose"
);
})
);
}
let n = new Noty(
Object.assign({}, notyDefault, {
text: error.message || error,
type: "error",
timeout: null,
buttons: btns,
})
);
n.show();
});
router.isReady().then(() => app.mount("#app"));

View File

@ -142,15 +142,9 @@ const routes = [
showHeader: true,
},
},
// {
// path: "/files",
// redirect: {
// path: "/files/",
// },
// },
{
path: "/:catchAll(.*)*",
redirect: (to) => `/files${to.params.catchAll}`,
redirect: (to) => `/files/${[...to.params.catchAll].join("/")}`,
},
];

View File

@ -1,7 +1,6 @@
import { defineStore } from "pinia";
import { useRouterStore } from "./router";
// import { useAuthPreferencesStore } from "./auth-preferences";
// import { useAuthEmailStore } from "./auth-email";
import { useLayoutStore } from "./layout";
export const useFileStore = defineStore("file", {
// convert to a function
@ -13,17 +12,17 @@ export const useFileStore = defineStore("file", {
multiple: false,
}),
getters: {
// user and jwt getter removed, no longer needed
selectedCount: (state) => state.selected.length,
route: () => {
const routerStore = useRouterStore();
return routerStore.router.currentRoute;
},
isFiles(state) {
return !state.loading && this.route.name === "Files";
isFiles: (state) => {
const layoutStore = useLayoutStore();
return !layoutStore.loading && state.route._value.name === "Files";
},
isListing(state) {
return this.isFiles && state.req.isDir;
isListing: (state) => {
return state.isFiles && state.req.isDir;
},
},
actions: {

View File

@ -123,7 +123,7 @@ export default {
if (
clean(res.path) !==
clean(`/${this.$route.params.path}`).replace(/,/g, "/")
clean(`/${[...this.$route.params.path].join("/")}`)
) {
throw new Error("Data Mismatch!");
}
@ -146,4 +146,3 @@ export default {
},
};
</script>
@/stores/file@/stores/layout

View File

@ -52,4 +52,3 @@ export default {
},
};
</script>
@/stores/auth@/stores/layout@/stores/file

View File

@ -66,4 +66,3 @@ export default {
},
};
</script>
@/stores/auth@/stores/file

View File

@ -360,4 +360,3 @@ export default {
},
};
</script>
@/stores/file@/stores/layout

View File

@ -146,4 +146,3 @@ export default {
},
};
</script>
@/stores/auth@/stores/file

View File

@ -905,4 +905,3 @@ export default {
},
};
</script>
@/stores/auth@/stores/clipboard@/stores/file@/stores/layout

View File

@ -360,4 +360,3 @@ export default {
},
};
</script>
@/stores/auth@/stores/file@/stores/layout

View File

@ -368,4 +368,3 @@ export default {
},
};
</script>
@/stores/auth@/stores/file

View File

@ -168,4 +168,3 @@ export default {
},
};
</script>
@/stores/auth@/stores/file

View File

@ -143,4 +143,3 @@ export default {
},
};
</script>
@/stores/auth@/stores/file

View File

@ -173,4 +173,3 @@ export default {
},
};
</script>
@/stores/auth@/stores/file@/stores/layout

View File

@ -74,4 +74,3 @@ export default {
},
};
</script>
@/stores/file