Skip to content

Commit 6f3fde5

Browse files
authored
fix(docs): Remove environmental configuration and add user configuration prompts (#3109)
* fix(docs): 去除环境配置, 增加用户配置提示 * fix(docs): 优化 * fix(docs): 修改颜色变量
1 parent cd774f0 commit 6f3fde5

File tree

5 files changed

+50
-17
lines changed

5 files changed

+50
-17
lines changed

examples/sites/demos/pc/webdoc/develop-demo-en.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,13 @@ npm install @opentiny/vue@3
4343
Then modify the`vite.config.js`, add the following code highlighted section:
4444

4545
```js {8-10}
46-
//vite.config.js
46+
// vite.config.js
4747

4848
import { defineConfig } from 'vite'
4949
import vue from '@vitejs/plugin-vue'
5050

5151
export default defineConfig({
52-
plugins: [vue()],
53-
define: {
54-
'process.env': { ...process.env }
55-
}
52+
plugins: [vue()]
5653
})
5754
```
5855

examples/sites/demos/pc/webdoc/develop-demo.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ import { defineConfig } from 'vite'
4949
import vue from '@vitejs/plugin-vue'
5050

5151
export default defineConfig({
52-
plugins: [vue()],
53-
define: {
54-
'process.env': { ...process.env }
55-
}
52+
plugins: [vue()]
5653
})
5754
```
5855

examples/sites/demos/pc/webdoc/installation-en.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ import { defineConfig } from 'vite'
4040
import vue from '@vitejs/plugin-vue'
4141

4242
export default defineConfig({
43-
plugins: [vue()],
44-
define: {
45-
'process.env': { ...process.env }
46-
}
43+
plugins: [vue()]
4744
})
4845
```
4946

examples/sites/demos/pc/webdoc/installation.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ import { defineConfig } from 'vite'
4040
import vue from '@vitejs/plugin-vue'
4141

4242
export default defineConfig({
43-
plugins: [vue()],
44-
define: {
45-
'process.env': { ...process.env }
46-
}
43+
plugins: [vue()]
4744
})
4845
```
4946

examples/sites/src/views/docs/docs.vue

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
<template>
22
<div class="ti-f-r ti-pt48 ti-pl48 ti-pr48 docs-container">
3+
<tiny-modal v-model="showModal" title="请注意" status="warning" show-footer>
4+
<div class="modal-body">
5+
TinyVue 从 <span class="modal-body-keyword">3.13.0</span> 开始不需要在
6+
<span class="modal-body-keyword">vite.config.js</span> 文件中配置
7+
<span class="modal-body-keyword">define: { 'process.env': { ...process.env } }</span>
8+
这段代码,这段代码会导致环境变量被打包到构建产物中,引起信息安全风险,请业务尽快升级到
9+
<span class="modal-body-keyword">3.13.0</span> 或以上版本!如果不升级版本可以改成:<span
10+
class="modal-body-keyword"
11+
>define: { 'process.env': { }}</span
12+
>
13+
同样也可以解决此问题!感谢您对 TinyVue 的支持!
14+
</div>
15+
<template #footer>
16+
<tiny-button type="primary" :disabled="disabled" @click="handleConfirm">{{
17+
disabled ? `${time} S后可关闭此提示` : '确认将不再弹出此提示'
18+
}}</tiny-button>
19+
<tiny-button @click="handleCancel">取消</tiny-button>
20+
</template>
21+
</tiny-modal>
322
<component id="doc_wrap" :is="docCmp" class="ti-w0 ti-fi-1" />
423
<!-- 目录列表 TODO: 需要锚点组件配置整改,处理id中的特殊字符 -->
524
<!-- <div v-if="anchorLinks.length > 0" class="docs-page-anchor catalog w128 sticky top32 ml24">
@@ -11,10 +30,33 @@
1130

1231
<script setup>
1332
import { ref, nextTick, watch, onMounted, shallowRef } from 'vue'
33+
import { Modal as TinyModal, Button as TinyButton } from '@opentiny/vue'
1434
import { getWord } from '@/tools'
1535
import docMDs from './docConfig.js'
1636
import { router } from '@/router.js'
1737
38+
const tipFlag = localStorage.getItem('tiny-vue-env-tip')
39+
const showModal = ref(tipFlag !== 'never')
40+
const disabled = ref(true)
41+
let time = ref(5)
42+
if (showModal.value) {
43+
let timer = setInterval(() => {
44+
if (time.value > 0) {
45+
time.value = time.value - 1
46+
} else {
47+
disabled.value = false
48+
clearInterval(timer)
49+
timer = null
50+
}
51+
}, 1000)
52+
}
53+
const handleConfirm = () => {
54+
showModal.value = false
55+
localStorage.setItem('tiny-vue-env-tip', 'never')
56+
}
57+
const handleCancel = () => {
58+
showModal.value = false
59+
}
1860
const isOpen = import.meta.env.VITE_BUILD_TARGET === 'open'
1961
const openDocMap = {
2062
'envpreparation': 'envpreparation-open'
@@ -54,6 +96,9 @@ onMounted(() => {
5496
</script>
5597
5698
<style lang="less">
99+
.modal-body .modal-body-keyword {
100+
color: var(--tv-base-color-error-6);
101+
}
57102
.docs-container {
58103
flex: 1;
59104
display: flex;

0 commit comments

Comments
 (0)