18 Commits

Author SHA1 Message Date
public_host 636d2f10c9 fix 4 years ago
public_host ce4f3eee63 fix 4 years ago
public_host 8564b74ec8 Merge remote-tracking branch 'origin/master' 4 years ago
public_host 96c6e7f780 fix 4 years ago
喵了个咪 79bc8a7fe9 fix 5 years ago
喵了个咪 927d0949e6 fix 5 years ago
喵了个咪 22e8aa2389 fix 5 years ago
3136352472 b3864e8ecd fix 5 years ago
3136352472 73bf82e3b5 fix 超时bug 5 years ago
3136352472 bb7faf28c8 fix 5 years ago
3136352472 4757a75ce1 去掉consile.log 5 years ago
3136352472 1229670576 fix 5 years ago
3136352472 28043bb6f5 fix 5 years ago
3136352472 57db461b85 fix 5 years ago
3136352472 a3e65c22c5 cache 5 years ago
3136352472 276db7e068 fix 5 years ago
3136352472 ee783db793 fix 5 years ago
3136352472 0a2a5b6441 文档更新 5 years ago
  1. 1
      .gitignore
  2. 6
      .idea/go-service-template.iml
  3. 723
      .idea/workspace.xml
  4. 20
      govue/bindata.go
  5. 34
      govue/cache.go
  6. 5
      govue/cmd/main.go
  7. 2
      govue/govue-js-src/domino
  8. 9
      govue/govue-js-src/src/index.js
  9. 795
      govue/govue-runtime/govue-dev.js
  10. 795
      govue/govue-runtime/govue-release.js
  11. 21
      govue/govue-runtime/header.js
  12. 2
      govue/govue-runtime/runtime.js
  13. 33
      govue/govue.go
  14. 327
      govue2/bindata.go
  15. 34
      govue2/cache.go
  16. 111
      govue2/cmd/main.go
  17. 57
      govue2/config.go
  18. 1
      govue2/govue-js-src/.gitignore
  19. 8
      govue2/govue-js-src/build.js
  20. 16
      govue2/govue-js-src/govue.js
  21. 40550
      govue2/govue-runtime/govue.js
  22. 176
      govue2/govue-runtime/header.js
  23. 7203
      govue2/govue-runtime/polyfill.js
  24. 43
      govue2/govue-runtime/runtime.js
  25. 211
      govue2/govue.go
  26. 58
      govue2/utils.go
  27. 22
      jsruntime/runtime.go
  28. 4
      pool/pool.go
  29. 2
      readme.md
  30. 110
      static/index.html
  31. 41
      static/index.html.bak
  32. 6
      static/index.js
  33. 21
      static/js/govue.js
  34. 38
      static/router.html
  35. 24
      static/use.js

1
.gitignore

@ -14,3 +14,4 @@
.idea
build
*.json
node_modules

6
.idea/go-service-template.iml

@ -1,11 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/govue-js-src" />
<excludeFolder url="file://$MODULE_DIR$/govue/govue-js-src" />
</content>
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>

723
.idea/workspace.xml

@ -1,679 +1,140 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="BranchesTreeState">
<expand>
<path>
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
<item name="LOCAL_ROOT" type="e8cecc67:BranchNodeDescriptor" />
</path>
<path>
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
</path>
<path>
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
<item name="GROUP_NODE:origin" type="e8cecc67:BranchNodeDescriptor" />
</path>
</expand>
<select />
</component>
<component name="ChangeListManager">
<list default="true" id="28e09409-bf4a-4792-a1b4-fc9301162fe5" name="Default Changelist" comment="fix">
<change afterPath="$PROJECT_DIR$/govue/config.go" afterDir="false" />
<change afterPath="$PROJECT_DIR$/govue/utils.go" afterDir="false" />
<change afterPath="$PROJECT_DIR$/readme.md" afterDir="false" />
<list default="true" id="1ed9cd54-bc74-41a2-84c0-b3db2772b1a0" name="Default Changelist" comment="fix">
<change afterPath="$PROJECT_DIR$/govue2/govue-js-src/.gitignore" afterDir="false" />
<change afterPath="$PROJECT_DIR$/govue2/govue-runtime/client.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/govue/bindata.go" beforeDir="false" afterPath="$PROJECT_DIR$/govue/bindata.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/govue/cmd/main.go" beforeDir="false" afterPath="$PROJECT_DIR$/govue/cmd/main.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/govue/govue-runtime/header.js" beforeDir="false" afterPath="$PROJECT_DIR$/govue/govue-runtime/header.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/govue/govue-runtime/runtime.js" beforeDir="false" afterPath="$PROJECT_DIR$/govue/govue-runtime/runtime.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/govue/govue.go" beforeDir="false" afterPath="$PROJECT_DIR$/govue/govue.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pool/pool.go" beforeDir="false" afterPath="$PROJECT_DIR$/pool/pool.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/static/css/main.css" beforeDir="false" afterPath="$PROJECT_DIR$/static/css/main.css" afterDir="false" />
<change beforePath="$PROJECT_DIR$/govue2/bindata.go" beforeDir="false" afterPath="$PROJECT_DIR$/govue2/bindata.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/govue2/govue-runtime/govue.js" beforeDir="false" afterPath="$PROJECT_DIR$/govue2/govue-runtime/govue.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/govue2/govue-runtime/header.js" beforeDir="false" afterPath="$PROJECT_DIR$/govue2/govue-runtime/header.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/govue2/govue-runtime/runtime.js" beforeDir="false" afterPath="$PROJECT_DIR$/govue2/govue-runtime/runtime.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/static/index.html" beforeDir="false" afterPath="$PROJECT_DIR$/static/index.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/static/use.js" beforeDir="false" afterPath="$PROJECT_DIR$/static/use.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/static/js/base64.js" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/static/js/govue.js" beforeDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/static/use.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="418">
<caret line="22" column="46" selection-start-line="22" selection-start-column="46" selection-end-line="22" selection-end-column="46" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/static/index.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="266">
<caret line="17" column="42" selection-start-line="17" selection-start-column="33" selection-end-line="17" selection-end-column="42" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/govue/govue.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-489">
<caret line="92" column="10" selection-start-line="92" selection-start-column="10" selection-end-line="92" selection-end-column="10" />
<folding>
<element signature="e#67#362#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/.gitignore">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="247">
<caret line="13" column="5" selection-start-line="13" selection-start-column="5" selection-end-line="13" selection-end-column="5" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/govue/cmd/main.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="57">
<caret line="26" column="31" selection-start-line="26" selection-start-column="27" selection-end-line="26" selection-end-column="31" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/readme.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="434">
<caret line="45" column="4" selection-start-line="45" selection-start-column="4" selection-end-line="45" selection-end-column="4" />
</first_editor>
<second_editor />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/govue/govue-runtime/runtime.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="304">
<caret line="19" column="20" selection-start-line="19" selection-start-column="14" selection-end-line="19" selection-end-column="20" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/govue/govue-runtime/header.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="254">
<caret line="112" column="9" selection-start-line="112" selection-start-column="9" selection-end-line="112" selection-end-column="9" />
<folding>
<element signature="e#337#1643#0" />
<element signature="e#365#1641#0" />
<element signature="e#689#715#0" />
<element signature="e#885#1189#0" />
<element signature="e#911#978#0" />
<element signature="e#1069#1129#0" />
<element signature="e#1256#1341#0" />
<element signature="e#1497#1544#0" />
<element signature="e#1562#1633#0" />
<element signature="n#!!doc;n#GetGoVueId#0" />
<element signature="e#1784#1867#0" />
<element signature="n#!!doc;n#RunInlineCode#0" />
<element signature="n#!!block;n#RunInlineCode#0" />
<element signature="e#2079#2889#0" />
<element signature="e#2233#2883#0" />
<element signature="e#2380#2430#0" />
<element signature="e#2491#2553#0" />
<element signature="e#2597#2656#0" />
<element signature="e#2688#2816#0" />
<element signature="e#2820#2873#0" />
<element signature="e#2923#3127#0" />
<element signature="e#2963#3029#0" />
<element signature="e#3067#3121#0" />
<element signature="n#!!doc;n#LoadGoParam#0" />
<element signature="e#3221#3238#0" />
<element signature="e#3269#5198#0" />
<element signature="e#3405#3428#0" />
<element signature="e#3459#4470#0" />
<element signature="e#3624#3778#0" />
<element signature="e#3964#4464#0" />
<element signature="e#4007#4067#0" />
<element signature="e#4226#4383#0" />
<element signature="e#4477#4506#0" />
<element signature="e#4538#5196#0" />
<element signature="e#4618#4835#0" />
<element signature="e#4746#4825#0" />
<element signature="e#4887#5190#0" />
<element signature="e#5017#5180#0" />
<element signature="e#5069#5166#0" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/../../../github.com/gin-gonic/gin/gin.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="183">
<caret line="295" column="22" selection-start-line="295" selection-start-column="22" selection-end-line="295" selection-end-column="22" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/govue/config.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="836">
<caret line="44" column="23" selection-start-line="44" selection-start-column="22" selection-end-line="44" selection-end-column="23" />
<folding>
<element signature="e#15#87#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="HTML File" />
<option value="JavaScript File" />
<option value="Go File" />
</list>
</option>
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>GoVueRequest</find>
<find>GoVueUse</find>
<find>暂不使用setTimeout</find>
<find>url.String()</find>
<find>loop.jobCount&quot;</find>
<find>loop.jobCount--</find>
<find>jobCount</find>
<find>Url</find>
<find>vue</find>
<find>jobCount--</find>
<find>GoUseRegisteredCall</find>
<find>GoUseCall</find>
<find>console</find>
<find>GoQuery</find>
<find>路由未找到</find>
<find>query</find>
<find>GoParam</find>
<find>RunString</find>
<find>Runs</find>
<find>timeo</find>
<find>dist</find>
<find>CreateFile</find>
<find>NotYetImplemented</find>
<find>v_ignore_class</find>
<find>govue-src</find>
<find>gv-common</find>
<find>hasaki</find>
<find>hsk</find>
<find>hskutils</find>
</findStrings>
</component>
<component name="GOROOT" path="C:\Go" />
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/govue-runtime/XMLHttpRequest.js" />
<option value="$PROJECT_DIR$/eventloop/eventloop.go" />
<option value="$PROJECT_DIR$/console/module.go" />
<option value="$PROJECT_DIR$/jsruntime/interval.go" />
<option value="$PROJECT_DIR$/jsruntime/console.go" />
<option value="$PROJECT_DIR$/jsruntime/go_request.go" />
<option value="$PROJECT_DIR$/jsruntime/use_callback.go" />
<option value="$PROJECT_DIR$/govue-runtime/runtime.js" />
<option value="$PROJECT_DIR$/jsruntime/timeout.go" />
<option value="$PROJECT_DIR$/govue-runtime/request.js" />
<option value="$PROJECT_DIR$/govue-runtime/header.js" />
<option value="$PROJECT_DIR$/../../../github.com/dop251/goja/runtime.go" />
<option value="$PROJECT_DIR$/jsruntime/runtime.go" />
<option value="$PROJECT_DIR$/main.go" />
<option value="$PROJECT_DIR$/govue/govue-runtime/govue.js" />
<option value="$PROJECT_DIR$/static/index.js" />
<option value="$PROJECT_DIR$/govue/govue-runtime/runtime.js" />
<option value="$PROJECT_DIR$/govue/govue-runtime/header.js" />
<option value="$PROJECT_DIR$/static/css/main.css" />
<option value="$PROJECT_DIR$/static/index.html" />
<option value="$PROJECT_DIR$/static/use.js" />
<option value="$PROJECT_DIR$/pool/pool.go" />
<option value="$PROJECT_DIR$/govue/utils.go" />
<option value="$PROJECT_DIR$/govue.json" />
<option value="$PROJECT_DIR$/govue/config.go" />
<option value="$PROJECT_DIR$/govue/cmd/main.go" />
<option value="$PROJECT_DIR$/readme.md" />
<option value="$PROJECT_DIR$/govue/govue.go" />
<option value="$PROJECT_DIR$/.gitignore" />
</list>
</option>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="130" />
<option name="y" value="36" />
<option name="width" value="1710" />
<option name="height" value="967" />
</component>
<component name="ProjectView">
<navigator proportions="" version="1">
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="go-service-template" type="b2602c69:ProjectViewProjectNode" />
<item name="go-service-template" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="go-service-template" type="b2602c69:ProjectViewProjectNode" />
<item name="go-service-template" type="462c0819:PsiDirectoryNode" />
<item name="govue" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="go-service-template" type="b2602c69:ProjectViewProjectNode" />
<item name="go-service-template" type="462c0819:PsiDirectoryNode" />
<item name="govue" type="462c0819:PsiDirectoryNode" />
<item name="cmd" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="go-service-template" type="b2602c69:ProjectViewProjectNode" />
<item name="go-service-template" type="462c0819:PsiDirectoryNode" />
<item name="govue" type="462c0819:PsiDirectoryNode" />
<item name="govue-runtime" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="go-service-template" type="b2602c69:ProjectViewProjectNode" />
<item name="go-service-template" type="462c0819:PsiDirectoryNode" />
<item name="static" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="go-service-template" type="b2602c69:ProjectViewProjectNode" />
<item name="go-service-template" type="462c0819:PsiDirectoryNode" />
<item name="static" type="462c0819:PsiDirectoryNode" />
<item name="css" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="Scope" />
</panes>
<component name="ProjectId" id="1dJLbYMiy9MlHcALaEI4SeWe1wf" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="DefaultGoTemplateProperty" value="Go File" />
<property name="DefaultHtmlFileTemplate" value="HTML File" />
<property name="GO_FMT" value="true" />
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="go.gopath.indexing.explicitly.defined" value="true" />
<property name="go.import.settings.migrated" value="true" />
<property name="go.sdk.automatically.set" value="true" />
<property name="last_opened_file_path" value="$USER_HOME$" />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/govue2/govue-js-src" />
<property name="nodejs_package_manager_path" value="npm" />
<property name="settings.editor.selected.configurable" value="preferences.pluginManager" />
</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="C:\Users\wailo\go\src\git.ouxuan.net\3136352472\go-service-template\static\js" />
<recent name="C:\Users\wailo\go\src\git.ouxuan.net\3136352472\go-service-template\static" />
<recent name="C:\Users\wailo\go\src\git.ouxuan.net\3136352472\go-service-template\govue\govue-runtime" />
<recent name="C:\Users\wailo\go\src\git.ouxuan.net\3136352472\go-service-template\govue-runtime" />
<recent name="C:\Users\wailo\go\src\git.ouxuan.net\3136352472\go-service-template" />
<recent name="C:\Users\admin\go\src\git.ouxuan.net\3136352472\go-service-template\govue2\govue-js-src" />
<recent name="C:\Users\admin\go\src\git.ouxuan.net\3136352472\go-service-template\static" />
<recent name="C:\Users\admin\go\src\git.ouxuan.net\3136352472\go-service-template\govue2\govue-runtime" />
<recent name="C:\Users\admin\go\src\git.ouxuan.net\3136352472\go-service-template" />
</key>
<key name="MoveFile.RECENT_KEYS">
<recent name="C:\Users\wailo\go\src\git.ouxuan.net\3136352472\go-service-template\static\js" />
<recent name="C:\Users\wailo\go\src\git.ouxuan.net\3136352472\go-service-template\govue" />
<recent name="C:\Users\wailo\go\src\git.ouxuan.net\3136352472\go-service-template" />
</key>
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager">
<configuration name="govue" type="GoApplicationRunConfiguration" factoryName="Go Application">
<configuration name="go build git.ouxuan.net/3136352472/go-service-template/govue2/cmd" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
<module name="go-service-template" />
<working_directory value="$PROJECT_DIR$/" />
<go_parameters value="-i" />
<kind value="DIRECTORY" />
<filePath value="$PROJECT_DIR$/" />
<package value="git.ouxuan.net/3136352472/go-service-template" />
<directory value="C:\Users\admin\go\src\git.ouxuan.net\3136352472\go-service-template\govue\cmd" />
<output_directory value="$PROJECT_DIR$/" />
<kind value="PACKAGE" />
<filePath value="$PROJECT_DIR$/govue2/cmd/main.go" />
<package value="git.ouxuan.net/3136352472/go-service-template/govue2/cmd" />
<directory value="$PROJECT_DIR$/" />
<method v="2" />
</configuration>
</component>
<component name="ToolWindowManager">
<frame x="-8" y="-8" width="1936" height="1056" extended-state="6" />
<editor active="true" />
<layout>
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.36993605" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info anchor="bottom" id="Run" order="2" sideWeight="0.49101797" visible="true" weight="0.2733189" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="bottom" id="Docker" order="7" show_stripe_button="false" />
<window_info anchor="bottom" id="Database Changes" order="8" />
<window_info anchor="bottom" id="Version Control" order="9" sideWeight="0.499501" weight="0.32997987" />
<window_info anchor="bottom" id="Terminal" order="10" sideWeight="0.49151698" weight="0.3275488" />
<window_info anchor="bottom" id="Event Log" order="11" sideWeight="0.500499" side_tool="true" weight="0.32997987" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
<window_info anchor="right" id="Database" order="3" />
</layout>
<recent_temporary>
<list>
<item itemvalue="Go Build.go build git.ouxuan.net/3136352472/go-service-template/govue2/cmd" />
</list>
</recent_temporary>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
<option name="version" value="2" />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State />
</value>
</entry>
</map>
</option>
<option name="oldMeFiltersMigrated" value="true" />
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="fix" />
<option name="LAST_COMMIT_MESSAGE" value="fix" />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/../../../github.com/dop251/goja/object_gomap_reflect_test.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="346">
<caret line="91" column="55" selection-start-line="91" selection-start-column="28" selection-end-line="91" selection-end-column="55" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../../../github.com/dop251/goja_nodejs/eventloop/eventloop.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="205">
<caret line="67" column="69" selection-start-line="67" selection-start-column="23" selection-end-line="67" selection-end-column="69" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/static/main.js" />
<entry file="file://$PROJECT_DIR$/eventloop/eventloop.go" />
<entry file="file://$PROJECT_DIR$/../../../github.com/dop251/goja_nodejs/require/module.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1736">
<caret line="43" column="19" selection-start-line="43" selection-start-column="19" selection-end-line="43" selection-end-column="19" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/console/module.go" />
<entry file="file://$PROJECT_DIR$/../../hasaki-service/hasaki-sdk/hskhttpdo/httpdo.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="379">
<caret line="33" column="37" selection-start-line="33" selection-start-column="37" selection-end-line="33" selection-end-column="37" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../../../github.com/gin-gonic/gin/context.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="188">
<caret line="45" column="14" selection-start-line="45" selection-start-column="14" selection-end-line="45" selection-end-column="27" />
</state>
</provider>
</entry>
<entry file="file://C:/Go/src/time/tick.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="169">
<caret line="10" column="20" selection-start-line="10" selection-start-column="20" selection-end-line="10" selection-end-column="20" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/jsruntime/use_callback.go" />
<entry file="file://$PROJECT_DIR$/jsruntime/go_request.go" />
<entry file="file://$PROJECT_DIR$/jsruntime/interval.go" />
<entry file="file://$PROJECT_DIR$/jsruntime/console.go" />
<entry file="file://$PROJECT_DIR$/../../../github.com/wailovet/android-vrc/cmd/main.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="399">
<caret line="28" column="57" selection-start-line="28" selection-start-column="57" selection-end-line="28" selection-end-column="57" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../../../github.com/elazarl/go-bindata-assetfs/assetfs.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="327">
<caret line="132" column="43" lean-forward="true" selection-start-line="132" selection-start-column="43" selection-end-line="132" selection-end-column="43" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/bindata.go" />
<entry file="file://C:/Go/src/net/http/fs.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="224">
<caret line="716" column="5" selection-start-line="716" selection-start-column="5" selection-end-line="716" selection-end-column="5" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/jsruntime/timeout.go" />
<entry file="file://C:/Go/src/time/time.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="210">
<caret line="1163" column="24" selection-start-line="1163" selection-start-column="14" selection-end-line="1163" selection-end-column="24" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/govue-runtime/request.js" />
<entry file="file://$PROJECT_DIR$/govue/bindata.go" />
<entry file="file://$PROJECT_DIR$/jsruntime/runtime.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="3306">
<caret line="186" column="5" selection-start-line="186" selection-start-column="5" selection-end-line="186" selection-end-column="5" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/main.go" />
<entry file="file://$PROJECT_DIR$/../../../github.com/jolestar/go-commons-pool/pool.go" />
<entry file="file://$PROJECT_DIR$/static/js/modernizr-3.8.0.min.js" />
<entry file="file://$PROJECT_DIR$/static/js/main.js" />
<entry file="file://$PROJECT_DIR$/static/js/jquery-3.4.1.min.js" />
<entry file="file://$PROJECT_DIR$/static/css/normalize.css" />
<entry file="file://$PROJECT_DIR$/../../../github.com/jolestar/go-commons-pool/config.go" />
<entry file="file://$PROJECT_DIR$/../../../github.com/dop251/goja/runtime.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="14934">
<caret line="802" column="36" selection-start-line="802" selection-start-column="36" selection-end-line="802" selection-end-column="36" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/static/js/vue.min.js" />
<entry file="file://$PROJECT_DIR$/govue/govue-runtime/govue.js" />
<entry file="file://$PROJECT_DIR$/../../../github.com/dop251/goja/parser/parser.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2356">
<caret line="133" column="46" selection-start-line="133" selection-start-column="38" selection-end-line="133" selection-end-column="46" />
</state>
</provider>
</entry>
<entry file="file://$APPLICATION_HOME_DIR$/plugins/JavaScriptLanguage/jsLanguageServicesImpl/external/lib.dom.d.ts">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="19">
<caret line="4750" column="4" selection-start-line="4750" selection-start-column="4" selection-end-line="4750" selection-end-column="4" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/static/index.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="38">
<caret line="2" column="11" selection-start-line="2" selection-start-column="11" selection-end-line="3" selection-end-column="62" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/static/css/main.css">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="304">
<caret line="16" column="1" selection-start-line="16" selection-start-column="1" selection-end-line="16" selection-end-column="1" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../../hasaki-service/hasaki-sdk/hskutils/utils.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="156">
<caret line="32" selection-start-line="32" selection-end-line="42" selection-end-column="1" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/pool/pool.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="209">
<caret line="17" column="34" selection-start-line="17" selection-start-column="34" selection-end-line="17" selection-end-column="34" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../updatemanage/helper/helper.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="156">
<caret line="50" selection-start-line="50" selection-end-line="54" selection-end-column="1" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/govue.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="38">
<caret line="2" column="25" selection-start-line="2" selection-start-column="25" selection-end-line="2" selection-end-column="25" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/govue/utils.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="299">
<caret line="49" column="19" selection-start-line="49" selection-start-column="19" selection-end-line="49" selection-end-column="19" />
<folding>
<element signature="e#15#70#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../../../github.com/gin-gonic/gin/gin.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="183">
<caret line="295" column="22" selection-start-line="295" selection-start-column="22" selection-end-line="295" selection-end-column="22" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/govue/cmd/main.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="57">
<caret line="26" column="31" selection-start-line="26" selection-start-column="27" selection-end-line="26" selection-end-column="31" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/govue/config.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="836">
<caret line="44" column="23" selection-start-line="44" selection-start-column="22" selection-end-line="44" selection-end-column="23" />
<folding>
<element signature="e#15#87#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/static/use.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="418">
<caret line="22" column="46" selection-start-line="22" selection-start-column="46" selection-end-line="22" selection-end-column="46" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/govue/govue-runtime/header.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="254">
<caret line="112" column="9" selection-start-line="112" selection-start-column="9" selection-end-line="112" selection-end-column="9" />
<folding>
<element signature="e#337#1643#0" />
<element signature="e#365#1641#0" />
<element signature="e#689#715#0" />
<element signature="e#885#1189#0" />
<element signature="e#911#978#0" />
<element signature="e#1069#1129#0" />
<element signature="e#1256#1341#0" />
<element signature="e#1497#1544#0" />
<element signature="e#1562#1633#0" />
<element signature="n#!!doc;n#GetGoVueId#0" />
<element signature="e#1784#1867#0" />
<element signature="n#!!doc;n#RunInlineCode#0" />
<element signature="n#!!block;n#RunInlineCode#0" />
<element signature="e#2079#2889#0" />
<element signature="e#2233#2883#0" />
<element signature="e#2380#2430#0" />
<element signature="e#2491#2553#0" />
<element signature="e#2597#2656#0" />
<element signature="e#2688#2816#0" />
<element signature="e#2820#2873#0" />
<element signature="e#2923#3127#0" />
<element signature="e#2963#3029#0" />
<element signature="e#3067#3121#0" />
<element signature="n#!!doc;n#LoadGoParam#0" />
<element signature="e#3221#3238#0" />
<element signature="e#3269#5198#0" />
<element signature="e#3405#3428#0" />
<element signature="e#3459#4470#0" />
<element signature="e#3624#3778#0" />
<element signature="e#3964#4464#0" />
<element signature="e#4007#4067#0" />
<element signature="e#4226#4383#0" />
<element signature="e#4477#4506#0" />
<element signature="e#4538#5196#0" />
<element signature="e#4618#4835#0" />
<element signature="e#4746#4825#0" />
<element signature="e#4887#5190#0" />
<element signature="e#5017#5180#0" />
<element signature="e#5069#5166#0" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/govue/govue-runtime/runtime.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="304">
<caret line="19" column="20" selection-start-line="19" selection-start-column="14" selection-end-line="19" selection-end-column="20" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/static/index.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="266">
<caret line="17" column="42" selection-start-line="17" selection-start-column="33" selection-end-line="17" selection-end-column="42" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/readme.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="434">
<caret line="45" column="4" selection-start-line="45" selection-start-column="4" selection-end-line="45" selection-end-column="4" />
</first_editor>
<second_editor />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/govue/govue.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-489">
<caret line="92" column="10" selection-start-line="92" selection-start-column="10" selection-end-line="92" selection-end-column="10" />
<folding>
<element signature="e#67#362#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/.gitignore">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="247">
<caret line="13" column="5" selection-start-line="13" selection-start-column="5" selection-end-line="13" selection-end-column="5" />
</state>
</provider>
</entry>
<component name="WindowStateProjectService">
<state x="401" y="468" key="#GOROOT" timestamp="1592138464823">
<screen x="0" y="0" width="1890" height="1024" />
</state>
<state x="401" y="468" key="#GOROOT/0.0.1890.1024@0.0.1890.1024" timestamp="1592138464823" />
<state width="1729" height="262" key="GridCell.Tab.0.bottom" timestamp="1592237447787">
<screen x="0" y="0" width="1890" height="1024" />
</state>
<state width="1729" height="262" key="GridCell.Tab.0.bottom/0.0.1890.1024@0.0.1890.1024" timestamp="1592237447787" />
<state width="1729" height="262" key="GridCell.Tab.0.center" timestamp="1592237447787">
<screen x="0" y="0" width="1890" height="1024" />
</state>
<state width="1729" height="262" key="GridCell.Tab.0.center/0.0.1890.1024@0.0.1890.1024" timestamp="1592237447787" />
<state width="1729" height="262" key="GridCell.Tab.0.left" timestamp="1592237447787">
<screen x="0" y="0" width="1890" height="1024" />
</state>
<state width="1729" height="262" key="GridCell.Tab.0.left/0.0.1890.1024@0.0.1890.1024" timestamp="1592237447787" />
<state width="1729" height="262" key="GridCell.Tab.0.right" timestamp="1592237447787">
<screen x="0" y="0" width="1890" height="1024" />
</state>
<state width="1729" height="262" key="GridCell.Tab.0.right/0.0.1890.1024@0.0.1890.1024" timestamp="1592237447787" />
<state x="370" y="243" key="Vcs.Push.Dialog.v2" timestamp="1592164477832">
<screen x="0" y="0" width="1890" height="1024" />
</state>
<state x="370" y="243" key="Vcs.Push.Dialog.v2/0.0.1890.1024@0.0.1890.1024" timestamp="1592164477832" />
<state x="477" y="243" width="599" height="534" key="find.popup" timestamp="1592161830863">
<screen x="0" y="0" width="1890" height="1024" />
</state>
<state x="477" y="243" width="599" height="534" key="find.popup/0.0.1890.1024@0.0.1890.1024" timestamp="1592161830863" />
</component>
</project>

20
govue/bindata.go
File diff suppressed because it is too large
View File

34
govue/cache.go

@ -0,0 +1,34 @@
package govue
import (
"sync"
"time"
)
var cache sync.Map
type mcache struct {
html string
creation int64
timeoutSec int64
}
func GetCache(key string) string {
v, _ := cache.Load(key)
if v != nil {
mc := v.(*mcache)
if time.Now().Unix() < mc.creation+mc.timeoutSec {
//log.Println("加载缓存")
return mc.html
}
}
return ""
}
func SetCache(key string, val string, timeoutSec int64) {
cache.Store(key, &mcache{
html: val,
creation: time.Now().Unix(),
timeoutSec: timeoutSec,
})
}

5
govue/cmd/main.go

@ -8,7 +8,6 @@ import (
"github.com/google/uuid"
"log"
"mime"
"net/http"
"path/filepath"
)
@ -75,7 +74,7 @@ func main() {
config.ErrorPage404 = errorPage404
}
gv.SetErrorPage404(config.ErrorPage404)
gv.SetCacheSec(5)
if err != nil {
panic(err)
}
@ -92,7 +91,7 @@ func main() {
}
if extData["cookie"].(map[string]string)["extdatasessionkey"] == "" {
context.SetCookie("extdatasessionkey", uuid.Must(uuid.NewUUID()).String(), 0, "", context.Request.Host, http.SameSiteLaxMode, false, false)
context.SetCookie("extdatasessionkey", uuid.Must(uuid.NewUUID()).String(), 0, "", context.Request.Host, false, false)
}
raw, err := gv.LoadStaticResources(context.Request, extData)

2
govue/govue-js-src/domino

@ -1 +1 @@
Subproject commit 91d80b72bce7c7361823eb5403ada13d878702db
Subproject commit e543301316335417ae43e5e645361fe2669fd05b

9
govue/govue-js-src/src/index.js

@ -33,9 +33,16 @@ function HTMLEncode(html) {
temp = null;
return output;
}
function Base64Encode(html) {
return new Buffer(html).toString('base64');
}
Vue.extend = function (a, b) {
if (Vue.use_raw) {
var template = HTMLEncode(a.template)
var template = Base64Encode(a.template)
a.template = "<gv-template-html>" + template + "</gv-template-html>"
Vue.use_raw = false;
}

795
govue/govue-runtime/govue-dev.js
File diff suppressed because it is too large
View File

795
govue/govue-runtime/govue-release.js
File diff suppressed because it is too large
View File

21
govue/govue-runtime/header.js

@ -103,7 +103,7 @@ function GoVueRender(template, app, context) {
var raw = GoReadFile(template);
console.log(vuessr);
// console.log(vuessr);
var renderer = vuessr.createRenderer({
template: raw
@ -207,6 +207,12 @@ var GoVueIgnore = function () {
* 忽略前置
*/
this.ignore = function () {
var templateTagNodes = document.getElementsByTagName("template");
for(var i = 0;i<templateTagNodes.length;i++){
templateTagNodes[i].outerHTML = templateTagNodes[i].outerHTML.replace(/<template/g,"<gv-template").replace(/<\/template>/g,"</gv-template>")
}
var gv_ignore = document.getElementsByTagName("gv-ignore");
gv_ignore_len = gv_ignore.length;
for (var i = gv_ignore_len - 1; i >= 0; i--) {
@ -215,7 +221,8 @@ var GoVueIgnore = function () {
}
var gv_ignore_class = document.querySelectorAll("[gv-ignore]");
gv_ignore_class_len = gv_ignore_class.length;
// console.log("gv_ignore_class_len",gv_ignore_class_len)
// console.log(document.innerHTML);
// console.log("gv_ignore_class_len",gv_ignore_class_len)
for (var i = 0; i < gv_ignore_class_len; i++) {
if (!gv_ignore_class_map[i]) {
gv_ignore_class_map[i] = {};
@ -232,6 +239,14 @@ var GoVueIgnore = function () {
gv_ignore_class[i].removeAttribute("gv-ignore");
gv_ignore_class[i].setAttribute("gv-ignore-val", "gv-ignore-" + i)
}
var templateTagNodes = document.getElementsByTagName("gv-template");
for(var i = 0;i<templateTagNodes.length;i++){
templateTagNodes[i].outerHTML = templateTagNodes[i].outerHTML.replace(/<gv-template/g,"<template").replace(/<\/gv-template>/g,"</template>")
}
};
/**
@ -306,6 +321,6 @@ function GoVueRestoreRawTemplate() {
var template = document.getElementsByTagName("gv-template-html");
for (var i in template) {
template[i].outerHTML = HTMLDecode(template[i].innerHTML);
template[i].outerHTML = Base64Decode(template[i].innerHTML);
}
}

2
govue/govue-runtime/runtime.js

@ -21,7 +21,7 @@ if (!IS_VUE_SSR) {
var goVueIgnore = new GoVueIgnore();
goVueIgnore.ignore();
// console.log(document.innerHTML);
} catch (e) {
console.log("goVueIgnore.ignore:" + e);
}

33
govue/govue.go

@ -23,6 +23,7 @@ type GoVue struct {
Resources *assetfs.AssetFS
IsDebugMode bool
jsRuntimePool *pool.JsRuntimePool
CacheSec int64
}
func NewGoVueDefaultConfig(debug bool) (gv *GoVue, err error) {
@ -46,6 +47,10 @@ func NewGoVue(useJsPath string, staticPath string, debug bool) (gv *GoVue, err e
return
}
func (gv *GoVue) SetCacheSec(cacheSec int64) {
gv.CacheSec = cacheSec
}
func (gv *GoVue) SetErrorPage404(page string) {
gv.ErrorPage404 = page
}
@ -146,6 +151,16 @@ func (gv *GoVue) StartPoolLog() {
}
func (gv *GoVue) LoadStaticResources(request *http.Request, goExtDataS ...interface{}) (result []byte, err error) {
cacheKey := fmt.Sprintf("%s|%s", request.URL.Path, request.URL.RawQuery)
if gv.CacheSec > 0 {
html := GetCache(cacheKey)
if html != "" {
//log.Println("加载缓存")
return []byte(html), nil
}
}
//log.Println("非缓存", cacheKey)
var staticDir string
var filePath = request.URL.Path
@ -183,9 +198,20 @@ func (gv *GoVue) LoadStaticResources(request *http.Request, goExtDataS ...interf
}
result, err = ioutil.ReadFile(filePath)
if err != nil {
return gv.renderErrPage(404, request, goExtDataS...)
govueDebug := request.URL.Query().Get("govue_debug")
if govueDebug == "1" {
return
}
if err != nil {
result, err = gv.renderErrPage(404, request, goExtDataS...)
if gv.CacheSec > 0 {
SetCache(cacheKey, string(result), gv.CacheSec)
}
return
} //
if filepath.Ext(filePath) != ".html" && filepath.Ext(filePath) != ".vue" {
return
}
@ -203,6 +229,9 @@ func (gv *GoVue) LoadStaticResources(request *http.Request, goExtDataS ...interf
err = jr.Render(filePath, fmt.Sprintf("http://%s%s", request.Host, request.RequestURI), string(result), goExtData, func(data string) {
result = []byte(data)
if gv.CacheSec > 0 {
SetCache(cacheKey, string(result), gv.CacheSec)
}
})
if err != nil {
result = []byte(err.Error())

327
govue2/bindata.go
File diff suppressed because it is too large
View File

34
govue2/cache.go

@ -0,0 +1,34 @@
package govue2
import (
"sync"
"time"
)
var cache sync.Map
type mcache struct {
html string
creation int64
timeoutSec int64
}
func GetCache(key string) string {
v, _ := cache.Load(key)
if v != nil {
mc := v.(*mcache)
if time.Now().Unix() < mc.creation+mc.timeoutSec {
//log.Println("加载缓存")
return mc.html
}
}
return ""
}
func SetCache(key string, val string, timeoutSec int64) {
cache.Store(key, &mcache{
html: val,
creation: time.Now().Unix(),
timeoutSec: timeoutSec,
})
}

111
govue2/cmd/main.go

@ -0,0 +1,111 @@
package main
import (
"flag"
"fmt"
govue "git.ouxuan.net/3136352472/go-service-template/govue2"
"github.com/gin-gonic/gin"
"log"
"mime"
"path/filepath"
)
func main() {
var addr string
var static string
var useFile string
var mode string
var path string
var errorPage404 string
flag.StringVar(&path, "config", "govue.json", "配置文件路径")
flag.StringVar(&static, "static", "", "静态文件目录")
flag.StringVar(&addr, "addr", "", "监听ip:port")
flag.StringVar(&mode, "mode", "", "模式release/debug")
flag.StringVar(&errorPage404, "error_page_404", "", "404错误页面路径")
flag.Parse()
if flag.Arg(0) == "init" {
err := govue.GenerateConfig(path)
if err != nil {
fmt.Print("文件:", path, "\n生成失败:", err)
} else {
abs, _ := filepath.Abs(path)
fmt.Print("文件:", abs, "\n生成成功:")
}
return
}
config, err := govue.GetConfig(path)
fmt.Println("配置载入:", path)
fmt.Println("渲染协程池最大总数:", config.Pool.MaxTotal)
fmt.Println("渲染协程池最大空闲数:", config.Pool.MaxIdle)
fmt.Println("渲染协程池最小空闲数:", config.Pool.MinIdle)
if addr != "" {
config.Addr = addr
}
if static != "" {
config.StaticDir = static
}
if useFile != "" {
config.UseJsFile = useFile
}
if mode != "" {
config.Mode = mode
}
gin.SetMode(config.Mode)
r := gin.Default()
govue.SetPoolConfig(config.Pool)
gv, err := govue.NewGoVue(config.UseJsFile, config.StaticDir, config.Mode == "debug")
if errorPage404 != "" {
config.ErrorPage404 = errorPage404
}
gv.SetErrorPage404(config.ErrorPage404)
gv.SetCacheSec(5)
if err != nil {
panic(err)
}
r.NoRoute(func(context *gin.Context) {
raw, err := gv.LoadStaticResources(context.Request)
if err != nil {
_, _ = context.Writer.Write(raw)
return
}
mime.TypeByExtension(filepath.Ext(context.Request.URL.Path))
ext := filepath.Ext(context.Request.URL.Path)
if ext == "" {
ext = ".html"
}
context.Writer.Header().Set("Content-Type", mime.TypeByExtension(ext)+"; charset=utf-8")
context.Writer.WriteHeader(200)
_, _ = context.Writer.Write(raw)
})
r.Use(func(context *gin.Context) {
context.Header("Access-Control-Allow-Origin", "*")
context.Header("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")
context.Header("Access-Control-Allow-Headers", "Action, Module, X-PINGOTHER, Content-Type, Content-Disposition")
})
gv.StartPoolLog()
for {
err = r.Run(config.Addr)
if err != nil {
log.Println("服务意外停止:", err)
}
}
}

57
govue2/config.go

@ -0,0 +1,57 @@
package govue2
import (
"errors"
"git.ouxuan.net/3136352472/go-service-template/pool"
)
type Config struct {
Addr string `json:"addr"`
StaticDir string `json:"static_dir"`
UseJsFile string `json:"use_js_file"`
ErrorPage404 string `json:"error_page_404"`
Mode string `json:"mode"`
Pool pool.Config `json:"pool"`
}
func GenerateConfig(path string) (err error) {
if pathExists(path) {
err = errors.New("配置文件已存在")
return
}
config := Config{
Addr: "0.0.0.0:8080",
StaticDir: "static",
UseJsFile: "static/use.js",
Mode: "release",
Pool: pool.Config{
MaxIdle: 2000,
MinIdle: 5,
MaxTotal: 6000,
},
}
jsonToFile(path, config)
return
}
func GetConfig(path string) (c *Config, err error) {
c = &Config{
Addr: "0.0.0.0:8080",
StaticDir: "static",
UseJsFile: "static/use.js",
Mode: "release",
Pool: pool.Config{
MaxIdle: 2000,
MinIdle: 5,
MaxTotal: 6000,
},
}
if pathExists(path) {
jsonByFile(path, c)
}
return
}

1
govue2/govue-js-src/.gitignore

@ -0,0 +1 @@
node_modules

8
govue2/govue-js-src/build.js

@ -0,0 +1,8 @@
var fs = require("fs");
var envify = require('envify/custom')
var browserify = require("browserify");
browserify("./govue.js")
.transform({ global: true }, envify({ NODE_ENV: 'production' }))
.bundle()
.pipe(fs.createWriteStream("../govue-runtime/govue.js"));

16
govue2/govue-js-src/govue.js

@ -0,0 +1,16 @@
var process = { env: { VUE_ENV: "server", NODE_ENV: "production" } }; this.global = { process: process };
Promise = require('es6-promise').Promise;
require('Vue');
require('vue-router')
require('vue-server-renderer')
require('axios');
require('qs');
require('axios/lib/helpers/buildURL');
require('axios/lib/core/buildFullPath');
require('axios/lib/core/settle');
require('axios/lib/core/createError');
require("htmlparser2");
GV.init = function(cb){
cb(require)
}

40550
govue2/govue-runtime/govue.js
File diff suppressed because it is too large
View File

176
govue2/govue-runtime/header.js

@ -0,0 +1,176 @@
var GV = {};
var isBrowser = false;
var Promise;
var GoUseCallback;
var GoUse = function (cb) {
GoUseCallback = "with(this){(" + cb.toString() + ")()}";
}
var net = {
request: function (c) {
var url = c["url"];
var data = c["data"];
var header = c["header"];
var method = c["method"];
var dataType = c["dataType"];
var timeout = c["timeout"];
var success = c["success"];
var fail = c["fail"];
var complete = c["complete"];
var isHost = url.indexOf("http://") > -1 || url.indexOf("https://") > -1;
var isAbs = (url[0] == '/');
if (!isHost) {
if (!isAbs) {
url = location.pathname + "/" + url
}
url = location.host + "/" + url;
for (; url.indexOf("//") > -1;) {
url = url.replace("//", "/")
}
url = location.protocol + "//" + url
}
if (data) {
if (method == "GET") {
url = $.param.querystring(url, data);
data = ""
} else {
if (typeof (data) == "object") {
if (header["Content-Type"].indexOf("application/json") > -1 || header["content-type"].indexOf("application/json") > -1) {
data = JSON.stringify(data);
} else {
data = $.param(data);
}
}
}
}
var resp = GoRequest({
url: url,
data: data,
method: method,
header: header,
timeout: timeout
});
resp = JSON.parse(resp);
var statusCode = resp["statusCode"];
var result = resp["data"];
if (dataType == "json") {
result = JSON.parse(result)
}
if (statusCode == 200) {
success && success({
data: result,
statusCode: statusCode + "",
});
} else {
fail && fail({
data: result,
statusCode: statusCode + "",
})
}
}
};
var axiosUse = function (ctx) {
var buildURL = ctx.require('axios/lib/helpers/buildURL');
var buildFullPath = ctx.require('axios/lib/core/buildFullPath');
var settle = ctx.require('axios/lib/core/settle');
var createError = ctx.require('axios/lib/core/createError');
function transformResponse(mpResponse, config, mpRequestOption) {
var headers = mpResponse.header || mpResponse.headers;
var status = mpResponse.statusCode || mpResponse.status;
var statusText = '';
if (status === 200) {
statusText = 'OK';
} else if (status === 400) {
statusText = 'Bad Request';
}
var response = {
data: mpResponse.data,
status: status,
statusText: statusText,
headers: headers,
config: config,
request: mpRequestOption
};
return response;
}
ctx.axios.defaults.adapter = function (config) {
return new Promise(function (resolve, reject) {
var mpRequestOption = {
url: buildURL(buildFullPath(config.baseURL, config.url), config.params, config.paramsSerializer),
method: config["method"] ? config["method"].toUpperCase() : "get",
data: config["data"],
header: config["headers"],
timeout: config["timeout"],
success: function (mpResponse) {
var response = transformResponse(mpResponse, config, mpRequestOption);
settle(resolve, reject, response);
},
fail: function (error) {
reject(createError(error.data));
},
};
net.request(mpRequestOption)
})
};
}
var GetGoVueTemplate = function (raw) {
var tagStart = "<!--gv-start-->";
var tagEnd = "<!--gv-end-->";
var start = raw.indexOf(tagStart)
if (start < 0) {
return
}
var end = raw.indexOf(tagEnd)
if (end < 0) {
throw "注释未闭合"
return
}
var content = raw.substring(start + tagStart.length, end);
var template = raw.substring(0, start) + "<!--vue-ssr-outlet-->\n{{{GoVueTemplate}}}\n{{{GoVueData}}}" + raw.substr(end + tagEnd.length);
return {
template: template,
content: content,
}
}
var GetGoVueJsCode = function (htmlparser2, raw) {
var codes = [];
var flag = false;
var parser = new htmlparser2.Parser(
{
onopentag: function (name, attribs) {
flag = (name === "script" && (attribs["gv-src"] || attribs["gv-src"] === ""))
if (flag) {
if (attribs.src) {
codes.push(GoReadFile(attribs.src))
}
}
// console.log("name", name, attribs["gv-src"]);
},
ontext: function (text) {
if (flag && text && text !== "") {
codes.push(text)
}
// console.log("-->", text);
},
},
{decodeEntities: true}
);
parser.write(raw)
parser.end();
return codes;
}

7203
govue2/govue-runtime/polyfill.js
File diff suppressed because it is too large
View File

43
govue2/govue-runtime/runtime.js

@ -0,0 +1,43 @@
GV.init(function (_require) {
new (function () {
this.require = _require;
this.Vue = _require('Vue');
this.VueRouter = _require('vue-router');
this.Vue.use(this.VueRouter)
this.axios = _require('axios');
var htmlparser2 = _require('htmlparser2');
axiosUse(this);
this.qs = _require('qs');
this.GoVueMount = function (app, context) {
var ctx = GetGoVueTemplate(GoHtmlSrc)
app.$options.template = ctx.content;
// console.log(ctx.template)
var renderer = _require('vue-server-renderer').createRenderer({
template: ctx.template
})
if(!context){
context = {}
}
context.GoVueTemplate = "<go-vue-template style='display: none'>" + Base64Encode(encodeURIComponent(ctx.content)) + "</go-vue-template>"
context.GoVueData = "<go-vue-data style='display: none'>" + Base64Encode(encodeURIComponent(JSON.stringify(app.$data))) + "</go-vue-data>"
renderer.renderToString(app, context, function (err, html) {
if (err) {
throw err
} else {
GoReturn(html);
}
})
}
eval(GoUseCallback)
var codes = GetGoVueJsCode(htmlparser2, GoHtmlSrc)
for(var i in codes){
eval("with(this){" + codes[i] + "}")
}
})()
})

211
govue2/govue.go

@ -0,0 +1,211 @@
package govue2
//go-bindata-assetfs --pkg=govue govue-runtime/...
import (
"fmt"
"git.ouxuan.net/3136352472/go-service-template/jsruntime"
"git.ouxuan.net/3136352472/go-service-template/pool"
"github.com/elazarl/go-bindata-assetfs"
"io/ioutil"
"log"
"net/http"
"os"
"path/filepath"
"time"
)
type GoVue struct {
StaticPath string
UseJsPath string
ErrorPage404 string
Resources *assetfs.AssetFS
IsDebugMode bool
jsRuntimePool *pool.JsRuntimePool
CacheSec int64
}
func NewGoVueDefaultConfig(debug bool) (gv *GoVue, err error) {
gv = &GoVue{
Resources: assetFS(),
IsDebugMode: debug,
}
err = gv.initRender(debug)
return
}
func NewGoVue(useJsPath string, staticPath string, debug bool) (gv *GoVue, err error) {
gv = &GoVue{
StaticPath: staticPath,
UseJsPath: useJsPath,
Resources: assetFS(),
IsDebugMode: debug,
}
err = gv.initRender(debug)
return
}
func (gv *GoVue) SetCacheSec(cacheSec int64) {
gv.CacheSec = cacheSec
}
func (gv *GoVue) SetErrorPage404(page string) {
gv.ErrorPage404 = page
}
func SetPoolConfig(config pool.Config) {
pool.DefaultConfig = config
}
func (gv *GoVue) initRender(debug bool) (err error) {
if gv.StaticPath == "" {
gv.StaticPath = filepath.Join(getSelfFilePath(), "static")
}
if gv.UseJsPath == "" {
gv.UseJsPath = filepath.Join(gv.StaticPath, "use.js")
}
headerScript, err := gv.Resources.Asset(filepath.Join("govue-runtime", "header.js"))
if err != nil {
return
}
polyfill, err := gv.Resources.Asset(filepath.Join("govue-runtime", "polyfill.js"))
if err != nil {
return
}
mainScript, err := gv.Resources.Asset(filepath.Join("govue-runtime", "runtime.js"))
if err != nil {
return
}
govueScriptFile := "govue.js"
govueScript, err := gv.Resources.Asset(filepath.Join("govue-runtime", govueScriptFile))
if err != nil {
return
}
gv.jsRuntimePool = pool.NewJsRuntimePool(string(mainScript), gv.UseJsPath, gv.StaticPath, jsruntime.Relys{
jsruntime.Rely{
Src: string(headerScript),
},
jsruntime.Rely{
Src: string(polyfill),
},
jsruntime.Rely{
Src: string(govueScript),
},
}, jsruntime.ModeSync, debug)
return
}
func (gv *GoVue) PoolLog() {
gv.jsRuntimePool.Log()
}
func (gv *GoVue) StartPoolLog() {
go func() {
defer func() {
recover()
log.Println("统计协程异常")
}()
lastidle := 0
lastactive := 0
for {
all, idle, active := gv.jsRuntimePool.NumInfo()
if idle != lastidle || active != lastactive {
fmt.Println("渲染协程数量变动变动:所有:", all, "空闲:", idle, "活动:", active)
}
lastidle = idle
lastactive = active
time.Sleep(time.Second)
}
}()
}
func (gv *GoVue) LoadStaticResources(request *http.Request, goExtDataS ...interface{}) (result []byte, err error) {
cacheKey := fmt.Sprintf("%s|%s", request.URL.Path, request.URL.RawQuery)
if gv.CacheSec > 0 {
html := GetCache(cacheKey)
if html != "" {
//log.Println("加载缓存")
return []byte(html), nil
}
}
//log.Println("非缓存", cacheKey)
var staticDir string
var filePath = request.URL.Path
if gv.StaticPath == "" {
staticDir = filepath.Join(getSelfFilePath(), "static")
} else {
staticDir = gv.StaticPath
}
filePath = filepath.Join(staticDir, filePath)
fi, err := os.Stat(filePath)
if err == nil {
if fi.IsDir() {
defaultPath := []string{"index.html"}
for e := range defaultPath {
path := filepath.Join(filePath, defaultPath[e])
_, err := os.Stat(path)
if err == nil {
filePath = path
break
}
}
}
}
result, err = ioutil.ReadFile(filePath)
if err != nil {
result, err = gv.renderErrPage(404, request, goExtDataS...)
if gv.CacheSec > 0 {
SetCache(cacheKey, string(result), gv.CacheSec)
}
return
}
if filepath.Ext(filePath) != ".html" {
return
}
err = gv.jsRuntimePool.JsRuntimeCall(func(jr *jsruntime.JsRuntime) {
err = jr.Render(filePath, fmt.Sprintf("http://%s%s", request.Host, request.RequestURI), string(result), nil, func(data string) {
result = []byte(data)
if gv.CacheSec > 0 {
SetCache(cacheKey, string(result), gv.CacheSec)
}
})
if err != nil {
result = []byte(err.Error())
}
})
return
}
func (gv *GoVue) renderErrPage(errCode int, request *http.Request, goExtDataS ...interface{}) (result []byte, err error) {
filePath := gv.ErrorPage404
if filePath == "" {
return []byte("页面不存在"), err
}
result, _ = ioutil.ReadFile(filePath)
var goExtData interface{}
if len(goExtDataS) > 0 {
goExtData = goExtDataS[0]
}
err = gv.jsRuntimePool.JsRuntimeCall(func(jr *jsruntime.JsRuntime) {
err = jr.Render(filePath, fmt.Sprintf("http://%s%s", request.Host, request.RequestURI), string(result), goExtData, func(data string) {
result = []byte(data)
})
})
return
}

58
govue2/utils.go

@ -0,0 +1,58 @@
package govue2
import (
"encoding/json"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"strings"
)
func pathExists(path string) bool {
_, err := os.Stat(path)
if err == nil {
return true
}
if os.IsNotExist(err) {
return false
}
return false
}
var selfFilePath string
func getSelfFilePath() string {
if selfFilePath == "" {
file, err := exec.LookPath(os.Args[0])
if err != nil {
return ""
}
path, err := filepath.Abs(file)
if err != nil {
return ""
}
i := strings.LastIndex(path, "/")
if i < 0 {
i = strings.LastIndex(path, "\\")
}
if i < 0 {
return ""
}
selfFilePath, _ = filepath.Abs(string(path[0 : i+1]))
}
return selfFilePath
}
func jsonToFile(file string, v interface{}) bool {
data, err := json.Marshal(v)
if err != nil {
return false
}
return ioutil.WriteFile(file, data, 0644) == nil
}
func jsonByFile(file string, v interface{}) {
data, _ := ioutil.ReadFile(file)
json.Unmarshal(data, v)
}

22
jsruntime/runtime.go

@ -2,6 +2,7 @@ package jsruntime
import (
"crypto/md5"
"encoding/base64"
"fmt"
"github.com/dop251/goja"
"html"
@ -25,6 +26,7 @@ type JsRuntime struct {
mutex sync.Mutex
RenderCallBackFun func(string)
IsDebugModel bool
isRenderIng bool
}
type Rely struct {
@ -59,6 +61,15 @@ func NewJsRuntime(mainScript string, extFileDir string, rels Relys, mode RunMode
jr.EnableConsoleFun()
jr.SetVariable("Base64Decode", func(text string) string {
code, _ := base64.StdEncoding.DecodeString(text)
return string(code)
})
jr.SetVariable("Base64Encode", func(text string) string {
code := base64.StdEncoding.EncodeToString([]byte(text))
return code
})
jr.SetVariable("GoReadFile", func(filePath string) string {
code, err := ioutil.ReadFile(filepath.Join(jr.ExtFileDir, filePath))
if err != nil {
@ -211,6 +222,7 @@ func (jr *JsRuntime) RunCode(code string) error {
}
func (jr *JsRuntime) Render(filePath, href, tplSrc string, GoExtData interface{}, cb func(data string)) (err error) {
jr.RenderCallBackFun = cb
jr.mutex.Lock()
defer jr.mutex.Unlock()
@ -218,9 +230,11 @@ func (jr *JsRuntime) Render(filePath, href, tplSrc string, GoExtData interface{}
runtime := jr.runtime
mainSrc := jr.MainSrc
isLock := true
jr.isRenderIng = true
//timeoutSec := jr.TimeoutSec
defer func() {
jr.isRenderIng = false
isLock = false
jr.runtime.ClearInterrupt()
}()
@ -260,9 +274,11 @@ func (jr *JsRuntime) Render(filePath, href, tplSrc string, GoExtData interface{}
jr.RenderCallBackFun(data)
})
t := time.AfterFunc(time.Duration(jr.TimeoutSec), func() {
jr.runtime.Interrupt("time out")
jr.runtime.ClearInterrupt()
t := time.AfterFunc(time.Duration(jr.TimeoutSec)*time.Second, func() {
if jr.isRenderIng {
jr.runtime.Interrupt("time out")
jr.runtime.ClearInterrupt()
}
})
defer t.Stop()

4
pool/pool.go

@ -69,7 +69,7 @@ func NewJsRuntimePool(mainScript string, useFileName string, staticPath string,
}()
for {
jrp.jsRuntimePool.PreparePool(jrp.ctx)
time.Sleep(time.Second / 5)
time.Sleep(time.Second)
}
}
go preparePoolTask()
@ -84,7 +84,7 @@ func NewJsRuntimePool(mainScript string, useFileName string, staticPath string,
for {
raw, _ := ioutil.ReadFile(useFileName)
useSrc = string(raw)
time.Sleep(time.Second)
time.Sleep(time.Second * 3)
}
}
go useSrcTask()

2
readme.md

@ -38,7 +38,7 @@
+ GoHtmlSrc[当前html原始代码,请不要使用]
+ GoParam[请求参数,map形式]
+ GoExtData[扩展数据,例如获取cookie,GoExtData['cookie'] ]
+ Vue.GV [用于判断是否处于服务端环境]
## 扩展标签
+ gv-id 定义页面ID,只能在html上

110
static/index.html

@ -1,36 +1,104 @@
<!doctype html>
<html lang="zh" gv-id="index">
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="keywords" content="">
<link rel="stylesheet" href="css/main.css">
<title>{{ title }}</title>
<script src="js/vue.js"></script>
</head>
<body>
<div id="app">
<div class="content">
<my-title></my-title>
<a v-on:click="click" gv-ignore>{{desc}}</a>
<br>
<!--gv-start-->
<div>
<div>{{title1}}</div>
<div>{{title2}}</div>
<assssss>{{title2}}</assssss>
<div>{{title3}}</div>
<a href="#" @click="click">{{title3}}</a>
<div id="app-4">
<ol>
<li v-for="todo in todos">
<a href="#" @click="click(todo.text)"> {{ todo.text }}</a>
</li>
</ol>
</div>
<input v-model="message" placeholder="edit me">
<textarea v-model="message" placeholder="add multiple lines"></textarea>
<p>Original message: "{{ message }}"</p>
<p>Computed reversed message: "{{ reversedMessage }}"</p>
<input type="checkbox" id="jack" value="Jack" v-model="checkedNames">
<label for="jack">Jack</label>
<input type="checkbox" id="john" value="John" v-model="checkedNames">
<label for="john">John</label>
<input type="checkbox" id="mike" value="Mike" v-model="checkedNames">
<label for="mike">Mike</label>
<br>
<span>Checked names: {{ checkedNames }}</span>
<div id="example-4">
<input type="radio" id="one" value="One" v-model="picked">
<label for="one">One</label>
<br>
<input type="radio" id="two" value="Two" v-model="picked">
<label for="two">Two</label>
<br>
<a href="#" v-on:click="ssr" gv-ignore>{{a}}</a>
<span>Picked: {{ picked }}</span>
</div>
<select v-model="selected">
<option v-for="option in options" v-bind:value="option.value">
{{ option.text }}
</option>
</select>
<span>Selected: {{ selected }}</span>
</div>
<!--gv-end-->
</body>
<script>
new Vue({
el: "#app",
<script src="js/govue.js"></script>
<script gv-src>
var app = new Vue({
data: {
message: 'Hello',
title1: "123",
title2: "456",
title3: "789",
todos: [
{text: '学习 JavaScript'},
{text: '学习 Vue'},
{text: '整个牛项目'},
{text: '{{a}}'}
],
checkedNames: [],
picked: '',
selected: 'A',
options: [
{text: 'One', value: 'A'},
{text: 'Two', value: 'B'},
{text: 'Three', value: 'C'}
]
},
computed: {
// 计算属性的 getter
reversedMessage: function () {
// `this` 指向 vm 实例
return this.message.split('').reverse().join('')
}
},
methods: {
click: function () {
alert("点击触发");
},
ssr: function () {
location.href = "ssr.html?test"
click: function (a) {
alert("点击触发:" + a);
},
}
},
});
GoVueMount(app, {
title: "123"
}, "body > div")
</script>
</html>

41
static/index.html.bak

@ -0,0 +1,41 @@
<!doctype html>
<html lang="zh" gv-id="index">
<head>
<meta charset="utf-8">
<meta name="keywords" content="">
<link rel="stylesheet" href="css/main.css">
<script src="js/vue.js"></script>
</head>
<body>
<div id="app">
<div class="content">
<my-title></my-title>
<template v-for="desc in descs">
<li >
<a @click="click" gv-ignore="@click">{{desc}}</a>
</li>
</template>
<br>
<br>
<br>
<a href="#" v-on:click="ssr" gv-ignore>{{a}}</a>
</div>
</div>
</body>
<script>
new Vue({
el: "#app",
methods: {
click: function () {
alert("点击触发");
},
ssr: function () {
location.href = "ssr.html?test"
},
}
});
</script>
</html>

6
static/index.js

@ -1,6 +0,0 @@
new Vue({
el: "#pre",
data: {
pre: "扩展参数\nhtml上的gv属性,值为页面id\nserc上的gv属性,表示脚本需要服务端渲染"
}
});

21
static/js/govue.js

@ -0,0 +1,21 @@
window.isBrowser = true;
function GoVueMount(app, ctx, el) {
var sourceTemplate = document.getElementsByTagName("go-vue-template");
var GoVueHTML = "";
if (sourceTemplate.length > 0) {
GoVueHTML = decodeURIComponent(atob(sourceTemplate[0].innerHTML))
}
var sourceData = document.getElementsByTagName("go-vue-data");
var GoVueData = {};
if (sourceData.length > 0) {
GoVueData = JSON.parse(decodeURIComponent(atob(sourceData[0].innerHTML)))
}
app.$options.template = GoVueHTML;
app.$mount(el);
for (var i in GoVueData) {
app[i] = GoVueData[i];
}
}

38
static/router.html

@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<title>{{ title }}</title>
<script src="js/vue.js"></script>
</head>
<body>
<!--gv-start-->
<div>
<h1>Hello App!</h1>
<p>
<router-link to="/foo">Go to Foo</router-link>
<router-link to="/bar">Go to Bar</router-link>
</p>
<router-view></router-view>
</div>
<!--gv-end-->
</body>
<script src="js/govue.js"></script>
<script gv-src>
var routes = [
{ path: '/router.html', component: {template: '123'}},
{path: '/bar.html', component: {template: '123'}}
]
var router = new VueRouter({
mode: 'history',
routes: routes
})
var app = new Vue({});
GoVueMount(app, {
title: "123"
})
</script>
</html>

24
static/use.js

@ -2,28 +2,4 @@
GoUse(function () {
});
//分页面
GoUseRegistered("index", function (query) {
// 定义一个名为 button-counter 的新组件
document.title = "govue";
document
.getElementsByName("keywords")[0]
.setAttribute("content", "govue,服务端渲染,ssr");
Vue.component('my-title', {
template: '<h1 id="title">govue</h1>'
});
new Vue({
el: "#app",
data: {
"desc": "基础golang开发的一套vue服务端渲染方案",
"a": "官方ssr模式",
},
});
});
Loading…
Cancel
Save