add mockjs
This commit is contained in:
parent
8448e5ffeb
commit
9247f6c004
1050
package-lock.json
generated
1050
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -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": [
|
||||||
|
|
|
@ -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)
|
||||||
|
|
||||||
// 监听selectedLocale的变化,并更新Vue I18n的locale
|
// 监听selectedLocale的变化,并更新Vue I18n的locale
|
||||||
|
@ -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)
|
||||||
|
|
|
@ -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: {
|
||||||
|
|
Loading…
Reference in a new issue