chore(web): 收口前几轮后台改动(品牌 / 媒资上传 / 轮播图 / 类型管理 / 操作日志 / App 用户)
为什么:这些改动在前几轮就已完成并在 :3005 验证过,但一直留在工作区没有入库。 下一步 3-4 的四个页面依赖其中的公共样式入口(src/styles/business/index.css)与 api/admin 的公共类型(PageResult 等),如果不先收口,新页面的提交就会夹带旧改动, 既说不清 diff 边界,也让 index.css 这类多轮共用的文件长期处于半提交状态。 本提交只做归档,不改行为: - 品牌与接口基址改成 FruitShorts / 短剧服务(.env.*、README、vite 代理) - 去掉前端 mock 数据目录(src/data、src/permissions、stores/auth),改为走真实接口 - 新增 api/admin 下的接口封装与 src/utils/uploader.ts(媒资分片直传) - 新增/改造:轮播图管理、类型管理、操作日志、App 用户管理、后台布局与公共样式
This commit is contained in:
1 parent
40546bfd01
commit
44c2c46a68
59 files changed
+4082
-982
No files matched your search
@@ -1,24 +0,0 @@
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
const authenticated = ref(localStorage.getItem('reelshort-auth') === '1')
|
||||
const currentRole = ref('超级管理员')
|
||||
|
||||
export function useAuth() {
|
||||
const isAuthenticated = computed(() => authenticated.value)
|
||||
function login(username, password) {
|
||||
if (username !== 'admin' || password !== 'admin123') return false
|
||||
localStorage.setItem('reelshort-auth', '1')
|
||||
currentRole.value = '超级管理员'
|
||||
authenticated.value = true
|
||||
return true
|
||||
}
|
||||
function logout() {
|
||||
localStorage.removeItem('reelshort-auth')
|
||||
currentRole.value = '超级管理员'
|
||||
authenticated.value = false
|
||||
}
|
||||
function setRole(role) {
|
||||
currentRole.value = role
|
||||
}
|
||||
return { isAuthenticated, currentRole, login, logout, setRole }
|
||||
}
|
||||
+14
-41
@@ -1,44 +1,17 @@
|
||||
import { reactive, computed } from 'vue'
|
||||
import { defaultRolePermissions } from '../permissions/permissions'
|
||||
import { useAuth } from './auth'
|
||||
import { customMenus } from '../data/customMenus'
|
||||
|
||||
const rolePermissions = reactive(
|
||||
Object.fromEntries(
|
||||
Object.entries(defaultRolePermissions).map(([role, list]) => [role, [...list]])
|
||||
)
|
||||
)
|
||||
rolePermissions['超级管理员'].push(...customMenus.map((menu) => menu.permission))
|
||||
import { computed } from 'vue'
|
||||
import { useUserStoreWithOut } from '@/store/modules/user'
|
||||
|
||||
/**
|
||||
* 权限判断:权限码由登录接口下发并存在 user store 中。
|
||||
* 用法:const { can, hasAny } = useRbac(); can('drama:create')
|
||||
*/
|
||||
export function useRbac() {
|
||||
const { currentRole } = useAuth()
|
||||
const permissions = computed(() => rolePermissions[currentRole.value] || [])
|
||||
const can = (permission) => permissions.value.includes(permission)
|
||||
function updateRolePermission(role, permission, enabled) {
|
||||
const current = rolePermissions[role] || (rolePermissions[role] = [])
|
||||
rolePermissions[role] = enabled
|
||||
? [...new Set([...current, permission])]
|
||||
: current.filter((item) => item !== permission)
|
||||
}
|
||||
function createRole(name) {
|
||||
if (!rolePermissions[name]) rolePermissions[name] = []
|
||||
}
|
||||
function createPermission(permission) {
|
||||
rolePermissions['超级管理员'] = [
|
||||
...new Set([...(rolePermissions['超级管理员'] || []), permission])
|
||||
]
|
||||
}
|
||||
function removePermission(permission) {
|
||||
for (const role of Object.keys(rolePermissions))
|
||||
rolePermissions[role] = rolePermissions[role].filter((item) => item !== permission)
|
||||
}
|
||||
return {
|
||||
permissions,
|
||||
can,
|
||||
rolePermissions,
|
||||
updateRolePermission,
|
||||
createRole,
|
||||
createPermission,
|
||||
removePermission
|
||||
}
|
||||
const userStore = useUserStoreWithOut()
|
||||
const permissions = computed(() => {
|
||||
const list = userStore.getUserInfo?.permissions
|
||||
return Array.isArray(list) ? list : []
|
||||
})
|
||||
const can = (code) => permissions.value.includes(code)
|
||||
const hasAny = (...codes) => codes.some((code) => permissions.value.includes(code))
|
||||
return { permissions, can, hasAny }
|
||||
}
|
||||
Reference in new issue
Block a user