Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,28 @@
<!-- end style -->

<!-- start script -->
<!-- Google tag -->
<script src="https://www.googletagmanager.com/gtag/js?id=G-NRZR81NZRZ" async></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'G-NRZR81NZRZ');
</script>
<script src="https://cdn.bootcdn.net/ajax/libs/typescript/5.2.2/typescript.min.js" defer></script>
<!-- end script -->
</head>
<body>
<div id="app"></div>
<script src="https://at.alicdn.com/t/c/font_3456619_mjzgx4y7hs.js?spm=a313x.manage_type_myprojects.i1.10.500f3a81nBhv5R&file=font_3456619_mjzgx4y7hs.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/typescript/5.2.2/typescript.min.js" defer></script>
<script>
// 初始化主题
document.documentElement.setAttribute("theme", "dark")
</script>
<script type="module" src="/src/main.ts"></script>
<!-- Google tag -->
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag("js", new Date());
gtag("config", "G-NRZR81NZRZ");
window.addEventListener("load", () => {
const scriptEle = document.createElement("script")
scriptEle.src = "https://www.googletagmanager.com/gtag/js?id=G-NRZR81NZRZ"
document.body.appendChild(scriptEle)
})
</script>
</body>
</html>
5 changes: 4 additions & 1 deletion src/views/components/editor-keeper/editor-keeper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ interface IProps extends IEditorProps {
tabId: number
}

const props = defineProps<IProps>()
const props = withDefaults(defineProps<IProps>(), {
code: "",
modelValue: "",
})
const editorKeeperService = new EditorKeeperService()
const attrs = useAttrs()

Expand Down
15 changes: 9 additions & 6 deletions src/views/components/modals/template-modal/hooks/use-template.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import useCodeFormatting from "@hooks/use-code-formatting"
import useEditorWrapperState from "@hooks/use-editor-wrapper-state"
import { useEditorConfigStore } from "@store/editor-config"
import { useEditorWrapperStore } from "@store/editor-wrapper"
Expand All @@ -13,6 +14,7 @@ const useTemplate = () => {
const editorWrapperStore = useEditorWrapperStore()
const editorConfigStore = useEditorConfigStore()
const { initDefaultWrapper, initComponentWrapper } = useEditorWrapperState()
const { formatEditorCode } = useCodeFormatting()

const getTemplateBaseInfo = () => {
const { codeMap, tabMap, isComponentMode } = editorWrapperStore
Expand Down Expand Up @@ -55,7 +57,7 @@ const useTemplate = () => {

/** 应用模板 */
const applyTemplate = async (template: ITemplateBase) => {
const { codeMap, editorConfig: { libraries = {}, prepMap }, isComponent } = template
const { codeMap, editorConfig: { libraries = {}, prepMap = {} }, isComponent } = template
const { batchUpdateEditorConfig } = editorConfigStore
const { batchUpdateEditorWrapper } = editorWrapperStore
const { origin2TabIdMap } = storeToRefs(editorWrapperStore)
Expand All @@ -66,11 +68,12 @@ const useTemplate = () => {
} else {
await initDefaultWrapper()
}
// 设置代码内容
const finalCodeMap = Object.entries(origin2TabIdMap.value).reduce((acc, [origin, tabId]) => {
acc[tabId] = codeMap[origin as OriginLang] || ""
return acc
}, {} as Record<number, string>)
const finalCodeMap: Record<number, string> = {}
for (const [origin, tabId] of Object.entries(origin2TabIdMap.value)) {
const code = codeMap[origin as OriginLang] || ""
const prep = prepMap[origin as OriginLang]
finalCodeMap[tabId] = await formatEditorCode(code, prep!)
}
batchUpdateEditorWrapper({ codeMap: finalCodeMap })
// 设置编辑器预处理、库等配置
batchUpdateEditorConfig({
Expand Down
3 changes: 3 additions & 0 deletions src/views/components/modals/template-modal/template-modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
:confirm-btn-opts="{
customClass: 'p-l',
disabled: !currTemplate,
loading: isConfirmLoading,
}"
@close="updateDisplayModal(null)"
@confirm="handleConfirmModal">
Expand Down Expand Up @@ -220,7 +221,9 @@ const handleConfirmModal = () => {
const handleUseTemplate = () => {
processUseTemplate()
}
const isConfirmLoading = ref<boolean>(false)
const processUseTemplate = async () => {
isConfirmLoading.value = true
await applyTemplate(currTemplate.value!)
isShowEditTipModal.value = false
updateDisplayModal(null)
Expand Down
2 changes: 1 addition & 1 deletion src/views/components/result/result.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const processRefreshIframe = () => {
codeMap,
prepMap,
libraries,
settings.value.other.headTags,
() => settings.value.other.headTags,
], () => {
if (settings.value.execute.autoExecute) {
previewService.refreshIframe()
Expand Down