publish: 发布2.7.4版本Beta (#1880)
* 媒体库增加批量导入URL * fix 描述错误 * feature: 自动化代码方法支持增加方法描述 * update: 更新依赖,升级为最新版本 * feature: 自动化代码预览部分支持黑夜模式 * fixed: 修复keepalive上线后失效的bug * feature: 增加自动化基础模板功能 * feature: 增加自动化基础模板功能 * 将用户配置保存到数据库,刷新或者异地登录配置不丢失 * update: 清除无用的userinfo配置信息 * fixed: 清理开发阶段页面无端进入404的bug * feature: 前端主题配置跟随用户,不再单独设置json编译生效。 * feature: 增加个人中心配置兼容性 * fix(package): 包名设置为中文会导致无法自动生成代码,禁止包名设置为中文 * feature: 格式化代码 * feature: 对严格模式新建根角色进行调整。 * feature: 版本变更为2.7.4 --------- Co-authored-by: sliboy <34034053+sliboy@users.noreply.github.com> Co-authored-by: ba0ch3ng <ba0ch3ng@foxmail.com> Co-authored-by: task <121913992@qq.com> Co-authored-by: task <ms.yangdan@gmail.com> Co-authored-by: 爱丽-黑子 <62006632+ailiheizi@users.noreply.github.com> Co-authored-by: sliboy <sliboy@hotmail.com>
This commit is contained in:
co-authored by
sliboy
ba0ch3ng
task
task
爱丽-黑子
sliboy
parent
df3fc0a9ef
commit
c20ea7e030
@@ -1,49 +1,24 @@
|
||||
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref, watchEffect, reactive } from 'vue'
|
||||
import originSetting from "@/config.json"
|
||||
import { setBodyPrimaryColor } from '@/utils/format'
|
||||
export const useAppStore = defineStore('app', () => {
|
||||
const theme = ref(localStorage.getItem('theme') || originSetting.darkMode || 'auto')
|
||||
|
||||
const device = ref("")
|
||||
const config = reactive({
|
||||
weakness: false,
|
||||
grey: false,
|
||||
primaryColor: '#79B6E7',
|
||||
primaryColor: '#3b82f6',
|
||||
showTabs: true,
|
||||
darkMode: 'light',
|
||||
darkMode: 'auto',
|
||||
layout_side_width : 256,
|
||||
layout_side_collapsed_width : 80,
|
||||
layout_side_item_height : 48,
|
||||
show_watermark: false,
|
||||
|
||||
show_watermark: true,
|
||||
side_mode : 'normal'
|
||||
})
|
||||
|
||||
// 初始化配置
|
||||
Object.keys(originSetting).forEach(key => {
|
||||
config[key] = originSetting[key]
|
||||
if(key === 'primaryColor'){
|
||||
setBodyPrimaryColor(originSetting[key],config.darkMode)
|
||||
}
|
||||
})
|
||||
|
||||
if (localStorage.getItem('darkMode')) {
|
||||
config.darkMode = localStorage.getItem('darkMode')
|
||||
}
|
||||
|
||||
|
||||
watchEffect(() =>{
|
||||
if (theme.value === 'dark'){
|
||||
document.documentElement.classList.add('dark');
|
||||
document.documentElement.classList.remove('light');
|
||||
localStorage.setItem('theme', 'dark');
|
||||
}else{
|
||||
document.documentElement.classList.add('light');
|
||||
document.documentElement.classList.remove('dark');
|
||||
localStorage.setItem('theme', 'light');
|
||||
}
|
||||
})
|
||||
const theme = ref( 'auto')
|
||||
|
||||
const toggleTheme = (dark) => {
|
||||
if (dark) {
|
||||
@@ -55,25 +30,14 @@ export const useAppStore = defineStore('app', () => {
|
||||
|
||||
const toggleWeakness = (e) => {
|
||||
config.weakness = e;
|
||||
if(e) {
|
||||
document.documentElement.classList.add('html-weakenss');
|
||||
}else{
|
||||
document.documentElement.classList.remove('html-weakenss');
|
||||
}
|
||||
}
|
||||
|
||||
const toggleGrey = (e) => {
|
||||
config.grey = e;
|
||||
if(e) {
|
||||
document.documentElement.classList.add('html-grey');
|
||||
}else{
|
||||
document.documentElement.classList.remove('html-grey');
|
||||
}
|
||||
}
|
||||
|
||||
const togglePrimaryColor = (e) => {
|
||||
config.primaryColor = e;
|
||||
setBodyPrimaryColor(e,config.darkMode)
|
||||
}
|
||||
|
||||
const toggleTabs = (e) => {
|
||||
@@ -86,12 +50,6 @@ export const useAppStore = defineStore('app', () => {
|
||||
|
||||
const toggleDarkMode = (e) => {
|
||||
config.darkMode = e
|
||||
localStorage.setItem('darkMode', e)
|
||||
if(e === 'dark'){
|
||||
toggleTheme(true)
|
||||
}else{
|
||||
toggleTheme(false)
|
||||
}
|
||||
}
|
||||
|
||||
const toggleDarkModeAuto = () =>{
|
||||
@@ -124,11 +82,49 @@ export const useAppStore = defineStore('app', () => {
|
||||
config.side_mode = e
|
||||
}
|
||||
|
||||
if(config.darkMode === 'auto'){
|
||||
toggleDarkModeAuto()
|
||||
}
|
||||
watchEffect(() => {
|
||||
if (theme.value === 'dark') {
|
||||
document.documentElement.classList.add('dark');
|
||||
document.documentElement.classList.remove('light');
|
||||
} else {
|
||||
document.documentElement.classList.add('light');
|
||||
document.documentElement.classList.remove('dark');
|
||||
}
|
||||
})
|
||||
watchEffect(() => {
|
||||
// 色弱模式监听处理
|
||||
if (config.weakness) {
|
||||
document.documentElement.classList.add('html-weakenss');
|
||||
} else {
|
||||
document.documentElement.classList.remove('html-weakenss');
|
||||
}
|
||||
})
|
||||
watchEffect(() => {
|
||||
// 灰色模式监听处理
|
||||
if (config.grey) {
|
||||
document.documentElement.classList.add('html-grey');
|
||||
} else {
|
||||
document.documentElement.classList.remove('html-grey');
|
||||
}
|
||||
})
|
||||
|
||||
toggleGrey(config.grey)
|
||||
|
||||
|
||||
watchEffect(() => {
|
||||
if(config.darkMode === 'auto'){
|
||||
toggleDarkModeAuto()
|
||||
}
|
||||
|
||||
if(config.darkMode === 'dark'){
|
||||
toggleTheme(true)
|
||||
}else{
|
||||
toggleTheme(false)
|
||||
}
|
||||
})
|
||||
|
||||
watchEffect(() => {
|
||||
setBodyPrimaryColor(config.primaryColor, theme.value)
|
||||
})
|
||||
|
||||
return {
|
||||
theme,
|
||||
|
||||
@@ -31,9 +31,7 @@ const KeepAliveFilter = (routes) => {
|
||||
routes && routes.forEach(item => {
|
||||
// 子菜单中有 keep-alive 的,父菜单也必须 keep-alive,否则无效。这里将子菜单中有 keep-alive 的父菜单也加入。
|
||||
if ((item.children && item.children.some(ch => ch.meta.keepAlive) || item.meta.keepAlive)) {
|
||||
const regex = /\(\) => import\("([^?]+)\??.*"\)/;
|
||||
const match = String(item.component).match(regex);
|
||||
const path = match ? match[1] : "";
|
||||
const path = item.meta.path
|
||||
keepAliveRoutersArr.push(pathInfo[path])
|
||||
nameMap[item.name] = pathInfo[path]
|
||||
}
|
||||
|
||||
@@ -7,7 +7,10 @@ import { ref, computed, watch } from 'vue'
|
||||
import { useRouterStore } from './router'
|
||||
import cookie from 'js-cookie'
|
||||
|
||||
import {useAppStore} from "@/pinia";
|
||||
|
||||
export const useUserStore = defineStore('user', () => {
|
||||
const appStore = useAppStore()
|
||||
const loadingInstance = ref(null)
|
||||
|
||||
const userInfo = ref({
|
||||
@@ -15,22 +18,25 @@ export const useUserStore = defineStore('user', () => {
|
||||
nickName: '',
|
||||
headerImg: '',
|
||||
authority: {},
|
||||
sideMode: 'dark',
|
||||
baseColor: '#fff'
|
||||
})
|
||||
const token = ref(window.localStorage.getItem('token') || cookie.get('x-token') || '')
|
||||
const setUserInfo = (val) => {
|
||||
userInfo.value = val
|
||||
if(val.originSetting){
|
||||
Object.keys(appStore.config).forEach(key => {
|
||||
appStore.config[key] = val.originSetting[key]
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const setToken = (val) => {
|
||||
token.value = val
|
||||
}
|
||||
|
||||
const NeedInit = () => {
|
||||
const NeedInit = async () => {
|
||||
token.value = ''
|
||||
window.localStorage.removeItem('token')
|
||||
router.push({ name: 'Init', replace: true })
|
||||
await router.push({name: 'Init', replace: true})
|
||||
}
|
||||
|
||||
const ResetUserInfo = (value = {}) => {
|
||||
@@ -89,6 +95,7 @@ export const useUserStore = defineStore('user', () => {
|
||||
window.localStorage.setItem('osType', 'MAC')
|
||||
}
|
||||
|
||||
|
||||
// 全部操作均结束,关闭loading并返回
|
||||
loadingInstance.value.close()
|
||||
return true
|
||||
@@ -114,38 +121,8 @@ export const useUserStore = defineStore('user', () => {
|
||||
sessionStorage.clear()
|
||||
window.localStorage.removeItem('token')
|
||||
cookie.remove('x-token')
|
||||
localStorage.removeItem('originSetting')
|
||||
}
|
||||
/* 设置侧边栏模式*/
|
||||
const changeSideMode = async(data) => {
|
||||
const res = await setSelfInfo({ sideMode: data })
|
||||
if (res.code === 0) {
|
||||
userInfo.value.sideMode = data
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: '设置成功'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const mode = computed(() => userInfo.value.sideMode)
|
||||
const sideMode = computed(() => {
|
||||
if (userInfo.value.sideMode === 'dark') {
|
||||
return '#191a23'
|
||||
} else if (userInfo.value.sideMode === 'light') {
|
||||
return '#fff'
|
||||
} else {
|
||||
return userInfo.value.sideMode
|
||||
}
|
||||
})
|
||||
const baseColor = computed(() => {
|
||||
if (userInfo.value.sideMode === 'dark') {
|
||||
return '#fff'
|
||||
} else if (userInfo.value.sideMode === 'light') {
|
||||
return '#191a23'
|
||||
} else {
|
||||
return userInfo.value.baseColor
|
||||
}
|
||||
})
|
||||
|
||||
watch(() => token.value, () => {
|
||||
window.localStorage.setItem('token', token.value)
|
||||
@@ -159,11 +136,7 @@ export const useUserStore = defineStore('user', () => {
|
||||
GetUserInfo,
|
||||
LoginIn,
|
||||
LoginOut,
|
||||
changeSideMode,
|
||||
mode,
|
||||
sideMode,
|
||||
setToken,
|
||||
baseColor,
|
||||
loadingInstance,
|
||||
ClearStorage
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user