-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support scoped and v-bind() #11459
Closed
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
1a640f4
feat: support scoped and v-bind()
xiangmaoshuo 87d089a
feat: 获取components时,不对index.vue文件进行hasDefaultExport校验,用以支持setup
xiangmaoshuo d168724
Merge branch 'main' into feat/sfc
xiangmaoshuo 4f254ae
feat: 兼容import路径中包含ext写法
xiangmaoshuo 8879042
feat: 完善生成vue文件样式依赖逻辑
xiangmaoshuo 2e08b7f
Merge branch 'youzan:main' into feat/sfc
xiangmaoshuo a6bd80f
feat: site模式下,对vue文件不进行样式拆分
xiangmaoshuo 2d24780
feat: 不进行vue style编译时,进行提示
xiangmaoshuo 90b4485
feat: 优化代码
xiangmaoshuo 07ebf88
feat: 修改 @vant/cli包名,后续自行维护
xiangmaoshuo 69e0161
feat: 支持vue2
xiangmaoshuo 4e8f5c9
feat: vant site 适配vue2
xiangmaoshuo File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Vue from 'vue'; | ||
import App from '../App.vue'; | ||
import DemoPlayground from '../components/DemoPlayground.vue'; | ||
import { router } from './router'; | ||
|
||
const app = new Vue({ | ||
router, | ||
render: (h) => h(App), | ||
}); | ||
Vue.component(DemoPlayground.name, DemoPlayground); | ||
|
||
setTimeout(() => { | ||
app.$mount('#app'); | ||
}, 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
import Vue, { nextTick } from 'vue'; | ||
import VueRouter from 'vue-router'; | ||
import { isMobile, decamelize } from '../../common'; | ||
import { config, documents } from 'site-desktop-shared'; | ||
import { getLang, setDefaultLang } from '../../common/locales'; | ||
import { listenToSyncPath, syncPathToChild } from '../../common/iframe-sync'; | ||
|
||
if (isMobile) { | ||
location.replace('mobile.html' + location.hash); | ||
} | ||
|
||
Vue.use(VueRouter); | ||
|
||
const { locales, defaultLang } = config.site; | ||
|
||
setDefaultLang(defaultLang); | ||
|
||
function parseName(name) { | ||
if (name.indexOf('_') !== -1) { | ||
const pairs = name.split('_'); | ||
const component = pairs.shift(); | ||
|
||
return { | ||
component: `${decamelize(component)}`, | ||
lang: pairs.join('-'), | ||
}; | ||
} | ||
|
||
return { | ||
component: `${decamelize(name)}`, | ||
lang: '', | ||
}; | ||
} | ||
|
||
function getLangFromRoute(route) { | ||
const lang = route.path.split('/')[1]; | ||
const langs = Object.keys(locales); | ||
|
||
if (langs.indexOf(lang) !== -1) { | ||
return lang; | ||
} | ||
|
||
return getLang(); | ||
} | ||
|
||
function getRoutes() { | ||
const routes: any[] = []; | ||
const names = Object.keys(documents); | ||
|
||
function addHomeRoute(Home, lang) { | ||
routes.push({ | ||
name: lang || 'home', | ||
path: `/${lang || ''}`, | ||
component: Home, | ||
meta: { lang }, | ||
}); | ||
} | ||
|
||
names.forEach((name) => { | ||
const { component, lang } = parseName(name); | ||
|
||
if (component === 'home') { | ||
addHomeRoute(documents[name], lang); | ||
} | ||
|
||
if (lang) { | ||
routes.push({ | ||
name: `${lang}/${component}`, | ||
path: `/${lang}/${component}`, | ||
component: documents[name], | ||
meta: { | ||
lang, | ||
name: component, | ||
}, | ||
}); | ||
} else { | ||
routes.push({ | ||
name: `${component}`, | ||
path: `/${component}`, | ||
component: documents[name], | ||
meta: { | ||
name: component, | ||
}, | ||
}); | ||
} | ||
}); | ||
|
||
if (locales) { | ||
routes.push({ | ||
name: 'notFound', | ||
path: '/:path(.*)+', | ||
redirect: (route) => ({ | ||
name: getLangFromRoute(route), | ||
}), | ||
}); | ||
} else { | ||
routes.push({ | ||
name: 'notFound', | ||
path: '/:path(.*)+', | ||
redirect: { | ||
name: 'home', | ||
}, | ||
}); | ||
} | ||
|
||
return routes; | ||
} | ||
|
||
export const router = new VueRouter({ | ||
routes: getRoutes(), | ||
scrollBehavior() { | ||
return { x: 0, y: 0 }; | ||
}, | ||
}); | ||
|
||
router.afterEach(() => { | ||
nextTick(syncPathToChild); | ||
}); | ||
|
||
if (config.site.simulator?.syncPathFromSimulator !== false) { | ||
listenToSyncPath(router); | ||
} | ||
|
||
window.vueRouter = router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import Vue from 'vue'; | ||
import DemoBlock from '../components/DemoBlock.vue'; | ||
import DemoSection from '../components/DemoSection.vue'; | ||
import { router } from './router'; | ||
import App from '../App.vue'; | ||
import '@vant/touch-emulator'; | ||
|
||
const app = new Vue({ | ||
router, | ||
render: (h) => h(App), | ||
}); | ||
Vue.component(DemoBlock.name, DemoBlock); | ||
Vue.component(DemoSection.name, DemoSection); | ||
|
||
setTimeout(() => { | ||
app.$mount('#app'); | ||
}, 0); | ||
|
||
// https://stackoverflow.com/questions/3885018/active-pseudo-class-doesnt-work-in-mobile-safari/33681490#33681490 | ||
document.addEventListener('touchstart', () => {}, { | ||
passive: true, | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
Client-side URL redirect