Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7e34f1a
up version to 1.0.0-preview.1 (#20)
Eskibear Oct 24, 2023
838d5ea
Merge pull request #30 from Azure/main
Eskibear Dec 14, 2023
36a89ad
Update version to 1.0.0-preview.2 (#34)
Eskibear Dec 14, 2023
f86cad2
Merge pull request #50 from Azure/main
Eskibear Mar 21, 2024
a034dc9
Update version to 1.0.0-preview.3 (#51)
Eskibear Mar 21, 2024
0939e7a
Merge branch 'main' into release/preview/v1
Eskibear Apr 10, 2024
5522a85
Update version to 1.0.0-preview.4 (#58)
Eskibear Apr 10, 2024
11e446e
Update version to 1.0.0 (#66)
Eskibear May 29, 2024
3f5c95d
Merge branch 'release/stable/v1' into yanzh/merge-main-to-release
Eskibear Jul 25, 2024
0996a45
Merge pull request #83 from Azure/yanzh/merge-main-to-release
Eskibear Jul 26, 2024
e0e5843
Update version to 1.0.1 (#84)
Eskibear Jul 26, 2024
a1a5340
Merge remote-tracking branch 'origin/main' into release/v1
Eskibear Aug 13, 2024
f2ddbb3
resolve conflict
zhiyuanliang-ms Aug 16, 2024
b57cb8a
Update linting rule to enforce to use semicolon (#91)
zhiyuanliang-ms Aug 20, 2024
7e9a312
use isRestError API (#94)
zhiyuanliang-ms Sep 13, 2024
e9db70a
Make testsuite compatible with node 22.x (#96)
zhiyuanliang-ms Sep 14, 2024
39cebdb
Adds additional undefined check (#104)
rossgrambo Sep 30, 2024
0d6f99c
add js file extension to imports (#109)
zhiyuanliang-ms Oct 17, 2024
af6a3d0
update typescript version (#112)
zhiyuanliang-ms Oct 22, 2024
b9ed65d
add requestTracingOptions (#114)
zhiyuanliang-ms Oct 24, 2024
477e48c
update
linglingye001 Oct 24, 2024
bd354a9
Merge branch 'main' of https://github.com/Azure/AppConfiguration-Java…
linglingye001 Oct 25, 2024
21e963b
Merge branch 'main' of https://github.com/Azure/AppConfiguration-Java…
linglingye001 Jan 17, 2025
6f5dac2
add example
linglingye001 Jan 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions examples/nuxt-example/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
210 changes: 210 additions & 0 deletions examples/nuxt-example/.nuxt/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
import Vue from 'vue'
import { decode, parsePath, withoutBase, withoutTrailingSlash, normalizeURL } from 'ufo'

import { getMatchedComponentsInstances, getChildrenComponentInstancesUsingFetch, promisify, globalHandleError, urlJoin, sanitizeComponent } from './utils'
import NuxtError from './components/nuxt-error.vue'
import NuxtLoading from './components/nuxt-loading.vue'
import NuxtBuildIndicator from './components/nuxt-build-indicator'

import _6f6c098b from '..\\layouts\\default.vue'

const layouts = { "_default": sanitizeComponent(_6f6c098b) }

export default {
render (h, props) {
const loadingEl = h('NuxtLoading', { ref: 'loading' })

const layoutEl = h(this.layout || 'nuxt')
const templateEl = h('div', {
domProps: {
id: '__layout'
},
key: this.layoutName
}, [layoutEl])

const transitionEl = h('transition', {
props: {
name: 'layout',
mode: 'out-in'
},
on: {
beforeEnter (el) {
// Ensure to trigger scroll event after calling scrollBehavior
window.$nuxt.$nextTick(() => {
window.$nuxt.$emit('triggerScroll')
})
}
}
}, [templateEl])

return h('div', {
domProps: {
id: '__nuxt'
}
}, [
loadingEl,
h(NuxtBuildIndicator),
transitionEl
])
},

data: () => ({
isOnline: true,

layout: null,
layoutName: '',

nbFetching: 0
}),

beforeCreate () {
Vue.util.defineReactive(this, 'nuxt', this.$options.nuxt)
},
created () {
// Add this.$nuxt in child instances
this.$root.$options.$nuxt = this

if (process.client) {
// add to window so we can listen when ready
window.$nuxt = this

this.refreshOnlineStatus()
// Setup the listeners
window.addEventListener('online', this.refreshOnlineStatus)
window.addEventListener('offline', this.refreshOnlineStatus)
}
// Add $nuxt.error()
this.error = this.nuxt.error
// Add $nuxt.context
this.context = this.$options.context
},

async mounted () {
this.$loading = this.$refs.loading
},

watch: {
'nuxt.err': 'errorChanged'
},

computed: {
isOffline () {
return !this.isOnline
},

isFetching () {
return this.nbFetching > 0
},
},

methods: {
refreshOnlineStatus () {
if (process.client) {
if (typeof window.navigator.onLine === 'undefined') {
// If the browser doesn't support connection status reports
// assume that we are online because most apps' only react
// when they now that the connection has been interrupted
this.isOnline = true
} else {
this.isOnline = window.navigator.onLine
}
}
},

async refresh () {
const pages = getMatchedComponentsInstances(this.$route)

if (!pages.length) {
return
}
this.$loading.start()

const promises = pages.map(async (page) => {
let p = []

// Old fetch
if (page.$options.fetch && page.$options.fetch.length) {
p.push(promisify(page.$options.fetch, this.context))
}

if (page.$options.asyncData) {
p.push(
promisify(page.$options.asyncData, this.context)
.then((newData) => {
for (const key in newData) {
Vue.set(page.$data, key, newData[key])
}
})
)
}

// Wait for asyncData & old fetch to finish
await Promise.all(p)
// Cleanup refs
p = []

if (page.$fetch) {
p.push(page.$fetch())
}
// Get all component instance to call $fetch
for (const component of getChildrenComponentInstancesUsingFetch(page.$vnode.componentInstance)) {
p.push(component.$fetch())
}

return Promise.all(p)
})
try {
await Promise.all(promises)
} catch (error) {
this.$loading.fail(error)
globalHandleError(error)
this.error(error)
}
this.$loading.finish()
},
errorChanged () {
if (this.nuxt.err) {
if (this.$loading) {
if (this.$loading.fail) {
this.$loading.fail(this.nuxt.err)
}
if (this.$loading.finish) {
this.$loading.finish()
}
}

let errorLayout = (NuxtError.options || NuxtError).layout;

if (typeof errorLayout === 'function') {
errorLayout = errorLayout(this.context)
}

this.nuxt.errPageReady = true
this.setLayout(errorLayout)
}
},

setLayout (layout) {
if(layout && typeof layout !== 'string') {
throw new Error('[nuxt] Avoid using non-string value as layout property.')
}

if (!layout || !layouts['_' + layout]) {
layout = 'default'
}
this.layoutName = layout
this.layout = layouts['_' + layout]
return this.layout
},
loadLayout (layout) {
if (!layout || !layouts['_' + layout]) {
layout = 'default'
}
return Promise.resolve(layouts['_' + layout])
},
},

components: {
NuxtLoading
}
}
Loading
Loading