初始化

This commit is contained in:
2026-03-26 20:18:20 +08:00
commit 120a5b4dfd
368 changed files with 35926 additions and 0 deletions

8
src/plugins/app.ts Normal file
View File

@@ -0,0 +1,8 @@
import type { App } from 'vue';
export function setupAppErrorHandle(app: App) {
app.config.errorHandler = (err, vm, info) => {
// eslint-disable-next-line no-console
console.error(err, vm, info);
};
}

8
src/plugins/assets.ts Normal file
View File

@@ -0,0 +1,8 @@
import 'virtual:svg-icons-register';
import 'element-plus/dist/index.css';
import 'element-plus/theme-chalk/dark/css-vars.css';
import 'uno.css';
import '../styles/css/global.css';
import 'swiper/css';
import 'swiper/css/navigation';
import 'swiper/css/pagination';

9
src/plugins/dayjs.ts Normal file
View File

@@ -0,0 +1,9 @@
import { extend } from 'dayjs';
import localeData from 'dayjs/plugin/localeData';
import { setDayjsLocale } from '../locales/dayjs';
export function setupDayjs() {
extend(localeData);
setDayjsLocale();
}

10
src/plugins/iconify.ts Normal file
View File

@@ -0,0 +1,10 @@
import { addAPIProvider } from '@iconify/vue';
/** Setup the iconify offline */
export function setupIconifyOffline() {
const { VITE_ICONIFY_URL } = import.meta.env;
if (VITE_ICONIFY_URL) {
addAPIProvider('', { resources: [VITE_ICONIFY_URL] });
}
}

6
src/plugins/index.ts Normal file
View File

@@ -0,0 +1,6 @@
export * from './loading';
export * from './nprogress';
export * from './iconify';
export * from './dayjs';
export * from './app';
export * from './ui';

51
src/plugins/loading.ts Normal file
View File

@@ -0,0 +1,51 @@
// @unocss-include
import { getRgb } from '@sa/color';
import { DARK_CLASS } from '@/constants/app';
import { localStg } from '@/utils/storage';
import { toggleHtmlClass } from '@/utils/common';
import systemLogo from '@/assets/svg-icon/logo.png';
import { $t } from '@/locales';
export function setupLoading() {
const themeColor = localStg.get('themeColor') || '#646cff';
const darkMode = localStg.get('darkMode') || false;
const { r, g, b } = getRgb(themeColor);
const primaryColor = `--primary-color: ${r} ${g} ${b}`;
if (darkMode) {
toggleHtmlClass(DARK_CLASS).add();
}
const loadingClasses = [
'left-0 top-0',
'left-0 bottom-0 animate-delay-500',
'right-0 top-0 animate-delay-1000',
'right-0 bottom-0 animate-delay-1500'
];
const dot = loadingClasses
.map(item => {
return `<div class="absolute w-16px h-16px bg-primary rounded-8px animate-pulse ${item}"></div>`;
})
.join('\n');
const loading = `
<div class="fixed-center flex-col bg-layout" style="${primaryColor}">
<img src="${systemLogo}" alt="logo" class="h-128px w-128px object-contain" />
<div class="w-56px h-56px my-36px">
<div class="relative h-full animate-spin">
${dot}
</div>
</div>
<h2 class="text-28px font-500 text-primary">${$t('system.title')}</h2>
</div>`;
const app = document.getElementById('app');
if (app) {
app.innerHTML = loading;
}
}

9
src/plugins/nprogress.ts Normal file
View File

@@ -0,0 +1,9 @@
import NProgress from 'nprogress';
/** Setup plugin NProgress */
export function setupNProgress() {
NProgress.configure({ easing: 'ease', speed: 500 });
// mount on window
window.NProgress = NProgress;
}

25
src/plugins/ui.ts Normal file
View File

@@ -0,0 +1,25 @@
import type { App } from 'vue';
import ElementPlus, { ElCard, ElForm, ElTable } from 'element-plus';
/** global table column align */
ElTable.TableColumn.props.align = {
type: String,
default: 'center'
};
/** global ElCard shadow */
ElCard.props.shadow = {
type: String,
default: 'never'
};
/** global ElForm require asterisk position */
ElForm.props.requireAsteriskPosition = {
type: String,
default: 'right'
};
/** full import ElementPlus */
export const setupUI = (app: App) => {
app.use(ElementPlus);
};