Skip to content

Commit

Permalink
feat: 抽取代码到zhi-sdk-基本流程加载
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Mar 12, 2023
1 parent 0e53451 commit 43c35ff
Show file tree
Hide file tree
Showing 42 changed files with 4,010 additions and 22 deletions.
661 changes: 661 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions apps/blog/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.json linguist-language=JSON-with-Comments
37 changes: 37 additions & 0 deletions apps/blog/enums/themeFromEnum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2023, Terwer . All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Terwer designates this
* particular file as subject to the "Classpath" exception as provided
* by Terwer in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com
* or visit www.terwer.space if you need additional information or have any
* questions.
*/

/**
* 主题来源
*
* @author terwer
* @since 0.0.1
*/
enum ThemeFromEnum {
ThemeFrom_Blog = "zhi-theme-blog",
ThemeFrom_Siyuan = "zhi-theme-siyuan",
}

export default ThemeFromEnum
6 changes: 3 additions & 3 deletions apps/blog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
"lintcss:fix": "stylelint *.styl --fix",
"prettier": "prettier --write ."
},
"dependencies": {
"zhi-log": "^1.5.5"
},
"devDependencies": {
"@nuxtjs/eslint-config-typescript": "^12.0.0",
"eslint": "^8.36.0",
Expand All @@ -35,6 +32,9 @@
"vite-plugin-eslint": "^1.8.1",
"vue-tsc": "^1.2.0"
},
"dependencies": {
"zhi-sdk": "^1.0.8"
},
"keywords": [
"zhi",
"blog"
Expand Down
16 changes: 16 additions & 0 deletions apps/blog/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,19 @@
<NuxtWelcome />
</div>
</template>

<script lang="ts" setup>
import ZhiUtil from "~/utils/ZhiUtil"
import { version } from "~/package.json"
import ThemeFromEnum from "~/enums/themeFromEnum"
const zhiSdk = ZhiUtil.zhiSdk()
const logger = zhiSdk.getLogger()
const common = zhiSdk.common
function hello(from: string): void {
logger.info(common.strUtil.f("Hello, {0} {1} v{2}! You are from {3}", "zhi", "theme", version, from))
}
hello(ThemeFromEnum.ThemeFrom_Siyuan)
</script>
20 changes: 18 additions & 2 deletions apps/blog/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions apps/blog/utils/Config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2023, Terwer . All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Terwer designates this
* particular file as subject to the "Classpath" exception as provided
* by Terwer in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com
* or visit www.terwer.space if you need additional information or have any
* questions.
*/

/**
* zhi 主题通用常量配置
*
* @author terwer
* @since 1.0.0
*/
class Config {}
export default Config
49 changes: 49 additions & 0 deletions apps/blog/utils/ZhiUtil.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (c) 2023, Terwer . All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Terwer designates this
* particular file as subject to the "Classpath" exception as provided
* by Terwer in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com
* or visit www.terwer.space if you need additional information or have any
* questions.
*/

import ZhiSdk from "zhi-sdk"
import Env from "zhi-env"

/**
* 工具类统一入口
*
* @author terwer
* @since 1.0.0
*/
class ZhiUtil {
private static zhiSdkObj: ZhiSdk
public static zhiSdk() {
if (!ZhiUtil.zhiSdkObj) {
const env = new Env(import.meta.env)
ZhiUtil.zhiSdkObj = new ZhiSdk(env)
const logger = ZhiUtil.zhiSdkObj.getLogger()
const common = ZhiUtil.zhiSdkObj.common
logger.info(common.strUtil.f("ZhiSdk inited, components are available now,like logger, env and so on."))
}
return ZhiUtil.zhiSdkObj
}
}

export default ZhiUtil
13 changes: 5 additions & 8 deletions apps/theme/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
es2021: true,
},

parser: "@typescript-eslint/parser",
parser: "vue-eslint-parser",

parserOptions: {
ecmaVersion: 12,
Expand All @@ -20,16 +20,13 @@ module.exports = {

plugins: ["@typescript-eslint", "prettier"],

extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
],
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"],

rules: {
// Note: you must disable the base rule as it can report incorrect errors
semi: "off",
quotes: "off",
"prettier/prettier": "error"
"@typescript-eslint/no-this-alias": "off",
"prettier/prettier": "error",
},
}
}
1 change: 1 addition & 0 deletions apps/theme/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.json linguist-language=JSON-with-Comments
2 changes: 1 addition & 1 deletion apps/theme/.stylelintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"import-notation": "string",
"string-quotes": "double",
"selector-combinator-space-after": "always",
"custom-property-no-missing-var-function": false,
"custom-property-no-missing-var-function": null,
"color-function-notation": "legacy",
"value-list-comma-space-before": "never",
"value-list-comma-space-after": "always",
Expand Down
3 changes: 2 additions & 1 deletion apps/theme/build.mts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// https://github.com/vitejs/vite/discussions/1736#discussioncomment-3229793

import { build, InlineConfig } from "vite"
import path from "path"
import path from "path";

/**
* zhi 主题构建
Expand Down Expand Up @@ -31,6 +31,7 @@ class ZhiBuild {
},
],
},
plugins: [],
build: {
outDir: "../../",
lib: {
Expand Down
Loading

0 comments on commit 43c35ff

Please sign in to comment.