Skip to content

Commit

Permalink
feat: extract local constants to LOCAL_KEY file
Browse files Browse the repository at this point in the history
  • Loading branch information
flingyp committed Jan 16, 2024
1 parent d833098 commit eeb61b9
Show file tree
Hide file tree
Showing 22 changed files with 60 additions and 71 deletions.
2 changes: 1 addition & 1 deletion public/config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"buildTime": 1705375061773
"buildTime": 1705385063201
}
37 changes: 37 additions & 0 deletions src/common/LOCAL_KEY.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { HandleRouteForm } from '~/types';

// system login route name
export const LOGIN_ROUTE_NAME = 'SystemAuth';

// not found 404 route name
export const NOT_FOUND_404_ROUTE_NAME = 'SystemNotFound';

// system home route name
export const SYSTEM_HOME_ROUTE_NAME = 'SystemAboutIndex';

// system white routes list
export const WHITE_ROUTE_LIST: string[] = [LOGIN_ROUTE_NAME];

// system handle route form
export const HANDLE_ROUTE_FORM: HandleRouteForm = 'SERVER';

// session storage auth token key
export const AUTH_TOKEN = 'AUTH_TOKEN';

// local storage tab menu key
export const TAB_MENU_KEY = 'TAB_MENU_KEY';

// local theme mode key
export const THEME_MODE_KEY = 'vueuse-color-scheme';

// local primary color key
export const PRIMARY_COLOR_KEY = 'PRIMARY_COLOR_KEY';

// local system config key
export const LOCAL_SYSTEM_KEY = 'LOCAL_SYSTEM_KEY';

// local reload content key
export const IS_RELOAD_CONTENT = 'IS_RELOAD_CONTENT';

// driver.js plugin config key
export const DRIVER_CONFIG_KEY = 'IS_DRIVER_CONFIG';
1 change: 1 addition & 0 deletions src/common/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './LOCAL_KEY'
2 changes: 1 addition & 1 deletion src/composables/common/useApp/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useGetLocalKey } from '@flypeng/tool/browser';
import { internationalReg, changeDayjsLocales } from '~/utils';
import { THEME_MODE_KEY } from '~/vadmire.config';
import { THEME_MODE_KEY } from '~/common';

// To do things when init application
export function useApp() {
Expand Down
2 changes: 1 addition & 1 deletion src/composables/common/useDriver/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useSetLocalKey } from '@flypeng/tool/browser';
import Driver, { Step } from 'driver.js';
import { DRIVER_CONFIG_KEY } from '~/vadmire.config';
import { DRIVER_CONFIG_KEY } from '~/common';

// More details reference https://github.com/kamranahmedse/driver.js
const driver = new Driver({
Expand Down
2 changes: 1 addition & 1 deletion src/layout/components/GlobalSetting.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { useSetLocalKey } from '@flypeng/tool/browser';
import { LOCAL_SYSTEM_KEY } from '~/vadmire.config';
import { LOCAL_SYSTEM_KEY } from '~/common';
import BaseThemeMode from './setting/BaseThemeMode.vue';
import BaseSystemName from './setting/BaseSystemName.vue';
Expand Down
2 changes: 1 addition & 1 deletion src/layout/components/layout/BasePersonalCenter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { DropdownOption } from 'naive-ui';
import AvatarLogo from '~/assets/img/avatar-logo.png';
import BaseHeaderItem from './BaseHeaderItem.vue';
import { LOGIN_ROUTE_NAME } from '~/vadmire.config';
import { LOGIN_ROUTE_NAME } from '~/common';
const router = useRouter();
const routeMenuStore = useRouteMenuStore();
Expand Down
2 changes: 1 addition & 1 deletion src/layout/components/layout/BaseSwitchLocale.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { useGetLocalKey, useSetLocalKey } from '@flypeng/tool/browser';
import { LOCAL_SYSTEM_KEY } from '~/vadmire.config';
import { LOCAL_SYSTEM_KEY } from '~/common';
import { Locales } from '~/types';
import BaseHeaderItem from './BaseHeaderItem.vue';
Expand Down
2 changes: 1 addition & 1 deletion src/layout/components/layout/BaseTabBarIcon.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { IS_RELOAD_CONTENT } from '~/vadmire.config';
import { IS_RELOAD_CONTENT } from '~/common';
const isReloadContent = inject<Ref<boolean>>(IS_RELOAD_CONTENT);
const { setLoading: setGlobalLoading } = inject('loading') as { setLoading: (value: boolean) => void };
Expand Down
2 changes: 1 addition & 1 deletion src/layout/components/setting/BaseThemeColor.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { useSetLocalKey } from '@flypeng/tool/browser';
import { PRIMARY_COLOR_KEY } from '~/vadmire.config';
import { PRIMARY_COLOR_KEY } from '~/common';
const { primaryColor } = storeToRefs(useVAdmireConfigStore());
Expand Down
2 changes: 1 addition & 1 deletion src/layout/mode/GlobalContent.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { IS_RELOAD_CONTENT } from '~/vadmire.config';
import { IS_RELOAD_CONTENT } from '~/common';
import GlobalTabBar from '~/layout/components/GlobalTabBar.vue';
const vadmireConfigStore = useVAdmireConfigStore();
Expand Down
3 changes: 2 additions & 1 deletion src/modules/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { App } from 'vue';
import { createI18n } from 'vue-i18n';
import { useGetLocalKey } from '@flypeng/tool/browser';
import { CN, EN, KR } from '~/locales';
import { defaultVAdmireConfig, LOCAL_SYSTEM_KEY } from '~/vadmire.config';
import { defaultVAdmireConfig } from '~/vadmire.config';
import { LOCAL_SYSTEM_KEY } from '~/common';

const { defaultLocales } = defaultVAdmireConfig();

Expand Down
2 changes: 1 addition & 1 deletion src/requests/modules-mock/base-table.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AUTH_TOKEN } from '~/vadmire.config';
import { AUTH_TOKEN } from '~/common';

interface TableParams {
page: number;
Expand Down
2 changes: 1 addition & 1 deletion src/requests/modules-mock/system-auth.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { VAdmireRoute } from 'vue-router';
import { AUTH_TOKEN } from '~/vadmire.config';
import { AUTH_TOKEN } from '~/common';

/**
* System auth login
Expand Down
8 changes: 1 addition & 7 deletions src/router/global-route-guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@ import { useCommonType, useDeepClone } from '@flypeng/tool/browser';
import { RouteMenuStore, useRouteMenuStore } from '~/store';
import { ASYNC_ROUTES, CONSTANT_ROUTES, MATCH_404_ROUTES } from './modules';
import { getSystemAccountInfo, getSystemAccountAsyncRoutes } from '~/requests';
import {
AUTH_TOKEN,
WHITE_ROUTE_LIST,
HANDLE_ROUTE_FORM,
LOGIN_ROUTE_NAME,
SYSTEM_HOME_ROUTE_NAME,
} from '~/vadmire.config';
import { AUTH_TOKEN, WHITE_ROUTE_LIST, HANDLE_ROUTE_FORM, LOGIN_ROUTE_NAME, SYSTEM_HOME_ROUTE_NAME } from '~/common';
import {
filterRoutes,
vadmireRouteToRouteRecordRaw,
Expand Down
2 changes: 1 addition & 1 deletion src/router/modules/constant-routes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { VAdmireRoute } from 'vue-router';
import { LOGIN_ROUTE_NAME, NOT_FOUND_404_ROUTE_NAME } from '~/vadmire.config';
import { LOGIN_ROUTE_NAME, NOT_FOUND_404_ROUTE_NAME } from '~/common';

export const CONSTANT_ROUTES: VAdmireRoute[] = [
{
Expand Down
2 changes: 1 addition & 1 deletion src/store/route-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { RouteRecordRaw, VAdmireRoute } from 'vue-router';
import { useGetLocalKey, useSetLocalKey } from '@flypeng/tool/browser';

import { SystemAccountInfo } from '~/requests';
import { TAB_MENU_KEY } from '~/vadmire.config';
import { TAB_MENU_KEY } from '~/common';

export interface RouteMenuStore {
account: SystemAccountInfo;
Expand Down
12 changes: 2 additions & 10 deletions src/store/vadmire-config.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
import { defineStore } from 'pinia';
import { GlobalThemeOverrides } from 'naive-ui';
import { useGetLocalKey, useRemoveLocalKey } from '@flypeng/tool/browser';

import { getDifSceneColor } from '~/utils';
import {
defaultVAdmireConfig,
AUTH_TOKEN,
THEME_MODE_KEY,
sceneColorMap,
PRIMARY_COLOR_KEY,
LOCAL_SYSTEM_KEY,
DRIVER_CONFIG_KEY,
} from '~/vadmire.config';
import { defaultVAdmireConfig, sceneColorMap } from '~/vadmire.config';
import { AUTH_TOKEN, THEME_MODE_KEY, PRIMARY_COLOR_KEY, LOCAL_SYSTEM_KEY, DRIVER_CONFIG_KEY } from '~/common';
import { VAdmireConfig } from '~/types';

const localVAdmireConfig = { ...defaultVAdmireConfig(), ...JSON.parse(useGetLocalKey(LOCAL_SYSTEM_KEY) || '{}') };
Expand Down
38 changes: 1 addition & 37 deletions src/vadmire.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { HandleRouteForm, VAdmireConfig } from './types';
import type { VAdmireConfig } from './types';
import type { ColorType } from './utils';

// different scene color
Expand Down Expand Up @@ -32,39 +32,3 @@ export function defaultVAdmireConfig(): VAdmireConfig {
defaultLocales: 'zh_CN',
};
}

// system login route name
export const LOGIN_ROUTE_NAME = 'SystemAuth';

// not found 404 route name
export const NOT_FOUND_404_ROUTE_NAME = 'SystemNotFound';

// system home route name
export const SYSTEM_HOME_ROUTE_NAME = 'SystemAboutIndex';

// system white routes list
export const WHITE_ROUTE_LIST: string[] = [LOGIN_ROUTE_NAME];

// system handle route form
export const HANDLE_ROUTE_FORM: HandleRouteForm = 'SERVER';

// session storage auth token key
export const AUTH_TOKEN = 'AUTH_TOKEN';

// local storage tab menu key
export const TAB_MENU_KEY = 'TAB_MENU_KEY';

// local theme mode key
export const THEME_MODE_KEY = 'vueuse-color-scheme';

// local primary color key
export const PRIMARY_COLOR_KEY = 'PRIMARY_COLOR_KEY';

// local system config key
export const LOCAL_SYSTEM_KEY = 'LOCAL_SYSTEM_KEY';

// local reload content key
export const IS_RELOAD_CONTENT = 'IS_RELOAD_CONTENT';

// driver.js plugin config key
export const DRIVER_CONFIG_KEY = 'IS_DRIVER_CONFIG';
2 changes: 1 addition & 1 deletion src/views/auth/components/SystemLogin.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import SystemPlatformAuth from './SystemPlatformAuth.vue';
import { useVAdmireConfigStore } from '~/store';
import { AUTH_TOKEN, SYSTEM_HOME_ROUTE_NAME } from '~/vadmire.config';
import { AUTH_TOKEN, SYSTEM_HOME_ROUTE_NAME } from '~/common';
import { SignInModelData, getSignInAuthToken } from '~/requests';
import Logo from '~/assets/svg/admire-logo.svg';
import { routeGenerateMenuProcess } from '~/router/global-route-guard';
Expand Down
2 changes: 1 addition & 1 deletion src/views/common/NotFound.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import NotFoundIcon from '~/assets/svg/not-found.svg';
import { SYSTEM_HOME_ROUTE_NAME } from '~/vadmire.config';
import { SYSTEM_HOME_ROUTE_NAME } from '~/common';
const router = useRouter();
const vadmireConfigStore = useVAdmireConfigStore();
Expand Down
2 changes: 1 addition & 1 deletion src/views/common/ServerDown.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import ServerDownIcon from '~/assets/svg/server-down.svg';
import { SYSTEM_HOME_ROUTE_NAME } from '~/vadmire.config';
import { SYSTEM_HOME_ROUTE_NAME } from '~/common';
const router = useRouter();
const vadmireConfigStore = useVAdmireConfigStore();
Expand Down

0 comments on commit eeb61b9

Please sign in to comment.