nuxt-glorious 0.7.9-7
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +29 -0
- package/dist/module.cjs +5 -0
- package/dist/module.d.mts +7 -0
- package/dist/module.d.ts +7 -0
- package/dist/module.json +5 -0
- package/dist/module.mjs +93 -0
- package/dist/runtime/assets/icons/glorious-arrow.svg +3 -0
- package/dist/runtime/assets/icons/glorious-check-fill.svg +10 -0
- package/dist/runtime/assets/icons/glorious-x.svg +3 -0
- package/dist/runtime/assets/style/components/buttons.css +88 -0
- package/dist/runtime/assets/style/components/drawer.css +55 -0
- package/dist/runtime/assets/style/components/dropdown.css +18 -0
- package/dist/runtime/assets/style/components/editor.css +4 -0
- package/dist/runtime/assets/style/components/file.css +65 -0
- package/dist/runtime/assets/style/components/input.css +91 -0
- package/dist/runtime/assets/style/components/modal.css +46 -0
- package/dist/runtime/assets/style/components/paginate.css +17 -0
- package/dist/runtime/assets/style/components/select.css +54 -0
- package/dist/runtime/assets/style/components/tab.css +9 -0
- package/dist/runtime/assets/style/components/textarea.css +64 -0
- package/dist/runtime/components/G/Breadcrump.vue +41 -0
- package/dist/runtime/components/G/Button.vue +163 -0
- package/dist/runtime/components/G/CountDown.vue +65 -0
- package/dist/runtime/components/G/Drawer.vue +80 -0
- package/dist/runtime/components/G/Dropdown.vue +63 -0
- package/dist/runtime/components/G/File.vue +142 -0
- package/dist/runtime/components/G/Icon/index.vue +142 -0
- package/dist/runtime/components/G/Input.vue +269 -0
- package/dist/runtime/components/G/IntersectionObserve.vue +22 -0
- package/dist/runtime/components/G/Loading.vue +35 -0
- package/dist/runtime/components/G/Modal.vue +92 -0
- package/dist/runtime/components/G/Paginate.vue +130 -0
- package/dist/runtime/components/G/Radio.vue +38 -0
- package/dist/runtime/components/G/Select.vue +145 -0
- package/dist/runtime/components/G/Tab.vue +57 -0
- package/dist/runtime/components/G/Wizard.vue +123 -0
- package/dist/runtime/components/G/textarea.vue +141 -0
- package/dist/runtime/composables/useGloriousAppSetting.d.ts +11 -0
- package/dist/runtime/composables/useGloriousAppSetting.mjs +37 -0
- package/dist/runtime/composables/useGloriousFetch.d.ts +13 -0
- package/dist/runtime/composables/useGloriousFetch.mjs +107 -0
- package/dist/runtime/composables/useGloriousHead.d.ts +8 -0
- package/dist/runtime/composables/useGloriousHead.mjs +33 -0
- package/dist/runtime/middlewares/Auth.d.ts +2 -0
- package/dist/runtime/middlewares/Auth.mjs +37 -0
- package/dist/runtime/middlewares/AuthStrategy.d.ts +2 -0
- package/dist/runtime/middlewares/AuthStrategy.mjs +17 -0
- package/dist/runtime/plugins/Drawer.d.ts +2 -0
- package/dist/runtime/plugins/Drawer.mjs +35 -0
- package/dist/runtime/plugins/Modal.d.ts +2 -0
- package/dist/runtime/plugins/Modal.mjs +38 -0
- package/dist/runtime/plugins/TailwindColor.d.ts +6 -0
- package/dist/runtime/plugins/TailwindColor.mjs +10 -0
- package/dist/runtime/plugins/glorious-app-setting.d.ts +2 -0
- package/dist/runtime/plugins/glorious-app-setting.mjs +11 -0
- package/dist/runtime/plugins/shortcut-key.d.ts +2 -0
- package/dist/runtime/plugins/shortcut-key.mjs +11 -0
- package/dist/runtime/stores/GloriousStore.d.ts +9 -0
- package/dist/runtime/stores/GloriousStore.mjs +88 -0
- package/dist/types.d.mts +16 -0
- package/dist/types.d.ts +16 -0
- package/package.json +53 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
import { useSeoMeta } from "@unhead/vue";
|
2
|
+
import { useRuntimeConfig } from "nuxt/app";
|
3
|
+
const head = {
|
4
|
+
title: ``,
|
5
|
+
description: "",
|
6
|
+
image: "",
|
7
|
+
type: "website"
|
8
|
+
};
|
9
|
+
export default function(object = head) {
|
10
|
+
const title = typeof object.title === "undefined" ? head.title : object.title;
|
11
|
+
const description = typeof object.description === "undefined" ? head.description : object.description;
|
12
|
+
const image = typeof object.image === "undefined" ? head.image : object.image;
|
13
|
+
const type = typeof object.type === "undefined" ? head.type : object.type;
|
14
|
+
const moduleConfig = useRuntimeConfig();
|
15
|
+
const seoObject = {
|
16
|
+
title: () => `${title + moduleConfig.public.glorious.seo.suffix}`,
|
17
|
+
ogTitle: () => `${title + moduleConfig.public.glorious.seo.suffix}`,
|
18
|
+
description: () => `${description}`,
|
19
|
+
ogDescription: () => `${description}`,
|
20
|
+
ogType: () => type
|
21
|
+
};
|
22
|
+
if (image !== "")
|
23
|
+
seoObject["image"] = image;
|
24
|
+
if (title === "") {
|
25
|
+
seoObject["title"] = moduleConfig.public.glorious.seo.title;
|
26
|
+
seoObject["ogTitle"] = moduleConfig.public.glorious.seo.title;
|
27
|
+
}
|
28
|
+
if (description === "") {
|
29
|
+
seoObject["description"] = moduleConfig.public.glorious.seo.description;
|
30
|
+
seoObject["ogDescription"] = moduleConfig.public.glorious.seo.description;
|
31
|
+
}
|
32
|
+
useSeoMeta(seoObject);
|
33
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import {
|
2
|
+
callWithNuxt,
|
3
|
+
useNuxtApp,
|
4
|
+
useRequestHeaders,
|
5
|
+
defineNuxtRouteMiddleware,
|
6
|
+
useRuntimeConfig,
|
7
|
+
useCookie,
|
8
|
+
navigateTo
|
9
|
+
} from "#app";
|
10
|
+
export default defineNuxtRouteMiddleware(async () => {
|
11
|
+
const nuxtApp = useNuxtApp();
|
12
|
+
const moduleConfig = useRuntimeConfig();
|
13
|
+
if (process.server) {
|
14
|
+
const { cookie } = await callWithNuxt(
|
15
|
+
nuxtApp,
|
16
|
+
() => useRequestHeaders(["cookie"])
|
17
|
+
);
|
18
|
+
if (typeof cookie !== "undefined") {
|
19
|
+
const cookieSplit = cookie?.split(`;`);
|
20
|
+
const findAuthCookie = cookieSplit.find(
|
21
|
+
(item) => item.includes(moduleConfig.public.glorious.auth.cookie.name)
|
22
|
+
);
|
23
|
+
if (typeof findAuthCookie === "undefined") {
|
24
|
+
return navigateTo(moduleConfig.public.glorious.auth.redirect.login, {
|
25
|
+
redirectCode: 302
|
26
|
+
});
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
if (process.client) {
|
31
|
+
const cookie = useCookie(moduleConfig.public.glorious.auth.cookie.name);
|
32
|
+
if (typeof cookie.value === "undefined")
|
33
|
+
return navigateTo(moduleConfig.public.glorious.auth.redirect.login, {
|
34
|
+
redirectCode: 302
|
35
|
+
});
|
36
|
+
}
|
37
|
+
});
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import {
|
2
|
+
GloriousStore,
|
3
|
+
defineNuxtRouteMiddleware,
|
4
|
+
useCookie,
|
5
|
+
useNuxtApp
|
6
|
+
} from "#imports";
|
7
|
+
export default defineNuxtRouteMiddleware(() => {
|
8
|
+
const nuxtApp = useNuxtApp();
|
9
|
+
const moduleConfig = nuxtApp.$config.public.glorious;
|
10
|
+
const gs = GloriousStore();
|
11
|
+
if (moduleConfig.auth.strategy.provider === "")
|
12
|
+
return;
|
13
|
+
const cookieToken = useCookie(moduleConfig.auth.cookie.name);
|
14
|
+
if (typeof cookieToken.value === "undefined")
|
15
|
+
return;
|
16
|
+
nuxtApp.hook("app:beforeMount", () => gs.authGetUser(cookieToken.value));
|
17
|
+
});
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import { defineNuxtPlugin } from "#app";
|
2
|
+
export default defineNuxtPlugin(() => {
|
3
|
+
const methods = {
|
4
|
+
addBlurBackground: (key) => {
|
5
|
+
const backgroundBlur = document.createElement("div");
|
6
|
+
backgroundBlur.classList.add("bg-blur-drawer");
|
7
|
+
const nuxt = document.getElementById("__nuxt");
|
8
|
+
nuxt.appendChild(backgroundBlur);
|
9
|
+
backgroundBlur.addEventListener("click", () => {
|
10
|
+
const componentId = document.getElementById(key);
|
11
|
+
componentId.classList.replace("open", "close");
|
12
|
+
backgroundBlur.remove();
|
13
|
+
});
|
14
|
+
},
|
15
|
+
drawer: {
|
16
|
+
provide: (key) => {
|
17
|
+
let drawer = document.getElementById(key);
|
18
|
+
if (drawer.classList.contains("close")) {
|
19
|
+
drawer.classList.remove("hidden");
|
20
|
+
drawer.classList.replace("close", "open");
|
21
|
+
methods.addBlurBackground(key);
|
22
|
+
} else {
|
23
|
+
drawer.classList.replace("open", "close");
|
24
|
+
const bgBlur = document.querySelector(".bg-blur-drawer");
|
25
|
+
bgBlur?.remove();
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
29
|
+
};
|
30
|
+
return {
|
31
|
+
provide: {
|
32
|
+
drawer: (key = "drawer") => methods.drawer.provide(key)
|
33
|
+
}
|
34
|
+
};
|
35
|
+
});
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import { defineNuxtPlugin } from "#app";
|
2
|
+
import { GloriousStore } from "../stores/GloriousStore.mjs";
|
3
|
+
export default defineNuxtPlugin(() => {
|
4
|
+
const methods = {
|
5
|
+
addBlurBackground: (key) => {
|
6
|
+
const backgroundBlur = document.createElement("div");
|
7
|
+
backgroundBlur.classList.add("bg-blur-modal");
|
8
|
+
const nuxt = document.getElementById("__nuxt");
|
9
|
+
nuxt.appendChild(backgroundBlur);
|
10
|
+
backgroundBlur.addEventListener("click", () => {
|
11
|
+
const componentId = document.getElementById(key);
|
12
|
+
componentId.classList.replace("open", "close");
|
13
|
+
backgroundBlur.remove();
|
14
|
+
});
|
15
|
+
},
|
16
|
+
modal: {
|
17
|
+
provide: (key, keepData = {}) => {
|
18
|
+
const modal = document.getElementById(key);
|
19
|
+
const gloriousStore = GloriousStore();
|
20
|
+
gloriousStore.keepData = keepData;
|
21
|
+
if (modal?.classList.contains("close")) {
|
22
|
+
modal?.classList.replace("close", "open");
|
23
|
+
modal.style.bottom = `-${modal.offsetHeight}px`;
|
24
|
+
methods.addBlurBackground(key);
|
25
|
+
} else {
|
26
|
+
modal?.classList.add("close");
|
27
|
+
const bgBlur = document.querySelector(".bg-blur-modal");
|
28
|
+
bgBlur?.remove();
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
};
|
33
|
+
return {
|
34
|
+
provide: {
|
35
|
+
modal: (key = "modal", keepData = {}) => methods.modal.provide(key, keepData)
|
36
|
+
}
|
37
|
+
};
|
38
|
+
});
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { defineNuxtPlugin } from "nuxt/app";
|
2
|
+
import colors from "tailwindcss/colors.js";
|
3
|
+
export default defineNuxtPlugin(() => {
|
4
|
+
const tailwindColor = colors;
|
5
|
+
return {
|
6
|
+
provide: {
|
7
|
+
tailwindColor: (color, value) => tailwindColor[color][value]
|
8
|
+
}
|
9
|
+
};
|
10
|
+
});
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { defineNuxtPlugin, useHead } from "#imports";
|
2
|
+
import { useGloriousAppSetting } from "../composables/useGloriousAppSetting.mjs";
|
3
|
+
export default defineNuxtPlugin(() => {
|
4
|
+
const gloriousAppSetting = useGloriousAppSetting.getSetting();
|
5
|
+
useHead({
|
6
|
+
htmlAttrs: {
|
7
|
+
dir: gloriousAppSetting.dir,
|
8
|
+
class: [gloriousAppSetting.darkMode ? "dark" : ""]
|
9
|
+
}
|
10
|
+
});
|
11
|
+
});
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { defineNuxtPlugin } from "#app";
|
2
|
+
import { useGloriousAppSetting } from "../composables/useGloriousAppSetting.mjs";
|
3
|
+
export default defineNuxtPlugin(() => {
|
4
|
+
window.addEventListener("keydown", (ev) => {
|
5
|
+
const html = document.getElementsByTagName("html")[0];
|
6
|
+
if (ev.key === "*")
|
7
|
+
useGloriousAppSetting.setDarkMode();
|
8
|
+
if (ev.key === "-")
|
9
|
+
useGloriousAppSetting.setDir(html.dir === "rtl" ? "ltr" : "rtl");
|
10
|
+
});
|
11
|
+
});
|
@@ -0,0 +1,9 @@
|
|
1
|
+
export declare const GloriousStore: import("pinia").StoreDefinition<"GloriousStore", any, {
|
2
|
+
authIsLogin(): boolean;
|
3
|
+
}, {
|
4
|
+
formCreate(key: string | Array<string>): void;
|
5
|
+
authLogout(): void;
|
6
|
+
authSetToken(token: string, to?: string | null): void;
|
7
|
+
authParseToken(token: any): any;
|
8
|
+
authGetUser(token?: string): void;
|
9
|
+
}>;
|
@@ -0,0 +1,88 @@
|
|
1
|
+
import { defineStore } from "pinia";
|
2
|
+
import { navigateTo, useCookie, useRuntimeConfig, useFetch } from "#imports";
|
3
|
+
export const GloriousStore = defineStore("GloriousStore", {
|
4
|
+
state: () => ({
|
5
|
+
auth: {
|
6
|
+
loaded: false,
|
7
|
+
user: {}
|
8
|
+
},
|
9
|
+
loading: {},
|
10
|
+
keepData: {},
|
11
|
+
forms: {}
|
12
|
+
}),
|
13
|
+
getters: {
|
14
|
+
authIsLogin() {
|
15
|
+
const moduleConfig = useRuntimeConfig();
|
16
|
+
const cookie = useCookie(moduleConfig.public.glorious.auth.cookie.name);
|
17
|
+
return typeof cookie.value !== "undefined";
|
18
|
+
}
|
19
|
+
},
|
20
|
+
actions: {
|
21
|
+
formCreate(key) {
|
22
|
+
this.forms = {};
|
23
|
+
if (typeof key === "string")
|
24
|
+
this.forms[key] = {
|
25
|
+
form: {},
|
26
|
+
errors: []
|
27
|
+
};
|
28
|
+
else
|
29
|
+
key.map((item) => {
|
30
|
+
this.forms[item] = {
|
31
|
+
form: {},
|
32
|
+
errors: []
|
33
|
+
};
|
34
|
+
});
|
35
|
+
},
|
36
|
+
authLogout() {
|
37
|
+
const moduleConfig = useRuntimeConfig();
|
38
|
+
const token = useCookie(moduleConfig.public.glorious.auth.cookie.name);
|
39
|
+
token.value = null;
|
40
|
+
this.auth.loaded = false;
|
41
|
+
navigateTo(moduleConfig.public.glorious.auth.redirect.logout);
|
42
|
+
},
|
43
|
+
authSetToken(token, to = null) {
|
44
|
+
const moduleConfig = useRuntimeConfig();
|
45
|
+
const decodeToken = this.authParseToken(token);
|
46
|
+
const cookie = useCookie(moduleConfig.public.glorious.auth.cookie.name, {
|
47
|
+
expires: new Date(Math.floor(decodeToken.exp * 1e3)),
|
48
|
+
httpOnly: moduleConfig.public.glorious.auth.cookie.httpOnly
|
49
|
+
});
|
50
|
+
cookie.value = token;
|
51
|
+
this.authGetUser(token);
|
52
|
+
if (to)
|
53
|
+
navigateTo(to);
|
54
|
+
},
|
55
|
+
authParseToken(token) {
|
56
|
+
const base64Url = token.split(".")[1];
|
57
|
+
const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
|
58
|
+
const jsonPayload = decodeURIComponent(
|
59
|
+
window.atob(base64).split("").map(function(c) {
|
60
|
+
return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
|
61
|
+
}).join("")
|
62
|
+
);
|
63
|
+
return JSON.parse(jsonPayload);
|
64
|
+
},
|
65
|
+
authGetUser(token = "") {
|
66
|
+
const moduleConfig = useRuntimeConfig();
|
67
|
+
useFetch(
|
68
|
+
moduleConfig.public.glorious.auth.strategy.endpoints.userInfo.url,
|
69
|
+
{
|
70
|
+
lazy: false,
|
71
|
+
baseURL: moduleConfig.public.glorious.fetch.baseURL,
|
72
|
+
headers: {
|
73
|
+
Accept: "application/json",
|
74
|
+
Authorization: "Bearer " + token
|
75
|
+
},
|
76
|
+
method: moduleConfig.public.glorious.auth.strategy.endpoints.userInfo.method
|
77
|
+
}
|
78
|
+
).then((data) => {
|
79
|
+
const pick = moduleConfig.public.glorious.auth.strategy.endpoints.userInfo.pick;
|
80
|
+
if (pick !== "")
|
81
|
+
this.auth.user = data.data.value[pick];
|
82
|
+
else
|
83
|
+
this.auth.user = data.data.value;
|
84
|
+
this.auth.loaded = true;
|
85
|
+
});
|
86
|
+
}
|
87
|
+
}
|
88
|
+
});
|
package/dist/types.d.mts
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
import type { ModuleOptions } from './module.js'
|
3
|
+
|
4
|
+
|
5
|
+
declare module '@nuxt/schema' {
|
6
|
+
interface NuxtConfig { ['glorious']?: Partial<ModuleOptions> }
|
7
|
+
interface NuxtOptions { ['glorious']?: ModuleOptions }
|
8
|
+
}
|
9
|
+
|
10
|
+
declare module 'nuxt/schema' {
|
11
|
+
interface NuxtConfig { ['glorious']?: Partial<ModuleOptions> }
|
12
|
+
interface NuxtOptions { ['glorious']?: ModuleOptions }
|
13
|
+
}
|
14
|
+
|
15
|
+
|
16
|
+
export type { ModuleOptions, default } from './module.js'
|
package/dist/types.d.ts
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
import type { ModuleOptions } from './module'
|
3
|
+
|
4
|
+
|
5
|
+
declare module '@nuxt/schema' {
|
6
|
+
interface NuxtConfig { ['glorious']?: Partial<ModuleOptions> }
|
7
|
+
interface NuxtOptions { ['glorious']?: ModuleOptions }
|
8
|
+
}
|
9
|
+
|
10
|
+
declare module 'nuxt/schema' {
|
11
|
+
interface NuxtConfig { ['glorious']?: Partial<ModuleOptions> }
|
12
|
+
interface NuxtOptions { ['glorious']?: ModuleOptions }
|
13
|
+
}
|
14
|
+
|
15
|
+
|
16
|
+
export type { ModuleOptions, default } from './module'
|
package/package.json
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
{
|
2
|
+
"version": "0.7.9-7",
|
3
|
+
"name": "nuxt-glorious",
|
4
|
+
"description": "This package provides many things needed by a project, including server requests and authentication, SEO and other requirements of a project.",
|
5
|
+
"repository": "sajadhzj/nuxt-glorious",
|
6
|
+
"author": "sajad hossein zadeh (https://github.com/sajadhzj)",
|
7
|
+
"license": "MIT",
|
8
|
+
"exports": {
|
9
|
+
".": {
|
10
|
+
"types": "./dist/types.d.ts",
|
11
|
+
"import": "./dist/module.mjs",
|
12
|
+
"require": "./dist/module.cjs"
|
13
|
+
}
|
14
|
+
},
|
15
|
+
"main": "./dist/module.cjs",
|
16
|
+
"types": "./dist/types.d.ts",
|
17
|
+
"files": [
|
18
|
+
"dist"
|
19
|
+
],
|
20
|
+
"scripts": {
|
21
|
+
"prepack": "nuxt-module-build build",
|
22
|
+
"dev": "nuxi dev playground",
|
23
|
+
"dev:build": "nuxi build playground",
|
24
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
25
|
+
"release": "npm run prepack && npm publish",
|
26
|
+
"lint": "eslint .",
|
27
|
+
"test": "vitest run",
|
28
|
+
"test:watch": "vitest watch"
|
29
|
+
},
|
30
|
+
"dependencies": {
|
31
|
+
"@nuxt/kit": "^3.11.1",
|
32
|
+
"@nuxtjs/tailwindcss": "^6.12.0",
|
33
|
+
"@pinia/nuxt": "^0.5.1",
|
34
|
+
"defu": "^6.1.4",
|
35
|
+
"pinia": "^2.1.7",
|
36
|
+
"sass": "^1.77.5"
|
37
|
+
},
|
38
|
+
"devDependencies": {
|
39
|
+
"@nuxt/devtools": "latest",
|
40
|
+
"@nuxt/eslint-config": "^0.2.0",
|
41
|
+
"@nuxt/module-builder": "^0.5.5",
|
42
|
+
"@nuxt/schema": "^3.11.1",
|
43
|
+
"@nuxt/test-utils": "^3.12.0",
|
44
|
+
"@types/node": "^20.11.29",
|
45
|
+
"changelogen": "^0.5.5",
|
46
|
+
"eslint": "^8.57.0",
|
47
|
+
"nuxt": "^3.11.1",
|
48
|
+
"vitest": "^1.4.0"
|
49
|
+
},
|
50
|
+
"overrides": {
|
51
|
+
"vue": "latest"
|
52
|
+
}
|
53
|
+
}
|