Skip to content

Commit f18d58e

Browse files
authored
Merge pull request #80 from opentiny/deploy/add-tech-college-package
refactor: add tech college package
2 parents d05d765 + 3b2f20f commit f18d58e

File tree

735 files changed

+32145
-5191
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

735 files changed

+32145
-5191
lines changed

.github/workflows/deploy-obs-tech-college.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,16 @@ jobs:
7676
- name: Build
7777
run: pnpm -F opentiny-tech-college build
7878
env:
79-
VITE_CONTEXT: /
79+
VITE_CONTEXT: /tech-college/
8080
VITE_BASE: //res-static.opentiny.design/opentiny-tech-college/${{ steps.ver.outputs.value }}/
8181
- name: Copy files
8282
run: |
83-
cp dist/index.html dist/404.html
83+
cp packages/tech-college/dist/index.html packages/tech-college/dist/404.html
8484
- name: Upload build artifact
8585
uses: actions/upload-artifact@v4
8686
with:
8787
name: dist-artifact
88-
path: dist/
88+
path: packages/tech-college/dist/
8989
# Deploy job
9090
deploy:
9191
needs: build
@@ -95,7 +95,7 @@ jobs:
9595
uses: actions/download-artifact@v4
9696
with:
9797
name: dist-artifact
98-
path: dist/
98+
path: packages/tech-college/dist/
9999
- name: Show version
100100
run: |
101101
echo "Deploying version: ${{ needs.build.outputs.version }}"
@@ -117,5 +117,5 @@ jobs:
117117
118118
# 把本地 dist/ 目录整站同步到桶根目录
119119
echo "needs.build.outputs.version: ${{ needs.build.outputs.version }}"
120-
mv dist ${{ needs.build.outputs.version }}
120+
mv packages/tech-college/dist ${{ needs.build.outputs.version }}
121121
obsutil cp ${{ needs.build.outputs.version }} obs://${{ env.HUAWEI_CLOUD_BUCKET }}/opentiny-tech-college/ -r -f

packages/common/src/components/header.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -549,15 +549,15 @@ const toggleTheme = (event: MouseEvent) => {
549549
cursor: pointer;
550550
}
551551
552-
@media screen and (max-width: 1670px) {
552+
@media screen and (max-width: 1890px) {
553553
.opentiny-design-header {
554-
margin-top: 16px;
555554
display: grid;
556555
grid-template-columns: 1fr auto; // 两列:左侧内容 + 右侧nav-right
557556
grid-template-rows: auto auto; // 两行
558557
align-items: center;
559558
560559
.nav-left {
560+
margin-top: 16px;
561561
grid-column: 1; // 第1列
562562
grid-row: 1; // 第1行
563563
}
@@ -571,6 +571,7 @@ const toggleTheme = (event: MouseEvent) => {
571571
}
572572
573573
.nav-right {
574+
margin-top: 16px;
574575
grid-column: 2; // 第2列
575576
grid-row: 1; // 第1行
576577
margin-left: 0; // 移除auto margin
@@ -588,7 +589,7 @@ const toggleTheme = (event: MouseEvent) => {
588589
}
589590
}
590591
591-
@media screen and (min-width: 1671px) {
592+
@media screen and (min-width: 1855px) {
592593
.opentiny-design-header {
593594
display: flex;
594595
justify-content: space-between;

packages/common/vite.config.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,14 @@ import { resolve } from 'path'
33
import vue from '@vitejs/plugin-vue'
44
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'
55
import { visualizer } from 'rollup-plugin-visualizer'
6-
import { viteStaticCopy } from 'vite-plugin-static-copy'
76

87
// https://vitejs.dev/config/
98
export default defineConfig(({ mode }) => ({
109
base: mode === 'github' || process.env.VITE_EnvName === 'github' ? '/opentiny.design/' : '/',
1110
plugins: [
12-
mode === 'analyze' ? visualizer({ open: true }) : undefined,
13-
vue(),
14-
cssInjectedByJsPlugin(),
15-
viteStaticCopy({
16-
targets: [
17-
{
18-
src: '../home/public/downloadFile/*',
19-
dest: `dist/home/downloadFile`
20-
}
21-
]
22-
})
11+
mode === 'analyze' ? visualizer({ open: true }) : undefined,
12+
vue(),
13+
cssInjectedByJsPlugin()
2314
],
2415
envDir: './env',
2516
resolve: {

packages/home/src/views/layout/back-to-top.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<script setup>
2-
import { watch } from 'vue'
32
const props = defineProps({
43
visible: {
54
type: Boolean,
@@ -19,7 +18,7 @@ const props = defineProps({
1918
</template>
2019

2120
<style scoped lang="less">
22-
@import '@/mixin.less';
21+
@import '../../mixin.less';
2322
.back-top {
2423
width: 66px;
2524
height: 66px;

packages/tech-college/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VITE_CONTEXT=/tech-college/

packages/tech-college/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# OpenTiny 技术学院

packages/tech-college/index.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" href="/favicon.ico" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>OpenTiny - 企业级产品的完整设计和开发解决方案</title>
8+
</head>
9+
<body>
10+
<div id="header"></div>
11+
<div id="app"></div>
12+
<script id="tinyui-design-common" src="https://opentiny.github.io/opentiny.design/tinyui-design-common.iife.js"></script>
13+
<script type="module" src="/src/main.ts"></script>
14+
<div id="footer"></div>
15+
</body>
16+
</html>
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import md_emoji from 'markdown-it-emoji'
2+
import md_prism from 'markdown-it-prism' // 高亮
3+
import md_sup from 'markdown-it-sup' // 上标 ^ ^
4+
import md_sub from 'markdown-it-sub' // 下标 ~ ~
5+
import md_mark from 'markdown-it-mark' // 高亮文字 == ==
6+
import md_anchor from 'markdown-it-anchor'
7+
import md_container from 'markdown-it-container' // 提示块
8+
9+
export const MdExt = [md_emoji, md_sub, md_sup, md_mark]
10+
11+
const RE = /{([\d,-]+)}/
12+
const highlightLines = (md) => {
13+
const fence = md.renderer.rules.fence
14+
md.renderer.rules.fence = (...args) => {
15+
const [tokens, idx, options, , self] = args
16+
const token = tokens[idx]
17+
18+
if (!token.info || !RE.test(token.info)) {
19+
return fence(...args)
20+
}
21+
22+
const lineNumbers = RE.exec(token.info)[1]
23+
.split(',')
24+
.map((v) => v.split('-').map((v) => parseInt(v, 10)))
25+
const langName = token.info.replace(RE, '').trim()
26+
27+
const code = options.highlight ? options.highlight(token.content, langName) : token.content
28+
const codeSplitsArr = code.split('\n').map((split, index) => {
29+
const lineNumber = index + 1
30+
const inRange = lineNumbers.some(([start, end]) => {
31+
if (start && end) {
32+
return lineNumber >= start && lineNumber <= end
33+
}
34+
return lineNumber === start
35+
})
36+
if (inRange) {
37+
return {
38+
code: `<span class="highlighted-line">${split}</span>`,
39+
highlighted: true
40+
}
41+
}
42+
return {
43+
code: split
44+
}
45+
})
46+
let highlightCode = ''
47+
codeSplitsArr.forEach((split) => {
48+
if (split.highlighted) {
49+
highlightCode += split.code
50+
} else {
51+
highlightCode += `${split.code}\n`
52+
}
53+
})
54+
// If custom highlighter wraps code with starting <pre..., don't wrap code
55+
if (highlightCode.startsWith('<pre')) {
56+
return highlightCode
57+
}
58+
const tmpToken = {
59+
attrs: [['class', langName ? `language-${langName}` : '']]
60+
}
61+
const attrs = self.renderAttrs(tmpToken)
62+
return `<pre${attrs}><code${attrs}>${highlightCode.trim()}</code></pre>`
63+
}
64+
}
65+
66+
// 自定义container
67+
function createContainer(klass) {
68+
return [
69+
md_container,
70+
klass,
71+
{
72+
render(tokens, idx) {
73+
const token = tokens[idx]
74+
const info = token.info.trim().slice(klass.length).trim() || ''
75+
if (token.nesting === 1) {
76+
return `<div class="${klass} custom-block"><p class="custom-block-title">${info}</p>\n`
77+
} else {
78+
return `</div>\n`
79+
}
80+
}
81+
}
82+
]
83+
}
84+
85+
export function mdInstall(md) {
86+
md.use(md_prism, { plugins: ['line-highlight'] })
87+
.use(...createContainer('tip'))
88+
.use(...createContainer('info'))
89+
.use(...createContainer('warning'))
90+
.use(...createContainer('danger'))
91+
.use(md_anchor, {
92+
permalink: true,
93+
permalinkBefore: true,
94+
permalinkSymbol: '',
95+
slugify: (s) => encodeURIComponent(s)
96+
})
97+
.use(highlightLines)
98+
}

packages/tech-college/package.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "opentiny-tech-college",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite",
8+
"build": "vite build",
9+
"preview": "vite preview"
10+
},
11+
"dependencies": {
12+
"@opentiny/vue": "^3.28.0",
13+
"@opentiny/vue-icon": "^3.28.3",
14+
"vue": "^3.3.11",
15+
"vue-router": "4.1.5",
16+
"prismjs": "^1.28.0",
17+
"github-markdown-css": "~5.6.1"
18+
},
19+
"devDependencies": {
20+
"@vitejs/plugin-vue": "^4.5.2",
21+
"@vueuse/head": "~2.0.0",
22+
"flexsearch": "0.7.31",
23+
"less": "^4.1.3",
24+
"markdown-it": "^14.1.0",
25+
"markdown-it-anchor": "^8.6.0",
26+
"markdown-it-container": "^4.0.0",
27+
"markdown-it-emoji": "^2.0.0",
28+
"markdown-it-mark": "^3.0.0",
29+
"markdown-it-prism": "^2.3.0",
30+
"markdown-it-sub": "^1.0.0",
31+
"markdown-it-sup": "^1.0.0",
32+
"markdown-it-table-of-contents": "^0.6.0",
33+
"markdown-it-toc-done-right": "^4.2.0",
34+
"typescript": "^5.2.2",
35+
"vite": "^5.0.8",
36+
"vite-plugin-md": "^0.22.4",
37+
"vue-tsc": "^1.8.25"
38+
}
39+
}
8.55 KB
Binary file not shown.

0 commit comments

Comments
 (0)