mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-27 02:10:40 +01:00
up
This commit is contained in:
@@ -2,7 +2,7 @@ import icons from './theme/icons'
|
|||||||
|
|
||||||
import { pick } from './runtime/utils'
|
import { pick } from './runtime/utils'
|
||||||
|
|
||||||
export const getDefaultUiConfig = (colors?: string[]) => ({
|
export const getDefaultUiConfig = (colors?: string[], csp?: { nonce?: string }) => ({
|
||||||
colors: pick({
|
colors: pick({
|
||||||
primary: 'green',
|
primary: 'green',
|
||||||
secondary: 'blue',
|
secondary: 'blue',
|
||||||
@@ -13,7 +13,7 @@ export const getDefaultUiConfig = (colors?: string[]) => ({
|
|||||||
neutral: 'slate'
|
neutral: 'slate'
|
||||||
}, [...(colors || []), 'neutral' as any]),
|
}, [...(colors || []), 'neutral' as any]),
|
||||||
icons,
|
icons,
|
||||||
csp: {
|
csp: csp || {
|
||||||
nonce: ''
|
nonce: ''
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -83,8 +83,7 @@ export default defineNuxtModule<ModuleOptions>({
|
|||||||
|
|
||||||
nuxt.options.alias['#ui'] = resolve('./runtime')
|
nuxt.options.alias['#ui'] = resolve('./runtime')
|
||||||
|
|
||||||
nuxt.options.appConfig.ui = defu(nuxt.options.appConfig.ui || {}, getDefaultUiConfig(options.theme.colors))
|
nuxt.options.appConfig.ui = defu(nuxt.options.appConfig.ui || {}, getDefaultUiConfig(options.theme.colors, options.csp))
|
||||||
nuxt.options.appConfig.ui.csp = defu(nuxt.options.appConfig.ui.csp || {}, options.csp)
|
|
||||||
|
|
||||||
// Isolate root node from portaled components
|
// Isolate root node from portaled components
|
||||||
nuxt.options.app.rootAttrs = nuxt.options.app.rootAttrs || {}
|
nuxt.options.app.rootAttrs = nuxt.options.app.rootAttrs || {}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export default defineNuxtPlugin(() => {
|
|||||||
const appConfig = useAppConfig()
|
const appConfig = useAppConfig()
|
||||||
const nuxtApp = useNuxtApp()
|
const nuxtApp = useNuxtApp()
|
||||||
|
|
||||||
const nonce = computed(() => (appConfig.ui as any)?.csp?.nonce as string | undefined)
|
const nonce = computed(() => appConfig.ui?.csp?.nonce)
|
||||||
|
|
||||||
const root = computed(() => {
|
const root = computed(() => {
|
||||||
const { neutral, ...colors } = appConfig.ui.colors
|
const { neutral, ...colors } = appConfig.ui.colors
|
||||||
@@ -42,7 +42,6 @@ export default defineNuxtPlugin(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Head
|
// Head
|
||||||
console.log('head nonce', nonce.value)
|
|
||||||
const headData: UseHeadInput = {
|
const headData: UseHeadInput = {
|
||||||
style: [{
|
style: [{
|
||||||
innerHTML: () => root.value,
|
innerHTML: () => root.value,
|
||||||
@@ -59,7 +58,6 @@ export default defineNuxtPlugin(() => {
|
|||||||
style.innerHTML = root.value
|
style.innerHTML = root.value
|
||||||
style.setAttribute('data-nuxt-ui-colors', '')
|
style.setAttribute('data-nuxt-ui-colors', '')
|
||||||
|
|
||||||
console.log('SPA nonce', nonce.value)
|
|
||||||
if (nonce.value) {
|
if (nonce.value) {
|
||||||
style.setAttribute('nonce', nonce.value)
|
style.setAttribute('nonce', nonce.value)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user