feat(P4): precompute移植+app.js sources双向回填+回归1003/1003+验收体积/文件/data.json
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Aurora Admin · ThemeSwitcher</title>
|
||||
<link rel="stylesheet" href="../.design_library/aurora-admin/colors_and_type.css" />
|
||||
<link rel="stylesheet" href="./ThemeSwitcher.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="aa-page">
|
||||
<h2 class="aa-h2">ThemeSwitcher 主题切换</h2>
|
||||
<p class="aa-desc">明暗主题 + 品牌色切换,实时预览,可保存偏好。</p>
|
||||
|
||||
<div class="aa-demo">
|
||||
<div class="aa-themesw" id="sw">
|
||||
<div class="aa-themesw-opt" role="radio" tabindex="0" data-mode="light"><span class="aa-themesw-dot light"></span>浅色</div>
|
||||
<div class="aa-themesw-opt" role="radio" tabindex="0" data-mode="dark"><span class="aa-themesw-dot dark"></span>深色</div>
|
||||
<div class="aa-themesw-colors" id="colors"></div>
|
||||
<div class="aa-themesw-label" id="label"></div>
|
||||
</div>
|
||||
<div class="aa-card" style="margin-top:12px">
|
||||
<div class="aa-card__body">
|
||||
<button class="aa-btn aa-btn--primary">品牌色按钮</button>
|
||||
<span style="margin-left:10px">当前主题:<b id="cur"></b></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var brands = ['#2F54EB', '#1677FF', '#722ED1', '#13C2C2', '#FA541C', '#EB2F96'];
|
||||
var mode = 'light', brand = '#2F54EB';
|
||||
var colorsEl = document.getElementById('colors');
|
||||
brands.forEach(function (c) {
|
||||
var s = document.createElement('span');
|
||||
s.className = 'aa-themesw-color'; s.setAttribute('role','radio'); s.setAttribute('tabindex','0'); s.style.background = c; s.dataset.c = c;
|
||||
s.onclick = function () { brand = c; render(); };
|
||||
colorsEl.appendChild(s);
|
||||
});
|
||||
document.querySelectorAll('.aa-themesw-opt').forEach(function (o) {
|
||||
o.onclick = function () { mode = o.dataset.mode; render(); };
|
||||
});
|
||||
function render() {
|
||||
document.querySelectorAll('.aa-themesw-opt').forEach(function (o) { o.classList.toggle('is-active', o.dataset.mode === mode); });
|
||||
Array.prototype.forEach.call(colorsEl.children, function (c) { c.classList.toggle('is-active', c.dataset.c === brand); });
|
||||
document.documentElement.style.setProperty('--brand', brand);
|
||||
document.getElementById('cur').textContent = mode === 'light' ? '浅色' : '深色';
|
||||
document.getElementById('label').textContent = '品牌色:' + brand + '(点击色块可切换,应用于 CSS 变量 --brand 实时预览)';
|
||||
}
|
||||
render();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,36 @@
|
||||
import React from 'react';
|
||||
import './ThemeSwitcher.css';
|
||||
|
||||
const MODES = [
|
||||
{ value: 'light', label: '浅色' },
|
||||
{ value: 'dark', label: '深色' }
|
||||
];
|
||||
const BRANDS = ['#2F54EB', '#1677FF', '#722ED1', '#13C2C2', '#FA541C', '#EB2F96'];
|
||||
|
||||
export default function ThemeSwitcher({ mode = 'light', brand = '#2F54EB', onModeChange, onBrandChange }) {
|
||||
return (
|
||||
<div className="aa-themesw">
|
||||
{MODES.map((m) => (
|
||||
<div
|
||||
key={m.value}
|
||||
className={'aa-themesw-opt' + (mode === m.value ? ' is-active' : '')}
|
||||
onClick={() => onModeChange && onModeChange(m.value)}
|
||||
>
|
||||
<span className={'aa-themesw-dot ' + m.value} />
|
||||
{m.label}
|
||||
</div>
|
||||
))}
|
||||
<div className="aa-themesw-colors">
|
||||
{BRANDS.map((c) => (
|
||||
<span
|
||||
key={c}
|
||||
className={'aa-themesw-color' + (brand === c ? ' is-active' : '')}
|
||||
style={{ background: c }}
|
||||
onClick={() => onBrandChange && onBrandChange(c)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
<div className="aa-themesw-label">品牌色:{brand}(应用于 CSS 变量 --brand 实时预览)</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<template>
|
||||
<div class="aa-themesw">
|
||||
<div
|
||||
v-for="m in modes"
|
||||
:key="m.value"
|
||||
class="aa-themesw-opt"
|
||||
:class="{ 'is-active': mode === m.value }"
|
||||
@click="$emit('update:mode', m.value)"
|
||||
>
|
||||
<span class="aa-themesw-dot" :class="m.value"></span>{{ m.label }}
|
||||
</div>
|
||||
<div class="aa-themesw-colors">
|
||||
<span
|
||||
v-for="c in brands"
|
||||
:key="c"
|
||||
class="aa-themesw-color"
|
||||
:class="{ 'is-active': brand === c }"
|
||||
:style="{ background: c }"
|
||||
@click="$emit('update:brand', c)"
|
||||
></span>
|
||||
</div>
|
||||
<div class="aa-themesw-label">品牌色:{{ brand }}(应用于 CSS 变量 --brand 实时预览)</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'AaThemeSwitcher',
|
||||
props: {
|
||||
mode: { type: String, default: 'light' },
|
||||
brand: { type: String, default: '#2F54EB' }
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
modes: [
|
||||
{ value: 'light', label: '浅色' },
|
||||
{ value: 'dark', label: '深色' }
|
||||
],
|
||||
brands: ['#2F54EB', '#1677FF', '#722ED1', '#13C2C2', '#FA541C', '#EB2F96']
|
||||
};
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style src="./ThemeSwitcher.css"></style>
|
||||
@@ -0,0 +1,39 @@
|
||||
<template>
|
||||
<div class="aa-themesw">
|
||||
<div
|
||||
v-for="m in modes"
|
||||
:key="m.value"
|
||||
class="aa-themesw-opt"
|
||||
:class="{ 'is-active': mode === m.value }"
|
||||
@click="emit('update:mode', m.value)"
|
||||
>
|
||||
<span class="aa-themesw-dot" :class="m.value"></span>{{ m.label }}
|
||||
</div>
|
||||
<div class="aa-themesw-colors">
|
||||
<span
|
||||
v-for="c in brands"
|
||||
:key="c"
|
||||
class="aa-themesw-color"
|
||||
:class="{ 'is-active': brand === c }"
|
||||
:style="{ background: c }"
|
||||
@click="emit('update:brand', c)"
|
||||
></span>
|
||||
</div>
|
||||
<div class="aa-themesw-label">品牌色:{{ brand }}(应用于 CSS 变量 --brand 实时预览)</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
defineProps({
|
||||
mode: { type: String, default: 'light' },
|
||||
brand: { type: String, default: '#2F54EB' }
|
||||
});
|
||||
const emit = defineEmits(['update:mode', 'update:brand']);
|
||||
const modes = [
|
||||
{ value: 'light', label: '浅色' },
|
||||
{ value: 'dark', label: '深色' }
|
||||
];
|
||||
const brands = ['#2F54EB', '#1677FF', '#722ED1', '#13C2C2', '#FA541C', '#EB2F96'];
|
||||
</script>
|
||||
|
||||
<style src="./ThemeSwitcher.css"></style>
|
||||
Reference in New Issue
Block a user