Split desktop and mobile layouts with shared page data so APIs fetch once per context.
Add layout shells, desktop views, module-level page caches, and UI fixes for auth, home, wallet, transactions, address, and related pages. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import { computed, inject, provide, type ComputedRef, type InjectionKey } from 'vue'
|
||||
import { useConfigStore } from '@/store/configStore'
|
||||
import {
|
||||
getProjectBaleLink,
|
||||
getProjectSupportPhoneLink,
|
||||
isBoursecuProject,
|
||||
} from '@/utils/config'
|
||||
import { getRulesBlocks, getRulesTitle, type RulesBlock } from '../rulesContent'
|
||||
|
||||
export interface RulesPageContext {
|
||||
config: ReturnType<typeof useConfigStore>
|
||||
nameProject: ComputedRef<string>
|
||||
isBoursecu: ComputedRef<boolean>
|
||||
rulesTitle: ComputedRef<string>
|
||||
rulesBlocks: ComputedRef<RulesBlock[]>
|
||||
getProjectSupportPhoneLink: typeof getProjectSupportPhoneLink
|
||||
getProjectBaleLink: typeof getProjectBaleLink
|
||||
}
|
||||
|
||||
export const RULES_PAGE_CONTEXT_KEY: InjectionKey<RulesPageContext> = Symbol('rulesPageContext')
|
||||
|
||||
export function useRulesPage() {
|
||||
const config = useConfigStore()
|
||||
|
||||
const nameProject = computed(
|
||||
() => config.config?.name_fa || config.config?.name || 'بورس مس',
|
||||
)
|
||||
|
||||
const isBoursecu = computed(() => isBoursecuProject())
|
||||
|
||||
const rulesTitle = computed(() => getRulesTitle(nameProject.value, isBoursecu.value))
|
||||
|
||||
const rulesBlocks = computed(() => getRulesBlocks(nameProject.value, isBoursecu.value))
|
||||
|
||||
const context: RulesPageContext = {
|
||||
config,
|
||||
nameProject,
|
||||
isBoursecu,
|
||||
rulesTitle,
|
||||
rulesBlocks,
|
||||
getProjectSupportPhoneLink,
|
||||
getProjectBaleLink,
|
||||
}
|
||||
|
||||
provide(RULES_PAGE_CONTEXT_KEY, context)
|
||||
return context
|
||||
}
|
||||
|
||||
export function useRulesPageContext() {
|
||||
const context = inject(RULES_PAGE_CONTEXT_KEY)
|
||||
if (!context) {
|
||||
throw new Error('useRulesPageContext must be used within a page that calls useRulesPage()')
|
||||
}
|
||||
return context
|
||||
}
|
||||
Reference in New Issue
Block a user