init
commit
d4252b9fe9
|
@ -0,0 +1,10 @@
|
||||||
|
__pycache__
|
||||||
|
*.txt
|
||||||
|
|
||||||
|
._*
|
||||||
|
|
||||||
|
.Spotlight-V100
|
||||||
|
.Trashes
|
||||||
|
.DS_Store
|
||||||
|
.AppleDouble
|
||||||
|
.LSOverride
|
|
@ -0,0 +1,9 @@
|
||||||
|
[Desktop Entry]
|
||||||
|
Name=Calendar
|
||||||
|
Comment[zh_CN]=中文万年历
|
||||||
|
Exec=calendar
|
||||||
|
Icon=calendar
|
||||||
|
Terminal=false
|
||||||
|
X-MultipleArgs=false
|
||||||
|
Type=Application
|
||||||
|
Categories=Utils;
|
|
@ -0,0 +1,12 @@
|
||||||
|
Package: calendar
|
||||||
|
Version: {{version}}
|
||||||
|
Section: utils
|
||||||
|
Architecture: all
|
||||||
|
Priority: optional
|
||||||
|
Maintainer: Yutent <yutent.io@gmail.com>
|
||||||
|
Installed-Size: {{size}}
|
||||||
|
Depends: python3-webengine-gtk3 (>=0.4.0)
|
||||||
|
Homepage: https://git.wkit.fun/appcat/calendar
|
||||||
|
Author: yutent
|
||||||
|
Description: 万年历
|
||||||
|
简单纯粹的万年历功能, 带有农历, 节气, 节日等功能, 可以自定义节假日。
|
|
@ -0,0 +1,23 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import gi
|
||||||
|
|
||||||
|
gi.require_version('Gtk', '3.0')
|
||||||
|
|
||||||
|
from gi.repository import Gtk
|
||||||
|
|
||||||
|
class Window(Gtk.Window):
|
||||||
|
def __init__(self, title = 'Untitled window', width = 840, height = 520):
|
||||||
|
Gtk.Window.__init__(self, title = title)
|
||||||
|
self.set_default_size(width, height)
|
||||||
|
self.resize(width, height)
|
||||||
|
self.set_wmclass('Hosts-Switch', 'Hosts-Switch')
|
||||||
|
self.set_title('Hosts-Switch')
|
||||||
|
self.set_icon_name('hosts-switch')
|
||||||
|
|
||||||
|
|
||||||
|
def toggle_visible(self, icon):
|
||||||
|
if self.is_visible():
|
||||||
|
self.hide()
|
||||||
|
else:
|
||||||
|
self.present()
|
|
@ -0,0 +1,67 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import gi, os, sys
|
||||||
|
|
||||||
|
gi.require_version('Gtk', '3.0')
|
||||||
|
|
||||||
|
from gi.repository import Gtk, Gdk, GLib, Gio, GObject, GdkPixbuf
|
||||||
|
|
||||||
|
from webengine.gtk3 import WebEngine, create_setting, create_hmr_server
|
||||||
|
from _window import Window
|
||||||
|
|
||||||
|
APP_ID = 'fun.wkit.hosts-switch'
|
||||||
|
__dir__ = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
|
web_root = os.path.join(__dir__, './webapp')
|
||||||
|
home_dir = os.getenv('HOME')
|
||||||
|
config_dir = os.path.join(home_dir, '.config/hosts-switch')
|
||||||
|
|
||||||
|
|
||||||
|
if not os.path.isdir(config_dir):
|
||||||
|
os.mkdir(config_dir)
|
||||||
|
|
||||||
|
|
||||||
|
class Application(Gtk.Application):
|
||||||
|
def __init__(self):
|
||||||
|
|
||||||
|
Gtk.Application.__init__(self, application_id = APP_ID)
|
||||||
|
|
||||||
|
self.window = Window()
|
||||||
|
|
||||||
|
web = WebEngine(self.window)
|
||||||
|
web.set_root(web_root)
|
||||||
|
|
||||||
|
if os.getenv('RUN_ENV') == 'development':
|
||||||
|
setting = create_setting({"devtools": True})
|
||||||
|
hmr = create_hmr_server()
|
||||||
|
web.use(setting).use(hmr)
|
||||||
|
|
||||||
|
web.connect('quit', self.quit_all)
|
||||||
|
web.load()
|
||||||
|
|
||||||
|
self.window.add(web)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def do_activate(self):
|
||||||
|
|
||||||
|
self.set_app_menu(None)
|
||||||
|
self.set_menubar(None)
|
||||||
|
|
||||||
|
self.add_window(self.window)
|
||||||
|
self.window.show_all()
|
||||||
|
|
||||||
|
|
||||||
|
def quit_all(self, widget):
|
||||||
|
self.remove_window(self.window)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
try:
|
||||||
|
app = Application()
|
||||||
|
app.run(sys.argv)
|
||||||
|
except Exception as err:
|
||||||
|
print(err)
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
/**
|
||||||
|
* {}
|
||||||
|
* @author yutent<yutent.io@gmail.com>
|
||||||
|
* @date 2023/07/20 14:19:13
|
||||||
|
*/
|
||||||
|
|
||||||
|
import 'es.shim'
|
||||||
|
import { html, css, Component } from 'wkit'
|
||||||
|
import { createApp, createRouter } from 'wkitd'
|
||||||
|
|
||||||
|
import store from './store.js'
|
||||||
|
import './components/home.js'
|
||||||
|
|
||||||
|
import { noop } from './utils/index.js'
|
||||||
|
|
||||||
|
createApp({
|
||||||
|
data: {
|
||||||
|
input: '',
|
||||||
|
img: '',
|
||||||
|
content: ''
|
||||||
|
},
|
||||||
|
styles: [
|
||||||
|
css`
|
||||||
|
:host {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
height: 100vh;
|
||||||
|
}
|
||||||
|
`
|
||||||
|
],
|
||||||
|
methods: {
|
||||||
|
quit() {
|
||||||
|
native.quit()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
render() {
|
||||||
|
return html` <wc-home @contextmenu.prevent=${noop}></wc-home> `
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.use(store)
|
||||||
|
.mount()
|
|
@ -0,0 +1,35 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="zh-CN">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
|
||||||
|
<link rel="stylesheet" href="/css/reset.css">
|
||||||
|
<style>
|
||||||
|
html,body {
|
||||||
|
width:100%;
|
||||||
|
height: 100%;
|
||||||
|
line-height: 1.5;
|
||||||
|
font-size: 14px;
|
||||||
|
cursor:default;
|
||||||
|
}
|
||||||
|
a {color:inherit;text-decoration: none;}
|
||||||
|
</style>
|
||||||
|
<script type="importmap">
|
||||||
|
{
|
||||||
|
"imports":{
|
||||||
|
"es.shim":"app:///lib/es.shim.js",
|
||||||
|
"wkit":"app:///lib/wkit.js",
|
||||||
|
"wkitd":"app:///lib/wkitd.js",
|
||||||
|
"fetch":"app:///lib/fetch.js",
|
||||||
|
"crypto":"app:///lib/crypto.js",
|
||||||
|
"ui/":"app:///lib/ui/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<script type="module" src="/app.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<wc-app></wc-app>
|
||||||
|
</body>
|
||||||
|
</html>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,56 @@
|
||||||
|
import"wkit";var c=Symbol("router"),d=Symbol("router-view"),m=Symbol("store"),g=new Set,f=new Map,$=new Set,I=class extends WeakMap{broadcast(){for(let t of g){if(t.removed){this.deassign(t);continue}t.$requestUpdate()}}assign(t){g.add(t)}deassign(t){g.delete(t)}},H=new I;Object.defineProperty(window,"wkitd",{get(){return H},set(t){console.error("Can not set readonly property wkitd of window")},enumerable:!1});import{html as x,css as M,Component as j}from"wkit";var z=encodeURIComponent,A=decodeURIComponent;function w(){}function L(t,r,e){Object.defineProperty(t,r,{get(){return e}})}function b(t,r,e){var o;if(Array.isArray(r))r.forEach(function(n,s){o=t?`${t}[${Array.isArray(n)?s:""}]`:s,typeof n=="object"?b(o,n,e):e(o,n)});else for(let n in r)o=t?`${t}[${n}]`:n,typeof r[n]=="object"?b(o,r[n],e):e(o,r[n])}function v(t=""){let r=new URLSearchParams(t),e=Object.create(null);for(let[o,n]of r.entries()){let s=A(o),i=A(n),a=0;if(/(\w+)\[(\w*?)\]/.test(s)){let l=RegExp.$1,p=RegExp.$2;s=l,!p||+p==+p?(i=[i],a|=2):(a|=1,i={[p]:i})}e[s]?a&2?e[s]=e[s].concat(i):a&1?Object.assign(e[s],i):(Array.isArray(e[i])||(e[s]=[e[s]]),e[s].push(i)):e[s]=i}return e}function k(t={}){if(t===null)return"";if(typeof t=="string"||typeof t=="number"||typeof t=="boolean")return t;let r=[];return typeof t=="object"&&b("",t,function(e,o){r.push(e+"="+z(o))}),r.join("&")}import{Component as q}from"wkit";import{bind as X}from"wkit";var Z=/^(#!|#)[\/]+?/,_=/(\/[^/]*)(:[\$@~\\!A-Za-z0-9_=\-]+)(\?)?/g,y="hash",N="history",S=class{type=y;#t=new Map;#r=new Set;#o=!1;#e=Object.create(null);#s=null;#i;constructor(t=y){this.type=t,X(window,"popstate",this.#a.bind(this))}get route(){return this.#e}get views(){return Array.from(this.#r)}#a(t){this.#o&&this.#p()}#l(t){if(t.path==="!")t.regexp=null;else{let r=[],e;if(t.path.includes("?")&&t.path.at(-1)!=="?")throw new SyntaxError(`The exp "?" can only be used in the last.
|
||||||
|
|
||||||
|
${JSON.stringify(t)}
|
||||||
|
`);e=t.path.replace(_,function(o,n,s,i=""){return r.push(s.slice(1)),n==="/"&&(n="/?"),n+"([\\$\\!@~A-Za-z0-9_=\\-]+)"+i}),e="^"+e+"$",t.regexp=new RegExp(e),t.vars=r}return t}#h(t){if(t.path!=="!"&&t.path[0]!=="/"){console.error('route path must start with "/"');return}t.path=t.path.replace(/^[\/]+|[\/]+$|\s+/g,"/"),this.#t.set(t.path,this.#l(t)),this.#r.add(t.name)}#p(){let t=this.type===y,r=window.wkitd.get(d),e=location.hash||"#/",o=t?e:location.href.replace(location.origin,"").replace(e,""),n="";if(o.includes("?")&&([o,n]=o.split("?")),o=o.replace(Z,"/"),o==="/index.html"&&(o="/"),!r||o===this.#e.path)return n!==k(this.#e.query)?(this.#e.query=v(n),this.#c()):void 0;for(let[s,i]of this.#t){let a=o.match(i.regexp);if(a){let l=Object.create(null);for(let u=1;u<a.length;u++)l[[i.vars[u-1]]]=a[u];let p={path:o,name:i.name,params:l,query:v(n)};return Object.defineProperty(p,"raw",{value:i.path}),this.#i?this.#i(this.route,p,()=>{this.#n(p)}):this.#n(p)}}if(this.#t.get("!")){let s=this.#t.get("!");r.current=s.name,this.#e={path:o,name:s.name,params:{},query:{}},this.#n(this.#e)}else this.#s&&(this.#n(this.#s),this.#s=null)}#n(t){let r=window.wkitd.get(d),e=this.#t.get(t.raw);r.current=t.name,this.#e=t,e&&typeof e.component=="function"&&(customElements.get(t.name)||(e.component(),delete e.component)),this.#c()}#c(){if(this.#o)for(let t of $)t(this.route)}init(){this.#o=!0,this.#a()}beforeEach(t=w){this.#i=t}addRoute(t){Array.isArray(t)?t.forEach(r=>{this.#h(r)}):this.#h(t),this.#o&&this.#a()}go(t=0){history.go(t)}back(){this.go(-1)}forward(){this.go(1)}push(t={path:"",query:{}},r=!1){let e="",o="";typeof t=="string"?e=t.trim():(o=k(t.query||""),e=t.path+(o?`?${o}`:"")),!(!e&&e===location.hash.slice(1))&&(this.#s=t,this.type===y?r?location.replace(e.replace(/^\//,"#/")):location.hash=e:(r?window.history.replaceState({path:e},null,e+o):window.history.pushState({path:e},null,e+o),this.#p()))}replace(t={path:"",query:{}}){this.push(t,!0)}};function O(){return()=>new S}function T(){return()=>new S(N)}import{Component as R,html as B,css as E,raw as C}from"wkit";import{Component as U}from"wkit";function P(t,r=["$store"]){return t===null?t:new Proxy(t,{get(e,o,n){let s=Reflect.get(e,o,n);return typeof s=="object"?P(s,r.concat(o)):s},set(e,o,n,s){let i=r.concat(o).join(".");return e[o]===n||(Reflect.set(e,o,n,s),f.get(i)&&f.get(i).forEach(a=>{a(n)}),window.wkitd.broadcast()),!0}})}function W(t,r=w){if(t.startsWith("$store.")){let e=f.get(t);e?e.add(r):(e=new Set,e.add(r),f.set(t,e))}else if(t.startsWith("$route"))$.add(r),r(window.wkitd.get(c).route);else return console.error("watch() only work on $store and $route")}function D(t={}){let r=!1;return function(){Object.defineProperty(U.prototype,"$store",{get(){return window.wkitd.assign(this),window.wkitd.get(m)},set(e){if(r)return console.error("Can not set readonly property $store of Component");window.wkitd.set(m,P(e)),r=!0}}),U.prototype.$store=t}}var G=class extends R{static props={transition:!1};static styles=E`
|
||||||
|
:host {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
`;get current(){return this.#t}set current(t){let r=this.#t,e=this.$refs;if(this.#t=t,this.keepAlive){if(r){let o=e[r];o?(o.removed=!0,o.deactivated(),o.remove()):this.$requestUpdate()}else this.$requestUpdate();if(t){let o=e[t];o?(this.root.appendChild(o),o.$requestUpdate(),this.transition&&o.$animate(),o.removed=!1,o.activated()):this.$requestUpdate()}}else this.$requestUpdate()}#t="";#r=[];created(){window.wkitd.set(d,this)}sync(t){this.#r=t}render(){let t={immediate:!0,custom:[{transform:"translateX(-32px)",opacity:0},{transform:"translateX(0)",opacity:1}]},r=this.current;if(r)return this.transition?C(`<${r} ref="${r}" ${this.keepAlive?"keep-alive":""} #animation="%s"></${r}>`,[t]):C(`<${r} ref="${r}" ${this.keepAlive?"keep-alive":""}></${r}>`)}},J=class extends R{static props={to:{type:null},disabled:!1};static styles=E`
|
||||||
|
:host {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
a {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: var(--router-link-gap, 0);
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: inherit;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
:host([disabled]) a {
|
||||||
|
opacity: 0.6;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
`;#t={path:""};#r="";#o(){let t=this.$router.type;this.disabled||(t==="hash"?location.hash=this.#r:this.$router.push(this.#t))}#e(){let t,r,e;if(typeof this.to=="string"){let o=this.to.split("?");t=o[0],e=o[1]||"",r=v(e)}else t=this.to.path||"",r=this.to.query||{},e=typeof r=="string"?r.replaceAll("?",""):k(r);t="/"+t.replace(/^\/+/,""),this.#t={path:t,query:r},e&&(t+="?"+e),this.#r=t}activated(){this.mounted()}deactivated(){this.unmounted()}mounted(){W("$route",t=>{this.removed||this.classList.toggle("active",t.path===this.#t.path)})}unmounted(){$.delete(this)}render(){return this.#e(),B`<a title=${this.#r} @click=${this.#o}
|
||||||
|
><slot></slot
|
||||||
|
></a>`}};G.reg("view","router"),J.reg("link","router");function K({history:t=O(),routes:r=[]}={}){let e=t();window.wkitd.set(c,e),e.addRoute(r);function o(){Object.defineProperty(q.prototype,"$router",{get(){return e}}),Object.defineProperty(q.prototype,"$route",{get(){return e.route}})}return o.beforeEach=e.beforeEach.bind(e),o}var h=class extends j{};function V({data:t={},styles:r=[],methods:e={},mounted:o=w,render:n}={}){return new function(){h.props=t,h.styles=r,Object.assign(h.prototype,e,{mounted:o,created(){L(j.prototype,"$app",this)}}),this.use=function(s=w,...i){return s.apply(h.prototype,i),this},this.mount=function(){let s=window.wkitd.get(c);n?h.prototype.render=n:s?h.prototype.render=function(){return x`<router-view></router-view>`}:(h.styles=M`
|
||||||
|
:host {
|
||||||
|
font-family: monospace;
|
||||||
|
color: #647889;
|
||||||
|
}
|
||||||
|
.code {
|
||||||
|
margin: 16px 0;
|
||||||
|
background: #f7f8fb;
|
||||||
|
}
|
||||||
|
`,h.prototype.render=function(){return x`
|
||||||
|
<h1>It works!!!</h1>
|
||||||
|
<cite>
|
||||||
|
If you don't use router, you may define the
|
||||||
|
<b>render</b> property.
|
||||||
|
</cite>
|
||||||
|
<div class="code">
|
||||||
|
<pre><code> createApp({</code></pre>
|
||||||
|
<pre><code> render() {</code></pre>
|
||||||
|
<pre><code> return html\`<wc-home></wc-home>\`</code></pre>
|
||||||
|
<pre><code> }</code></pre>
|
||||||
|
<pre><code> })</code></pre>
|
||||||
|
<pre><code> .mount()</code></pre>
|
||||||
|
</div>
|
||||||
|
`}),s&&(h.prototype.mounted=function(...i){let a=window.wkitd.get(d);if(a)a.sync(s.views),s.init(),o.call(this,...i);else throw new Error('<router-view /> not found, "Router" works Unexpected.')}),h.reg("app","v")}}}function F(){return window.wkitd.get(m)}function Q(){return window.wkitd.get(c)}function Y(){return window.wkitd.get(c)?.route}export{V as createApp,K as createRouter,D as createStore,O as createWebHashHistory,T as createWebHistory,Y as getCurrentPage,Q as getRouter,F as getStore,W as watch};
|
|
@ -0,0 +1,15 @@
|
||||||
|
/**
|
||||||
|
* {}
|
||||||
|
* @author yutent<yutent.io@gmail.com>
|
||||||
|
* @date 2023/09/04 11:11:51
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { createStore } from 'wkitd'
|
||||||
|
|
||||||
|
export default createStore({
|
||||||
|
HOST_DATA: {},
|
||||||
|
activeDomain: localStorage.getItem('last_domain') || '', //当前选中的域名
|
||||||
|
domains: [],
|
||||||
|
records: [],
|
||||||
|
tmp_records: []
|
||||||
|
})
|
Loading…
Reference in New Issue