add mockjs

This commit is contained in:
KUN1007 2023-05-22 23:42:21 +08:00
parent a3e418523e
commit efa523e51b
4 changed files with 1057 additions and 12 deletions

1050
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -23,6 +23,7 @@
"animate.css": "^4.1.1", "animate.css": "^4.1.1",
"animejs": "^3.2.1", "animejs": "^3.2.1",
"axios": "^1.4.0", "axios": "^1.4.0",
"mockjs": "^1.1.0",
"pinia": "^2.0.35", "pinia": "^2.0.35",
"vue": "^3.2.47", "vue": "^3.2.47",
"vue-i18n": "^9.3.0-beta.17", "vue-i18n": "^9.3.0-beta.17",
@ -33,10 +34,12 @@
"@types/less": "^3.0.3", "@types/less": "^3.0.3",
"@types/node": "^18.15.12", "@types/node": "^18.15.12",
"@vitejs/plugin-vue": "^4.1.0", "@vitejs/plugin-vue": "^4.1.0",
"cross-env": "^7.0.3",
"less": "^4.1.3", "less": "^4.1.3",
"rollup-plugin-visualizer": "^5.9.0", "rollup-plugin-visualizer": "^5.9.0",
"typescript": "^4.9.3", "typescript": "^4.9.3",
"vite": "^4.2.0", "vite": "^4.2.0",
"vite-plugin-mock": "^3.0.0",
"vue-tsc": "^1.2.0" "vue-tsc": "^1.2.0"
}, },
"keywords": [ "keywords": [

View file

@ -14,7 +14,10 @@ import { storeToRefs } from 'pinia'
// i18n // i18n
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
const { t, locale } = useI18n({ useScope: 'global' }) /*
* 网站的语言设置
*/
const { locale } = useI18n({ useScope: 'global' })
const selectedLocale = ref(locale.value) const selectedLocale = ref(locale.value)
// selectedLocaleVue I18nlocale // selectedLocaleVue I18nlocale
@ -24,7 +27,7 @@ watch(selectedLocale, (newVal) => {
// localStorage // localStorage
onMounted(() => { onMounted(() => {
const savedLocale = localStorage.getItem('locale') const savedLocale = localStorage.getItem('KUNGalgame-locale')
if (savedLocale) { if (savedLocale) {
selectedLocale.value = savedLocale selectedLocale.value = savedLocale
} }
@ -32,13 +35,16 @@ onMounted(() => {
// localStorage // localStorage
watch(locale, (newVal) => { watch(locale, (newVal) => {
localStorage.setItem('locale', newVal) localStorage.setItem('KUNGalgame-locale', newVal)
}) })
const changeLanguage = () => { const changeLanguage = () => {
locale.value = selectedLocale.value locale.value = selectedLocale.value
} }
/*
* 设置面板显示切换
*/
// 使 store // 使 store
const settingsStore = useSettingsPanelStore() const settingsStore = useSettingsPanelStore()
const { showSettings } = storeToRefs(settingsStore) const { showSettings } = storeToRefs(settingsStore)

View file

@ -3,10 +3,12 @@ import path, { resolve } from 'path'
import vue from '@vitejs/plugin-vue' import vue from '@vitejs/plugin-vue'
// 引入 Rollup Plugin Visualizer 打包可视化工具 // 引入 Rollup Plugin Visualizer 打包可视化工具
import { visualizer } from 'rollup-plugin-visualizer' import { visualizer } from 'rollup-plugin-visualizer'
// 引入 mock-js
import { viteMockServe } from 'vite-plugin-mock'
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
plugins: [vue(), visualizer() as PluginOption], plugins: [vue(), visualizer() as PluginOption, viteMockServe()],
/* src 别名为 @ */ /* src 别名为 @ */
resolve: { resolve: {
alias: { alias: {