first commit

This commit is contained in:
编码猿
2024-09-27 00:57:27 +08:00
commit 18df0f5e4b
2548 changed files with 253280 additions and 0 deletions

View File

@@ -0,0 +1 @@
2c196b31-1743-44f5-bc79-6d655593b8ad

View File

@@ -0,0 +1,29 @@
/**
* 同步父窗口和 iframe 的 vue-router 状态
*/
import { iframeReady, isMobile } from '.';
window.syncPath = function() {
const router = window.vueRouter;
const isInIframe = window !== window.top;
const currentDir = router.history.current.path;
if (isInIframe) {
window.top.replacePath(currentDir);
} else if (!isMobile) {
const iframe = document.querySelector('iframe');
if (iframe) {
iframeReady(iframe, () => {
iframe.contentWindow.replacePath(currentDir);
});
}
}
};
window.replacePath = function(path = '') {
// should preserve hash for anchor
if (window.vueRouter.currentRoute.path !== path) {
window.vueRouter.replace(path).catch(() => {});
}
};

View File

@@ -0,0 +1,30 @@
function iframeReady(iframe, callback) {
const doc = iframe.contentDocument || iframe.contentWindow.document;
const interval = () => {
if (iframe.contentWindow.replacePath) {
callback();
} else {
setTimeout(() => {
interval();
}, 50);
}
};
if (doc.readyState === 'complete') {
interval();
} else {
iframe.onload = interval;
}
}
const ua = navigator.userAgent.toLowerCase();
const isMobile = /ios|iphone|ipod|ipad|android/.test(ua);
export function decamelize(str, sep = '-') {
return str
.replace(/([a-z\d])([A-Z])/g, '$1' + sep + '$2')
.replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1' + sep + '$2')
.toLowerCase();
}
export { isMobile, iframeReady };

View File

@@ -0,0 +1,30 @@
const ZH_CN = 'zh-CN';
const EN_US = 'en-US';
const CACHE_KEY = 'vant-cli-lang';
let currentLang = ZH_CN;
export function getLang() {
return currentLang;
}
export function setLang(lang) {
currentLang = lang;
localStorage.setItem(CACHE_KEY, lang);
}
export function setDefaultLang(langFromConfig) {
const cached = localStorage.getItem(CACHE_KEY);
if (cached) {
currentLang = cached;
return;
}
if (navigator.language && navigator.language.indexOf('zh-') !== -1) {
currentLang = ZH_CN;
return;
}
currentLang = langFromConfig || EN_US;
}

View File

@@ -0,0 +1 @@
bec7060d-dbcd-4465-b730-de9b5ccae70a

View File

@@ -0,0 +1,46 @@
@import './var';
body {
min-width: 1100px;
margin: 0;
overflow-x: auto;
color: @van-doc-black;
font-size: 16px;
font-family: PingFang SC, 'Helvetica Neue', Arial, sans-serif;
background-color: @van-doc-background-color;
-webkit-font-smoothing: antialiased;
}
p {
margin: 0;
}
h1,
h2,
h3,
h4,
h5,
h6 {
margin: 0;
font-size: inherit;
}
ul,
ol {
margin: 0;
padding: 0;
list-style: none;
}
a {
text-decoration: none;
}
.van-doc-row {
width: 100%;
@media (min-width: @van-doc-row-max-width) {
width: @van-doc-row-max-width;
margin: 0 auto;
}
}

View File

@@ -0,0 +1,79 @@
@import './var';
code {
position: relative;
display: block;
margin-top: 20px;
overflow-x: auto;
color: @van-doc-code-color;
font-weight: 400;
font-size: 13.4px;
font-family: @van-doc-code-font-family;
line-height: 26px;
white-space: pre-wrap;
word-wrap: break-word;
-webkit-font-smoothing: auto;
}
pre {
margin: 0;
}
.hljs {
display: block;
padding: 0.5em;
overflow-x: auto;
background: #fff;
}
.hljs-subst {
color: @van-doc-code-color;
}
.hljs-string,
.hljs-meta,
.hljs-symbol,
.hljs-template-tag,
.hljs-template-variable,
.hljs-addition {
color: @van-doc-green;
}
.hljs-comment,
.hljs-quote {
color: #999;
}
.hljs-params,
.hljs-keyword,
.hljs-attribute {
color: @van-doc-purple;
}
.hljs-deletion,
.hljs-variable,
.hljs-number,
.hljs-regexp,
.hljs-literal,
.hljs-bullet,
.hljs-link {
color: #eb6f6f;
}
.hljs-attr,
.hljs-selector-tag,
.hljs-title,
.hljs-section,
.hljs-built_in,
.hljs-doctag,
.hljs-type,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class,
.hljs-strong {
color: #4994df;
}
.hljs-emphasis {
font-style: italic;
}

View File

@@ -0,0 +1,29 @@
@van-doc-black: #323233;
@van-doc-blue: #1989fa;
@van-doc-purple: #8080ff;
@van-doc-fuchsia: #a7419e;
@van-doc-green: #4fc08d;
@van-doc-text-color: #34495e;
@van-doc-text-light-blue: rgba(69, 90, 100, 0.6);
@van-doc-background-color: #f7f8fa;
@van-doc-grey: #999;
@van-doc-dark-grey: #666;
@van-doc-light-grey: #ccc;
@van-doc-border-color: #f1f4f8;
@van-doc-code-color: #58727e;
@van-doc-code-background-color: #f1f4f8;
@van-doc-code-font-family: 'Source Code Pro', 'Monaco', 'Inconsolata', monospace;
@van-doc-padding: 30px;
@van-doc-row-max-width: 1680px;
@van-doc-nav-width: 220px;
@van-doc-border-radius: 12px;
// header
@van-doc-header-top-height: 60px;
@van-doc-header-bottom-height: 50px;
// simulator
@van-doc-simulator-width: 360px;
@van-doc-simulator-small-width: 320px;
@van-doc-simulator-height: 620px;
@van-doc-simulator-small-height: 560px;