UPDATE: Logo y versión (#2)

This commit is contained in:
Moisés de Jesús Cortés Castellanos 2024-12-16 15:55:10 -06:00 committed by GitHub
parent 1ceb542c61
commit 70b6fe99a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 33 additions and 22 deletions

View File

@ -1,2 +0,0 @@
*
!.gitignore

View File

@ -8,7 +8,7 @@ import { i18n, lang } from '@/lang/i18n.js';
import router from '@Router/Auth' import router from '@Router/Auth'
import Notify from '@Plugins/Notify' import Notify from '@Plugins/Notify'
import TailwindScreen from '@Plugins/TailwindScreen' import TailwindScreen from '@Plugins/TailwindScreen'
import { pagePlugin } from '@Services/Page'; import { defineApp, pagePlugin, reloadApp } from '@Services/Page';
import Auth from '@Holos/Layout/Auth.vue' import Auth from '@Holos/Layout/Auth.vue'
@ -22,16 +22,21 @@ window.TwScreen = new TailwindScreen();
async function boot() { async function boot() {
try { try {
const { data } = await axios.get(import.meta.env.VITE_API_URL + '/api/routes'); const routes = await axios.get(import.meta.env.VITE_API_URL + '/api/resources/routes');
const app = await axios.get(import.meta.env.VITE_API_URL + '/api/resources/app');
// Iniciar rutas // Iniciar rutas
window.Ziggy = data; window.Ziggy = routes.data;
window.route = useRoute(); window.route = useRoute();
defineApp(app.data);
} catch (error) { } catch (error) {
console.error(error); console.error(error);
alert('Failed to load routes'); alert('Failed to load routes');
} }
reloadApp();
createApp(Auth) createApp(Auth)
.use(createPinia()) .use(createPinia())
.use(i18n) .use(i18n)

View File

@ -1,7 +1,6 @@
<script setup> <script setup>
import { onBeforeMount, onMounted } from 'vue'; import { onBeforeMount, onMounted } from 'vue';
import { bootPermissions } from '@Plugins/RolePermission.js'; import { bootPermissions } from '@Plugins/RolePermission.js';
import { reloadApp } from '@Services/Page';
import useDarkMode from '@Stores/DarkMode' import useDarkMode from '@Stores/DarkMode'
import useLeftSidebar from '@Stores/LeftSidebar' import useLeftSidebar from '@Stores/LeftSidebar'
import useNotificationSidebar from '@Stores/NotificationSidebar' import useNotificationSidebar from '@Stores/NotificationSidebar'
@ -23,7 +22,6 @@ defineProps({
/** Ciclos */ /** Ciclos */
onBeforeMount(() => { onBeforeMount(() => {
bootPermissions() bootPermissions()
reloadApp();
}) })
onMounted(()=> { onMounted(()=> {

View File

@ -59,7 +59,7 @@ onMounted(() => {
</div> </div>
<div> <div>
<span> <span>
Versión {{ APP_VERSION }} APP {{ APP_VERSION }} API {{ $page.app.version }}
</span> </span>
</div> </div>
</footer> </footer>

View File

@ -13,6 +13,6 @@ const home = () => router.push(view({ name: 'index' }));
class="flex w-full justify-center items-center space-x-2 cursor-pointer" class="flex w-full justify-center items-center space-x-2 cursor-pointer"
@click="home" @click="home"
> >
<img src="/images/logo.png" class="h-20" /> <img :src="$page.app.logo" class="h-20" />
</div> </div>
</template> </template>

View File

@ -45,7 +45,7 @@ const year = (new Date).getFullYear();
&copy {{year}} {{ APP_COPYRIGHT }} &copy {{year}} {{ APP_COPYRIGHT }}
</p> </p>
<p class="text-center text-xs text-yellow-500 cursor-pointer"> <p class="text-center text-xs text-yellow-500 cursor-pointer">
V{{ APP_VERSION }} APP {{ APP_VERSION }} API {{ $page.app.version }}
</p> </p>
</div> </div>
</div> </div>

View File

@ -9,9 +9,9 @@ import router from '@Router/Index'
import Notify from '@Plugins/Notify' import Notify from '@Plugins/Notify'
import TailwindScreen from '@Plugins/TailwindScreen' import TailwindScreen from '@Plugins/TailwindScreen'
import { pagePlugin } from '@Services/Page'; import { pagePlugin } from '@Services/Page';
import { reloadApp,view } from '@Services/Page';
import App from '@Layouts/AppLayout.vue' import App from '@Layouts/AppLayout.vue'
import { view } from '@Services/Page';
// Configurar axios // Configurar axios
axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
@ -24,10 +24,10 @@ window.TwScreen = new TailwindScreen();
async function boot() { async function boot() {
try { try {
const { data } = await axios.get(import.meta.env.VITE_API_URL + '/api/routes'); const routes = await axios.get(import.meta.env.VITE_API_URL + '/api/resources/routes');
// Iniciar rutas // Iniciar rutas
window.Ziggy = data; window.Ziggy = routes.data;
window.route = useRoute(); window.route = useRoute();
window.view = view; window.view = view;
} catch (error) { } catch (error) {
@ -39,6 +39,8 @@ async function boot() {
await import('@Services/Broadcast') await import('@Services/Broadcast')
} }
reloadApp();
createApp(App) createApp(App)
.use(createPinia()) .use(createPinia())
.use(i18n) .use(i18n)

View File

@ -36,7 +36,6 @@ onMounted(() => {
api.get(apiTo('roles', { user: props.userId }), { api.get(apiTo('roles', { user: props.userId }), {
onSuccess: (r) => { onSuccess: (r) => {
console.log(r);
form.roles = r.roles form.roles = r.roles
} }
}); });

View File

@ -41,8 +41,6 @@ watch(twoFactorEnabled, () => {
const enableTwoFactorAuthentication = () => { const enableTwoFactorAuthentication = () => {
enabling.value = true; enabling.value = true;
console.log('enabling ...');
api.post(route('two-factor.enable'), { api.post(route('two-factor.enable'), {
onSuccess: () => Promise.all([ onSuccess: () => Promise.all([
showQrCode(), showQrCode(),

View File

@ -22,7 +22,6 @@ const updatePassword = () => {
Notify.success(Lang('account.password.updated')); Notify.success(Lang('account.password.updated'));
}, },
onError: (e) => { onError: (e) => {
console.log(e);
if (form.errors.password) { if (form.errors.password) {
form.reset('password', 'password_confirmation'); form.reset('password', 'password_confirmation');
passwordInput.value.focus(); passwordInput.value.focus();

View File

@ -10,6 +10,7 @@ import { resetPermissions } from '@Plugins/RolePermission';
*/ */
const page = reactive({ const page = reactive({
lang: 'es', lang: 'es',
app: {},
user: { user: {
id: 0, id: 0,
name: 'public' name: 'public'
@ -21,10 +22,15 @@ const page = reactive({
*/ */
const reloadApp = () => { const reloadApp = () => {
const user = localStorage.user const user = localStorage.user
const app = localStorage.app
if(user) { if(user) {
page.user = JSON.parse(user); page.user = JSON.parse(user);
} }
if(app) {
page.app = JSON.parse(app);
}
} }
/** /**
@ -62,6 +68,13 @@ const defineUser = (user) => {
}); });
} }
/**
* Definir datos de la aplicación
*/
const defineApp = (app) => {
localStorage.app = JSON.stringify(app);
}
/** /**
* Instalar el componente de forma nativa * Instalar el componente de forma nativa
*/ */
@ -76,8 +89,6 @@ const pagePlugin = {
* Reload user * Reload user
*/ */
const reloadUser = () => { const reloadUser = () => {
console.log('reloadUser')
return api.get(route('user.show'), { return api.get(route('user.show'), {
onSuccess: (r) => { onSuccess: (r) => {
defineUser(r.user) defineUser(r.user)
@ -107,10 +118,11 @@ const logout = () => {
export { export {
pagePlugin, pagePlugin,
page, page,
defineApp,
defineUser,
reloadApp, reloadApp,
reloadUser, reloadUser,
resetPage, resetPage,
defineUser,
logout, logout,
view view
} }