初始化
This commit is contained in:
1
src/plugins/animate.css/index.ts
Normal file
1
src/plugins/animate.css/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
import 'animate.css'
|
||||
98
src/plugins/cache/index.js
vendored
Normal file
98
src/plugins/cache/index.js
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
import router from '@/router'
|
||||
import { name as appName } from '../../../package.json'
|
||||
|
||||
let name = `${appName}-${import.meta.env.VITE_NODE_ENV}`
|
||||
|
||||
const sessionCache = {
|
||||
set(key, value) {
|
||||
if (!sessionStorage) {
|
||||
return
|
||||
}
|
||||
if (key != null && value != null) {
|
||||
let storageStr = sessionStorage.getItem(name)
|
||||
let storage = storageStr ? JSON.parse(storageStr) : {}
|
||||
Reflect.set(storage, key, value)
|
||||
sessionStorage.setItem(name, JSON.stringify(storage))
|
||||
}
|
||||
},
|
||||
get(key) {
|
||||
if (!sessionStorage) {
|
||||
return null
|
||||
}
|
||||
if (key == null) {
|
||||
return null
|
||||
}
|
||||
let storageStr = sessionStorage.getItem(name)
|
||||
let storage = storageStr ? JSON.parse(storageStr) : {}
|
||||
return storage[key]
|
||||
},
|
||||
remove(key) {
|
||||
if (!sessionStorage) {
|
||||
return null
|
||||
}
|
||||
if (key == null) {
|
||||
return null
|
||||
}
|
||||
let storageStr = sessionStorage.getItem(name)
|
||||
let storage = storageStr ? JSON.parse(storageStr) : {}
|
||||
delete storage[key]
|
||||
sessionStorage.setItem(name, JSON.stringify(storage))
|
||||
}
|
||||
}
|
||||
const localCache = {
|
||||
set(key, value) {
|
||||
if (!localStorage) {
|
||||
return
|
||||
}
|
||||
if (key != null && value != null) {
|
||||
let storageStr = localStorage.getItem(name)
|
||||
let storage = storageStr ? JSON.parse(storageStr) : {}
|
||||
Reflect.set(storage, key, value)
|
||||
localStorage.setItem(name, JSON.stringify(storage))
|
||||
}
|
||||
},
|
||||
get(key) {
|
||||
if (!localStorage) {
|
||||
return null
|
||||
}
|
||||
if (key == null) {
|
||||
return null
|
||||
}
|
||||
let storageStr = localStorage.getItem(name)
|
||||
let storage = storageStr ? JSON.parse(storageStr) : {}
|
||||
return storage[key]
|
||||
},
|
||||
remove(key) {
|
||||
if (!localStorage) {
|
||||
return null
|
||||
}
|
||||
if (key == null) {
|
||||
return null
|
||||
}
|
||||
let storageStr = localStorage.getItem(name)
|
||||
let storage = storageStr ? JSON.parse(storageStr) : {}
|
||||
delete storage[key]
|
||||
localStorage.setItem(name, JSON.stringify(storage))
|
||||
}
|
||||
}
|
||||
|
||||
function setParams(params) {
|
||||
sessionCache.set(`${router.currentRoute.value.name}-search`, params)
|
||||
}
|
||||
|
||||
function getParams() {
|
||||
return sessionCache.get(`${router.currentRoute.value.name}-search`)
|
||||
}
|
||||
|
||||
export default {
|
||||
/**
|
||||
* 会话级缓存
|
||||
*/
|
||||
session: sessionCache,
|
||||
/**
|
||||
* 本地缓存
|
||||
*/
|
||||
local: localCache,
|
||||
setParams,
|
||||
getParams
|
||||
}
|
||||
45
src/plugins/echarts/index.ts
Normal file
45
src/plugins/echarts/index.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import * as echarts from 'echarts/core'
|
||||
|
||||
import {
|
||||
BarChart,
|
||||
LineChart,
|
||||
PieChart,
|
||||
MapChart,
|
||||
PictorialBarChart,
|
||||
RadarChart,
|
||||
GaugeChart
|
||||
} from 'echarts/charts'
|
||||
|
||||
import {
|
||||
TitleComponent,
|
||||
TooltipComponent,
|
||||
GridComponent,
|
||||
PolarComponent,
|
||||
AriaComponent,
|
||||
ParallelComponent,
|
||||
LegendComponent,
|
||||
ToolboxComponent
|
||||
} from 'echarts/components'
|
||||
|
||||
import { CanvasRenderer } from 'echarts/renderers'
|
||||
|
||||
echarts.use([
|
||||
LegendComponent,
|
||||
TitleComponent,
|
||||
TooltipComponent,
|
||||
ToolboxComponent,
|
||||
GridComponent,
|
||||
PolarComponent,
|
||||
AriaComponent,
|
||||
ParallelComponent,
|
||||
BarChart,
|
||||
LineChart,
|
||||
PieChart,
|
||||
MapChart,
|
||||
CanvasRenderer,
|
||||
PictorialBarChart,
|
||||
RadarChart,
|
||||
GaugeChart
|
||||
])
|
||||
|
||||
export default echarts
|
||||
17
src/plugins/elementPlus/index.ts
Normal file
17
src/plugins/elementPlus/index.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import type { App } from 'vue'
|
||||
// 需要全局引入一些组件,如ElScrollbar,不然一些下拉项样式有问题
|
||||
import { ElLoading, ElScrollbar, ElButton } from 'element-plus'
|
||||
|
||||
const plugins = [ElLoading]
|
||||
|
||||
const components = [ElScrollbar, ElButton]
|
||||
|
||||
export const setupElementPlus = (app: App<Element>) => {
|
||||
plugins.forEach((plugin) => {
|
||||
app.use(plugin)
|
||||
})
|
||||
|
||||
components.forEach((component) => {
|
||||
app.component(component.name, component)
|
||||
})
|
||||
}
|
||||
43
src/plugins/formCreate/index.ts
Normal file
43
src/plugins/formCreate/index.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import type { App } from 'vue'
|
||||
// 👇使用 form-create 需额外全局引入 element plus 组件
|
||||
import {
|
||||
ElAside,
|
||||
ElPopconfirm,
|
||||
ElHeader,
|
||||
ElMain,
|
||||
ElContainer,
|
||||
ElDivider,
|
||||
ElTransfer,
|
||||
ElAlert,
|
||||
ElTabs,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElTabPane
|
||||
} from 'element-plus'
|
||||
|
||||
import formCreate from '@form-create/element-ui'
|
||||
import install from '@form-create/element-ui/auto-import'
|
||||
|
||||
const components = [
|
||||
ElAside,
|
||||
ElPopconfirm,
|
||||
ElHeader,
|
||||
ElMain,
|
||||
ElContainer,
|
||||
ElDivider,
|
||||
ElTransfer,
|
||||
ElAlert,
|
||||
ElTabs,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElTabPane
|
||||
]
|
||||
|
||||
// 参考 http://www.form-create.com/v3/element-ui/auto-import.html 文档
|
||||
export const setupFormCreate = (app: App<Element>) => {
|
||||
components.forEach((component) => {
|
||||
app.component(component.name, component)
|
||||
})
|
||||
formCreate.use(install)
|
||||
app.use(formCreate)
|
||||
}
|
||||
3
src/plugins/svgIcon/index.ts
Normal file
3
src/plugins/svgIcon/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import 'virtual:svg-icons-register'
|
||||
|
||||
import '@purge-icons/generated'
|
||||
23
src/plugins/tongji/index.ts
Normal file
23
src/plugins/tongji/index.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import router from '@/router'
|
||||
|
||||
// 用于 router push
|
||||
window._hmt = window._hmt || []
|
||||
// HM_ID
|
||||
const HM_ID = import.meta.env.VITE_APP_BAIDU_CODE
|
||||
;(function () {
|
||||
// 有值的时候,才开启
|
||||
if (!HM_ID) {
|
||||
return
|
||||
}
|
||||
const hm = document.createElement('script')
|
||||
hm.src = 'https://hm.baidu.com/hm.js?' + HM_ID
|
||||
const s = document.getElementsByTagName('script')[0]
|
||||
s.parentNode.insertBefore(hm, s)
|
||||
})()
|
||||
|
||||
router.afterEach(function (to) {
|
||||
if (!HM_ID) {
|
||||
return
|
||||
}
|
||||
_hmt.push(['_trackPageview', to.fullPath])
|
||||
})
|
||||
3
src/plugins/vueI18n/helper.ts
Normal file
3
src/plugins/vueI18n/helper.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export const setHtmlPageLang = (locale: LocaleType) => {
|
||||
document.querySelector('html')?.setAttribute('lang', locale)
|
||||
}
|
||||
42
src/plugins/vueI18n/index.ts
Normal file
42
src/plugins/vueI18n/index.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import type { App } from 'vue'
|
||||
import { createI18n } from 'vue-i18n'
|
||||
import { useLocaleStoreWithOut } from '@/store/modules/locale'
|
||||
import type { I18n, I18nOptions } from 'vue-i18n'
|
||||
import { setHtmlPageLang } from './helper'
|
||||
|
||||
export let i18n: ReturnType<typeof createI18n>
|
||||
|
||||
const createI18nOptions = async (): Promise<I18nOptions> => {
|
||||
const localeStore = useLocaleStoreWithOut()
|
||||
const locale = localeStore.getCurrentLocale
|
||||
const localeMap = localeStore.getLocaleMap
|
||||
const defaultLocal = await import(`../../locales/${locale.lang}.ts`)
|
||||
const message = defaultLocal.default ?? {}
|
||||
|
||||
setHtmlPageLang(locale.lang)
|
||||
|
||||
localeStore.setCurrentLocale({
|
||||
lang: locale.lang
|
||||
// elLocale: elLocal
|
||||
})
|
||||
|
||||
return {
|
||||
legacy: false,
|
||||
locale: locale.lang,
|
||||
fallbackLocale: locale.lang,
|
||||
messages: {
|
||||
[locale.lang]: message
|
||||
},
|
||||
availableLocales: localeMap.map((v) => v.lang),
|
||||
sync: true,
|
||||
silentTranslationWarn: true,
|
||||
missingWarn: false,
|
||||
silentFallbackWarn: true
|
||||
}
|
||||
}
|
||||
|
||||
export const setupI18n = async (app: App<Element>) => {
|
||||
const options = await createI18nOptions()
|
||||
i18n = createI18n(options) as I18n
|
||||
app.use(i18n)
|
||||
}
|
||||
3
src/plugins/windi.css/index.ts
Normal file
3
src/plugins/windi.css/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import 'virtual:windi.css'
|
||||
|
||||
import 'virtual:windi-devtools'
|
||||
Reference in New Issue
Block a user