mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-10-17 06:55:38 +00:00
feat: 初始化前端项目基础结构
- 添加项目配置文件(tsconfig, eslint, prettier等) - 实现基础路由和页面布局 - 添加全局状态管理和API请求封装 - 集成UI组件库和主题系统 - 添加文档网站和示例页面 - 配置CI/CD和工作流
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* 获取当前页面路径
|
||||
* @returns 当前页面路径
|
||||
*/
|
||||
export function getCurrentPath() {
|
||||
const pages = getCurrentPages()
|
||||
const currentPage = pages[pages.length - 1]
|
||||
return currentPage.route || ''
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* 存储工具类
|
||||
* 提供localStorage和sessionStorage操作方法
|
||||
*/
|
||||
|
||||
/**
|
||||
* localStorage 存储
|
||||
*/
|
||||
function set(key: string, value: any): void {
|
||||
uni.setStorageSync(key, JSON.stringify(value))
|
||||
}
|
||||
|
||||
function get<T>(key: string, defaultValue?: T): T {
|
||||
const value = uni.getStorageSync(key)
|
||||
if (!value)
|
||||
return defaultValue as T
|
||||
|
||||
try {
|
||||
return JSON.parse(value)
|
||||
}
|
||||
catch {
|
||||
// 如果解析失败,返回原始字符串
|
||||
return value as unknown as T
|
||||
}
|
||||
}
|
||||
|
||||
function remove(key: string): void {
|
||||
uni.removeStorageSync(key)
|
||||
}
|
||||
|
||||
export const Storage = {
|
||||
set,
|
||||
get,
|
||||
remove,
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// 跳转到登录页
|
||||
export function toLoginPage(
|
||||
options: { mode?: 'navigateTo' | 'reLaunch' } = {},
|
||||
) {
|
||||
const { mode = 'navigateTo' } = options
|
||||
|
||||
if (mode === 'reLaunch') {
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/index',
|
||||
})
|
||||
}
|
||||
else {
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/index',
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user